MDL-35147 lesson qformat import: Dirty hack to support array questiontext structures.
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 30 Aug 2012 20:58:52 +0000 (22:58 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 31 Aug 2012 01:02:53 +0000 (03:02 +0200)
mod/lesson/format.php

index 4d8faf1..95bb645 100644 (file)
@@ -384,6 +384,15 @@ class qformat_default {
                         $newpage->title = "Page $count";
                     }
                     $newpage->contents = $question->questiontext;
+                    $newpage->contentsformat = isset($question->questionformat) ? $question->questionformat : FORMAT_HTML;
+
+                    // Sometimes, questiontext is not a simple text, but one array
+                    // containing both text and format, so we need to support here
+                    // that case with the following dirty patch. MDL-35147
+                    if (is_array($question->questiontext)) {
+                        $newpage->contents = isset($question->questiontext['text']) ? $question->questiontext['text'] : '';
+                        $newpage->contentsformat = isset($question->questiontext['format']) ? $question->questiontext['format'] : FORMAT_HTML;
+                    }
 
                     // set up page links
                     if ($pageid) {