Merge branch 'MDL-73354-master' of git://github.com/abgreeve/moodle

This commit is contained in:
Jake Dallimore
2022-02-10 14:14:41 +08:00
17 changed files with 124 additions and 142 deletions
@@ -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
+6 -2
View File
@@ -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);
@@ -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
];
}
}
@@ -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));
}
/**
+10 -82
View File
@@ -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);
}
@@ -286,6 +288,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 +852,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;
}
@@ -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 $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, int $timelimit = 0) {
$this->cmid = $cmid;
$this->showsubmit = $showsubmit;
$this->showedit = $showedit;
$this->submission = $submission;
$this->teamsubmission = $teamsubmission;
$this->timelimit = $timelimit;
}
/**
@@ -115,15 +119,34 @@ 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);
}
if ($status === ASSIGN_SUBMISSION_STATUS_NEW) {
$newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get');
$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) {
+2
View File
@@ -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';
-9
View File
@@ -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');
+22 -16
View File
@@ -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');
@@ -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';
@@ -4563,6 +4559,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');
@@ -4640,9 +4637,10 @@ 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']);
@@ -4651,11 +4649,15 @@ 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 .= $this->get_renderer()->render($gradingactions);
$o .= groups_print_activity_menu($this->get_course_module(), $currenturl, true);
@@ -4924,10 +4926,13 @@ 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(),
$this->show_intro(),
false,
$this->get_course_module()->id,
$title,
'',
@@ -5835,7 +5840,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 +5862,8 @@ class assign {
$course->relativedatesmode,
$course->startdate,
$this->can_grade(),
$isvisible
$isvisible,
$this->get_course_module()
);
}
@@ -5922,10 +5929,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);
}
@@ -5974,7 +5977,8 @@ class assign {
$showsubmit,
$showedit,
$submission,
$teamsubmission
$teamsubmission,
$instance->timelimit
);
return $this->get_renderer()->render($actionbuttons);
@@ -8207,6 +8211,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);
+2 -2
View File
@@ -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.
+1
View File
@@ -87,6 +87,7 @@ $PAGE->activityheader->set_attrs([
"description" => "",
"hidecompletion" => true
]);
$PAGE->set_secondary_active_tab('mod_assign_useroverrides');
echo $OUTPUT->header();
+1
View File
@@ -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' => '',
+8
View File
@@ -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');
}
+6 -1
View File
@@ -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|null $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;
}
}
@@ -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>
@@ -166,12 +166,19 @@
{{/previoussubmission}}
{{#edit}}
<div class="col-xs-6 mr-3">
{{#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}}
</div>
{{/edit}}
{{#remove}}
-7
View File
@@ -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();