MDL-73354 mod_assign: Overrides page updates to tertiary navigation.

This commit is contained in:
Adrian Greeve 2022-01-13 12:55:19 +08:00
parent 33e6a36daf
commit 1b0fec7f03
5 changed files with 19 additions and 11 deletions

View file

@ -44,8 +44,6 @@ class override_actionmenu implements templatable, renderable {
protected $currenturl; protected $currenturl;
/** @var \cm_info course module information */ /** @var \cm_info course module information */
protected $cm; protected $cm;
/** @var int The activity group mode */
protected $groupmode;
/** @var bool Can all groups be accessed */ /** @var bool Can all groups be accessed */
protected $canaccessallgroups; protected $canaccessallgroups;
/** @var array Groups related to this activity */ /** @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) { public function __construct(moodle_url $currenturl, \cm_info $cm) {
$this->currenturl = $currenturl; $this->currenturl = $currenturl;
$this->cm = $cm; $this->cm = $cm;
$this->groupmode = groups_get_activity_groupmode($this->cm); $groupmode = groups_get_activity_groupmode($this->cm);
$this->canaccessallgroups = ($this->groupmode === NOGROUPS) || $this->canaccessallgroups = ($groupmode === NOGROUPS) ||
has_capability('moodle/site:accessallgroups', $this->cm->context); has_capability('moodle/site:accessallgroups', $this->cm->context);
$this->groups = $this->canaccessallgroups ? groups_get_all_groups($this->cm->course) : $this->groups = $this->canaccessallgroups ? groups_get_all_groups($this->cm->course) :
groups_get_activity_allowed_groups($this->cm); 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 * @return bool
*/ */
protected function show_groups(): bool { protected function show_groups(): bool {
if ($this->groupmode == NOGROUPS) { $groups = groups_get_all_groups($this->cm->course);
return false; return !(empty($groups));
}
return !empty($this->groups);
} }
/** /**

View file

@ -389,6 +389,8 @@ $string['none'] = 'None';
$string['noonlinesubmissions'] = 'This assignment does not require you to submit anything online'; $string['noonlinesubmissions'] = 'This assignment does not require you to submit anything online';
$string['noopen'] = 'No open date'; $string['noopen'] = 'No open date';
$string['nooverridedata'] = 'You must override at least one of the assignment settings.'; $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['nosavebutnext'] = 'Next';
$string['nosubmission'] = 'Nothing has been submitted for this assignment'; $string['nosubmission'] = 'Nothing has been submitted for this assignment';
$string['nosubmissionyet'] = 'No submissions have been made yet'; $string['nosubmissionyet'] = 'No submissions have been made yet';

View file

@ -98,12 +98,11 @@ class assign_override_form extends moodleform {
$assigninstance = $this->assign->get_instance($userid); $assigninstance = $this->assign->get_instance($userid);
$inrelativedatesmode = !empty($this->assign->get_course()->relativedatesmode); $inrelativedatesmode = !empty($this->assign->get_course()->relativedatesmode);
$mform->addElement('header', 'override', get_string('override', 'assign'));
$assigngroupmode = groups_get_activity_groupmode($cm); $assigngroupmode = groups_get_activity_groupmode($cm);
$accessallgroups = ($assigngroupmode == NOGROUPS) || has_capability('moodle/site:accessallgroups', $this->context); $accessallgroups = ($assigngroupmode == NOGROUPS) || has_capability('moodle/site:accessallgroups', $this->context);
if ($this->groupmode) { if ($this->groupmode) {
$mform->addElement('header', 'override', get_string('groupoverrides', 'assign'));
// Group override. // Group override.
if ($this->groupid) { if ($this->groupid) {
// There is already a groupid, so freeze the selector. // 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'); $mform->addRule('groupid', get_string('required'), 'required', null, 'client');
} }
} else { } else {
$mform->addElement('header', 'override', get_string('useroverrides', 'assign'));
// User override. // User override.
if ($this->userid) { if ($this->userid) {
// There is already a userid, so freeze the selector. // There is already a userid, so freeze the selector.

View file

@ -257,6 +257,7 @@ $PAGE->navbar->add($pagetitle);
$PAGE->set_pagelayout('admin'); $PAGE->set_pagelayout('admin');
$PAGE->set_title($pagetitle); $PAGE->set_title($pagetitle);
$PAGE->set_heading($course->fullname); $PAGE->set_heading($course->fullname);
$PAGE->set_secondary_active_tab('mod_assign_useroverrides');
$activityheader = $PAGE->activityheader; $activityheader = $PAGE->activityheader;
$activityheader->set_attrs([ $activityheader->set_attrs([
'description' => '', 'description' => '',

View file

@ -89,6 +89,7 @@ $activityheader->set_attrs([
'title' => $activityheader->is_title_allowed() ? format_string($assign->name, true, ['context' => $context]) : "" 'title' => $activityheader->is_title_allowed() ? format_string($assign->name, true, ['context' => $context]) : ""
]); ]);
echo $OUTPUT->header(); echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('overrides', 'mod_assign'), 2);
$overridemenu = new \mod_assign\output\override_actionmenu($url, $cm); $overridemenu = new \mod_assign\output\override_actionmenu($url, $cm);
$renderer = $PAGE->get_renderer('mod_assign'); $renderer = $PAGE->get_renderer('mod_assign');
echo $renderer->render($overridemenu); echo $renderer->render($overridemenu);
@ -298,7 +299,14 @@ foreach ($overrides as $override) {
echo html_writer::start_tag('div', array('id' => 'assignoverrides')); echo html_writer::start_tag('div', array('id' => 'assignoverrides'));
if (count($table->data)) { if (count($table->data)) {
echo html_writer::table($table); 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) { if ($hasinactive) {
echo $OUTPUT->notification(get_string('inactiveoverridehelp', 'assign'), 'dimmed_text'); echo $OUTPUT->notification(get_string('inactiveoverridehelp', 'assign'), 'dimmed_text');
} }