Skip to content

Commit

Permalink
MDL-80746 mod_assign: fix action bar rendering
Browse files Browse the repository at this point in the history
As per prior commit, this fixes the export_for_template() method as
well as the template itself, ensuring no rendering is done in the
renderable, and ensuring the template defers to the comboboxsearch
or dialog partials with the data-only (no html) contexts.
  • Loading branch information
snake authored and Mihail Geshoski committed Sep 25, 2024
1 parent 8982cc6 commit b62aff2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
18 changes: 9 additions & 9 deletions mod/assign/classes/output/grading_actionmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

use assign;
use context_module;
use core_course\output\actionbar\group_selector;
use core_course\output\actionbar\user_selector;
use templatable;
use renderable;
use moodle_url;
Expand Down Expand Up @@ -88,12 +90,10 @@ public function __construct(
* @return array Data to render.
*/
public function export_for_template(\renderer_base $output): array {
global $PAGE, $OUTPUT;
global $PAGE;

$course = $this->assign->get_course();
$cm = get_coursemodule_from_id('assign', $this->cmid);
$actionbarrenderer = $PAGE->get_renderer('core_course', 'actionbar');

$data = [];

$userid = optional_param('userid', null, PARAM_INT);
Expand All @@ -103,15 +103,15 @@ public function export_for_template(\renderer_base $output): array {

$resetlink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grading']);
$groupid = groups_get_course_group($course, true);
$userselector = new \core_course\output\actionbar\user_selector(
$userselector = new user_selector(
course: $course,
resetlink: $resetlink,
userid: $userid,
groupid: $groupid,
usersearch: $usersearch,
instanceid: $this->assign->get_instance()->id
);
$data['userselector'] = $actionbarrenderer->render($userselector);
$data['userselector'] = $userselector->export_for_template($output);

$hasinitials = !empty($this->userinitials['firstname']) || !empty($this->userinitials['lastname']);
$additionalparams = ['action' => 'grading', 'id' => $this->cmid];
Expand All @@ -132,16 +132,16 @@ public function export_for_template(\renderer_base $output): array {
additionalparams: $additionalparams
);

$data['initialselector'] = $actionbarrenderer->render($initialselector);
$data['initialselector'] = $initialselector->export_for_template($output);

if (groups_get_activity_groupmode($cm, $course)) {
$data['groupselector'] = $actionbarrenderer->render(
new \core_course\output\actionbar\group_selector($PAGE->context));
$gs = new group_selector($PAGE->context);
$data['groupselector'] = $gs->export_for_template($output);
}

if ($extrafiltersdropdown = $this->get_extra_filters_dropdown()) {
$PAGE->requires->js_call_amd('mod_assign/actionbar/grading/extra_filters_dropdown', 'init', []);
$data['extrafiltersdropdown'] = $OUTPUT->render($extrafiltersdropdown);
$data['extrafiltersdropdown'] = $extrafiltersdropdown->export_for_template($output);
}

$activitygroup = groups_get_activity_group($cm);
Expand Down
13 changes: 7 additions & 6 deletions mod/assign/templates/grading_actionmenu.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
Example context (json):
{
"userselector": "<div class='user-search'></div>",
"groupselector": "<div class='group-selector'></div>",
"userselector": {"user selector": "context here"},
"groupselector": {"group selector": "context here"},
"initialselector": {"initial selector": "context here"},
"statusselector": {
"name": "filter",
"value": "submitted",
Expand Down Expand Up @@ -74,19 +75,19 @@
<div class="navitem-divider d-none d-sm-flex"></div>
{{#userselector}}
<div class="navitem">
{{{.}}}
{{>core/comboboxsearch}}
</div>
<div class="navitem-divider d-none d-sm-flex"></div>
{{/userselector}}
{{#groupselector}}
<div class="navitem">
{{{.}}}
{{>core/comboboxsearch}}
</div>
<div class="navitem-divider d-none d-sm-flex"></div>
{{/groupselector}}
{{#initialselector}}
<div class="navitem d-flex flex-column align-self-center">
{{{.}}}
{{>core/comboboxsearch}}
</div>
<div class="navitem-divider"></div>
{{/initialselector}}
Expand All @@ -103,7 +104,7 @@
{{/statusselector}}
{{#extrafiltersdropdown}}
<div class="navitem">
{{{.}}}
{{>core/local/dropdown/dialog}}
</div>
<div class="navitem-divider d-none d-sm-flex"></div>
{{/extrafiltersdropdown}}
Expand Down

0 comments on commit b62aff2

Please sign in to comment.