Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 9b8afa9b5591bc2585fa01b433bccd5376cfa0e4 1 parent 84cf3cc
@damyon damyon authored
View
13 mod/assign/gradingtable.php
@@ -88,7 +88,9 @@ function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgr
$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 @@ function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgr
// 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 @@ function __construct(assign $assignment, $perpage, $filter, $rowoffset, $quickgr
// 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 @@ function other_cols($colname, $row){
}
return '';
}
- return NULL;
+ return $row->$colname;
}
/**
View
2  mod/assign/locallib.php
@@ -1769,7 +1769,7 @@ private function view_single_grade_page($mform, $offset=0) {
}
$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
View
6 mod/assign/renderable.php
@@ -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;
}
}
View
10 mod/assign/renderer.php
@@ -133,10 +133,18 @@ public function render_assign_user_summary(assign_user_summary $summary) {
$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();
Please sign in to comment.
Something went wrong with that request. Please try again.