From 764607014d70af8ef8ccb4066376e1dbd1e42ef7 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 2 Nov 2011 11:03:17 +0100 Subject: [PATCH] MDL-29030 minor completion report cleanup --- report/completion/db/access.php | 45 ++++++++-------- report/completion/db/install.php | 4 +- report/completion/index.php | 52 +++++++++---------- .../completion/lang/en/report_completion.php | 28 +++++++++- report/completion/lib.php | 14 ++--- report/completion/version.php | 5 +- 6 files changed, 88 insertions(+), 60 deletions(-) diff --git a/report/completion/db/access.php b/report/completion/db/access.php index 851b4b38e90..080a6e8b5ca 100644 --- a/report/completion/db/access.php +++ b/report/completion/db/access.php @@ -1,27 +1,28 @@ . -/////////////////////////////////////////////////////////////////////////// -// // -// NOTICE OF COPYRIGHT // -// // -// Moodle - Modular Object-Oriented Dynamic Learning Environment // -// http://moodle.com // -// // -// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // -// // -// 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 + * + * @package report + * @subpackage completion + * @copyright 2009 Catalyst IT Ltd + * @author Aaron Barnes + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ $capabilities = array( diff --git a/report/completion/db/install.php b/report/completion/db/install.php index ce7911c1f6c..b47e2740f79 100644 --- a/report/completion/db/install.php +++ b/report/completion/db/install.php @@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die; function xmldb_report_completion_install() { // this is a hack which is needed for cleanup of original coursereport_completion stuff - unset_all_config_for_plugin('coursereport_online'); - capabilities_cleanup('coursereport_online'); + unset_all_config_for_plugin('coursereport_completion'); + capabilities_cleanup('coursereport_completion'); } diff --git a/report/completion/index.php b/report/completion/index.php index 7385220eed7..e8708dbed4b 100644 --- a/report/completion/index.php +++ b/report/completion/index.php @@ -1,5 +1,4 @@ . - /** * Course completion progress report * - * @package moodlecore - * @copyright 2009 Catalyst IT Ltd - * @author Aaron Barnes - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package report + * @subpackage completion + * @copyright 2009 Catalyst IT Ltd + * @author Aaron Barnes + * @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'); /** @@ -33,7 +33,7 @@ require_once($CFG->libdir.'/completionlib.php'); define('COMPLETION_REPORT_PAGE', 25); define('COMPLETION_REPORT_COL_TITLES', true); -/** +/* * Setup page, check permissions */ @@ -65,8 +65,8 @@ $idnumbers = $CFG->grade_report_showuseridnumber; // Function for quoting csv cell values function csv_quote($value) { global $excel; - if($excel) { - $tl=textlib_get_instance(); + if ($excel) { + $tl = textlib_get_instance(); return $tl->convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE'); } else { return '"'.str_replace('"',"'",$value).'"'; @@ -82,7 +82,7 @@ require_capability('report/completion:view', $context); // Get group mode $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); } @@ -139,7 +139,7 @@ if (!$csv) { } } -/** +/* * Setup page header */ if ($csv) { @@ -148,7 +148,7 @@ if ($csv) { header('Content-Disposition: attachment; filename=progress.'. preg_replace('/[^a-z0-9-]/','_',$textlib->strtolower(strip_tags($shortname))).'.csv'); // Unicode byte-order mark for Excel - if($excel) { + if ($excel) { header('Content-Type: text/csv; charset=UTF-16LE'); print chr(0xFF).chr(0xFE); $sep="\t".chr(0); @@ -267,7 +267,7 @@ foreach ($initials as $initial) { } // Do we need a paging bar? -if($total > COMPLETION_REPORT_PAGE) { +if ($total > COMPLETION_REPORT_PAGE) { // Paging bar $pagingbar .= '
'; @@ -314,12 +314,12 @@ if($total > COMPLETION_REPORT_PAGE) { } -/** +/* * Draw table header */ // Start of table -if(!$csv) { +if (!$csv) { print '
'; // ugh $total_header = ($total == $grandtotal) ? $total : "{$total}/{$grandtotal}"; @@ -456,7 +456,7 @@ if(!$csv) { $sistring = "&silast={$silast}&sifirst={$sifirst}"; - if($firstnamesort) { + if ($firstnamesort) { print get_string('firstname')." / id}{$sistring}\">". get_string('lastname').''; @@ -469,7 +469,7 @@ if(!$csv) { // Print user id number column - if($idnumbers) { + if ($idnumbers) { print ''.get_string('idnumber').''; } @@ -540,7 +540,7 @@ if(!$csv) { } else { // TODO - if($idnumbers) { + if ($idnumbers) { print $sep; } } @@ -552,9 +552,9 @@ if(!$csv) { foreach ($progress as $user) { // User name - if($csv) { + if ($csv) { print csv_quote(fullname($user)); - if($idnumbers) { + if ($idnumbers) { print $sep.csv_quote($user->idnumber); } } else { @@ -562,7 +562,7 @@ foreach ($progress as $user) { print ''.fullname($user).''; - if($idnumbers) { + if ($idnumbers) { print ''.htmlspecialchars($user->idnumber).''; } } @@ -580,7 +580,7 @@ foreach ($progress as $user) { // 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]; $state=$thisprogress->completionstate; $date=userdate($thisprogress->timemodified); @@ -611,7 +611,7 @@ foreach ($progress as $user) { $a->activity=strip_tags($activity->name); $fulldescribe=get_string('progress-title','completion',$a); - if($csv) { + if ($csv) { print $sep.csv_quote($describe).$sep.csv_quote($date); } else { print ''; @@ -693,14 +693,14 @@ foreach ($progress as $user) { print ''; } - if($csv) { + if ($csv) { print $line; } else { print ''; } } -if($csv) { +if ($csv) { exit; } print ''; diff --git a/report/completion/lang/en/report_completion.php b/report/completion/lang/en/report_completion.php index 808f4c8d392..cf251e17196 100644 --- a/report/completion/lang/en/report_completion.php +++ b/report/completion/lang/en/report_completion.php @@ -1,6 +1,30 @@ . + +/** + * Lang strings + * + * @package report + * @subpackage completion + * @copyright 2009 Catalyst IT Ltd + * @author Aaron Barnes + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ $string['completion:view'] = 'View course completion report'; -$string['completiondate']='Completion date'; +$string['completiondate'] = 'Completion date'; $string['pluginpagetype'] = 'Course completion report'; -$string['pluginname']='Course completion'; +$string['pluginname'] = 'Course completion'; diff --git a/report/completion/lib.php b/report/completion/lib.php index 2a862bc806d..3bb40de9e80 100644 --- a/report/completion/lib.php +++ b/report/completion/lib.php @@ -1,5 +1,4 @@ . /** - * This file contains functions used by the progress report + * Version details. * - * @package course-report - * @copyright 2009 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package report + * @subpackage completion + * @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 @@ -35,6 +35,8 @@ require_once($CFG->libdir.'/completionlib.php'); function report_completion_extend_navigation_course($navigation, $course, $context) { global $CFG, $OUTPUT; + require_once($CFG->libdir.'/completionlib.php'); + if (has_capability('report/completion:view', $context)) { $completion = new completion_info($course); if ($completion->is_enabled() && $completion->has_criteria()) { diff --git a/report/completion/version.php b/report/completion/version.php index c368e665ae3..a92a0069fed 100644 --- a/report/completion/version.php +++ b/report/completion/version.php @@ -15,11 +15,12 @@ // along with Moodle. If not, see . /** - * Version details. + * Version details * * @package report * @subpackage completion - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) + * @copyright 2009 Catalyst IT Ltd + * @author Aaron Barnes * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */