Permalink
Browse files

MDL-31918 Use cached module info for activity completion report

  • Loading branch information...
1 parent 256e3ed commit 739af42c9c36e82ee66c77111aa95c2bda590877 @andrewnicols andrewnicols committed with Sam Hemelryk Mar 6, 2012
Showing with 5 additions and 8 deletions.
  1. +5 −8 course/report/completion/index.php
View
13 course/report/completion/index.php
@@ -90,6 +90,9 @@ function csv_quote($value) {
* Load data
*/
+// Retrieve course_module data for all modules in the course
+$modinfo = get_fast_modinfo($course);
+
// Get criteria for course
$completion = new completion_info($course);
@@ -486,13 +489,10 @@ function csv_quote($value) {
switch ($criterion->criteriatype) {
case COMPLETION_CRITERIA_TYPE_ACTIVITY:
- // Load activity
- $activity = $criterion->get_mod_instance();
-
// Display icon
$icon = $OUTPUT->pix_url('icon', $criterion->module);
$iconlink = $CFG->wwwroot.'/mod/'.$criterion->module.'/view.php?id='.$criterion->moduleinstance;
- $icontitle = $activity->name;
+ $icontitle = $modinfo->cms[$criterion->moduleinstance]->name;
$iconalt = get_string('modulename', $criterion->module);
break;
@@ -574,10 +574,7 @@ function csv_quote($value) {
if ($criterion->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
// Load activity
- $mod = $criterion->get_mod_instance();
- $activity = $DB->get_record('course_modules', array('id' => $criterion->moduleinstance));
- $activity->name = $mod->name;
-
+ $activity = $modinfo->cms[$criterion->moduleinstance];
// Get progress information and state
if(array_key_exists($activity->id,$user->progress)) {

0 comments on commit 739af42

Please sign in to comment.