MDL-32769 completion: Fixed up display of completion information
authorSam Hemelryk <sam@moodle.com>
Thu, 21 Jun 2012 22:42:56 +0000 (10:42 +1200)
committerSam Hemelryk <sam@moodle.com>
Thu, 21 Jun 2012 22:42:56 +0000 (10:42 +1200)
course/format/renderer.php
lang/en/completion.php
lang/en/moodle.php

index 77caeda..b7c0e21 100644 (file)
@@ -315,7 +315,6 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
      * @return string HTML to output.
      */
     private function section_activity_summary($section, $course, $mods) {
-        $completioninfo = new completion_info($course);
         if (empty($section->sequence)) {
             return '';
         }
@@ -324,6 +323,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
         $sectionmods = array();
         $total = 0;
         $complete = 0;
+        $cancomplete = isloggedin() && !isguestuser();
+        $completioninfo = new completion_info($course);
         $modsequence = explode(',', $section->sequence);
         foreach ($modsequence as $cmid) {
             $thismod = $mods[$cmid];
@@ -340,10 +341,9 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
                     $sectionmods[$thismod->modname]['name'] = $thismod->modplural;
                     $sectionmods[$thismod->modname]['count'] = 1;
                 }
-                if ($completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE && isloggedin() &&
-                                !isguestuser() && $thismod->uservisible) {
+                if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
                     $total++;
-                    $completiondata = $completioninfo->get_data($thismod,true);
+                    $completiondata = $completioninfo->get_data($thismod, true);
                     if ($completiondata->completionstate == COMPLETION_COMPLETE) {
                         $complete++;
                     }
@@ -367,12 +367,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base {
         $o.= html_writer::end_tag('div');
 
         // Output section completion data
-        if ($completioninfo->is_enabled() != COMPLETION_TRACKING_NONE && isloggedin() &&
-                        !isguestuser() && $total !== 0) {
+        if ($total > 0) {
+            $a = new stdClass;
+            $a->complete = $complete;
+            $a->total = $total;
+
             $o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right'));
-            $o.= html_writer::start_tag('span', array('class' => 'activity-count'));
-            $o.= get_string("progress")." $complete / $total";
-            $o.= html_writer::end_tag('span');
+            $o.= html_writer::tag('span', get_string('progresstotal', 'completion', $a), array('class' => 'activity-count'));
             $o.= html_writer::end_tag('div');
         }
 
index f1de5c0..0683c79 100644 (file)
@@ -78,6 +78,7 @@ $string['err_system'] = 'An internal error occurred in the completion system. (S
 $string['excelcsvdownload'] = 'Download in Excel-compatible format (.csv)';
 $string['progress'] = 'Student progress';
 $string['progress-title'] = '{$a->user}, {$a->activity}: {$a->state} {$a->date}';
+$string['progresstotal'] = 'Progress: {$a->complete} / {$a->total}';
 $string['reportpage'] = 'Showing users {$a->from} to {$a->to} of {$a->total}.';
 $string['restoringcompletiondata'] = 'Writing completion data';
 $string['saved'] = 'Saved';
index 2419f01..ba5553c 100644 (file)
@@ -1331,7 +1331,6 @@ $string['previoussection'] = 'Previous section';
 $string['primaryadminsetup'] = 'Setup administrator account';
 $string['profile'] = 'Profile';
 $string['profilenotshown'] = 'This profile description will not be shown until this person is enrolled in at least one course.';
-$string['progress'] = 'Progress:';
 $string['publicprofile'] = 'Public profile';
 $string['publicsitefileswarning'] = 'Note: files placed here can be accessed by anyone';
 $string['publicsitefileswarning2'] = 'Note: Files placed here can be accessed by anyone who knows (or can guess) the URL. For security reasons, it is recommended that any backup files are deleted immediately after restoring them.';