MDL-58365 block_myoverview: Show course summary in plain text
authorJun Pataleta <jun@moodle.com>
Thu, 23 Mar 2017 08:06:41 +0000 (16:06 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 4 Apr 2017 10:01:51 +0000 (11:01 +0100)
Part of MDL-55611 epic.

blocks/myoverview/classes/output/course_summary.php
blocks/myoverview/classes/output/courses_view.php
blocks/myoverview/templates/course-summary.mustache
blocks/myoverview/templates/courses-view-course-item.mustache

index 26beaed..5155930 100644 (file)
@@ -57,14 +57,16 @@ class course_summary implements renderable, templatable {
      * Export this data so it can be used as the context for a mustache template.
      *
      * @param \renderer_base $output
-     * @return stdClass
+     * @return array
      */
     public function export_for_template(renderer_base $output) {
 
         $data = [];
-        foreach ($this->courses as $courseid => $value) {
+        foreach ($this->courses as $courseid => $course) {
             $context = \context_course::instance($courseid);
-            $exporter = new course_summary_exporter($this->courses[$courseid], array('context' => $context));
+            // Convert summary to plain text.
+            $course->summary = content_to_text($course->summary, false);
+            $exporter = new course_summary_exporter($course, array('context' => $context));
             $exportedcourse = $exporter->export($output);
 
             if (isset($this->coursesprogress[$courseid])) {
index f20f280..86b0e49 100644 (file)
@@ -77,6 +77,8 @@ class courses_view implements renderable, templatable {
             $enddate = $course->enddate;
             $courseid = $course->id;
             $context = \context_course::instance($courseid);
+            // Convert summary to plain text.
+            $course->summary = content_to_text($course->summary, false);
             $exporter = new course_summary_exporter($course, [
                 'context' => $context
             ]);
index 6dabb7c..fd56fcf 100644 (file)
@@ -56,6 +56,6 @@
         {{/enddate}}
     </p>
     <p class="text-muted">
-        {{#shortentext}} 140, {{{summary}}}{{/shortentext}}
+        {{#shortentext}} 140, {{summary}}{{/shortentext}}
     </p>
 </div>
index c625cd1..c36b8e7 100644 (file)
@@ -54,7 +54,7 @@
                 {{/enddate}}
             </p>
             <p class="text-muted">
-                {{#shortentext}} 140, {{{summary}}}{{/shortentext}}
+                {{#shortentext}} 140, {{summary}}{{/shortentext}}
             </p>
         </div>
     </div>