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:
@@ -111,7 +111,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') . ', ';
|
||||
$extrauserfields = get_extra_user_fields($this->assignment->get_context());
|
||||
|
||||
$fields = user_picture::fields('u', $extrauserfields) . ', ';
|
||||
$fields .= 'u.id as userid, ';
|
||||
$fields .= 's.status as status, ';
|
||||
$fields .= 's.id as submissionid, ';
|
||||
@@ -181,6 +183,11 @@ 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);
|
||||
}
|
||||
} else {
|
||||
// Record ID.
|
||||
$columns[] = 'recordid';
|
||||
@@ -290,6 +297,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('recordid');
|
||||
@@ -848,7 +858,13 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
* @param stdClass $row The submission row
|
||||
* @return mixed string or NULL
|
||||
*/
|
||||
function other_cols($colname, $row){
|
||||
public function other_cols($colname, $row) {
|
||||
// For extra user fields the result is already in $row.
|
||||
if (empty($this->plugincache[$colname])) {
|
||||
return $row->$colname;
|
||||
}
|
||||
|
||||
// This must be a plugin field.
|
||||
$plugincache = $this->plugincache[$colname];
|
||||
|
||||
$plugin = $plugincache[0];
|
||||
|
||||
@@ -2287,12 +2287,14 @@ class assign {
|
||||
}
|
||||
$user = $DB->get_record('user', array('id' => $userid));
|
||||
if ($user) {
|
||||
$o .= $this->get_renderer()->render(new assign_user_summary($user,
|
||||
$this->get_course()->id,
|
||||
has_capability('moodle/site:viewfullnames',
|
||||
$this->get_course_context()),
|
||||
$this->is_blind_marking(),
|
||||
$this->get_uniqueid_for_user($user->id)));
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context());
|
||||
$usersummary = new assign_user_summary($user,
|
||||
$this->get_course()->id,
|
||||
$viewfullnames,
|
||||
$this->is_blind_marking(),
|
||||
$this->get_uniqueid_for_user($user->id),
|
||||
get_extra_user_fields($this->get_context()));
|
||||
$o .= $this->get_renderer()->render($usersummary);
|
||||
}
|
||||
$submission = $this->get_user_submission($userid, false);
|
||||
$submissiongroup = null;
|
||||
|
||||
@@ -120,19 +120,30 @@ class assign_user_summary implements renderable {
|
||||
public $blindmarking = false;
|
||||
/** @var int $uniqueidforuser */
|
||||
public $uniqueidforuser;
|
||||
/** @var array $extrauserfields */
|
||||
public $extrauserfields;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param stdClass $user
|
||||
* @param int $courseid
|
||||
* @param bool $viewfullnames
|
||||
* @param bool $blindmarking
|
||||
* @param int $uniqueidforuser
|
||||
* @param array $extrauserfields
|
||||
*/
|
||||
public function __construct(stdClass $user, $courseid, $viewfullnames, $blindmarking, $uniqueidforuser) {
|
||||
public function __construct(stdClass $user,
|
||||
$courseid,
|
||||
$viewfullnames,
|
||||
$blindmarking,
|
||||
$uniqueidforuser,
|
||||
$extrauserfields) {
|
||||
$this->user = $user;
|
||||
$this->courseid = $courseid;
|
||||
$this->viewfullnames = $viewfullnames;
|
||||
$this->blindmarking = $blindmarking;
|
||||
$this->uniqueidforuser = $uniqueidforuser;
|
||||
$this->extrauserfields = $extrauserfields;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-4
@@ -136,10 +136,17 @@ class mod_assign_renderer extends plugin_renderer_base {
|
||||
} else {
|
||||
$o .= $this->output->user_picture($summary->user);
|
||||
$o .= $this->output->spacer(array('width'=>30));
|
||||
$o .= $this->output->action_link(new moodle_url('/user/view.php',
|
||||
array('id' => $summary->user->id,
|
||||
'course'=>$summary->courseid)),
|
||||
fullname($summary->user, $summary->viewfullnames));
|
||||
$urlparams = array('id' => $summary->user->id, 'course'=>$summary->courseid);
|
||||
$url = new moodle_url('/user/view.php', $urlparams);
|
||||
$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($url, $fullname);
|
||||
}
|
||||
$o .= $this->output->box_end();
|
||||
$o .= $this->output->container_end();
|
||||
|
||||
Reference in New Issue
Block a user