Permalink
Browse files

Merge branch 'MDL-38061-24' of git://github.com/damyon/moodle into MO…

…ODLE_24_STABLE
  • Loading branch information...
2 parents a083389 + 351cd14 commit 45551ed4df0312ba8db62777e1e54dc32b864b27 @danpoltawski danpoltawski committed Feb 25, 2013
Showing with 49 additions and 13 deletions.
  1. +18 −2 mod/assign/gradingtable.php
  2. +8 −6 mod/assign/locallib.php
  3. +12 −1 mod/assign/renderable.php
  4. +11 −4 mod/assign/renderer.php
@@ -111,7 +111,9 @@ public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $
$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 @@ public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $
// 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 @@ public function __construct(assign $assignment, $perpage, $filter, $rowoffset, $
// 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 @@ private function format_plugin_summary_with_link(assign_plugin $plugin, stdClass
* @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 @@ private function view_single_grade_page($mform, $offset=0) {
}
$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;
}
}
@@ -136,10 +136,17 @@ public function render_assign_user_summary(assign_user_summary $summary) {
} 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();

0 comments on commit 45551ed

Please sign in to comment.