mirror of
https://github.com/moodle/moodle.git
synced 2025-01-30 03:58:34 +01:00
MDL-26647 (5) Support showuseridentity on course and activity completion reports
This commit is contained in:
parent
43aa295b95
commit
24e14bc7a6
@ -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.'<tr style="vertical-align: top">';
|
||||
print '<th scope="row" class="rowheader">'.get_string('criteriagroup', 'completion').'</th>';
|
||||
echo '<th scope="row" class="rowheader" colspan="' . $leftcols . '">' .
|
||||
get_string('criteriagroup', 'completion') . '</th>';
|
||||
|
||||
$current_group = false;
|
||||
$col_count = 0;
|
||||
@ -371,7 +374,8 @@ if(!$csv) {
|
||||
|
||||
// Print aggregation methods
|
||||
print PHP_EOL.'<tr style="vertical-align: top">';
|
||||
print '<th scope="row" class="rowheader">'.get_string('aggregationmethod', 'completion').'</th>';
|
||||
echo '<th scope="row" class="rowheader" colspan="' . $leftcols . '">' .
|
||||
get_string('aggregationmethod', 'completion').'</th>';
|
||||
|
||||
$current_group = false;
|
||||
$col_count = 0;
|
||||
@ -430,7 +434,8 @@ if(!$csv) {
|
||||
if (COMPLETION_REPORT_COL_TITLES) {
|
||||
|
||||
print PHP_EOL.'<tr>';
|
||||
print '<th scope="row" class="rowheader">'.get_string('criteria', 'completion').'</th>';
|
||||
echo '<th scope="row" class="rowheader" colspan="' . $leftcols . '">' .
|
||||
get_string('criteria', 'completion') . '</th>';
|
||||
|
||||
foreach ($criteria as $criterion) {
|
||||
// Get criteria details
|
||||
@ -468,9 +473,10 @@ if(!$csv) {
|
||||
print '</th>';
|
||||
|
||||
|
||||
// Print user id number column
|
||||
if($idnumbers) {
|
||||
print '<th>'.get_string('idnumber').'</th>';
|
||||
// Print user identity columns
|
||||
foreach ($extrafields as $field) {
|
||||
echo '<th scope="col" class="completion-identifyfield">' .
|
||||
get_user_field_name($field) . '</th>';
|
||||
}
|
||||
|
||||
///
|
||||
@ -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.'<tr id="user-'.$user->id.'">';
|
||||
|
||||
print '<th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
||||
$user->id.'&course='.$course->id.'">'.fullname($user).'</a></th>';
|
||||
if($idnumbers) {
|
||||
print '<td>'.htmlspecialchars($user->idnumber).'</td>';
|
||||
foreach ($extrafields as $field) {
|
||||
echo '<td>' . s($user->{$field}) . '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 '</th>';
|
||||
|
||||
if($idnumbers) {
|
||||
print '<th>'.get_string('idnumber').'</th>';
|
||||
// Print user identity columns
|
||||
foreach ($extrafields as $field) {
|
||||
echo '<th scope="col" class="completion-identifyfield">' .
|
||||
get_user_field_name($field) . '</th>';
|
||||
}
|
||||
|
||||
} 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 '<tr><th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
||||
$user->id.'&course='.$course->id.'">'.fullname($user).'</a></th>';
|
||||
if($idnumbers) {
|
||||
print '<td>'.htmlspecialchars($user->idnumber).'</td>';
|
||||
foreach ($extrafields as $field) {
|
||||
echo '<td>' . s($user->{$field}) . '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user