-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
739c1e9
commit 35f7284
Showing
3 changed files
with
66 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace mod_adleradaptivity\output; | ||
|
||
use moodle_url; | ||
use plugin_renderer_base; | ||
use stdClass; | ||
|
||
class index_renderer extends plugin_renderer_base { | ||
public function render_page(stdClass $course): string { | ||
// Get all the appropriate data. | ||
if (!$adleradaptivities = get_all_instances_in_course('adleradaptivity', $course)) { | ||
notice(get_string('thereareno', 'moodle', get_string('modulenameplural', 'adleradaptivity')), "../../course/view.php?id=$course->id"); | ||
die; | ||
} | ||
|
||
// Prepare the data for the Mustache template. | ||
$data = [ | ||
'module_name_plural' => get_string('modulenameplural', 'adleradaptivity'), | ||
'course_format_uses_sections' => course_format_uses_sections($course->format), | ||
'column_title_section' => course_format_uses_sections($course->format) ? get_string('sectionname', 'format_' . $course->format) : '', | ||
'column_title_activity_name' => get_string('name'), | ||
|
||
'adleradaptivities' => array_map(function($adleradaptivity) use ($course) { | ||
return [ | ||
'section' => course_format_uses_sections($course->format) ? format_string(get_section_name($course, $adleradaptivity->section)) : '', | ||
'coursemodule_name' => format_string($adleradaptivity->name), | ||
'coursemodule_url' => new moodle_url('/mod/adleradaptivity/view.php', ['id' => $adleradaptivity->coursemodule]), | ||
]; | ||
}, $adleradaptivities) | ||
]; | ||
|
||
// Render the Mustache template with the data. | ||
return $this->render_from_template('mod_adleradaptivity/index_page', $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{! This is the Mustache template for the index page }} | ||
|
||
<h2>{{ module_name_plural }}</h2> | ||
|
||
|
||
<table class="generaltable"> | ||
<thead> | ||
<tr> | ||
{{#course_format_uses_sections}} | ||
<th>{{ column_title_section }}</th> | ||
{{/course_format_uses_sections}} | ||
<th>{{ column_title_activity_name }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#adleradaptivities}} | ||
<tr> | ||
{{#course_format_uses_sections}} | ||
<td>{{ section }}</td> | ||
{{/course_format_uses_sections}} | ||
<td><a href="{{ coursemodule_url }}">{{ coursemodule_name }}</a></td> | ||
</tr> | ||
|
||
{{/adleradaptivities}} | ||
</tbody> | ||
</table> |