diff --git a/course/report/participation/mod.php b/course/report/participation/mod.php deleted file mode 100644 index 5c1fbffb147..00000000000 --- a/course/report/participation/mod.php +++ /dev/null @@ -1,14 +0,0 @@ -'; - $participationreport = get_string('participationreport'); - echo "wwwroot}/course/report/participation/index.php?id={$course->id}\">"; - echo "$participationreport\n"; - echo '
'; - } - diff --git a/course/report/participation/version.php b/course/report/participation/version.php deleted file mode 100644 index 819c2f13db1..00000000000 --- a/course/report/participation/version.php +++ /dev/null @@ -1,29 +0,0 @@ -version = 2010090501; -$plugin->requires = 2010090501; - - diff --git a/lib/pluginlib.php b/lib/pluginlib.php index 3d4437c94fb..1fc85b29ab2 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -304,7 +304,7 @@ class plugin_manager { ), 'coursereport' => array( - 'log', 'participation', 'stats' + 'log', 'stats' ), 'datafield' => array( @@ -407,7 +407,7 @@ class plugin_manager { 'report' => array( 'backups', 'completion', 'configlog', 'courseoverview', - 'log', 'outline', 'progress', 'questioninstances', 'security', 'stats' + 'log', 'outline', 'participation', 'progress', 'questioninstances', 'security', 'stats' ), 'repository' => array( diff --git a/course/report/participation/db/access.php b/report/participation/db/access.php similarity index 94% rename from course/report/participation/db/access.php rename to report/participation/db/access.php index 6a3293e2730..52287689937 100644 --- a/course/report/participation/db/access.php +++ b/report/participation/db/access.php @@ -25,7 +25,7 @@ $capabilities = array( - 'coursereport/participation:view' => array( + 'report/participation:view' => array( 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, @@ -35,7 +35,7 @@ $capabilities = array( 'manager' => CAP_ALLOW ), - 'clonepermissionsfrom' => 'moodle/site:viewreports', + 'clonepermissionsfrom' => 'coursereport/participation:view', ) ); diff --git a/report/participation/db/install.php b/report/participation/db/install.php new file mode 100644 index 00000000000..46d47307ef2 --- /dev/null +++ b/report/participation/db/install.php @@ -0,0 +1,33 @@ +. + +/** + * Post installation and migration code. + * + * @package report + * @subpackage participation + * @copyright 2011 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +function xmldb_report_participation_install() { + // this is a hack which is needed for cleanup of original coursereport_participation stuff + unset_all_config_for_plugin('coursereport_participation'); + capabilities_cleanup('coursereport_participation'); +} + diff --git a/course/report/participation/index.php b/report/participation/index.php similarity index 97% rename from course/report/participation/index.php rename to report/participation/index.php index 659b198559f..7b0860bd113 100644 --- a/course/report/participation/index.php +++ b/report/participation/index.php @@ -1,6 +1,6 @@ dirroot.'/lib/tablelib.php'); define('DEFAULT_PAGE_SIZE', 20); @@ -14,7 +14,7 @@ $page = optional_param('page', 0, PARAM_INT); // which page to show $perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page - $url = new moodle_url('/course/report/participation/index.php', array('id'=>$id)); + $url = new moodle_url('/report/participation/index.php', array('id'=>$id)); if ($roleid !== 0) $url->param('roleid'); if ($instanceid !== 0) $url->param('instanceid'); if ($timefrom !== 0) $url->param('timefrom'); @@ -38,7 +38,7 @@ require_login($course); $context = get_context_instance(CONTEXT_COURSE, $course->id); - require_capability('coursereport/participation:view', $context); + require_capability('report/participation:view', $context); add_to_log($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->id); @@ -141,7 +141,7 @@ echo html_writer::select($actionoptions,'action',$action,false); echo ''."\n\n"; - $baseurl = $CFG->wwwroot.'/course/report/participation/index.php?id='.$course->id.'&roleid=' + $baseurl = $CFG->wwwroot.'/report/participation/index.php?id='.$course->id.'&roleid=' .$roleid.'&instanceid='.$instanceid.'&timefrom='.$timefrom.'&action='.$action.'&perpage='.$perpage; if (!empty($instanceid) && !empty($roleid)) { @@ -296,7 +296,7 @@ echo ''."\n"; echo ''."\n"; - $PAGE->requires->js_init_call('M.coursereport_participation.init'); + $PAGE->requires->js_init_call('M.report_participation.init'); } echo $OUTPUT->footer(); diff --git a/course/report/participation/lang/en/coursereport_participation.php b/report/participation/lang/en/report_participation.php similarity index 100% rename from course/report/participation/lang/en/coursereport_participation.php rename to report/participation/lang/en/report_participation.php diff --git a/course/report/participation/lib.php b/report/participation/lib.php similarity index 69% rename from course/report/participation/lib.php rename to report/participation/lib.php index c11c2a7579b..6fbc75f09d7 100644 --- a/course/report/participation/lib.php +++ b/report/participation/lib.php @@ -1,5 +1,4 @@ $course->id)); - $navigation->add(get_string('participationreport'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); + if (has_capability('report/participation:view', $context)) { + $url = new moodle_url('/report/participation/index.php', array('id'=>$course->id)); + $navigation->add(get_string('pluginname', 'report_participation'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', '')); } } @@ -44,8 +43,9 @@ function participation_report_extend_navigation($navigation, $course, $context) * @param string $pagetype current page type * @param stdClass $parentcontext Block's parent context * @param stdClass $currentcontext Current context of block + * @return array */ -function participation_page_type_list($pagetype, $parentcontext, $currentcontext) { +function report_participation_page_type_list($pagetype, $parentcontext, $currentcontext) { $array = array( '*' => get_string('page-x', 'pagetype'), 'course-report-*' => get_string('page-course-report-x', 'pagetype'), diff --git a/course/report/participation/module.js b/report/participation/module.js similarity index 93% rename from course/report/participation/module.js rename to report/participation/module.js index e4340818947..d3984392c17 100644 --- a/course/report/participation/module.js +++ b/report/participation/module.js @@ -1,7 +1,7 @@ -M.coursereport_participation = {}; +M.report_participation = {}; -M.coursereport_participation.init = function(Y) { +M.report_participation.init = function(Y) { Y.on('submit', function(e) { Y.one('#formactionselect').get('options').each(function() { diff --git a/report/participation/version.php b/report/participation/version.php new file mode 100644 index 00000000000..aad80ed51ec --- /dev/null +++ b/report/participation/version.php @@ -0,0 +1,30 @@ +. + +/** + * Version info + * + * @package report + * @subpackage participation + * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die; + +$plugin->version = 2011110200; // The current plugin version (Date: YYYYMMDDXX) +$plugin->requires = 2011102700.01; // Requires this Moodle version +$plugin->component = 'report_participation'; // Full name of the plugin (used for diagnostics) diff --git a/report/progress/db/access.php b/report/progress/db/access.php index d6f3fb4ebfd..df074747a1e 100644 --- a/report/progress/db/access.php +++ b/report/progress/db/access.php @@ -1,27 +1,27 @@ . -/////////////////////////////////////////////////////////////////////////// -// // -// 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 progress + * @copyright 2008 Sam Marshall + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ $capabilities = array( diff --git a/report/progress/db/install.php b/report/progress/db/install.php index 8d2a21810fa..1e8139547b3 100644 --- a/report/progress/db/install.php +++ b/report/progress/db/install.php @@ -18,7 +18,7 @@ * Post installation and migration code. * * @package report - * @subpackage completion + * @subpackage progress * @copyright 2011 Petr Skoda {@link http://skodak.org} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/report/progress/index.php b/report/progress/index.php index c1bb36c5a2d..f14d6649e67 100644 --- a/report/progress/index.php +++ b/report/progress/index.php @@ -1,13 +1,37 @@ . + +/** + * 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'); require_once($CFG->libdir . '/completionlib.php'); define('COMPLETION_REPORT_PAGE', 25); // Get course $id = required_param('course',PARAM_INT); -$course=$DB->get_record('course',array('id'=>$id)); -if(!$course) { +$course = $DB->get_record('course',array('id'=>$id)); +if (!$course) { print_error('invalidcourseid'); } @@ -24,7 +48,7 @@ $csv = $format == 'csv' || $excel; $start = optional_param('start', 0, PARAM_INT); $sifirst = optional_param('sifirst', 'all', PARAM_ALPHA); $silast = optional_param('silast', 'all', PARAM_ALPHA); -$start = optional_param('start',0,PARAM_INT); +$start = optional_param('start', 0, PARAM_INT); // Whether to show idnumber // TODO: This should really not be using a config option 'intended' for @@ -34,8 +58,8 @@ $idnumbers = $CFG->grade_report_showuseridnumber; 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).'"'; @@ -58,20 +82,20 @@ $PAGE->set_pagelayout('report'); require_login($course); // Check basic permission -$context=get_context_instance(CONTEXT_COURSE,$course->id); +$context = get_context_instance(CONTEXT_COURSE,$course->id); require_capability('report/progress:view',$context); // Get group mode -$group=groups_get_course_group($course,true); // Supposed to verify group -if($group===0 && $course->groupmode==SEPARATEGROUPS) { +$group = groups_get_course_group($course,true); // Supposed to verify group +if ($group===0 && $course->groupmode==SEPARATEGROUPS) { 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) -$reportsurl=$CFG->wwwroot.'/course/report.php?id='.$course->id; -$completion=new completion_info($course); -$activities=$completion->get_activities(); +$reportsurl = $CFG->wwwroot.'/course/report.php?id='.$course->id; +$completion = new completion_info($course); +$activities = $completion->get_activities(); // Generate where clause $where = array(); @@ -107,14 +131,14 @@ if ($total) { ); } -if($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are some users/actvs +if ($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are some users/actvs $shortname = format_string($course->shortname, true, array('context' => $context)); $textlib = textlib_get_instance(); 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); @@ -136,7 +160,7 @@ if($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); - if($svgcleverness) { + if ($svgcleverness) { $PAGE->requires->yui2_lib('event'); $PAGE->requires->js('/report/progress/textrotate.js'); } @@ -145,7 +169,7 @@ if($csv && $grandtotal && count($activities)>0) { // Only show CSV if there are groups_print_course_menu($course,$CFG->wwwroot.'/report/progress/?course='.$course->id); } -if(count($activities)==0) { +if (count($activities)==0) { echo $OUTPUT->container(get_string('err_noactivities', 'completion'), 'errorbox errorboxcontent'); echo $OUTPUT->footer(); exit; @@ -199,7 +223,7 @@ foreach ($initials as $initial) { } // Do we need a paging bar? -if($total > COMPLETION_REPORT_PAGE) { +if ($total > COMPLETION_REPORT_PAGE) { // Paging bar $pagingbar .= '