Skip to content

Commit 5b557e1

Browse files
vanjadi1katodaVanja Dimkovskabozicm
authored
Update format_weeksrev for Moodle 4.5 (#6)
* replace deprecated format_base with core_courseformat\base * update .travis.yml with moodle 4+ versions --------- Co-authored-by: 1katoda <tj3143@student.uni-lj.si> Co-authored-by: Vanja Dimkovska <vanja.dimkovska@arnes.si> Co-authored-by: Martin Božič <martin.bozic@arnes.si>
1 parent 0c62b89 commit 5b557e1

File tree

9 files changed

+151
-134
lines changed

9 files changed

+151
-134
lines changed

.travis.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@ cache:
1818
- $HOME/.npm
1919

2020
php:
21-
- 7.1
22-
- 7.2
2321
- 7.3
22+
- 7.4
23+
- 8.0
2424
env:
2525
matrix:
2626
- DB=mysqli MOODLE_BRANCH=master
2727
- DB=pgsql MOODLE_BRANCH=master
28-
- DB=mysqli MOODLE_BRANCH=MOODLE_39_STABLE
29-
- DB=pgsql MOODLE_BRANCH=MOODLE_39_STABLE
30-
- DB=mysqli MOODLE_BRANCH=MOODLE_38_STABLE
31-
- DB=pgsql MOODLE_BRANCH=MOODLE_38_STABLE
32-
- DB=mysqli MOODLE_BRANCH=MOODLE_37_STABLE
33-
- DB=pgsql MOODLE_BRANCH=MOODLE_37_STABLE
34-
- DB=mysqli MOODLE_BRANCH=MOODLE_36_STABLE
35-
- DB=pgsql MOODLE_BRANCH=MOODLE_36_STABLE
36-
- DB=mysqli MOODLE_BRANCH=MOODLE_35_STABLE
37-
- DB=pgsql MOODLE_BRANCH=MOODLE_35_STABLE
28+
- DB=mysqli MOODLE_BRANCH=MOODLE_404_STABLE
29+
- DB=pgsql MOODLE_BRANCH=MOODLE_404_STABLE
30+
- DB=mysqli MOODLE_BRANCH=MOODLE_403_STABLE
31+
- DB=pgsql MOODLE_BRANCH=MOODLE_403_STABLE
32+
- DB=mysqli MOODLE_BRANCH=MOODLE_402_STABLE
33+
- DB=pgsql MOODLE_BRANCH=MOODLE_402_STABLE
34+
- DB=mysqli MOODLE_BRANCH=MOODLE_401_STABLE
35+
- DB=pgsql MOODLE_BRANCH=MOODLE_401_STABLE
36+
- DB=mysqli MOODLE_BRANCH=MOODLE_400_STABLE
37+
- DB=pgsql MOODLE_BRANCH=MOODLE_400_STABLE
3838

3939
before_install:
4040
- phpenv config-rm xdebug.ini
41-
- nvm install 14.2.0
42-
- nvm use 14.2.0
41+
- nvm install 20
42+
- nvm use 20
4343
- cd ../..
4444
- composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2
4545
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ See [MDL-61198](https://tracker.moodle.org/browse/MDL-61198).
1212
v3.0.0
1313
------
1414
* Add support for Moodle versions 3.3 and higher by complete rewrite using Moodle 3.3 format_weeks as code base
15-
* Add "Hide future week" settings
15+
* Add "Hide future week" settings

renderer.php renamed to classes/output/renderer.php

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@
2424
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2525
*/
2626

27+
namespace format_weeksrev\output;
28+
29+
use core_courseformat\output\section_renderer;
30+
use core_courseformat\output\local\content\section;
31+
use core_courseformat\output\local\content\section\cmlist;
32+
use core_courseformat\output\local\content\section\availability;
33+
use core_courseformat\output\local\content\section\summary;
34+
use core_courseformat\output\local\content\addsection;
35+
use html_writer;
2736

2837
defined('MOODLE_INTERNAL') || die();
29-
require_once($CFG->dirroot.'/course/format/renderer.php');
38+
require_once($CFG->dirroot.'/course/format/weeksrev/classes/output/renderer.php');
3039
require_once($CFG->dirroot.'/course/format/weeksrev/lib.php');
3140

32-
3341
/**
3442
* Basic renderer for weeksrev format.
3543
*
@@ -38,7 +46,8 @@
3846
* based on code from 2012 Dan Poltawski
3947
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4048
*/
41-
class format_weeksrev_renderer extends format_section_renderer_base {
49+
class renderer extends section_renderer {
50+
4251
/**
4352
* Generate the starting container html for a list of sections
4453
* @return string HTML to output.
@@ -59,7 +68,7 @@ protected function end_section_list() {
5968
* @return string the page title
6069
*/
6170
protected function page_title() {
62-
return get_string('weeklyoutline');
71+
return get_string('weeklyoutline', 'format_weeksrev');
6372
}
6473

6574
/**
@@ -111,18 +120,14 @@ protected function section_header($section, $course, $onsectionpage, $sectionret
111120
}
112121

113122
$o .= html_writer::start_tag('li', ['id' => 'section-' . $section->section,
114-
'class' => 'section main clearfix' . $sectionstyle, 'role' => 'region',
123+
$sectionstyle, 'role' => 'region',
115124
'aria-label' => get_section_name($course, $section)]);
116125

117126
// Create a span that contains the section title to be used to create the keyboard section move menu.
118127
$o .= html_writer::tag('span', get_section_name($course, $section), ['class' => 'hidden sectionname']);
119128

120-
$leftcontent = $this->section_left_content($section, $course, $onsectionpage);
121-
$o .= html_writer::tag('div', $leftcontent, ['class' => 'left side']);
122-
123-
$rightcontent = $this->section_right_content($section, $course, $onsectionpage);
124-
$o .= html_writer::tag('div', $rightcontent, ['class' => 'right side']);
125-
$o .= html_writer::start_tag('div', ['class' => 'content']);
129+
$sectionoutput = new section($courseformat, $section);
130+
$o .= $this->render($sectionoutput);
126131

127132
// When not on a section page, we display the section titles except the general section if null.
128133
$hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name)));
@@ -134,13 +139,13 @@ protected function section_header($section, $course, $onsectionpage, $sectionret
134139
if ($hasnamenotsecpg || $hasnamesecpg) {
135140
$classes = '';
136141
}
137-
$sectionname = html_writer::tag('span', $this->section_title($section, $course));
138-
$o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes);
139142

140-
$o .= $this->section_availability($section);
143+
$availability = new availability($courseformat, $section);
144+
$o .= $this->render($availability);
141145

142146
$o .= html_writer::start_tag('div', ['class' => 'summary']);
143-
$o .= $this->format_summary_text($section);
147+
$summary = new summary($courseformat, $section);
148+
$o .= $summary->format_summary_text();
144149
$o .= html_writer::end_tag('div');
145150

146151
return $o;
@@ -185,11 +190,13 @@ protected function section_summary($section, $course, $mods) {
185190
$o .= $this->output->heading($title, 3, 'section-title');
186191

187192
$o .= html_writer::start_tag('div', ['class' => 'summarytext']);
188-
$o .= $this->format_summary_text($section);
193+
$summary = new summary($courseformat, $section);
194+
$o .= $summary->format_summary_text();
189195
$o .= html_writer::end_tag('div');
190196
$o .= $this->section_activity_summary($section, $course, null);
191197

192-
$o .= $this->section_availability($section);
198+
$availability = new availability($courseformat, $section);
199+
$o .= $this->render($availability);
193200

194201
$o .= html_writer::end_tag('div');
195202
$o .= html_writer::end_tag('li');
@@ -207,7 +214,7 @@ protected function section_summary($section, $course, $mods) {
207214
* @param int $displaysection The section number in the course which is being displayed
208215
*/
209216
public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection) {
210-
$context = context_course::instance($course->id);
217+
$context = \context_course::instance($course->id);
211218
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
212219
if ($course->hidefuture && $canviewhidden) {
213220
echo html_writer::tag('ul',
@@ -232,19 +239,16 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
232239
$courseformat = course_get_format($course);
233240
$course = $courseformat->get_course();
234241

235-
$context = context_course::instance($course->id);
242+
$context = \context_course::instance($course->id);
236243
// Title with completion help icon.
237-
$completioninfo = new completion_info($course);
238-
echo $completioninfo->display_help_icon();
244+
$completioninfo = new \completion_info($course);
245+
echo $this->output->help_icon('completion', 'completion');
239246
echo $this->output->heading($this->page_title(), 2, 'accesshide');
240247

241-
// Copy activity clipboard..
242-
echo $this->course_activity_clipboard($course, 0);
243-
244248
$canviewhidden = has_capability('moodle/course:viewhiddensections', $context);
245249
if ($course->hidefuture && $canviewhidden) {
246-
echo html_writer::tag('ul',
247-
html_writer::tag('li', get_string('futureweeks', 'format_weeksrev'), ['class' => 'future-legend']),
250+
echo \html_writer::tag('ul',
251+
\html_writer::tag('li', get_string('futureweeks', 'format_weeksrev'), ['class' => 'future-legend']),
248252
['class' => 'weeksrev']
249253
);
250254
}
@@ -263,9 +267,6 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
263267
// 0-section is displayed a little different then the others.
264268
if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
265269
echo $this->section_header($thissection, $course, false, 0);
266-
echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
267-
echo $this->courserenderer->course_section_add_cm_control($course, 0, 0);
268-
echo $this->section_footer();
269270
}
270271
continue;
271272
}
@@ -295,11 +296,6 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
295296
echo $this->section_summary($thissection, $course, null);
296297
} else {
297298
echo $this->section_header($thissection, $course, false, 0);
298-
if ($thissection->uservisible) {
299-
echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
300-
echo $this->courserenderer->course_section_add_cm_control($course, $section, 0);
301-
}
302-
echo $this->section_footer();
303299
}
304300
}
305301

@@ -311,13 +307,12 @@ public function print_multiple_section_page($course, $sections, $mods, $modnames
311307
continue;
312308
}
313309
echo $this->stealth_section_header($section);
314-
echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
315-
echo $this->stealth_section_footer();
316310
}
317311

318312
echo $this->end_section_list();
319313

320-
echo $this->change_number_sections($course, 0);
314+
$addsection = new addsection($courseformat);
315+
echo $this->render($addsection);
321316
} else {
322317
echo $this->end_section_list();
323318
}

format.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@
3939
}
4040
// End backwards-compatible aliasing..
4141

42+
$format = course_get_format($course);
43+
4244
// Make sure section 0 is created.
43-
$course = course_get_format($course)->get_course();
44-
course_create_sections_if_missing($course, 0);
45+
course_create_sections_if_missing($format->get_course(), 0);
4546

4647
$renderer = $PAGE->get_renderer('format_weeksrev');
4748

49+
if (!is_null($displaysection)) {
50+
$format->set_sectionnum($displaysection);
51+
}
52+
4853
if (!empty($displaysection)) {
4954
$renderer->print_single_section_page($course, null, null, null, null, $displaysection);
5055
} else {

lang/en/format_weeksrev.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@
4444
$string['showfromothers'] = 'Show week';
4545
$string['automaticenddate'] = 'Calculate the end date from the number of sections';
4646
$string['automaticenddate_help'] = 'If enabled, the end date for the course will be automatically calculated from the number of sections and the course start date.';
47-
$string['privacy:metadata'] = 'The Reverse Weekly format plugin does not store any personal data.';
47+
$string['privacy:metadata'] = 'The Reverse Weekly format plugin does not store any personal data.';
48+
$string['weeklyoutline'] = 'Weekly outline';

0 commit comments

Comments
 (0)