Skip to content

Commit

Permalink
fixup! MDL-73354 mod_assign: General tidy up of tertiary navigation.
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Feb 9, 2022
1 parent ddb35c1 commit 965f4e7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
18 changes: 16 additions & 2 deletions mod/assign/classes/output/grading_actionmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

/**
Expand All @@ -56,9 +66,13 @@ public function __construct(int $cmid) {
* @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
];
}
}
6 changes: 3 additions & 3 deletions mod/assign/classes/output/user_submission_actionmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -119,7 +119,7 @@ public function export_for_template(\renderer_base $output): array {
'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);
Expand Down
11 changes: 4 additions & 7 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4536,10 +4536,6 @@ protected function view_grading_table() {
$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';
Expand Down Expand Up @@ -4641,9 +4637,9 @@ protected function view_grading_table() {
$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']);
Expand All @@ -4661,6 +4657,7 @@ protected function view_grading_table() {
$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);

Expand Down Expand Up @@ -4930,7 +4927,7 @@ protected function view_edit_submission_page($mform, $notices) {
$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(),
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/templates/grading_actionmenu.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 965f4e7

Please sign in to comment.