Skip to content

Commit

Permalink
WR422914 Added course select interface
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonThornett committed Sep 24, 2024
1 parent b55bf9d commit fc7f76b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
23 changes: 22 additions & 1 deletion classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class renderer extends plugin_renderer_base {
* @return void
*/
public function render_reports() : void {
global $PAGE;
$reports = get_reports();
$reportoutputs = [];
foreach ($reports as $report) {
Expand All @@ -47,11 +48,31 @@ public function render_reports() : void {
usort($reportoutputs, function($a, $b) {
return $a['weight'] <=> $b['weight'];
});
$courseselectoptions = [];
$courseselect = '';
$categories = \core_course_category::make_categories_list();

foreach ($categories as $categoryid => $category) {
$courses = get_courses($categoryid);
foreach ($courses as $course) {
$courseselectoptions[$course->id] = $category . ' - ' . $course->fullname;
}
}
if (!empty($courseselectoptions)) {
$courseselect = $this->single_select(
'#',
'courseid',
$courseselectoptions,
$PAGE->course->id != SITEID ? $PAGE->course->id : '',
['' => get_string('courseselect', 'local_assessfreq')],
);
}
$output = $this->output->header();
$output .= $this->render_from_template(
'local_assessfreq/index',
[
'reports' => $reportoutputs
'reports' => $reportoutputs,
'courseselect' => $courseselect,
]
);
$output .= $this->output->footer();
Expand Down
1 change: 1 addition & 0 deletions lang/en/local_assessfreq.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
$string['task:dataprocess'] = 'Data collection task';
$string['task:quiztracking'] = 'Quiz tracking task';

$string['courseselect'] = 'Select course...';
$string['noreports'] = 'No reports have been configured for you.
If you believe this is an error please contact your site administrator.';

Expand Down
14 changes: 5 additions & 9 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@
* @param context $context The context of the course
*/
function local_assessfreq_extend_navigation_course(navigation_node $navigation, stdClass $course, context $context) {
global $CFG, $OUTPUT;
if (has_capability('local/assessfreq:view', $context)) {
$url = new moodle_url('/local/assessfreq/', ['courseid' => $course->id]);
$navigation->add(
get_string('pluginname', 'local_assessfreq'),
$url,
navigation_node::TYPE_SETTING,
null,
null,
new pix_icon('i/report', '')
);
$settingsnode = navigation_node::create(get_string('pluginname', 'local_assessfreq'), $url);
$reportnode = $navigation->get('coursereports');
if (isset($settingsnode) && !empty($reportnode)) {
$reportnode->add_node($settingsnode);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions templates/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
}}

<div id="local-assessfreq-index">
<!-- Course select interface -->
<p>
{{{courseselect}}}
</p>
<!-- Tabs -->
{{> local_assessfreq/tabs}}
</div>
Expand Down

0 comments on commit fc7f76b

Please sign in to comment.