MDL-29030 minor completion report cleanup

This commit is contained in:
Petr Skoda 2011-11-02 11:03:17 +01:00
parent 13fdaaacc3
commit 764607014d
6 changed files with 88 additions and 60 deletions

View File

@ -1,27 +1,28 @@
<?php <?php
// 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/>.
/////////////////////////////////////////////////////////////////////////// /**
// // * Capabilities
// NOTICE OF COPYRIGHT // *
// // * @package report
// Moodle - Modular Object-Oriented Dynamic Learning Environment // * @subpackage completion
// http://moodle.com // * @copyright 2009 Catalyst IT Ltd
// // * @author Aaron Barnes <aaronb@catalyst.net.nz>
// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
// // */
// This program 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 2 of the License, or //
// (at your option) any later version. //
// //
// This program 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: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
$capabilities = array( $capabilities = array(

View File

@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die;
function xmldb_report_completion_install() { function xmldb_report_completion_install() {
// this is a hack which is needed for cleanup of original coursereport_completion stuff // this is a hack which is needed for cleanup of original coursereport_completion stuff
unset_all_config_for_plugin('coursereport_online'); unset_all_config_for_plugin('coursereport_completion');
capabilities_cleanup('coursereport_online'); capabilities_cleanup('coursereport_completion');
} }

View File

@ -1,5 +1,4 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -15,16 +14,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Course completion progress report * Course completion progress report
* *
* @package moodlecore * @package report
* @copyright 2009 Catalyst IT Ltd * @subpackage completion
* @author Aaron Barnes <aaronb@catalyst.net.nz> * @copyright 2009 Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Aaron Barnes <aaronb@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
require_once('../../config.php');
require('../../config.php');
require_once($CFG->libdir.'/completionlib.php'); require_once($CFG->libdir.'/completionlib.php');
/** /**
@ -33,7 +33,7 @@ require_once($CFG->libdir.'/completionlib.php');
define('COMPLETION_REPORT_PAGE', 25); define('COMPLETION_REPORT_PAGE', 25);
define('COMPLETION_REPORT_COL_TITLES', true); define('COMPLETION_REPORT_COL_TITLES', true);
/** /*
* Setup page, check permissions * Setup page, check permissions
*/ */
@ -65,8 +65,8 @@ $idnumbers = $CFG->grade_report_showuseridnumber;
// Function for quoting csv cell values // Function for quoting csv cell values
function csv_quote($value) { function csv_quote($value) {
global $excel; global $excel;
if($excel) { if ($excel) {
$tl=textlib_get_instance(); $tl = textlib_get_instance();
return $tl->convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE'); return $tl->convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE');
} else { } else {
return '"'.str_replace('"',"'",$value).'"'; return '"'.str_replace('"',"'",$value).'"';
@ -82,7 +82,7 @@ require_capability('report/completion:view', $context);
// Get group mode // Get group mode
$group = groups_get_course_group($course, true); // Supposed to verify group $group = groups_get_course_group($course, true); // Supposed to verify group
if($group === 0 && $course->groupmode == SEPARATEGROUPS) { if ($group === 0 && $course->groupmode == SEPARATEGROUPS) {
require_capability('moodle/site:accessallgroups',$context); require_capability('moodle/site:accessallgroups',$context);
} }
@ -139,7 +139,7 @@ if (!$csv) {
} }
} }
/** /*
* Setup page header * Setup page header
*/ */
if ($csv) { if ($csv) {
@ -148,7 +148,7 @@ if ($csv) {
header('Content-Disposition: attachment; filename=progress.'. header('Content-Disposition: attachment; filename=progress.'.
preg_replace('/[^a-z0-9-]/','_',$textlib->strtolower(strip_tags($shortname))).'.csv'); preg_replace('/[^a-z0-9-]/','_',$textlib->strtolower(strip_tags($shortname))).'.csv');
// Unicode byte-order mark for Excel // Unicode byte-order mark for Excel
if($excel) { if ($excel) {
header('Content-Type: text/csv; charset=UTF-16LE'); header('Content-Type: text/csv; charset=UTF-16LE');
print chr(0xFF).chr(0xFE); print chr(0xFF).chr(0xFE);
$sep="\t".chr(0); $sep="\t".chr(0);
@ -267,7 +267,7 @@ foreach ($initials as $initial) {
} }
// Do we need a paging bar? // Do we need a paging bar?
if($total > COMPLETION_REPORT_PAGE) { if ($total > COMPLETION_REPORT_PAGE) {
// Paging bar // Paging bar
$pagingbar .= '<div class="paging">'; $pagingbar .= '<div class="paging">';
@ -314,12 +314,12 @@ if($total > COMPLETION_REPORT_PAGE) {
} }
/** /*
* Draw table header * Draw table header
*/ */
// Start of table // Start of table
if(!$csv) { if (!$csv) {
print '<br class="clearer"/>'; // ugh print '<br class="clearer"/>'; // ugh
$total_header = ($total == $grandtotal) ? $total : "{$total}/{$grandtotal}"; $total_header = ($total == $grandtotal) ? $total : "{$total}/{$grandtotal}";
@ -456,7 +456,7 @@ if(!$csv) {
$sistring = "&amp;silast={$silast}&amp;sifirst={$sifirst}"; $sistring = "&amp;silast={$silast}&amp;sifirst={$sifirst}";
if($firstnamesort) { if ($firstnamesort) {
print print
get_string('firstname')." / <a href=\"./?course={$course->id}{$sistring}\">". get_string('firstname')." / <a href=\"./?course={$course->id}{$sistring}\">".
get_string('lastname').'</a>'; get_string('lastname').'</a>';
@ -469,7 +469,7 @@ if(!$csv) {
// Print user id number column // Print user id number column
if($idnumbers) { if ($idnumbers) {
print '<th>'.get_string('idnumber').'</th>'; print '<th>'.get_string('idnumber').'</th>';
} }
@ -540,7 +540,7 @@ if(!$csv) {
} else { } else {
// TODO // TODO
if($idnumbers) { if ($idnumbers) {
print $sep; print $sep;
} }
} }
@ -552,9 +552,9 @@ if(!$csv) {
foreach ($progress as $user) { foreach ($progress as $user) {
// User name // User name
if($csv) { if ($csv) {
print csv_quote(fullname($user)); print csv_quote(fullname($user));
if($idnumbers) { if ($idnumbers) {
print $sep.csv_quote($user->idnumber); print $sep.csv_quote($user->idnumber);
} }
} else { } else {
@ -562,7 +562,7 @@ foreach ($progress as $user) {
print '<th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='. print '<th scope="row"><a href="'.$CFG->wwwroot.'/user/view.php?id='.
$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></th>'; $user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></th>';
if($idnumbers) { if ($idnumbers) {
print '<td>'.htmlspecialchars($user->idnumber).'</td>'; print '<td>'.htmlspecialchars($user->idnumber).'</td>';
} }
} }
@ -580,7 +580,7 @@ foreach ($progress as $user) {
// Get progress information and state // Get progress information and state
if(array_key_exists($activity->id,$user->progress)) { if (array_key_exists($activity->id,$user->progress)) {
$thisprogress=$user->progress[$activity->id]; $thisprogress=$user->progress[$activity->id];
$state=$thisprogress->completionstate; $state=$thisprogress->completionstate;
$date=userdate($thisprogress->timemodified); $date=userdate($thisprogress->timemodified);
@ -611,7 +611,7 @@ foreach ($progress as $user) {
$a->activity=strip_tags($activity->name); $a->activity=strip_tags($activity->name);
$fulldescribe=get_string('progress-title','completion',$a); $fulldescribe=get_string('progress-title','completion',$a);
if($csv) { if ($csv) {
print $sep.csv_quote($describe).$sep.csv_quote($date); print $sep.csv_quote($describe).$sep.csv_quote($date);
} else { } else {
print '<td class="completion-progresscell">'; print '<td class="completion-progresscell">';
@ -693,14 +693,14 @@ foreach ($progress as $user) {
print '</td>'; print '</td>';
} }
if($csv) { if ($csv) {
print $line; print $line;
} else { } else {
print '</tr>'; print '</tr>';
} }
} }
if($csv) { if ($csv) {
exit; exit;
} }
print '</table>'; print '</table>';

View File

@ -1,6 +1,30 @@
<?php <?php
// 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/>.
/**
* Lang strings
*
* @package report
* @subpackage completion
* @copyright 2009 Catalyst IT Ltd
* @author Aaron Barnes <aaronb@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['completion:view'] = 'View course completion report'; $string['completion:view'] = 'View course completion report';
$string['completiondate']='Completion date'; $string['completiondate'] = 'Completion date';
$string['pluginpagetype'] = 'Course completion report'; $string['pluginpagetype'] = 'Course completion report';
$string['pluginname']='Course completion'; $string['pluginname'] = 'Course completion';

View File

@ -1,5 +1,4 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -16,14 +15,15 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* This file contains functions used by the progress report * Version details.
* *
* @package course-report * @package report
* @copyright 2009 Sam Hemelryk * @subpackage completion
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2009 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
require_once($CFG->libdir.'/completionlib.php'); defined('MOODLE_INTERNAL') || die;
/** /**
* This function extends the navigation with the report items * This function extends the navigation with the report items
@ -35,6 +35,8 @@ require_once($CFG->libdir.'/completionlib.php');
function report_completion_extend_navigation_course($navigation, $course, $context) { function report_completion_extend_navigation_course($navigation, $course, $context) {
global $CFG, $OUTPUT; global $CFG, $OUTPUT;
require_once($CFG->libdir.'/completionlib.php');
if (has_capability('report/completion:view', $context)) { if (has_capability('report/completion:view', $context)) {
$completion = new completion_info($course); $completion = new completion_info($course);
if ($completion->is_enabled() && $completion->has_criteria()) { if ($completion->is_enabled() && $completion->has_criteria()) {

View File

@ -15,11 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Version details. * Version details
* *
* @package report * @package report
* @subpackage completion * @subpackage completion
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @copyright 2009 Catalyst IT Ltd
* @author Aaron Barnes <aaronb@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */