Skip to content

Commit 63b580d

Browse files
committed
Some code cleaner
1 parent 20819e3 commit 63b580d

7 files changed

Lines changed: 29 additions & 88 deletions

File tree

block_course_modulenavigation.php

Lines changed: 12 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function specialization() {
7777
public function applicable_formats() {
7878
return [
7979
'site-index' => true,
80-
'course-view-*' => true
80+
'course-view-*' => true,
8181
];
8282
}
8383

@@ -132,18 +132,7 @@ public function get_content() {
132132
return $this->content;
133133
}
134134

135-
if (($format instanceof format_digidagotabs) || ($format instanceof format_horizontaltabs)) {
136-
// Don't show the menu in a tab.
137-
if ($intab) {
138-
return $this->content;
139-
}
140-
// Only show the block inside activities of courses.
141-
if ($this->page->pagelayout == 'incourse') {
142-
$sections = $format->tabs_get_sections();
143-
}
144-
} else {
145-
$sections = $format->get_sections();
146-
}
135+
$sections = $format->get_sections();
147136

148137
if (empty($sections)) {
149138
return $this->content;
@@ -163,7 +152,7 @@ public function get_content() {
163152

164153
$completionok = [
165154
COMPLETION_COMPLETE,
166-
COMPLETION_COMPLETE_PASS
155+
COMPLETION_COMPLETE_PASS,
167156
];
168157

169158
$thiscontext = context::instance_by_id($this->page->context->id);
@@ -185,56 +174,6 @@ public function get_content() {
185174
}
186175
}
187176

188-
if ($format instanceof format_digidagotabs || $format instanceof format_horizontaltabs) {
189-
$coursesections = $DB->get_records(
190-
'course_sections',
191-
[ 'course' => $course->id ],
192-
);
193-
$mysection = 0;
194-
foreach ($coursesections as $cs) {
195-
$csmodules = explode(
196-
',',
197-
$cs->sequence,
198-
);
199-
if (in_array(
200-
$myactivityid,
201-
$csmodules,
202-
)) {
203-
$mysection = $cs->id;
204-
}
205-
}
206-
207-
if ($mysection) {
208-
$formatcourse = course_get_format($course->id);
209-
if ($formatcourse == 'horizontaltabs') {
210-
if (($DB->get_records(
211-
'format_horizontaltabs_tabs',
212-
[
213-
'courseid' => $course->id,
214-
'sectionid' => $mysection
215-
],
216-
))) {
217-
// This is a module inside a tab of the Dynamic tabs course format.
218-
// Prevent showing of this menu.
219-
return $this->content;
220-
}
221-
}
222-
if ($formatcourse == 'digidagotabs') {
223-
if (($DB->get_records(
224-
'format_digidagotabs_tabs',
225-
[
226-
'courseid' => $course->id,
227-
'sectionid' => $mysection
228-
],
229-
))) {
230-
// This is a module inside a tab of the Dynamic tabs course format.
231-
// Prevent showing of this menu.
232-
return $this->content;
233-
}
234-
}
235-
}
236-
}
237-
238177
$template->inactivity = $inactivity;
239178

240179
if (count($sections) > 1) {
@@ -283,7 +222,7 @@ public function get_content() {
283222
$section->summaryformat,
284223
[
285224
'para' => false,
286-
'context' => $context
225+
'context' => $context,
287226
],
288227
);
289228
$title = $format->get_section_name($section);
@@ -308,9 +247,9 @@ public function get_content() {
308247
'toggletitles',
309248
);
310249

311-
$thissection->collapse = ($toggleclickontitle == 2); // Display the menu if true, else go to link
250+
$thissection->collapse = ($toggleclickontitle == 2); // Display the menu if true, else go to link.
312251
$thissection->selected = ($togglecollapse == 2);
313-
$thissection->onlytitles = ($toggletitles == 2); // Show only titles if true, else show titles and contents
252+
$thissection->onlytitles = ($toggletitles == 2); // Show only titles if true, else show titles and contents.
314253

315254
if ($i == $selected && !$inactivity) {
316255
$thissection->selected = true;
@@ -339,7 +278,6 @@ public function get_content() {
339278
$thissection,
340279
);
341280
}
342-
343281
$thissection->modules[] = $thismod;
344282
} else {
345283
$thissection->modules[] = $this->checkmodule(
@@ -355,7 +293,8 @@ public function get_content() {
355293
}
356294

357295
$thissection->hasmodules = (count($thissection->modules) > 0);
358-
if ($thissection->hasmodules && $thissection->uservisible) {
296+
// We prevent case of section (mod_subsection) are added at the end ...
297+
if ($thissection->hasmodules && $thissection->uservisible && $section->component !== "mod_subsection") {
359298
$template->sections[] = $thissection;
360299
}
361300
}
@@ -371,7 +310,7 @@ public function get_content() {
371310
'/course/view.php',
372311
[
373312
'id' => $course->id,
374-
'section' => $i
313+
'section' => $i,
375314
],
376315
);
377316
$template->courseurl = $courseurl->out();
@@ -387,7 +326,7 @@ public function get_content() {
387326
'/course/view.php',
388327
[
389328
'id' => $course->id,
390-
'section' => $pn->prev
329+
'section' => $pn->prev,
391330
],
392331
);
393332
$template->prevurl = $prevurl->out(false);
@@ -396,7 +335,7 @@ public function get_content() {
396335
'/course/view.php',
397336
[
398337
'id' => $course->id,
399-
'section' => $thissection->number
338+
'section' => $thissection->number,
400339
],
401340
);
402341
$template->currurl = $currurl->out(false);
@@ -405,7 +344,7 @@ public function get_content() {
405344
'/course/view.php',
406345
[
407346
'id' => $course->id,
408-
'section' => $pn->next
347+
'section' => $pn->next,
409348
],
410349
);
411350
$template->nexturl = $nexturl->out(false);

classes/privacy/provider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
/**
1818
* Course module navigation block main controller
19+
*
1920
* @package block_course_modulenavigation
2021
* @copyright 2019 Pimenko <contact@pimenko.com> <pimenko.com>
2122
* @author Sylvain Revneu | Jordan Kesraoui | Pimenko
@@ -28,6 +29,7 @@
2829

2930
/**
3031
* Privacy Subsystem for block_course_modulenavigation implementing null_provider.
32+
*
3133
* @copyright 2019 Pimenko <contact@pimenko.com> <pimenko.com>
3234
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3335
*/
@@ -37,9 +39,10 @@ class provider implements // This plugin does not store any personal user data.
3739
/**
3840
* Get the language string identifier with the component's language
3941
* file to explain why this plugin stores no data.
42+
*
4043
* @return string
4144
*/
42-
public static function get_reason() : string {
45+
public static function get_reason(): string {
4346
return 'privacy:null_reason';
4447
}
4548
}

db/access.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
'contextlevel' => CONTEXT_BLOCK,
3232
'archetypes' => [
3333
'editingteacher' => CAP_ALLOW,
34-
'manager' => CAP_ALLOW
34+
'manager' => CAP_ALLOW,
3535
],
3636

37-
'clonepermissionsfrom' => 'moodle/site:manageblocks'
37+
'clonepermissionsfrom' => 'moodle/site:manageblocks',
3838
],
3939
];

lang/en/block_course_modulenavigation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@
3232
$string['course_modulenavigation:addinstance'] = 'Add a new course contents block';
3333
$string['notusingsections'] = 'This course format does not use sections.';
3434
$string['pluginname'] = 'Course Module Navigation';
35+
$string['privacy:null_reason'] = 'The Blog Course Module Navigation block only shows data stored in other locations';
3536
$string['toggleclickontitle'] = 'Clicking on the title';
3637
$string['toggleclickontitle_desc'] = "'Displays the menu' or 'Goes to that page'.";
3738
$string['toggleclickontitle_menu'] = 'Displays the menu';
3839
$string['toggleclickontitle_page'] = 'Goes to that page';
39-
$string['toggleshowlabels'] = 'Show labels';
40-
$string['toggleshowlabels_desc'] = 'Choose whether to display labels or not';
4140
$string['togglecollapse'] = 'Collapse tabs';
4241
$string['togglecollapse_desc'] = 'Choose whether to display all tabs not collapsed';
42+
$string['toggleshowlabels'] = 'Show labels';
43+
$string['toggleshowlabels_desc'] = 'Choose whether to display labels or not';
4344
$string['toggletitles'] = 'Show only titles';
4445
$string['toggletitles_desc'] = 'Choose whether to display only titles or titles and content';
45-
$string['privacy:null_reason'] = 'The Blog Course Module Navigation block only shows data stored in other locations';

renderer.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@
3434
class block_course_modulenavigation_nav_renderer extends plugin_renderer_base {
3535

3636
/**
37+
* Renders navigation based on the provided template configuration.
3738
*
38-
* Render HTML template.
39+
* @param object $template The template object containing configuration settings.
3940
*
40-
* @param $template
41-
* @return bool|string
42-
* @throws moodle_exception
41+
* @return string Rendered navigation content based on the template configuration.
4342
*/
4443
public function render_nav($template) {
4544
if (isset($template->config->onesection) && ($template->config->onesection == 1)) {

settings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
$choices = [
7272
1 => new lang_string('no'),
7373
// No.
74-
2 => new lang_string('yes')
74+
2 => new lang_string('yes'),
7575
// Yes.
7676
];
7777
$settings->add(
@@ -98,7 +98,7 @@
9898
$choices = [
9999
1 => new lang_string('no'),
100100
// No.
101-
2 => new lang_string('yes')
101+
2 => new lang_string('yes'),
102102
// Yes.
103103
];
104104
$settings->add(
@@ -125,7 +125,7 @@
125125
$choices = [
126126
1 => new lang_string('no'),
127127
// No.
128-
2 => new lang_string('yes')
128+
2 => new lang_string('yes'),
129129
// Yes.
130130
];
131131
$settings->add(

version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
defined('MOODLE_INTERNAL') || die();
2525

2626
$plugin->component = 'block_course_modulenavigation';
27-
$plugin->release = 'v4.7';
28-
$plugin->version = 2024101001;
27+
$plugin->release = 'v4.7.1';
28+
$plugin->version = 2024101401; // YYYYMMDD.
2929
$plugin->requires = 2024100100; // Moodle 4.0.5 and above.
3030
$plugin->maturity = MATURITY_STABLE;

0 commit comments

Comments
 (0)