diff --git a/course/report/completion/index.php b/course/report/completion/index.php
index af07f65774c..32430de8a76 100644
--- a/course/report/completion/index.php
+++ b/course/report/completion/index.php
@@ -45,6 +45,7 @@ $edituser = optional_param('edituser', 0, PARAM_INT);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
+$context = context_course::instance($course->id);
$url = new moodle_url('/course/report/completion/index.php', array('course'=>$course->id));
$PAGE->set_url($url);
@@ -59,8 +60,9 @@ $start = optional_param('start', 0, PARAM_INT);
$sifirst = optional_param('sifirst', 'all', PARAM_ALPHA);
$silast = optional_param('silast', 'all', PARAM_ALPHA);
-// Whether to show idnumber
-$idnumbers = $CFG->grade_report_showuseridnumber;
+// Whether to show extra user identity information
+$extrafields = get_extra_user_fields($context);
+$leftcols = 1 + count($extrafields);
// Function for quoting csv cell values
function csv_quote($value) {
@@ -77,7 +79,6 @@ function csv_quote($value) {
// Check permissions
require_login($course);
-$context=get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('coursereport/completion:view', $context);
// Get group mode
@@ -221,7 +222,8 @@ if ($total) {
$group,
$firstnamesort ? 'u.firstname ASC' : 'u.lastname ASC',
$csv ? 0 : COMPLETION_REPORT_PAGE,
- $csv ? 0 : $start
+ $csv ? 0 : $start,
+ $context
);
}
@@ -337,7 +339,8 @@ if(!$csv) {
// Print criteria group names
print PHP_EOL.'
';
- print '';
+ echo '';
$current_group = false;
$col_count = 0;
@@ -371,7 +374,8 @@ if(!$csv) {
// Print aggregation methods
print PHP_EOL.'
';
- print '';
+ echo '';
$current_group = false;
$col_count = 0;
@@ -430,7 +434,8 @@ if(!$csv) {
if (COMPLETION_REPORT_COL_TITLES) {
print PHP_EOL.'
';
- print '';
+ echo '';
foreach ($criteria as $criterion) {
// Get criteria details
@@ -468,9 +473,10 @@ if(!$csv) {
print '';
- // Print user id number column
- if($idnumbers) {
- print '| '.get_string('idnumber').' | ';
+ // Print user identity columns
+ foreach ($extrafields as $field) {
+ echo '' .
+ get_user_field_name($field) . ' | ';
}
///
@@ -539,10 +545,7 @@ if(!$csv) {
} else {
- // TODO
- if($idnumbers) {
- print $sep;
- }
+ // The CSV file does not contain any headers
}
@@ -554,16 +557,16 @@ foreach ($progress as $user) {
// User name
if($csv) {
print csv_quote(fullname($user));
- if($idnumbers) {
- print $sep.csv_quote($user->idnumber);
+ foreach ($extrafields as $field) {
+ echo $sep . csv_quote($user->{$field});
}
} else {
print PHP_EOL.'
';
print '| '.fullname($user).' | ';
- if($idnumbers) {
- print ''.htmlspecialchars($user->idnumber).' | ';
+ foreach ($extrafields as $field) {
+ echo '' . s($user->{$field}) . ' | ';
}
}
diff --git a/course/report/progress/index.php b/course/report/progress/index.php
index 323d2b89025..a6abf9660b6 100644
--- a/course/report/progress/index.php
+++ b/course/report/progress/index.php
@@ -10,6 +10,7 @@ $course=$DB->get_record('course',array('id'=>$id));
if(!$course) {
print_error('invalidcourseid');
}
+$context = context_course::instance($course->id);
// Sort (default lastname, optionally firstname)
$sort = optional_param('sort','',PARAM_ALPHA);
@@ -26,11 +27,9 @@ $sifirst = optional_param('sifirst', 'all', PARAM_ALPHA);
$silast = optional_param('silast', 'all', PARAM_ALPHA);
$start = optional_param('start',0,PARAM_INT);
-// Whether to show idnumber
-// TODO: This should really not be using a config option 'intended' for
-// gradebook, but that option is also used in quiz reports as well. There ought
-// to be a generic option somewhere.
-$idnumbers = $CFG->grade_report_showuseridnumber;
+// Whether to show extra user identity information
+$extrafields = get_extra_user_fields($context);
+$leftcols = 1 + count($extrafields);
function csv_quote($value) {
global $excel;
@@ -58,7 +57,6 @@ $PAGE->set_pagelayout('report');
require_login($course);
// Check basic permission
-$context=get_context_instance(CONTEXT_COURSE,$course->id);
require_capability('coursereport/progress:view',$context);
// Get group mode
@@ -103,7 +101,8 @@ if ($total) {
$group,
$firstnamesort ? 'u.firstname ASC' : 'u.lastname ASC',
$csv ? 0 : COMPLETION_REPORT_PAGE,
- $csv ? 0 : $start
+ $csv ? 0 : $start,
+ $context
);
}
@@ -277,13 +276,14 @@ if(!$csv) {
}
print '';
- if($idnumbers) {
- print ''.get_string('idnumber').' | ';
+ // Print user identity columns
+ foreach ($extrafields as $field) {
+ echo '' .
+ get_user_field_name($field) . ' | ';
}
-
} else {
- if($idnumbers) {
- print $sep;
+ foreach ($extrafields as $field) {
+ echo $sep . csv_quote(get_user_field_name($field));
}
}
@@ -328,14 +328,14 @@ foreach($progress as $user) {
// User name
if($csv) {
print csv_quote(fullname($user));
- if($idnumbers) {
- print $sep.csv_quote($user->idnumber);
+ foreach ($extrafields as $field) {
+ echo $sep . csv_quote($user->{$field});
}
} else {
print '
| '.fullname($user).' | ';
- if($idnumbers) {
- print ''.htmlspecialchars($user->idnumber).' | ';
+ foreach ($extrafields as $field) {
+ echo '' . s($user->{$field}) . ' | ';
}
}
diff --git a/lib/completionlib.php b/lib/completionlib.php
index cce41d0d922..b8d9df60495 100644
--- a/lib/completionlib.php
+++ b/lib/completionlib.php
@@ -1057,10 +1057,12 @@ class completion_info {
* @param string $sort Order by clause (optional)
* @param integer $limitfrom Result start (optional)
* @param integer $limitnum Result max size (optional)
+ * @param context $extracontext If set, includes extra user information fields
+ * as appropriate to display for current user in this context
* @return array
*/
function get_tracked_users($where = '', $where_params = array(), $groupid = 0,
- $sort = '', $limitfrom = '', $limitnum = '') {
+ $sort = '', $limitfrom = '', $limitnum = '', context $extracontext = null) {
global $DB;
@@ -1074,6 +1076,9 @@ class completion_info {
u.lastname,
u.idnumber
";
+ if ($extracontext) {
+ $sql .= get_extra_user_fields_sql($extracontext, 'u', '', array('idnumber'));
+ }
$sql .= $tracked->sql;
@@ -1190,16 +1195,19 @@ class completion_info {
* @param int $groupid Group ID or 0 (default)/false for all groups
* @param int $pagesize Number of users to actually return (optional)
* @param int $start User to start at if paging (optional)
+ * @param context $extracontext If set, includes extra user information fields
+ * as appropriate to display for current user in this context
* @return Object with ->total and ->start (same as $start) and ->users;
* an array of user objects (like mdl_user id, firstname, lastname)
* containing an additional ->progress array of coursemoduleid => completionstate
*/
public function get_progress_all($where = '', $where_params = array(), $groupid = 0,
- $sort = '', $pagesize = '', $start = '') {
+ $sort = '', $pagesize = '', $start = '', context $extracontext = null) {
global $CFG, $DB;
// Get list of applicable users
- $users = $this->get_tracked_users($where, $where_params, $groupid, $sort, $start, $pagesize);
+ $users = $this->get_tracked_users($where, $where_params, $groupid, $sort,
+ $start, $pagesize, $extracontext);
// Get progress information for these users in groups of 1, 000 (if needed)
// to avoid making the SQL IN too long
diff --git a/theme/base/style/core.css b/theme/base/style/core.css
index 62a5bfe860d..ff8775494ee 100644
--- a/theme/base/style/core.css
+++ b/theme/base/style/core.css
@@ -361,7 +361,8 @@ table.mod_index {width:100%;}
*/
.completion-expired {background:#FFDDDD;}
.completion-expected {font-size:0.75em;}
-.completion-sortchoice {font-size:0.75em;vertical-align:bottom;}
+.completion-sortchoice,
+.completion-identifyfield {font-size:0.75em;vertical-align:bottom;}
.completion-progresscell {text-align:right;}
.completion-expired .completion-expected {font-weight:bold;}
#page-course-report-progress-index th,
|---|