MDL-26647 (7) Support showuseridentity on assignment report
authorsam marshall <s.marshall@open.ac.uk>
Thu, 3 Nov 2011 17:24:58 +0000 (17:24 +0000)
committersam marshall <s.marshall@open.ac.uk>
Fri, 4 Nov 2011 13:57:19 +0000 (13:57 +0000)
mod/assignment/lib.php

index c4a390c..1cb2e25 100644 (file)
@@ -1239,19 +1239,28 @@ class assignment_base {
             }
         }
 
-        $tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade');
+        $extrafields = get_extra_user_fields($context);
+        $tablecolumns = array_merge(array('picture', 'fullname'), $extrafields,
+                array('grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade'));
         if ($uses_outcomes) {
             $tablecolumns[] = 'outcome'; // no sorting based on outcomes column
         }
 
-        $tableheaders = array('',
-                              get_string('fullnameuser'),
-                              get_string('grade'),
-                              get_string('comment', 'assignment'),
-                              get_string('lastmodified').' ('.get_string('submission', 'assignment').')',
-                              get_string('lastmodified').' ('.get_string('grade').')',
-                              get_string('status'),
-                              get_string('finalgrade', 'grades'));
+        $extrafieldnames = array();
+        foreach ($extrafields as $field) {
+            $extrafieldnames[] = get_user_field_name($field);
+        }
+        $tableheaders = array_merge(
+                array('', get_string('fullnameuser')),
+                $extrafieldnames,
+                array(
+                    get_string('grade'),
+                    get_string('comment', 'assignment'),
+                    get_string('lastmodified').' ('.get_string('submission', 'assignment').')',
+                    get_string('lastmodified').' ('.get_string('grade').')',
+                    get_string('status'),
+                    get_string('finalgrade', 'grades'),
+                ));
         if ($uses_outcomes) {
             $tableheaders[] = get_string('outcome', 'grades');
         }
@@ -1272,6 +1281,9 @@ class assignment_base {
 
         $table->column_class('picture', 'picture');
         $table->column_class('fullname', 'fullname');
+        foreach ($extrafields as $field) {
+            $table->column_class($field, $field);
+        }
         $table->column_class('grade', 'grade');
         $table->column_class('submissioncomment', 'comment');
         $table->column_class('timemodified', 'timemodified');
@@ -1312,7 +1324,7 @@ class assignment_base {
             $sort = ' ORDER BY '.$sort;
         }
 
-        $ufields = user_picture::fields('u');
+        $ufields = user_picture::fields('u', $extrafields);
         if (!empty($users)) {
             $select = "SELECT $ufields,
                               s.id AS submissionid, s.grade, s.submissioncomment,
@@ -1473,7 +1485,13 @@ class assignment_base {
                         }
 
                         $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&amp;course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $this->context)) . '</a>';
-                        $row = array($picture, $userlink, $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
+                        $extradata = array();
+                        foreach ($extrafields as $field) {
+                            $extradata[] = $auser->{$field};
+                        }
+                        $row = array_merge(array($picture, $userlink), $extradata,
+                                array($grade, $comment, $studentmodified, $teachermodified,
+                                $status, $finalgrade));
                         if ($uses_outcomes) {
                             $row[] = $outcomes;
                         }