MDL-38061 Assignment - Use $CFG->showuseridentity to add extra fields to the assignment grading table/user summary.
Conflicts: mod/assign/gradingtable.php mod/assign/locallib.php mod/assign/renderable.php mod/assign/renderer.php
This commit is contained in:
@@ -88,7 +88,9 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
$params['assignmentid1'] = (int)$this->assignment->get_instance()->id;
|
||||
$params['assignmentid2'] = (int)$this->assignment->get_instance()->id;
|
||||
|
||||
$fields = user_picture::fields('u') . ', u.id as userid, ';
|
||||
$extrauserfields = get_extra_user_fields($this->assignment->get_context());
|
||||
|
||||
$fields = user_picture::fields('u', $extrauserfields) . ', u.id as userid, ';
|
||||
$fields .= 's.status as status, s.id as submissionid, s.timecreated as firstsubmission, s.timemodified as timesubmitted, ';
|
||||
$fields .= 'g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, g.mailed as mailed, g.locked as locked';
|
||||
$from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' .
|
||||
@@ -136,6 +138,10 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
// Fullname
|
||||
$columns[] = 'fullname';
|
||||
$headers[] = get_string('fullname');
|
||||
foreach ($extrauserfields as $extrafield) {
|
||||
$columns[] = $extrafield;
|
||||
$headers[] = get_user_field_name($extrafield);
|
||||
}
|
||||
|
||||
// Submission status
|
||||
if ($assignment->is_any_submission_plugin_enabled()) {
|
||||
@@ -194,6 +200,9 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
// set the columns
|
||||
$this->define_columns($columns);
|
||||
$this->define_headers($headers);
|
||||
foreach ($extrauserfields as $extrafield) {
|
||||
$this->column_class($extrafield, $extrafield);
|
||||
}
|
||||
// We require at least one unique column for the sort.
|
||||
$this->sortable(true, 'userid');
|
||||
$this->no_sorting('finalgrade');
|
||||
@@ -610,7 +619,7 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
return NULL;
|
||||
return $row->$colname;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1769,7 +1769,7 @@ class assign {
|
||||
}
|
||||
$user = $DB->get_record('user', array('id' => $userid));
|
||||
if ($user) {
|
||||
$o .= $this->output->render(new assign_user_summary($user, $this->get_course()->id, has_capability('moodle/site:viewfullnames', $this->get_course_context())));
|
||||
$o .= $this->output->render(new assign_user_summary($user, $this->get_course()->id, has_capability('moodle/site:viewfullnames', $this->get_course_context()), get_extra_user_fields($this->get_context())));
|
||||
}
|
||||
$submission = $this->get_user_submission($userid, false);
|
||||
// get the current grade
|
||||
|
||||
@@ -113,17 +113,21 @@ class assign_user_summary implements renderable {
|
||||
public $courseid;
|
||||
/** @var bool $viewfullnames */
|
||||
public $viewfullnames = false;
|
||||
/** @var array $extrauserfields */
|
||||
public $extrauserfields;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param stdClass $user
|
||||
* @param int $courseid
|
||||
* @param bool $viewfullnames
|
||||
* @param array $extrauserfield
|
||||
*/
|
||||
public function __construct(stdClass $user, $courseid, $viewfullnames) {
|
||||
public function __construct(stdClass $user, $courseid, $viewfullnames, $extrauserfields) {
|
||||
$this->user = $user;
|
||||
$this->courseid = $courseid;
|
||||
$this->viewfullnames = $viewfullnames;
|
||||
$this->extrauserfields = $extrauserfields;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,10 +133,18 @@ class mod_assign_renderer extends plugin_renderer_base {
|
||||
$o .= $this->output->box_start('boxaligncenter usersummarysection');
|
||||
$o .= $this->output->user_picture($summary->user);
|
||||
$o .= $this->output->spacer(array('width'=>30));
|
||||
$fullname = fullname($summary->user, $summary->viewfullnames);
|
||||
$extrainfo = array();
|
||||
foreach ($summary->extrauserfields as $extrafield) {
|
||||
$extrainfo[] = $summary->user->$extrafield;
|
||||
}
|
||||
if (count($extrainfo)) {
|
||||
$fullname .= ' (' . implode(', ', $extrainfo) . ')';
|
||||
}
|
||||
$o .= $this->output->action_link(new moodle_url('/user/view.php',
|
||||
array('id' => $summary->user->id,
|
||||
'course'=>$summary->courseid)),
|
||||
fullname($summary->user, $summary->viewfullnames));
|
||||
$fullname);
|
||||
$o .= $this->output->box_end();
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user