MDL-49061 reports: call format_string on activities names
authorMarina Glancy <marina@moodle.com>
Thu, 12 Mar 2015 11:44:39 +0000 (19:44 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 13 May 2015 04:14:13 +0000 (12:14 +0800)
completion/criteria/completion_criteria_activity.php
report/completion/index.php
report/progress/index.php

index 4fa66b5..c64805e 100644 (file)
@@ -60,7 +60,11 @@ class completion_criteria_activity extends completion_criteria {
      * @param stdClass $data details of various modules
      */
     public function config_form_display(&$mform, $data = null) {
-        $mform->addElement('checkbox', 'criteria_activity['.$data->id.']', ucfirst(self::get_mod_name($data->module)).' - '.$data->name);
+        $modnames = get_module_types_names();
+        $mform->addElement('checkbox', 'criteria_activity['.$data->id.']',
+                $modnames[self::get_mod_name($data->module)].
+                ' - '.
+                format_string($data->name));
 
         if ($this->id) {
             $mform->setDefault('criteria_activity['.$data->id.']', 1);
@@ -177,7 +181,8 @@ class completion_criteria_activity extends completion_criteria {
         $module = $DB->get_record('course_modules', array('id' => $this->moduleinstance));
         $activity = $DB->get_record($this->module, array('id' => $module->instance));
 
-        return shorten_text(urldecode($activity->name));
+        return shorten_text(format_string($activity->name, true,
+                array('context' => context_module::instance($module->id))));
     }
 
     /**
index 5f84c26..0791018 100644 (file)
@@ -468,7 +468,7 @@ if (!$csv) {
                 // Display icon
                 $icon = $OUTPUT->pix_url('icon', $criterion->module);
                 $iconlink = $CFG->wwwroot.'/mod/'.$criterion->module.'/view.php?id='.$criterion->moduleinstance;
-                $icontitle = $modinfo->cms[$criterion->moduleinstance]->name;
+                $icontitle = $modinfo->cms[$criterion->moduleinstance]->get_formatted_name();
                 $iconalt = get_string('modulename', $criterion->module);
                 break;
 
@@ -532,8 +532,9 @@ if (!$csv) {
 
             // Load activity
             $mod = $criterion->get_mod_instance();
-            $row[] = $mod->name;
-            $row[] = $mod->name . ' - ' . get_string('completiondate', 'report_completion');
+            $row[] = $formattedname = format_string($mod->name, true,
+                    array('context' => context_module::instance($criterion->moduleinstance)));
+            $row[] = $formattedname . ' - ' . get_string('completiondate', 'report_completion');
         }
         else {
             // Handle all other criteria
@@ -616,7 +617,7 @@ foreach ($progress as $user) {
             $a->state     = $describe;
             $a->date      = $date;
             $a->user      = fullname($user);
-            $a->activity  = strip_tags($activity->name);
+            $a->activity  = $activity->get_formatted_name();
             $fulldescribe = get_string('progress-title', 'completion', $a);
 
             if ($csv) {
@@ -626,7 +627,7 @@ foreach ($progress as $user) {
                 print '<td class="completion-progresscell">';
 
                 print '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).
-                      '" alt="'.$describe.'" class="icon" title="'.$fulldescribe.'" />';
+                      '" alt="'.s($describe).'" class="icon" title="'.s($fulldescribe).'" />';
 
                 print '</td>';
             }
@@ -672,11 +673,12 @@ foreach ($progress as $user) {
                     )
                 );
 
-                print '<a href="'.$toggleurl->out().'" title="'.get_string('clicktomarkusercomplete', 'report_completion').'">' .
+                print '<a href="'.$toggleurl->out().'" title="'.s(get_string('clicktomarkusercomplete', 'report_completion')).'">' .
                     '<img src="'.$OUTPUT->pix_url('i/completion-manual-'.($is_complete ? 'y' : 'n')).
-                    '" alt="'.$describe.'" class="icon" /></a></td>';
+                    '" alt="'.s($describe).'" class="icon" /></a></td>';
             } else {
-                print '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).'" alt="'.$describe.'" class="icon" title="'.$fulldescribe.'" /></td>';
+                print '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).'" alt="'.s($describe).
+                        '" class="icon" title="'.s($fulldescribe).'" /></td>';
             }
 
             print '</td>';
@@ -717,7 +719,7 @@ foreach ($progress as $user) {
 
         // Display course completion status icon
         print '<img src="'.$OUTPUT->pix_url('i/completion-auto-'.$completiontype).
-               '" alt="'.$describe.'" class="icon" title="'.$fulldescribe.'" />';
+               '" alt="'.s($describe).'" class="icon" title="'.s($fulldescribe).'" />';
 
         print '</td>';
     }
index 8f87baa..ac781f6 100644 (file)
@@ -317,18 +317,19 @@ foreach($activities as $activity) {
     }
 
     // Some names (labels) come URL-encoded and can be very long, so shorten them
-    $displayname = shorten_text($activity->name);
+    $displayname = format_string($activity->name, true, array('context' => $activity->context));
 
     if ($csv) {
-        print $sep.csv_quote(strip_tags($displayname)).$sep.csv_quote($datetext);
+        print $sep.csv_quote($displayname).$sep.csv_quote($datetext);
     } else {
-        $formattedactivityname = format_string($displayname, true, array('context' => $activity->context));
+        $shortenedname = shorten_text($displayname);
         print '<th scope="col" class="'.$datepassedclass.'">'.
             '<a href="'.$CFG->wwwroot.'/mod/'.$activity->modname.
-            '/view.php?id='.$activity->id.'" title="' . $formattedactivityname . '">'.
+            '/view.php?id='.$activity->id.'" title="' . s($displayname) . '">'.
             '<img src="'.$OUTPUT->pix_url('icon', $activity->modname).'" alt="'.
-            get_string('modulename',$activity->modname).'" /> <span class="completion-activityname">'.
-            $formattedactivityname.'</span></a>';
+            s(get_string('modulename', $activity->modname)).
+                '" /> <span class="completion-activityname">'.
+            $shortenedname.'</span></a>';
         if ($activity->completionexpected) {
             print '<div class="completion-expected"><span>'.$datetext.'</span></div>';
         }
@@ -392,7 +393,7 @@ foreach($progress as $user) {
         $a->state=$describe;
         $a->date=$date;
         $a->user=fullname($user);
-        $a->activity = format_string($formattedactivities[$activity->id]->displayname, true, array('context' => $activity->context));
+        $a->activity = $formattedactivities[$activity->id]->displayname;
         $fulldescribe=get_string('progress-title','completion',$a);
 
         if ($csv) {
@@ -400,7 +401,7 @@ foreach($progress as $user) {
         } else {
             print '<td class="completion-progresscell '.$formattedactivities[$activity->id]->datepassedclass.'">'.
                 '<img src="'.$OUTPUT->pix_url('i/'.$completionicon).
-                '" alt="'.$describe.'" title="'.$fulldescribe.'" /></td>';
+                '" alt="'.s($describe).'" title="'.s($fulldescribe).'" /></td>';
         }
     }