fixup! MDL-73354 mod_assign: General tidy up of tertiary navigation.

This commit is contained in:
Adrian Greeve 2022-02-08 10:01:55 +08:00
parent ddb35c124a
commit 965f4e74cd
5 changed files with 26 additions and 13 deletions

View File

@ -39,14 +39,24 @@ class grading_actionmenu implements templatable, renderable {
/** @var int Course module ID. */
protected $cmid;
/** @var bool If any submission plugins are enabled. */
protected $submissionpluginenabled;
/** @var int The number of submissions made. */
protected $submissioncount;
/**
* Constructor for this object.
*
* @param int $cmid Course module ID.
* @param bool $submissionpluginenabled If any submission plugins are enabled.
* @param int $submissioncount The number of submissions made.
*/
public function __construct(int $cmid) {
public function __construct(int $cmid, bool $submissionpluginenabled = false, int $submissioncount = 0) {
$this->cmid = $cmid;
$this->submissionpluginenabled = $submissionpluginenabled;
$this->submissioncount = $submissioncount;
}
/**
@ -56,9 +66,13 @@ class grading_actionmenu implements templatable, renderable {
* @return array Data to render.
*/
public function export_for_template(\renderer_base $output): array {
$downloadall = '';
if ($this->submissionpluginenabled && $this->submissioncount) {
$downloadall = (new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'downloadall']))->out(false);
}
return [
'back' => (new moodle_url('/mod/assign/view.php', ['id' => $this->cmid]))->out(false),
'downloadall' => (new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'downloadall']))->out(false)
'downloadall' => $downloadall
];
}
}

View File

@ -61,10 +61,10 @@ class user_submission_actionmenu implements templatable, renderable {
* @param bool $showedit Whether to show the edit button.
* @param stdClass|null $submission A submission for this activity.
* @param stdClass|null $teamsubmission A team submission for this activity.
* @param int|null $timelimit The time limit for completing this activity.
* @param int $timelimit The time limit for completing this activity.
*/
public function __construct(int $cmid, bool $showsubmit, bool $showedit, stdClass $submission = null,
stdClass $teamsubmission = null, $timelimit = 0) {
stdClass $teamsubmission = null, int $timelimit = 0) {
$this->cmid = $cmid;
$this->showsubmit = $showsubmit;
@ -119,7 +119,7 @@ class user_submission_actionmenu implements templatable, renderable {
'help' => $help->export_for_template($output)
];
$url = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'editsubmission']);
$newattemptbutton = new single_button($url, get_string('addnewattempt', 'mod_assign'), 'get');
$newattemptbutton = new single_button($url, get_string('addnewattempt', 'mod_assign'), 'get', true);
$newattempthelp = new help_icon('addnewattempt', 'mod_assign');
$data['edit']['button'] = $newattemptbutton->export_for_template($output);
$data['edit']['help'] = $newattempthelp->export_for_template($output);

View File

@ -4536,10 +4536,6 @@ class assign {
$gradebookurl = '/grade/report/grader/index.php?id=' . $this->get_course()->id;
$links[$gradebookurl] = get_string('viewgradebook', 'assign');
}
if ($this->is_any_submission_plugin_enabled() && $this->count_submissions()) {
$downloadurl = '/mod/assign/view.php?id=' . $cmid . '&action=downloadall';
$links[$downloadurl] = get_string('downloadall', 'assign');
}
if ($this->is_blind_marking() &&
has_capability('mod/assign:revealidentities', $this->get_context())) {
$revealidentitiesurl = '/mod/assign/view.php?id=' . $cmid . '&action=revealidentities';
@ -4641,9 +4637,9 @@ class assign {
$gradingoptionsdata->workflowfilter = $workflowfilter;
$gradingoptionsform->set_data($gradingoptionsdata);
$buttons = new \mod_assign\output\grading_actionmenu($this->get_course_module()->id);
$buttons = new \mod_assign\output\grading_actionmenu($this->get_course_module()->id,
$this->is_any_submission_plugin_enabled(), $this->count_submissions());
$actionformtext = $this->get_renderer()->render($buttons);
$actionformtext .= $this->get_renderer()->render($gradingactions);
$PAGE->activityheader->set_attrs(['hidecompletion' => true]);
$currenturl = new moodle_url('/mod/assign/view.php', ['id' => $this->get_course_module()->id, 'action' => 'grading']);
@ -4661,6 +4657,7 @@ class assign {
$o .= $actionformtext;
$o .= $this->get_renderer()->heading(get_string('gradeitem:submissions', 'mod_assign'), 2);
$o .= $this->get_renderer()->render($gradingactions);
$o .= groups_print_activity_menu($this->get_course_module(), $currenturl, true);
@ -4930,7 +4927,7 @@ class assign {
$PAGE->blocks->add_fake_block($bc, reset($regions));
}
$PAGE->activityheader->set_hidecompletion(true);
$PAGE->activityheader->disable();
$o .= $this->get_renderer()->render(
new assign_header($this->get_instance(),

View File

@ -570,7 +570,7 @@ class assign_grading_summary implements renderable {
* @param int $coursestartdate unix timestamp representation of the course start date.
* @param bool $cangrade
* @param bool $isvisible
* @param cm_info $cm The course module object.
* @param cm_info|null $cm The course module object.
*/
public function __construct($participantcount,
$submissiondraftsenabled,

View File

@ -37,8 +37,10 @@
<div class="float-left">
<a class="btn btn-secondary" href="{{back}}">{{#str}}back, mod_assign{{/str}}</a>
</div>
{{#downloadall}}
<div class="float-right">
<a class="btn btn-secondary" href="{{downloadall}}">{{#str}}downloadall, mod_assign{{/str}}</a>
</div>
{{/downloadall}}
</div>
</div>