diff --git a/mod/assign/classes/output/grading_actionmenu.php b/mod/assign/classes/output/grading_actionmenu.php index 62f2d88af9a..9cac2d04e30 100644 --- a/mod/assign/classes/output/grading_actionmenu.php +++ b/mod/assign/classes/output/grading_actionmenu.php @@ -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 ]; } } diff --git a/mod/assign/classes/output/user_submission_actionmenu.php b/mod/assign/classes/output/user_submission_actionmenu.php index 3717013f58f..e42fb6ac2b5 100644 --- a/mod/assign/classes/output/user_submission_actionmenu.php +++ b/mod/assign/classes/output/user_submission_actionmenu.php @@ -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); diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 5863c17b561..57e9ec074c1 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -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(), diff --git a/mod/assign/renderable.php b/mod/assign/renderable.php index 70e9134ec76..c6240963526 100644 --- a/mod/assign/renderable.php +++ b/mod/assign/renderable.php @@ -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, diff --git a/mod/assign/templates/grading_actionmenu.mustache b/mod/assign/templates/grading_actionmenu.mustache index fe77a9ffd0d..a7e0720b084 100644 --- a/mod/assign/templates/grading_actionmenu.mustache +++ b/mod/assign/templates/grading_actionmenu.mustache @@ -37,8 +37,10 @@
{{#str}}back, mod_assign{{/str}}
+ {{#downloadall}}
{{#str}}downloadall, mod_assign{{/str}}
+ {{/downloadall}}