Skip to content

Commit

Permalink
CTP-3650 Assignment double marking preview
Browse files Browse the repository at this point in the history
  • Loading branch information
leonstr committed Oct 17, 2024
1 parent 9ec7e01 commit 59d3665
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 25 deletions.
2 changes: 1 addition & 1 deletion mod/assign/amd/build/grading_panel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/assign/amd/build/grading_panel.min.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions mod/assign/amd/src/grading_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,13 @@ define([
var data = form.serialize();
var assignmentid = this._region.attr('data-assignmentid');

var vars = window.location.search.substring(1).split('&');
var marker = vars.includes('action=marker');

// Now we can continue...
ajax.call([{
methodname: 'mod_assign_submit_grading_form',
args: {assignmentid: assignmentid, userid: this._lastUserId, jsonformdata: JSON.stringify(data)},
args: {assignmentid: assignmentid, userid: this._lastUserId, marker: marker, jsonformdata: JSON.stringify(data)},
done: this._handleFormSubmissionResponse.bind(this, data, nextUserId, nextUser),
fail: notification.exception
}]);
Expand Down Expand Up @@ -324,8 +327,12 @@ define([
this._niceReplaceNodeContents(this._region, html, js).done(function() {
if (userid > 0) {
this._region.show();
var vars = window.location.search.substring(1).split('&');
var marker = vars.includes('action=marker');
// Reload the grading form "fragment" for this user.
var params = {userid: userid, attemptnumber: attemptnumber, jsonformdata: JSON.stringify(submissiondata)};
var params = {userid: userid, attemptnumber: attemptnumber,
jsonformdata: JSON.stringify(submissiondata),
marker: marker};
fragment.loadFragment('mod_assign', 'gradingpanel', contextid, params).done(function(html, js) {
this._niceReplaceNodeContents(this._region, html, js)
.done(function() {
Expand Down
15 changes: 12 additions & 3 deletions mod/assign/classes/output/actionmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ class actionmenu implements templatable, renderable {
/** @var int The course module ID. */
private $cmid;

/** @var int Number of markers, 2 for double marking, etc. */
private $markercount;

/**
* Constructor for this object.
*
* @param int $cmid The course module ID.
*/
public function __construct(int $cmid) {
public function __construct(int $cmid, int $markercount) {
$this->cmid = $cmid;
$this->markercount = $markercount;
}

/**
Expand All @@ -51,8 +55,13 @@ public function export_for_template(\renderer_base $output): array {
$return = [];

if (has_capability('mod/assign:grade', \context_module::instance($this->cmid))) {
$gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grader']);
$return['gradelink'] = $gradelink->out(false);
if ($this->markercount > 1) {
$gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'marker']);
$return['marklink'] = $gradelink->out(false);
} else {
$gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grader']);
$return['gradelink'] = $gradelink->out(false);
}
}

return $return;
Expand Down
11 changes: 10 additions & 1 deletion mod/assign/classes/output/grading_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,27 @@ class grading_app implements templatable, renderable {
*/
public $participants = [];

/**
* @var bool - True to show fields for marking, false to show fields for
* grading (used when there are multiple markers).
*/
public $marker = false;

/**
* Constructor for this renderable.
*
* @param int $userid The user we will open the grading app too.
* @param int $groupid If groups are enabled this is the current course group.
* @param \assign $assignment The assignment class
* @param bool $marker If assignment instance uses multiple markers $marker
* is true to show fields for marking (as opposed to grading).
*/
public function __construct($userid, $groupid, $assignment) {
public function __construct($userid, $groupid, $assignment, $marker = false) {
$this->userid = $userid;
$this->groupid = $groupid;
$this->assignment = $assignment;
$this->participants = $assignment->list_participants_with_filter_status_and_group($groupid);
$this->marker = $marker;
if (!$this->userid && count($this->participants)) {
$this->userid = reset($this->participants)->id;
}
Expand Down
Loading

0 comments on commit 59d3665

Please sign in to comment.