From 33e6a36daf1e999c81511283b07fe680a16a7be4 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Wed, 12 Jan 2022 14:52:52 +0800 Subject: [PATCH 1/7] MDL-73354 mod_assign: General tidy up of tertiary navigation. --- mod/assign/classes/output/renderer.php | 86 ++----------------- .../output/user_submission_actionmenu.php | 2 +- mod/assign/lib.php | 9 -- mod/assign/locallib.php | 23 +++-- mod/assign/renderable.php | 7 +- 5 files changed, 28 insertions(+), 99 deletions(-) diff --git a/mod/assign/classes/output/renderer.php b/mod/assign/classes/output/renderer.php index 216e21e7156..3097c8fcedf 100644 --- a/mod/assign/classes/output/renderer.php +++ b/mod/assign/classes/output/renderer.php @@ -286,6 +286,12 @@ class renderer extends \plugin_renderer_base { $o = ''; $o .= $this->output->container_start('gradingsummary'); $o .= $this->output->heading(get_string('gradingsummary', 'assign'), 3); + + if (isset($summary->cm)) { + $currenturl = new \moodle_url('/mod/assign/view.php', array('id' => $summary->cm->id)); + $o .= groups_print_activity_menu($summary->cm, $currenturl->out(), true); + } + $o .= $this->output->box_start('boxaligncenter gradingsummarytable'); $t = new \html_table(); $t->attributes['class'] = 'generaltable table-bordered'; @@ -844,86 +850,6 @@ class renderer extends \plugin_renderer_base { $o .= \html_writer::table($t); $o .= $this->output->box_end(); - // Links. - if ($status->view == assign_submission_status::STUDENT_VIEW) { - if ($status->canedit) { - if (!$submission || $submission->status == ASSIGN_SUBMISSION_STATUS_NEW) { - $o .= $this->output->box_start('generalbox submissionaction'); - $urlparams = array('id' => $status->coursemoduleid, 'action' => 'editsubmission'); - - if ($timelimitenabled && empty($submission->timestarted)) { - $confirmation = new \confirm_action( - get_string( - 'confirmstart', - 'assign', - format_time($status->timelimit) - ), - null, - get_string('beginassignment', 'assign') - ); - $o .= $this->output->action_link( - new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('beginassignment', 'assign'), - $confirmation, - array('class' => 'btn btn-primary') - ); - } else { - $o .= $this->output->single_button( - new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('addsubmission', 'assign'), 'get', array('primary' => true) - ); - } - - $o .= $this->output->box_start('boxaligncenter submithelp'); - $o .= get_string('addsubmission_help', 'assign'); - $o .= $this->output->box_end(); - $o .= $this->output->box_end(); - } else if ($submission->status == ASSIGN_SUBMISSION_STATUS_REOPENED) { - $o .= $this->output->box_start('generalbox submissionaction'); - $urlparams = array('id' => $status->coursemoduleid, - 'action' => 'editprevioussubmission', - 'sesskey'=>sesskey()); - $o .= $this->output->single_button(new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('addnewattemptfromprevious', 'assign'), 'get'); - $o .= $this->output->box_start('boxaligncenter submithelp'); - $o .= get_string('addnewattemptfromprevious_help', 'assign'); - $o .= $this->output->box_end(); - $o .= $this->output->box_end(); - $o .= $this->output->box_start('generalbox submissionaction'); - $urlparams = array('id' => $status->coursemoduleid, 'action' => 'editsubmission'); - $o .= $this->output->single_button(new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('addnewattempt', 'assign'), 'get'); - $o .= $this->output->box_start('boxaligncenter submithelp'); - $o .= get_string('addnewattempt_help', 'assign'); - $o .= $this->output->box_end(); - $o .= $this->output->box_end(); - } else { - $o .= $this->output->box_start('generalbox submissionaction'); - $urlparams = array('id' => $status->coursemoduleid, 'action' => 'editsubmission'); - $o .= $this->output->single_button(new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('editsubmission', 'assign'), 'get'); - $urlparams = array('id' => $status->coursemoduleid, 'action' => 'removesubmissionconfirm'); - $o .= $this->output->single_button(new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('removesubmission', 'assign'), 'get'); - $o .= $this->output->box_start('boxaligncenter submithelp'); - $o .= get_string('editsubmission_help', 'assign'); - $o .= $this->output->box_end(); - $o .= $this->output->box_end(); - } - } - - if ($status->cansubmit) { - $urlparams = array('id' => $status->coursemoduleid, 'action'=>'submit'); - $o .= $this->output->box_start('generalbox submissionaction'); - $o .= $this->output->single_button(new \moodle_url('/mod/assign/view.php', $urlparams), - get_string('submitassignment', 'assign'), 'get'); - $o .= $this->output->box_start('boxaligncenter submithelp'); - $o .= get_string('submitassignment_help', 'assign'); - $o .= $this->output->box_end(); - $o .= $this->output->box_end(); - } - } - $o .= $this->output->container_end(); return $o; } diff --git a/mod/assign/classes/output/user_submission_actionmenu.php b/mod/assign/classes/output/user_submission_actionmenu.php index 09ab87d9396..4f7e2dccfba 100644 --- a/mod/assign/classes/output/user_submission_actionmenu.php +++ b/mod/assign/classes/output/user_submission_actionmenu.php @@ -121,7 +121,7 @@ class user_submission_actionmenu implements templatable, renderable { $data['edit']['help'] = $newattempthelp->export_for_template($output); } if ($status === ASSIGN_SUBMISSION_STATUS_NEW) { - $newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get'); + $newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get', true); $data['edit']['button'] = $newattemptbutton->export_for_template($output); $data['edit']['help'] = ''; } diff --git a/mod/assign/lib.php b/mod/assign/lib.php index d1f9c785f96..8d3c0739b49 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -442,15 +442,6 @@ function assign_extend_settings_navigation(settings_navigation $settings, naviga $navref->add_node($node, $beforekey); } - // Link to gradebook. - if (has_capability('gradereport/grader:view', $cm->context) && - has_capability('moodle/grade:viewall', $cm->context)) { - $link = new moodle_url('/grade/report/grader/index.php', array('id' => $course->id)); - $linkname = get_string('viewgradebook', 'assign'); - $node = $navref->add($linkname, $link, navigation_node::TYPE_SETTING); - $node->set_force_into_more_menu(true); - } - if (has_capability('mod/assign:revealidentities', $context)) { $dbparams = array('id'=>$cm->instance); $assignment = $DB->get_record('assign', $dbparams, 'blindmarking, revealidentities'); diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 99049f9b40e..a1a5f088bd8 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -4521,7 +4521,7 @@ class assign { * @return string */ protected function view_grading_table() { - global $USER, $CFG, $SESSION; + global $USER, $CFG, $SESSION, $PAGE; // Include grading options form. require_once($CFG->dirroot . '/mod/assign/gradingoptionsform.php'); @@ -4563,6 +4563,7 @@ class assign { $gradingactions = new url_select($links); $gradingactions->set_label(get_string('choosegradingaction', 'assign')); + $gradingactions->class .= ' mb-1'; $gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions'); @@ -4643,6 +4644,7 @@ class assign { $buttons = new \mod_assign\output\grading_actionmenu($this->get_course_module()->id); $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']); @@ -4651,11 +4653,14 @@ class assign { false, $this->get_course_module()->id, get_string('grading', 'assign'), - $actionformtext, + '', '', $currenturl); $o .= $this->get_renderer()->render($header); + $o .= $actionformtext; + + $o .= $this->get_renderer()->heading(get_string('gradeitem:submissions', 'mod_assign'), 2); $o .= groups_print_activity_menu($this->get_course_module(), $currenturl, true); @@ -4924,6 +4929,8 @@ class assign { $bc->content = $navbc; $PAGE->blocks->add_fake_block($bc, reset($regions)); } + $PAGE->activityheader->disable(); + $o .= $this->get_renderer()->render( new assign_header($this->get_instance(), $this->get_context(), @@ -5835,7 +5842,8 @@ class assign { $course->relativedatesmode, $course->startdate, $this->can_grade(), - $isvisible + $isvisible, + $this->get_course_module() ); } else { // The active group has already been updated in groups_print_activity_menu(). @@ -5856,7 +5864,8 @@ class assign { $course->relativedatesmode, $course->startdate, $this->can_grade(), - $isvisible + $isvisible, + $this->get_course_module() ); } @@ -5922,10 +5931,6 @@ class assign { $actionbuttons = new \mod_assign\output\actionmenu($this->get_course_module()->id); $o .= $this->get_renderer()->submission_actionmenu($actionbuttons); - // Group selector will only be displayed if necessary. - $currenturl = new moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id)); - $o .= groups_print_activity_menu($this->get_course_module(), $currenturl->out(), true); - $summary = $this->get_assign_grading_summary_renderable(); $o .= $this->get_renderer()->render($summary); } @@ -8207,6 +8212,8 @@ class assign { $requiresubmissionstatement = false; } + $mform->addElement('header', 'submission header', get_string('addsubmission', 'mod_assign')); + // Only show submission statement if we are editing our own submission. if ($requiresubmissionstatement && !$draftsenabled && $userid == $USER->id) { $mform->addElement('checkbox', 'submissionstatement', '', $submissionstatement); diff --git a/mod/assign/renderable.php b/mod/assign/renderable.php index ef67918a054..70e9134ec76 100644 --- a/mod/assign/renderable.php +++ b/mod/assign/renderable.php @@ -541,6 +541,8 @@ class assign_grading_summary implements renderable { public $cangrade = false; /** @var boolean isvisible - Is the assignment's context module visible to students? */ public $isvisible = true; + /** @var cm_info $cm - The course module object. */ + public $cm = null; /** @var string no warning needed about group submissions */ const WARN_GROUPS_NO = false; @@ -568,6 +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. */ public function __construct($participantcount, $submissiondraftsenabled, @@ -584,7 +587,8 @@ class assign_grading_summary implements renderable { $courserelativedatesmode, $coursestartdate, $cangrade = true, - $isvisible = true) { + $isvisible = true, + cm_info $cm = null) { $this->participantcount = $participantcount; $this->submissiondraftsenabled = $submissiondraftsenabled; $this->submissiondraftscount = $submissiondraftscount; @@ -601,6 +605,7 @@ class assign_grading_summary implements renderable { $this->coursestartdate = $coursestartdate; $this->cangrade = $cangrade; $this->isvisible = $isvisible; + $this->cm = $cm; } } From 1b0fec7f03baf06afb654fa148ccab964ad6c693 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 13 Jan 2022 12:55:19 +0800 Subject: [PATCH 2/7] MDL-73354 mod_assign: Overrides page updates to tertiary navigation. --- mod/assign/classes/output/override_actionmenu.php | 15 ++++++--------- mod/assign/lang/en/assign.php | 2 ++ mod/assign/override_form.php | 4 ++-- mod/assign/overrideedit.php | 1 + mod/assign/overrides.php | 8 ++++++++ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/mod/assign/classes/output/override_actionmenu.php b/mod/assign/classes/output/override_actionmenu.php index 05bcae3a1cd..5779012fc07 100644 --- a/mod/assign/classes/output/override_actionmenu.php +++ b/mod/assign/classes/output/override_actionmenu.php @@ -44,8 +44,6 @@ class override_actionmenu implements templatable, renderable { protected $currenturl; /** @var \cm_info course module information */ protected $cm; - /** @var int The activity group mode */ - protected $groupmode; /** @var bool Can all groups be accessed */ protected $canaccessallgroups; /** @var array Groups related to this activity */ @@ -60,8 +58,8 @@ class override_actionmenu implements templatable, renderable { public function __construct(moodle_url $currenturl, \cm_info $cm) { $this->currenturl = $currenturl; $this->cm = $cm; - $this->groupmode = groups_get_activity_groupmode($this->cm); - $this->canaccessallgroups = ($this->groupmode === NOGROUPS) || + $groupmode = groups_get_activity_groupmode($this->cm); + $this->canaccessallgroups = ($groupmode === NOGROUPS) || has_capability('moodle/site:accessallgroups', $this->cm->context); $this->groups = $this->canaccessallgroups ? groups_get_all_groups($this->cm->course) : groups_get_activity_allowed_groups($this->cm); @@ -83,15 +81,14 @@ class override_actionmenu implements templatable, renderable { } /** - * Whether to show groups or not. + * Whether to show groups or not. Assignments can be have group overrides if there are groups available in the course. + * There is no restriction related to the assignment group setting. * * @return bool */ protected function show_groups(): bool { - if ($this->groupmode == NOGROUPS) { - return false; - } - return !empty($this->groups); + $groups = groups_get_all_groups($this->cm->course); + return !(empty($groups)); } /** diff --git a/mod/assign/lang/en/assign.php b/mod/assign/lang/en/assign.php index cf24524869d..45a29180974 100644 --- a/mod/assign/lang/en/assign.php +++ b/mod/assign/lang/en/assign.php @@ -389,6 +389,8 @@ $string['none'] = 'None'; $string['noonlinesubmissions'] = 'This assignment does not require you to submit anything online'; $string['noopen'] = 'No open date'; $string['nooverridedata'] = 'You must override at least one of the assignment settings.'; +$string['nogroupoverrides'] = 'There are currently no group overrides.'; +$string['nouseroverrides'] = 'There are currently no user overrides.'; $string['nosavebutnext'] = 'Next'; $string['nosubmission'] = 'Nothing has been submitted for this assignment'; $string['nosubmissionyet'] = 'No submissions have been made yet'; diff --git a/mod/assign/override_form.php b/mod/assign/override_form.php index ffa8f2c806f..2533f833810 100644 --- a/mod/assign/override_form.php +++ b/mod/assign/override_form.php @@ -98,12 +98,11 @@ class assign_override_form extends moodleform { $assigninstance = $this->assign->get_instance($userid); $inrelativedatesmode = !empty($this->assign->get_course()->relativedatesmode); - $mform->addElement('header', 'override', get_string('override', 'assign')); - $assigngroupmode = groups_get_activity_groupmode($cm); $accessallgroups = ($assigngroupmode == NOGROUPS) || has_capability('moodle/site:accessallgroups', $this->context); if ($this->groupmode) { + $mform->addElement('header', 'override', get_string('groupoverrides', 'assign')); // Group override. if ($this->groupid) { // There is already a groupid, so freeze the selector. @@ -141,6 +140,7 @@ class assign_override_form extends moodleform { $mform->addRule('groupid', get_string('required'), 'required', null, 'client'); } } else { + $mform->addElement('header', 'override', get_string('useroverrides', 'assign')); // User override. if ($this->userid) { // There is already a userid, so freeze the selector. diff --git a/mod/assign/overrideedit.php b/mod/assign/overrideedit.php index 87cc0442580..28c05295a7b 100644 --- a/mod/assign/overrideedit.php +++ b/mod/assign/overrideedit.php @@ -257,6 +257,7 @@ $PAGE->navbar->add($pagetitle); $PAGE->set_pagelayout('admin'); $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); +$PAGE->set_secondary_active_tab('mod_assign_useroverrides'); $activityheader = $PAGE->activityheader; $activityheader->set_attrs([ 'description' => '', diff --git a/mod/assign/overrides.php b/mod/assign/overrides.php index 806c716c1c6..42494351a8b 100644 --- a/mod/assign/overrides.php +++ b/mod/assign/overrides.php @@ -89,6 +89,7 @@ $activityheader->set_attrs([ 'title' => $activityheader->is_title_allowed() ? format_string($assign->name, true, ['context' => $context]) : "" ]); echo $OUTPUT->header(); +echo $OUTPUT->heading(get_string('overrides', 'mod_assign'), 2); $overridemenu = new \mod_assign\output\override_actionmenu($url, $cm); $renderer = $PAGE->get_renderer('mod_assign'); echo $renderer->render($overridemenu); @@ -298,7 +299,14 @@ foreach ($overrides as $override) { echo html_writer::start_tag('div', array('id' => 'assignoverrides')); if (count($table->data)) { echo html_writer::table($table); +} else { + if ($groupmode) { + echo $OUTPUT->notification(get_string('nogroupoverrides', 'mod_assign'), 'info'); + } else { + echo $OUTPUT->notification(get_string('nouseroverrides', 'mod_assign'), 'info'); + } } + if ($hasinactive) { echo $OUTPUT->notification(get_string('inactiveoverridehelp', 'assign'), 'dimmed_text'); } From 75aed26e78df6b0f083255a205424350898d3bcf Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Fri, 14 Jan 2022 15:46:26 +0800 Subject: [PATCH 3/7] MDL-73354 advanced grading: Updated management page. The management page will no longer show the activity name in the title if using secondary navigation. --- .../rubric/tests/behat/publish_rubric_templates.feature | 2 +- grade/grading/manage.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grade/grading/form/rubric/tests/behat/publish_rubric_templates.feature b/grade/grading/form/rubric/tests/behat/publish_rubric_templates.feature index c1a5cbdf1e1..a94dfe353cd 100644 --- a/grade/grading/form/rubric/tests/behat/publish_rubric_templates.feature +++ b/grade/grading/form/rubric/tests/behat/publish_rubric_templates.feature @@ -37,7 +37,7 @@ Feature: Publish rubrics as templates And I log in as "teacher1" And I am on "Course 1" course homepage And I set "Test assignment 2 name" activity to use "Assignment 1 rubric" grading form - Then I should see "Advanced grading: Test assignment 2 name (Submissions)" + Then I should see "Advanced grading" And I should see "Criterion 1" And I should see "Assignment 1 description" And I go to "Test assignment 2 name" advanced grading definition page diff --git a/grade/grading/manage.php b/grade/grading/manage.php index d38c96721dc..12034fea664 100644 --- a/grade/grading/manage.php +++ b/grade/grading/manage.php @@ -148,8 +148,12 @@ if (!empty($message)) { echo $output->management_message($message); } -echo $output->heading(get_string('gradingmanagementtitle', 'core_grading', array( - 'component' => $manager->get_component_title(), 'area' => $manager->get_area_title()))); +if ($PAGE->has_secondary_navigation()) { + echo $output->heading(get_string('gradingmanagement', 'core_grading')); +} else { + echo $output->heading(get_string('gradingmanagementtitle', 'core_grading', array( + 'component' => $manager->get_component_title(), 'area' => $manager->get_area_title()))); +} // display the active grading method information and selector echo $output->management_method_selector($manager, $PAGE->url); From c565ec4535e5b1014653b623fef5ec19e921b414 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 18 Jan 2022 14:37:20 +0800 Subject: [PATCH 4/7] MDL-73354 mod_assign: Removed unused test code. --- mod/assign/view.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mod/assign/view.php b/mod/assign/view.php index a38d6fcbce2..830fec3a11c 100644 --- a/mod/assign/view.php +++ b/mod/assign/view.php @@ -43,13 +43,6 @@ $urlparams = array('id' => $id, $url = new moodle_url('/mod/assign/view.php', $urlparams); $PAGE->set_url($url); -// MDL-71915 Will remove this place holder. -if (defined('BEHAT_SITE_RUNNING')) { - $PAGE->has_secondary_navigation_setter(false); - if ($urlparams['action'] !== 'grader') { - $PAGE->add_header_action($OUTPUT->region_main_settings_menu()); - } -} // Update module completion status. $assign->set_module_viewed(); From ac32195022f88e1f421bae5bfbf6c99dbe49636f Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Thu, 20 Jan 2022 15:20:52 +0800 Subject: [PATCH 5/7] MDL-73354 mod_assign: Fixed broken timed assignment feature. --- mod/assign/classes/output/renderer.php | 6 ++-- .../output/user_submission_actionmenu.php | 31 ++++++++++++++++--- mod/assign/locallib.php | 8 +++-- .../user_submission_actionmenu.mustache | 19 ++++++++---- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/mod/assign/classes/output/renderer.php b/mod/assign/classes/output/renderer.php index 3097c8fcedf..cf68a47c58d 100644 --- a/mod/assign/classes/output/renderer.php +++ b/mod/assign/classes/output/renderer.php @@ -245,9 +245,11 @@ class renderer extends \plugin_renderer_base { $this->page->set_heading($this->page->course->fullname); $description = $header->preface; - if ($header->showintro) { + if ($header->showintro || $header->activity) { $description = $this->output->box_start('generalbox boxaligncenter', 'intro'); - $description .= format_module_intro('assign', $header->assign, $header->coursemoduleid); + if ($header->showintro) { + $description .= format_module_intro('assign', $header->assign, $header->coursemoduleid); + } if ($header->activity) { $description .= $this->format_activity_text($header->assign, $header->coursemoduleid); } diff --git a/mod/assign/classes/output/user_submission_actionmenu.php b/mod/assign/classes/output/user_submission_actionmenu.php index 4f7e2dccfba..3717013f58f 100644 --- a/mod/assign/classes/output/user_submission_actionmenu.php +++ b/mod/assign/classes/output/user_submission_actionmenu.php @@ -50,6 +50,8 @@ class user_submission_actionmenu implements templatable, renderable { protected $submission; /** @var stdClass A team submission for this activity. */ protected $teamsubmission; + /** @var int The time limit for the submission. 0 = no time limit. */ + protected $timelimit; /** * Constructor for this object. @@ -59,15 +61,17 @@ 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. */ public function __construct(int $cmid, bool $showsubmit, bool $showedit, stdClass $submission = null, - stdClass $teamsubmission = null) { + stdClass $teamsubmission = null, $timelimit = 0) { $this->cmid = $cmid; $this->showsubmit = $showsubmit; $this->showedit = $showedit; $this->submission = $submission; $this->teamsubmission = $teamsubmission; + $this->timelimit = $timelimit; } /** @@ -121,9 +125,28 @@ class user_submission_actionmenu implements templatable, renderable { $data['edit']['help'] = $newattempthelp->export_for_template($output); } if ($status === ASSIGN_SUBMISSION_STATUS_NEW) { - $newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get', true); - $data['edit']['button'] = $newattemptbutton->export_for_template($output); - $data['edit']['help'] = ''; + + if ($this->timelimit && empty($this->submission->timestarted)) { + $confirmation = new \confirm_action( + get_string('confirmstart', 'assign', format_time($this->timelimit)), + null, + get_string('beginassignment', 'assign') + ); + $urlparams = array('id' => $this->cmid, 'action' => 'editsubmission'); + $beginbutton = new \action_link( + new moodle_url('/mod/assign/view.php', $urlparams), + get_string('beginassignment', 'assign'), + $confirmation, + ['class' => 'btn btn-primary'] + ); + $data['edit']['button'] = $beginbutton->export_for_template($output); + $data['edit']['begin'] = true; + $data['edit']['help'] = ''; + } else { + $newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get', true); + $data['edit']['button'] = $newattemptbutton->export_for_template($output); + $data['edit']['help'] = ''; + } } } if ($this->showsubmit) { diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index a1a5f088bd8..5863c17b561 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -4929,12 +4929,13 @@ class assign { $bc->content = $navbc; $PAGE->blocks->add_fake_block($bc, reset($regions)); } - $PAGE->activityheader->disable(); + + $PAGE->activityheader->set_hidecompletion(true); $o .= $this->get_renderer()->render( new assign_header($this->get_instance(), $this->get_context(), - $this->show_intro(), + false, $this->get_course_module()->id, $title, '', @@ -5979,7 +5980,8 @@ class assign { $showsubmit, $showedit, $submission, - $teamsubmission + $teamsubmission, + $instance->timelimit ); return $this->get_renderer()->render($actionbuttons); diff --git a/mod/assign/templates/user_submission_actionmenu.mustache b/mod/assign/templates/user_submission_actionmenu.mustache index 28e5d6df6e9..2bb2c94794c 100644 --- a/mod/assign/templates/user_submission_actionmenu.mustache +++ b/mod/assign/templates/user_submission_actionmenu.mustache @@ -166,12 +166,19 @@ {{/previoussubmission}} {{#edit}}
- {{#button}} - {{>core/single_button}} - {{/button}} - {{#help}} - {{>core/help_icon}} - {{/help}} + {{#begin}} + {{#button}} + {{>core/action_link}} + {{/button}} + {{/begin}} + {{^begin}} + {{#button}} + {{>core/single_button}} + {{/button}} + {{#help}} + {{>core/help_icon}} + {{/help}} + {{/begin}}
{{/edit}} {{#remove}} From ddb35c124a57f43bf59e009714314361ac7f1136 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 8 Feb 2022 10:01:43 +0800 Subject: [PATCH 6/7] fixup! MDL-73354 mod_assign: Overrides page updates to tertiary navigation. --- mod/assign/overridedelete.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mod/assign/overridedelete.php b/mod/assign/overridedelete.php index 611f458bb83..f00fc9a7a6e 100644 --- a/mod/assign/overridedelete.php +++ b/mod/assign/overridedelete.php @@ -87,6 +87,7 @@ $PAGE->activityheader->set_attrs([ "description" => "", "hidecompletion" => true ]); +$PAGE->set_secondary_active_tab('mod_assign_useroverrides'); echo $OUTPUT->header(); From 965f4e74cdf4128f6ed0ef898514ecd1e9cf2d6d Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 8 Feb 2022 10:01:55 +0800 Subject: [PATCH 7/7] fixup! MDL-73354 mod_assign: General tidy up of tertiary navigation. --- .../classes/output/grading_actionmenu.php | 18 ++++++++++++++++-- .../output/user_submission_actionmenu.php | 6 +++--- mod/assign/locallib.php | 11 ++++------- mod/assign/renderable.php | 2 +- .../templates/grading_actionmenu.mustache | 2 ++ 5 files changed, 26 insertions(+), 13 deletions(-) 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 @@ + {{#downloadall}} + {{/downloadall}}