Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section filter to overview #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DegrangeM
Copy link

@DegrangeM DegrangeM commented Jun 15, 2020

Fix #59

Work with any section type (thematics, weekly, etc.).

image

@DegrangeM
Copy link
Author

Is it possible to merge it ? @jonof Thanks.

Comment on lines +176 to +189
$sql = "SELECT DISTINCT s.id, s.section
FROM {course_sections} s
WHERE s.course = :courseid
AND s.sequence <> ''";
$params = array('courseid' => $courseid);
$sectionrecords = $DB->get_records_sql($sql, $params);
$sections = array_values($sectionrecords);
$numberofsections = count($sections);
$sectionstodisplay = array(0 => get_string('allsections', 'block_completion_progress'));
for ($i = 0; $i < $numberofsections; $i++) {
$sectionstodisplay[$sections[$i]->id] = get_section_name($courseid, $sections[$i]->section);
}
echo '&nbsp;' .get_string('section') . '&nbsp;';
echo $OUTPUT->single_select($PAGE->url, 'section', $sectionstodisplay, $section);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using this instead:

// Output the sections menu.
$format = course_get_format($COURSE);
if ($format->uses_sections()) {
    $sections = [ -1 => get_string('allsections', 'block_completion_progress') ];
    foreach ($format->get_sections() as $sectinfo) {
        $sections[$sectinfo->section] = $format->get_section_name($sectinfo);
    }
    echo '&nbsp;' . get_string('section') . '&nbsp;';
    echo $OUTPUT->single_select($PAGE->url, 'section', $sections, $section);
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other adjustments as a consequence of using the section number instead of its record ID are obviously necessary with that change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I will check that :)

@danmarsden
Copy link
Contributor

Just saw this - I would suggest updating the overview report to use the new \core_user\table\participants class with the new participants_filterset before you start adding extra filters like this.

(I have a heavily custom version of Michael's old block on a clients site and I was coming here to see if anyone had updated the overview report to use the new classes.)

@DegrangeM
Copy link
Author

Just saw this - I would suggest updating the overview report to use the new \core_user\table\participants class with the new participants_filterset before you start adding extra filters like this.

(I have a heavily custom version of Michael's old block on a clients site and I was coming here to see if anyone had updated the overview report to use the new classes.)

I will check that too when I have time, I am currently a little busy with all covid stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add section dropdown in overview.php (next to role dropdown)
3 participants