Skip to content

Commit

Permalink
MDL74535 mod_assign: Support Custom User fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mhughes2k committed Apr 22, 2024
1 parent 7b9a4ee commit 03a1c7e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mod/assign/gradingtable.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,14 @@ public function __construct(assign $assignment,
$params['assignmentid3'] = (int)$this->assignment->get_instance()->id;
$params['newstatus'] = ASSIGN_SUBMISSION_STATUS_NEW;

// TODO Does not support custom user profile fields (MDL-70456).
$userfieldsapi = \core_user\fields::for_identity($this->assignment->get_context(), false)->with_userpic();
$userfields = $userfieldsapi->get_sql('u', false, '', '', false)->selects;
$userfieldsapi = \core_user\fields::for_identity($this->assignment->get_context(), true)->with_userpic();
$sql = $userfieldsapi->get_sql('u', true, '', '', false);
$userfields = $sql->selects;
$joins = $sql->joins;
$eufparams = $sql->params;
$mappings = $sql->mappings;
$extrauserfields = $userfieldsapi->get_required_fields([\core_user\fields::PURPOSE_IDENTITY]);

$fields = $userfields . ', ';
$fields .= 'u.id as userid, ';
$fields .= 's.status as status, ';
Expand All @@ -163,12 +167,17 @@ public function __construct(assign $assignment,
AND s.assignment = :assignmentid1
AND s.latest = 1 ';

$from .= $joins;

// For group assignments, there can be a grade with no submission.
$from .= ' LEFT JOIN {assign_grades} g
ON g.assignment = :assignmentid2
AND u.id = g.userid
AND (g.attemptnumber = s.attemptnumber OR s.attemptnumber IS NULL) ';

// Add Extra fields parameters.
$params += $eufparams;

$from .= 'LEFT JOIN {assign_user_flags} uf
ON u.id = uf.userid
AND uf.assignment = :assignmentid3 ';
Expand Down Expand Up @@ -1507,7 +1516,7 @@ public function other_cols($colname, $row) {
if ($submission) {
if ($submission->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
// For a newly reopened submission - we want to show the previous submission in the table.
$this->get_group_and_submission($row->id, $group, $submission, $submission->attemptnumber-1);
$this->get_group_and_submission($row->id, $group, $submission, $submission->attemptnumber - 1);
}
if (isset($field)) {
return $plugin->get_editor_text($field, $submission->id);
Expand Down

0 comments on commit 03a1c7e

Please sign in to comment.