2008-07-28 12:31:29 +00:00
|
|
|
<?php
|
2011-11-02 11:24:44 +01:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activity progress reports
|
|
|
|
*
|
|
|
|
* @package report
|
|
|
|
* @subpackage progress
|
|
|
|
* @copyright 2008 Sam Marshall
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
require('../../config.php');
|
2009-05-08 09:00:41 +00:00
|
|
|
require_once($CFG->libdir . '/completionlib.php');
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
define('COMPLETION_REPORT_PAGE', 25);
|
2008-10-24 16:20:37 +00:00
|
|
|
|
2008-07-28 12:31:29 +00:00
|
|
|
// Get course
|
2009-09-21 07:22:57 +00:00
|
|
|
$id = required_param('course',PARAM_INT);
|
2011-11-02 11:24:44 +01:00
|
|
|
$course = $DB->get_record('course',array('id'=>$id));
|
|
|
|
if (!$course) {
|
2008-11-18 08:13:26 +00:00
|
|
|
print_error('invalidcourseid');
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
2011-04-13 17:24:56 +01:00
|
|
|
$context = context_course::instance($course->id);
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
// Sort (default lastname, optionally firstname)
|
2010-08-12 03:40:35 +00:00
|
|
|
$sort = optional_param('sort','',PARAM_ALPHA);
|
|
|
|
$firstnamesort = $sort == 'firstname';
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
// CSV format
|
2010-08-12 03:40:35 +00:00
|
|
|
$format = optional_param('format','',PARAM_ALPHA);
|
|
|
|
$excel = $format == 'excelcsv';
|
|
|
|
$csv = $format == 'csv' || $excel;
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
// Paging
|
|
|
|
$start = optional_param('start', 0, PARAM_INT);
|
|
|
|
$sifirst = optional_param('sifirst', 'all', PARAM_ALPHA);
|
|
|
|
$silast = optional_param('silast', 'all', PARAM_ALPHA);
|
2011-11-02 11:24:44 +01:00
|
|
|
$start = optional_param('start', 0, PARAM_INT);
|
2008-10-24 16:20:37 +00:00
|
|
|
|
2011-04-13 17:24:56 +01:00
|
|
|
// Whether to show extra user identity information
|
|
|
|
$extrafields = get_extra_user_fields($context);
|
|
|
|
$leftcols = 1 + count($extrafields);
|
2008-07-29 10:37:46 +00:00
|
|
|
|
2008-07-28 12:31:29 +00:00
|
|
|
function csv_quote($value) {
|
2008-07-28 17:11:51 +00:00
|
|
|
global $excel;
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($excel) {
|
2012-01-21 13:28:20 +01:00
|
|
|
return textlib::convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE');
|
2008-07-28 17:11:51 +00:00
|
|
|
} else {
|
|
|
|
return '"'.str_replace('"',"'",$value).'"';
|
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
2011-11-02 11:19:41 +01:00
|
|
|
$url = new moodle_url('/report/progress/index.php', array('course'=>$id));
|
2009-09-21 07:22:57 +00:00
|
|
|
if ($sort !== '') {
|
|
|
|
$url->param('sort', $sort);
|
|
|
|
}
|
|
|
|
if ($format !== '') {
|
|
|
|
$url->param('format', $format);
|
|
|
|
}
|
2010-05-19 07:57:00 +00:00
|
|
|
if ($start !== 0) {
|
2009-09-21 07:22:57 +00:00
|
|
|
$url->param('start', $start);
|
|
|
|
}
|
|
|
|
$PAGE->set_url($url);
|
2010-12-02 07:31:48 +00:00
|
|
|
$PAGE->set_pagelayout('report');
|
2009-09-21 07:22:57 +00:00
|
|
|
|
2008-11-29 14:22:10 +00:00
|
|
|
require_login($course);
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
// Check basic permission
|
2011-11-02 11:19:41 +01:00
|
|
|
require_capability('report/progress:view',$context);
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
// Get group mode
|
2011-11-02 11:24:44 +01:00
|
|
|
$group = groups_get_course_group($course,true); // Supposed to verify group
|
|
|
|
if ($group===0 && $course->groupmode==SEPARATEGROUPS) {
|
2008-07-28 12:31:29 +00:00
|
|
|
require_capability('moodle/site:accessallgroups',$context);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get data on activities and progress of all users, and give error if we've
|
|
|
|
// nothing to display (no users or no activities)
|
2011-11-02 11:24:44 +01:00
|
|
|
$reportsurl = $CFG->wwwroot.'/course/report.php?id='.$course->id;
|
|
|
|
$completion = new completion_info($course);
|
|
|
|
$activities = $completion->get_activities();
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
// Generate where clause
|
|
|
|
$where = array();
|
2010-09-08 02:32:43 +00:00
|
|
|
$where_params = array();
|
2010-08-12 03:40:35 +00:00
|
|
|
|
|
|
|
if ($sifirst !== 'all') {
|
2010-09-08 02:32:43 +00:00
|
|
|
$where[] = $DB->sql_like('u.firstname', ':sifirst', false);
|
|
|
|
$where_params['sifirst'] = $sifirst.'%';
|
2010-08-12 03:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($silast !== 'all') {
|
2010-09-08 02:32:43 +00:00
|
|
|
$where[] = $DB->sql_like('u.lastname', ':silast', false);
|
|
|
|
$where_params['silast'] = $silast.'%';
|
2010-08-12 03:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get user match count
|
2010-09-08 02:32:43 +00:00
|
|
|
$total = $completion->get_num_tracked_users(implode(' AND ', $where), $where_params, $group);
|
2010-08-12 03:40:35 +00:00
|
|
|
|
|
|
|
// Total user count
|
2010-09-08 02:32:43 +00:00
|
|
|
$grandtotal = $completion->get_num_tracked_users('', array(), $group);
|
2010-08-12 03:40:35 +00:00
|
|
|
|
|
|
|
// Get user data
|
|
|
|
$progress = array();
|
|
|
|
|
|
|
|
if ($total) {
|
|
|
|
$progress = $completion->get_progress_all(
|
|
|
|
implode(' AND ', $where),
|
2010-09-08 02:32:43 +00:00
|
|
|
$where_params,
|
2010-08-12 03:40:35 +00:00
|
|
|
$group,
|
|
|
|
$firstnamesort ? 'u.firstname ASC' : 'u.lastname ASC',
|
|
|
|
$csv ? 0 : COMPLETION_REPORT_PAGE,
|
2011-04-13 17:24:56 +01:00
|
|
|
$csv ? 0 : $start,
|
|
|
|
$context
|
2010-08-12 03:40:35 +00:00
|
|
|
);
|
|
|
|
}
|
2008-07-28 17:11:51 +00:00
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are some users/actvs
|
2011-09-07 11:46:28 +12:00
|
|
|
|
|
|
|
$shortname = format_string($course->shortname, true, array('context' => $context));
|
2008-07-28 12:31:29 +00:00
|
|
|
header('Content-Disposition: attachment; filename=progress.'.
|
2012-01-21 13:28:20 +01:00
|
|
|
preg_replace('/[^a-z0-9-]/','_',textlib::strtolower(strip_tags($shortname))).'.csv');
|
2008-07-28 17:11:51 +00:00
|
|
|
// Unicode byte-order mark for Excel
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($excel) {
|
2008-07-28 17:11:51 +00:00
|
|
|
header('Content-Type: text/csv; charset=UTF-16LE');
|
|
|
|
print chr(0xFF).chr(0xFE);
|
|
|
|
$sep="\t".chr(0);
|
2008-11-18 08:13:26 +00:00
|
|
|
$line="\n".chr(0);
|
2008-07-28 17:11:51 +00:00
|
|
|
} else {
|
|
|
|
header('Content-Type: text/csv; charset=UTF-8');
|
|
|
|
$sep=",";
|
|
|
|
$line="\n";
|
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
// Use SVG to draw sideways text if supported
|
2009-06-12 11:57:15 +00:00
|
|
|
$svgcleverness = can_use_rotated_text();
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
// Navigation and header
|
|
|
|
$strreports = get_string("reports");
|
2010-10-18 10:15:37 +00:00
|
|
|
$strcompletion = get_string('activitycompletion', 'completion');
|
2009-09-03 08:47:24 +00:00
|
|
|
|
|
|
|
$PAGE->set_title($strcompletion);
|
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($svgcleverness) {
|
2009-12-16 20:25:14 +00:00
|
|
|
$PAGE->requires->yui2_lib('event');
|
2011-11-02 11:19:41 +01:00
|
|
|
$PAGE->requires->js('/report/progress/textrotate.js');
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle groups (if enabled)
|
2011-11-02 11:19:41 +01:00
|
|
|
groups_print_course_menu($course,$CFG->wwwroot.'/report/progress/?course='.$course->id);
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if (count($activities)==0) {
|
2011-01-10 15:20:24 +00:00
|
|
|
echo $OUTPUT->container(get_string('err_noactivities', 'completion'), 'errorbox errorboxcontent');
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If no users in this course what-so-ever
|
|
|
|
if (!$grandtotal) {
|
|
|
|
echo $OUTPUT->container(get_string('err_nousers', 'completion'), 'errorbox errorboxcontent');
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
// Build link for paging
|
2011-11-02 11:19:41 +01:00
|
|
|
$link = $CFG->wwwroot.'/report/progress/?course='.$course->id;
|
2010-08-12 03:40:35 +00:00
|
|
|
if (strlen($sort)) {
|
|
|
|
$link .= '&sort='.$sort;
|
|
|
|
}
|
|
|
|
$link .= '&start=';
|
|
|
|
|
|
|
|
// Build the the page by Initial bar
|
|
|
|
$initials = array('first', 'last');
|
|
|
|
$alphabet = explode(',', get_string('alphabet', 'langconfig'));
|
|
|
|
|
|
|
|
$pagingbar = '';
|
|
|
|
foreach ($initials as $initial) {
|
|
|
|
$var = 'si'.$initial;
|
|
|
|
|
2011-08-16 12:00:29 +09:30
|
|
|
$othervar = $initial == 'first' ? 'silast' : 'sifirst';
|
|
|
|
$othervar = $$othervar != 'all' ? "&{$othervar}={$$othervar}" : '';
|
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
$pagingbar .= ' <div class="initialbar '.$initial.'initial">';
|
|
|
|
$pagingbar .= get_string($initial.'name').': ';
|
2008-10-24 16:20:37 +00:00
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
if ($$var == 'all') {
|
|
|
|
$pagingbar .= '<strong>'.get_string('all').'</strong> ';
|
|
|
|
}
|
|
|
|
else {
|
2011-08-16 12:00:29 +09:30
|
|
|
$pagingbar .= "<a href=\"{$link}{$othervar}\">".get_string('all').'</a> ';
|
2010-08-12 03:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($alphabet as $letter) {
|
|
|
|
if ($$var === $letter) {
|
|
|
|
$pagingbar .= '<strong>'.$letter.'</strong> ';
|
|
|
|
}
|
|
|
|
else {
|
2011-08-16 12:00:29 +09:30
|
|
|
$pagingbar .= "<a href=\"$link&$var={$letter}{$othervar}\">$letter</a> ";
|
2008-10-24 16:20:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
$pagingbar .= '</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do we need a paging bar?
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($total > COMPLETION_REPORT_PAGE) {
|
2008-10-24 16:20:37 +00:00
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
// Paging bar
|
|
|
|
$pagingbar .= '<div class="paging">';
|
|
|
|
$pagingbar .= get_string('page').': ';
|
|
|
|
|
2011-08-16 12:00:29 +09:30
|
|
|
$sistrings = array();
|
2011-10-19 16:50:23 +13:00
|
|
|
if ($sifirst != 'all') {
|
|
|
|
$sistrings[] = "sifirst={$sifirst}";
|
|
|
|
}
|
|
|
|
if ($silast != 'all') {
|
|
|
|
$sistrings[] = "silast={$silast}";
|
|
|
|
}
|
|
|
|
$sistring = !empty($sistrings) ? '&'.implode('&', $sistrings) : '';
|
2011-08-16 12:00:29 +09:30
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
// Display previous link
|
|
|
|
if ($start > 0) {
|
|
|
|
$pstart = max($start - COMPLETION_REPORT_PAGE, 0);
|
2011-08-16 12:00:29 +09:30
|
|
|
$pagingbar .= "(<a class=\"previous\" href=\"{$link}{$pstart}{$sistring}\">".get_string('previous').'</a>) ';
|
2008-10-24 16:20:37 +00:00
|
|
|
}
|
|
|
|
|
2010-08-12 03:40:35 +00:00
|
|
|
// Create page links
|
|
|
|
$curstart = 0;
|
|
|
|
$curpage = 0;
|
|
|
|
while ($curstart < $total) {
|
|
|
|
$curpage++;
|
|
|
|
|
|
|
|
if ($curstart == $start) {
|
|
|
|
$pagingbar .= ' '.$curpage.' ';
|
2011-11-02 11:24:44 +01:00
|
|
|
} else {
|
2011-08-16 12:00:29 +09:30
|
|
|
$pagingbar .= " <a href=\"{$link}{$curstart}{$sistring}\">$curpage</a> ";
|
2010-08-12 03:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$curstart += COMPLETION_REPORT_PAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display next link
|
|
|
|
$nstart = $start + COMPLETION_REPORT_PAGE;
|
|
|
|
if ($nstart < $total) {
|
2011-08-16 12:00:29 +09:30
|
|
|
$pagingbar .= " (<a class=\"next\" href=\"{$link}{$nstart}{$sistring}\">".get_string('next').'</a>)';
|
2010-08-12 03:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$pagingbar .= '</div>';
|
2008-10-24 16:20:37 +00:00
|
|
|
}
|
|
|
|
|
2008-07-28 12:31:29 +00:00
|
|
|
// Okay, let's draw the table of progress info,
|
|
|
|
|
2008-11-18 08:13:26 +00:00
|
|
|
// Start of table
|
2011-11-02 11:24:44 +01:00
|
|
|
if (!$csv) {
|
2008-07-28 12:31:29 +00:00
|
|
|
print '<br class="clearer"/>'; // ugh
|
2010-08-12 03:40:35 +00:00
|
|
|
|
|
|
|
print $pagingbar;
|
|
|
|
|
|
|
|
if (!$total) {
|
2010-09-22 08:52:02 +00:00
|
|
|
echo $OUTPUT->heading(get_string('nothingtodisplay'));
|
|
|
|
echo $OUTPUT->footer();
|
2008-07-28 12:31:29 +00:00
|
|
|
exit;
|
|
|
|
}
|
2010-08-12 03:40:35 +00:00
|
|
|
|
2012-03-12 10:37:35 +00:00
|
|
|
print '<div id="completion-progress-wrapper" class="no-overflow">';
|
2008-07-28 12:31:29 +00:00
|
|
|
print '<table id="completion-progress" class="generaltable flexible boxaligncenter" style="text-align:left"><tr style="vertical-align:top">';
|
|
|
|
|
|
|
|
// User heading / sort option
|
|
|
|
print '<th scope="col" class="completion-sortchoice">';
|
2011-08-16 12:00:29 +09:30
|
|
|
|
|
|
|
$sistring = "&silast={$silast}&sifirst={$sifirst}";
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($firstnamesort) {
|
2008-11-18 08:13:26 +00:00
|
|
|
print
|
2011-08-16 12:00:29 +09:30
|
|
|
get_string('firstname')." / <a href=\"./?course={$course->id}{$sistring}\">".
|
2008-07-28 12:31:29 +00:00
|
|
|
get_string('lastname').'</a>';
|
|
|
|
} else {
|
2011-08-16 12:00:29 +09:30
|
|
|
print "<a href=\"./?course={$course->id}&sort=firstname{$sistring}\">".
|
2008-07-28 12:31:29 +00:00
|
|
|
get_string('firstname').'</a> / '.
|
|
|
|
get_string('lastname');
|
|
|
|
}
|
|
|
|
print '</th>';
|
2008-11-18 08:13:26 +00:00
|
|
|
|
2011-04-13 17:24:56 +01:00
|
|
|
// Print user identity columns
|
|
|
|
foreach ($extrafields as $field) {
|
|
|
|
echo '<th scope="col" class="completion-identifyfield">' .
|
|
|
|
get_user_field_name($field) . '</th>';
|
2008-07-29 10:37:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
2011-04-13 17:24:56 +01:00
|
|
|
foreach ($extrafields as $field) {
|
|
|
|
echo $sep . csv_quote(get_user_field_name($field));
|
2008-07-29 10:37:46 +00:00
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Activities
|
|
|
|
foreach($activities as $activity) {
|
|
|
|
$activity->datepassed = $activity->completionexpected && $activity->completionexpected <= time();
|
|
|
|
$activity->datepassedclass=$activity->datepassed ? 'completion-expired' : '';
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($activity->completionexpected) {
|
2008-07-28 12:31:29 +00:00
|
|
|
$datetext=userdate($activity->completionexpected,get_string('strftimedate','langconfig'));
|
|
|
|
} else {
|
|
|
|
$datetext='';
|
|
|
|
}
|
2008-11-18 08:13:26 +00:00
|
|
|
|
2008-08-21 16:35:12 +00:00
|
|
|
// Some names (labels) come URL-encoded and can be very long, so shorten them
|
2010-02-14 20:18:10 +00:00
|
|
|
$activity->name = shorten_text($activity->name);
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv) {
|
2008-10-24 10:12:33 +00:00
|
|
|
print $sep.csv_quote(strip_tags($activity->name)).$sep.csv_quote($datetext);
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
print '<th scope="col" class="'.$activity->datepassedclass.'">'.
|
|
|
|
'<a href="'.$CFG->wwwroot.'/mod/'.$activity->modname.
|
|
|
|
'/view.php?id='.$activity->id.'">'.
|
2010-08-12 18:30:32 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('icon', $activity->modname).'" alt="'.
|
2008-07-28 12:31:29 +00:00
|
|
|
get_string('modulename',$activity->modname).'" /> <span class="completion-activityname">'.
|
|
|
|
format_string($activity->name).'</span></a>';
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($activity->completionexpected) {
|
2008-07-28 12:31:29 +00:00
|
|
|
print '<div class="completion-expected"><span>'.$datetext.'</span></div>';
|
|
|
|
}
|
|
|
|
print '</th>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv) {
|
2008-07-28 17:11:51 +00:00
|
|
|
print $line;
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
print '</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Row for each user
|
2010-08-12 03:40:35 +00:00
|
|
|
foreach($progress as $user) {
|
2008-07-28 12:31:29 +00:00
|
|
|
// User name
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv) {
|
2008-07-28 12:31:29 +00:00
|
|
|
print csv_quote(fullname($user));
|
2011-04-13 17:24:56 +01:00
|
|
|
foreach ($extrafields as $field) {
|
|
|
|
echo $sep . csv_quote($user->{$field});
|
2008-07-29 10:37:46 +00:00
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
print '<tr><th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
|
|
|
$user->id.'&course='.$course->id.'">'.fullname($user).'</a></th>';
|
2011-04-13 17:24:56 +01:00
|
|
|
foreach ($extrafields as $field) {
|
|
|
|
echo '<td>' . s($user->{$field}) . '</td>';
|
2008-07-29 10:37:46 +00:00
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Progress for each activity
|
|
|
|
foreach($activities as $activity) {
|
|
|
|
|
|
|
|
// Get progress information and state
|
2011-11-02 11:24:44 +01:00
|
|
|
if (array_key_exists($activity->id,$user->progress)) {
|
2008-10-24 16:20:37 +00:00
|
|
|
$thisprogress=$user->progress[$activity->id];
|
|
|
|
$state=$thisprogress->completionstate;
|
|
|
|
$date=userdate($thisprogress->timemodified);
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
$state=COMPLETION_INCOMPLETE;
|
|
|
|
$date='';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Work out how it corresponds to an icon
|
|
|
|
switch($state) {
|
2008-11-06 17:29:07 +00:00
|
|
|
case COMPLETION_INCOMPLETE : $completiontype='n'; break;
|
|
|
|
case COMPLETION_COMPLETE : $completiontype='y'; break;
|
|
|
|
case COMPLETION_COMPLETE_PASS : $completiontype='pass'; break;
|
|
|
|
case COMPLETION_COMPLETE_FAIL : $completiontype='fail'; break;
|
2008-11-18 08:13:26 +00:00
|
|
|
}
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2008-11-06 17:29:07 +00:00
|
|
|
$completionicon='completion-'.
|
|
|
|
($activity->completion==COMPLETION_TRACKING_AUTOMATIC ? 'auto' : 'manual').
|
|
|
|
'-'.$completiontype;
|
2008-11-18 08:13:26 +00:00
|
|
|
|
2008-11-06 17:29:07 +00:00
|
|
|
$describe=get_string('completion-alt-auto-'.$completiontype,'completion');
|
2008-07-28 12:31:29 +00:00
|
|
|
$a=new StdClass;
|
|
|
|
$a->state=$describe;
|
|
|
|
$a->date=$date;
|
|
|
|
$a->user=fullname($user);
|
2008-08-21 16:43:33 +00:00
|
|
|
$a->activity=strip_tags($activity->name);
|
2008-07-28 12:31:29 +00:00
|
|
|
$fulldescribe=get_string('progress-title','completion',$a);
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv) {
|
2008-07-28 17:11:51 +00:00
|
|
|
print $sep.csv_quote($describe).$sep.csv_quote($date);
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
print '<td class="completion-progresscell '.$activity->datepassedclass.'">'.
|
2009-12-16 21:50:45 +00:00
|
|
|
'<img src="'.$OUTPUT->pix_url('i/'.$completionicon).
|
2009-07-03 04:23:05 +00:00
|
|
|
'" alt="'.$describe.'" title="'.$fulldescribe.'" /></td>';
|
2008-07-28 12:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv) {
|
2008-07-28 17:11:51 +00:00
|
|
|
print $line;
|
2008-07-28 12:31:29 +00:00
|
|
|
} else {
|
|
|
|
print '</tr>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-02 11:24:44 +01:00
|
|
|
if ($csv) {
|
2008-07-28 12:31:29 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
print '</table>';
|
2012-03-12 10:37:35 +00:00
|
|
|
print '</div>';
|
2008-10-24 16:20:37 +00:00
|
|
|
print $pagingbar;
|
2008-07-28 12:31:29 +00:00
|
|
|
|
|
|
|
print '<ul class="progress-actions"><li><a href="index.php?course='.$course->id.
|
2008-07-28 17:11:51 +00:00
|
|
|
'&format=csv">'.get_string('csvdownload','completion').'</a></li>
|
|
|
|
<li><a href="index.php?course='.$course->id.'&format=excelcsv">'.
|
|
|
|
get_string('excelcsvdownload','completion').'</a></li></ul>';
|
2008-07-28 12:31:29 +00:00
|
|
|
|
2009-08-06 14:10:33 +00:00
|
|
|
echo $OUTPUT->footer();
|
2009-11-04 08:11:02 +00:00
|
|
|
|