From 3afce1a574abb8df4781cfd69aebe99c5438158e Mon Sep 17 00:00:00 2001
From: Petr Skoda
Date: Wed, 2 Nov 2011 11:24:44 +0100
Subject: [PATCH] MDL-29030 convert participation report to new report type
AMOS BEGIN
MOV [participation:view,coursereport_participation],[participation:view,report_participation]
MOV [pluginpagetype,coursereport_participation],[pluginpagetype,report_participation]
MOV [pluginname,coursereport_participation],[pluginname,report_participation]
AMOS END
---
course/report/participation/mod.php | 14 ---
course/report/participation/version.php | 29 ------
lib/pluginlib.php | 4 +-
.../participation/db/access.php | 4 +-
report/participation/db/install.php | 33 +++++++
.../report => report}/participation/index.php | 10 +-
.../lang/en/report_participation.php | 0
.../report => report}/participation/lib.php | 20 ++--
.../report => report}/participation/module.js | 4 +-
report/participation/version.php | 30 ++++++
report/progress/db/access.php | 44 ++++-----
report/progress/db/install.php | 2 +-
report/progress/index.php | 91 ++++++++++++-------
report/progress/lang/en/report_progress.php | 10 +-
report/progress/lib.php | 14 +--
report/progress/styles.css | 7 ++
theme/base/style/core.css | 7 --
17 files changed, 184 insertions(+), 139 deletions(-)
delete mode 100644 course/report/participation/mod.php
delete mode 100644 course/report/participation/version.php
rename {course/report => report}/participation/db/access.php (94%)
create mode 100644 report/participation/db/install.php
rename {course/report => report}/participation/index.php (97%)
rename course/report/participation/lang/en/coursereport_participation.php => report/participation/lang/en/report_participation.php (100%)
rename {course/report => report}/participation/lib.php (69%)
rename {course/report => report}/participation/module.js (93%)
create mode 100644 report/participation/version.php
create mode 100644 report/progress/styles.css
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 '';
@@ -228,8 +252,7 @@ if($total > COMPLETION_REPORT_PAGE) {
if ($curstart == $start) {
$pagingbar .= ' '.$curpage.' ';
- }
- else {
+ } else {
$pagingbar .= "
$curpage ";
}
@@ -248,7 +271,7 @@ if($total > COMPLETION_REPORT_PAGE) {
// Okay, let's draw the table of progress info,
// Start of table
-if(!$csv) {
+if (!$csv) {
print '
'; // ugh
print $pagingbar;
@@ -266,7 +289,7 @@ if(!$csv) {
$sistring = "&silast={$silast}&sifirst={$sifirst}";
- if($firstnamesort) {
+ if ($firstnamesort) {
print
get_string('firstname')." /
id}{$sistring}\">".
get_string('lastname').'';
@@ -277,12 +300,12 @@ if(!$csv) {
}
print '';
- if($idnumbers) {
+ if ($idnumbers) {
print '
'.get_string('idnumber').' | ';
}
} else {
- if($idnumbers) {
+ if ($idnumbers) {
print $sep;
}
}
@@ -292,7 +315,7 @@ foreach($activities as $activity) {
$activity->datepassed = $activity->completionexpected && $activity->completionexpected <= time();
$activity->datepassedclass=$activity->datepassed ? 'completion-expired' : '';
- if($activity->completionexpected) {
+ if ($activity->completionexpected) {
$datetext=userdate($activity->completionexpected,get_string('strftimedate','langconfig'));
} else {
$datetext='';
@@ -301,7 +324,7 @@ foreach($activities as $activity) {
// Some names (labels) come URL-encoded and can be very long, so shorten them
$activity->name = shorten_text($activity->name);
- if($csv) {
+ if ($csv) {
print $sep.csv_quote(strip_tags($activity->name)).$sep.csv_quote($datetext);
} else {
print '
'.
@@ -310,14 +333,14 @@ foreach($activities as $activity) {
' '.
format_string($activity->name).'';
- if($activity->completionexpected) {
+ if ($activity->completionexpected) {
print ''.$datetext.' ';
}
print ' | ';
}
}
-if($csv) {
+if ($csv) {
print $line;
} else {
print '';
@@ -326,15 +349,15 @@ if($csv) {
// Row for each user
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 {
print '
| '.fullname($user).' | ';
- if($idnumbers) {
+ if ($idnumbers) {
print ''.htmlspecialchars($user->idnumber).' | ';
}
}
@@ -343,7 +366,7 @@ foreach($progress as $user) {
foreach($activities as $activity) {
// 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);
@@ -372,7 +395,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 ''.
@@ -381,14 +404,14 @@ foreach($progress as $user) {
}
}
- if($csv) {
+ if ($csv) {
print $line;
} else {
print ' |
|---|
';
}
}
-if($csv) {
+if ($csv) {
exit;
}
print '';
diff --git a/report/progress/lang/en/report_progress.php b/report/progress/lang/en/report_progress.php
index bf8adf16775..621680e3357 100644
--- a/report/progress/lang/en/report_progress.php
+++ b/report/progress/lang/en/report_progress.php
@@ -1,5 +1,4 @@
.
/**
- * Strings for component 'coursereport_progress', language 'en', branch 'MOODLE_20_STABLE'
+ * Lang strings
*
- * @package coursereport_progress
- * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package report
+ * @subpackage progress
+ * @copyright 2008 Sam Marshall
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Activity completion';
diff --git a/report/progress/lib.php b/report/progress/lib.php
index d677248ad21..b56f6adfad3 100644
--- a/report/progress/lib.php
+++ b/report/progress/lib.php
@@ -1,5 +1,4 @@
libdir.'/completionlib.php');
+defined('MOODLE_INTERNAL') || die;
/**
* This function extends the navigation with the report items
@@ -35,8 +35,10 @@ require_once($CFG->libdir.'/completionlib.php');
function report_progress_extend_navigation_course($navigation, $course, $context) {
global $CFG, $OUTPUT;
+ require_once($CFG->libdir.'/completionlib.php');
+
$showonnavigation = has_capability('report/progress:view', $context);
- $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) {
$showonnavigation = ($showonnavigation && has_capability('moodle/site:accessallgroups', $context));
}
diff --git a/report/progress/styles.css b/report/progress/styles.css
new file mode 100644
index 00000000000..c58e9cc2b58
--- /dev/null
+++ b/report/progress/styles.css
@@ -0,0 +1,7 @@
+#page-report-progress-index th,
+#page-report-progress-index td {padding:2px 4px;font-weight:normal;border-right: 1px solid #EEE;}
+#page-report-progress-index .progress-actions {text-align:center;}
+#page-report-progress-index .completion_pagingbar {margin:1em 0;text-align:center;}
+#page-report-progress-index .completion_prev {display:inline;margin-right:2em;}
+#page-report-progress-index .completion_pagingbar p {display:inline;margin:0;}
+#page-report-progress-index .completion_next {display:inline;margin-left:2em;}
diff --git a/theme/base/style/core.css b/theme/base/style/core.css
index 62a5bfe860d..b063edd08c0 100644
--- a/theme/base/style/core.css
+++ b/theme/base/style/core.css
@@ -364,13 +364,6 @@ table.mod_index {width:100%;}
.completion-sortchoice {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,
-#page-course-report-progress-index td {padding:2px 4px;font-weight:normal;border-right: 1px solid #EEE;}
-#page-course-report-progress-index .progress-actions {text-align:center;}
-#page-course-report-progress-index .completion_pagingbar {margin:1em 0;text-align:center;}
-#page-course-report-progress-index .completion_prev {display:inline;margin-right:2em;}
-#page-course-report-progress-index .completion_pagingbar p {display:inline;margin:0;}
-#page-course-report-progress-index .completion_next {display:inline;margin-left:2em;}
/**
* Tags