]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19822 Upgraded calls to helpbutton, print_simple_box* and notify
authornicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:19:00 +0000 (05:19 +0000)
committernicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:19:00 +0000 (05:19 +0000)
19 files changed:
question/backuplib.php
question/editlib.php
question/export.php
question/format.php
question/format/gift/format.php
question/format/qti_two/format.php
question/format/xhtml/format.php
question/format/xml/format.php
question/import.php
question/question.php
question/type/calculated/questiontype.php
question/type/match/questiontype.php
question/type/multianswer/questiontype.php
question/type/multichoice/questiontype.php
question/type/numerical/questiontype.php
question/type/questiontype.php
question/type/random/questiontype.php
question/type/randomsamatch/questiontype.php
question/type/truefalse/questiontype.php

index 9e36aae957354bbd7c4c37aead782578d36e77d6..876ea343499bbd716a31f4a1d57ee957de49ef29 100644 (file)
     }
 
     function question_insert_site_file_names($course, $backup_unique_code){
-        global $QTYPES, $CFG, $DB;
+        global $QTYPES, $CFG, $DB, $OUTPUT;
         $status = true;
         $questionids = question_ids_by_backup ($backup_unique_code);
         $urls = array();
                 $inserturl->path = $url;
                 $status = $status && $DB->insert_record('backup_files', $inserturl);
             } else {
-                notify(get_string('linkedfiledoesntexist', 'question', $url));
+                echo $OUTPUT->notification(get_string('linkedfiledoesntexist', 'question', $url));
             }
         }
         return $status;
index d022ca61a8b89b67e8106a1973a4d198bad641fa..b0dd53e61e0a646c922dc3841d9fd00c314cfec3 100644 (file)
@@ -1140,7 +1140,7 @@ class question_bank_view {
         if (!$category = $DB->get_record('question_categories',
                 array('id' => $categoryid, 'contextid' => $contextid))) {
             echo $OUTPUT->box_start('generalbox questionbank');
-            notify('Category not found!');
+            echo $OUTPUT->notification('Category not found!');
             echo $OUTPUT->box_end();
             return false;
         }
@@ -1910,12 +1910,12 @@ function print_qtype_to_add_option($qtype, $localizedname) {
  * @param boolean $disabled if true, the button will be disabled.
  */
 function create_new_question_button($categoryid, $params, $caption, $tooltip = '', $disabled = false) {
-    global $CFG, $PAGE;
+    global $CFG, $PAGE, $OUTPUT;
     static $choiceformprinted = false;
     $params['category'] = $categoryid;
     print_single_button($CFG->wwwroot . '/question/addquestion.php', $params,
             $caption,'get', '', false, $tooltip, $disabled);
-    helpbutton('types', get_string('createnewquestion', 'question'), 'question');
+    echo $OUTPUT->help_icon(moodle_help_icon::make('types', get_string('createnewquestion', 'question'), 'question'));
     $PAGE->requires->yui_lib('dragdrop');
     $PAGE->requires->yui_lib('container');
     if (!$choiceformprinted) {
index 8d0f70e8ddcf4761d79c2ebd6aa6317bbd93ce59..84729baf53749bf9157e01facf5cd5cf82ab37d0 100644 (file)
             $PAGE->requires->js_function_call('document.location.replace', array($efile))->after_delay(1);
         }
 
-        print_continue('edit.php?' . $thispageurl->get_query_string());
+        echo $OUTPUT->continue_button('edit.php?' . $thispageurl->get_query_string());
         echo $OUTPUT->footer();
         exit;
     }
index 5108c509e2e0f07c4b0b01babf1cadc5a14089e1..1356844ca2e8d4212f812a5333696b29d8fd5892 100644 (file)
@@ -216,30 +216,30 @@ class qformat_default {
      * @return boolean success
      */
     function importprocess() {
-        global $USER, $DB;
+        global $USER, $DB, $OUTPUT;
 
        // reset the timer in case file upload was slow
        @set_time_limit();
 
        // STAGE 1: Parse the file
-       notify( get_string('parsingquestions','quiz') );
+       echo $OUTPUT->notification( get_string('parsingquestions','quiz') );
 
         if (! $lines = $this->readdata($this->filename)) {
-            notify( get_string('cannotread','quiz') );
+            echo $OUTPUT->notification( get_string('cannotread','quiz') );
             return false;
         }
 
         if (! $questions = $this->readquestions($lines)) {   // Extract all the questions
-            notify( get_string('noquestionsinfile','quiz') );
+            echo $OUTPUT->notification( get_string('noquestionsinfile','quiz') );
             return false;
         }
 
         // STAGE 2: Write data to database
-        notify( get_string('importingquestions','quiz',$this->count_questions($questions)) );
+        echo $OUTPUT->notification( get_string('importingquestions','quiz',$this->count_questions($questions)) );
 
         // check for errors before we continue
         if ($this->stoponerror and ($this->importerrors>0)) {
-            notify( get_string('importparseerror','quiz') );
+            echo $OUTPUT->notification( get_string('importparseerror','quiz') );
             return true;
         }
 
@@ -265,7 +265,7 @@ class qformat_default {
                     }
                 }
                 if (!$answersvalid) {
-                    notify(get_string('matcherror', 'quiz'));
+                    echo $OUTPUT->notification(get_string('matcherror', 'quiz'));
                     ++$gradeerrors;
                     continue;
                 }
@@ -324,12 +324,12 @@ class qformat_default {
                     ->save_question_options($question);
 
             if (!empty($result->error)) {
-                notify($result->error);
+                echo $OUTPUT->notification($result->error);
                 return false;
             }
 
             if (!empty($result->notice)) {
-                notify($result->notice);
+                echo $OUTPUT->notification($result->notice);
                 return true;
             }
 
@@ -641,7 +641,7 @@ class qformat_default {
      * @return boolean success
      */
     function exportprocess() {
-        global $CFG;
+        global $CFG, $OUTPUT;
 
         // create a directory for the exports (if not already existing)
         if (! $export_dir = make_upload_directory($this->question_get_export_dir())) {
@@ -657,7 +657,7 @@ class qformat_default {
             $questions = $this->questions;
         }
 
-        notify( get_string('exportingquestions','quiz') );
+        echo $OUTPUT->notification( get_string('exportingquestions','quiz') );
         $count = 0;
 
         // results are first written into string (and then to a file)
index c246dceee4fe5bac346f3c0052d0f628b7673f9b..bb3bc13c81e8570af6e4156afd9c335a8ec4385e 100755 (executable)
@@ -528,7 +528,7 @@ function repchar( $text, $format=0 ) {
     }
 
 function writequestion( $question ) {
-    global $QTYPES;
+    global $QTYPES, $OUTPUT;
     // turns question into string
     // question reflects database fields for general question and specific to type
 
@@ -648,7 +648,7 @@ function writequestion( $question ) {
         }
         else {
             $expout .= "Question type $question->qtype is not supported\n";
-            notify( get_string('nohandler', 'qformat_gift', $QTYPES[$question->qtype]->local_name()) );
+            echo $OUTPUT->notification( get_string('nohandler', 'qformat_gift', $QTYPES[$question->qtype]->local_name()) );
         }
     }
     // add empty line to delimit questions
index e3fc297ba0f95e97aaec873325e202196ad3ec8d..a5dfa597c893ca79988cf3849e56ae353d6d4867 100644 (file)
@@ -235,7 +235,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
  */
     function exportprocess() {
 
-        global $CFG;
+        global $CFG, $OUTPUT;
         $courseid = $this->course->id;
 
         // create a directory for the exports (if not already existing)
@@ -247,7 +247,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
         // get the questions (from database) in this category
         $questions = get_questions_category( $this->category );
 
-        notify("Exporting ".count($questions)." questions.");
+        echo $OUTPUT->notification("Exporting ".count($questions)." questions.");
         $count = 0;
 
         // create the imsmanifest file
@@ -256,7 +256,7 @@ function handle_questions_media(&$questions, $path, $courseid) {
         // copy files used by the main questions to the export directory
         $result = $this->handle_questions_media($questions, $path, $courseid);
         if ($result !== true) {
-            notify(implode("<br />", $result));
+            echo $OUTPUT->notification(implode("<br />", $result));
         }
 
         $manifestquestions = $this->objects_to_array($questions);
index 62e924cbd8e73b5997baf621284ab58ba1359c97..5e89e2798a951086eb6f185db3b17aa5f18493ed 100755 (executable)
@@ -19,6 +19,7 @@ function repchar( $text ) {
     }
 
 function writequestion( $question ) {
+    global $OUTPUT;
     // turns question into string
     // question reflects database fields for general question and specific to type
 
@@ -108,7 +109,7 @@ function writequestion( $question ) {
         $expout .= "<!-- CLOZE type is not supported  -->\n";
         break;
     default:
-        notify("No handler for qtype $question->qtype for GIFT export" );
+        echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" );
     }
     // close off div 
     $expout .= "</div>\n\n\n";
index 3d3af94696a70df63a3ebb9d8f8da6d1a05c833d..0d69e44f773ac0ac6336846fe919c5a3e3cd3ea6 100755 (executable)
@@ -227,6 +227,7 @@ class qformat_xml extends qformat_default {
      */
     function import_truefalse( $question ) {
         // get common parts
+        global $OUTPUT;
         $qo = $this->import_headers( $question );
 
         // 'header' parts particular to true/false
@@ -263,7 +264,7 @@ class qformat_xml extends qformat_default {
             $a = new stdClass;
             $a->questiontext = $qo->questiontext;
             $a->answer = get_string($qo->answer ? 'true' : 'false', 'quiz');
-            notify(get_string('truefalseimporterror', 'quiz', $a));
+            echo $OUTPUT->notification(get_string('truefalseimporterror', 'quiz', $a));
         }
         return $qo;
     }
@@ -772,7 +773,7 @@ class qformat_xml extends qformat_default {
      * @return string xml segment
      */
     function writequestion( $question ) {
-    global $CFG,$QTYPES;
+    global $CFG,$QTYPES, $OUTPUT;
         // initial string;
         $expout = "";
 
@@ -1013,7 +1014,7 @@ class qformat_xml extends qformat_default {
         default:
             // try support by optional plugin
             if (!$data = $this->try_exporting_using_qtypes( $question->qtype, $question )) { 
-                notify( get_string( 'unsupportedexport','qformat_xml',$QTYPES[$question->qtype]->local_name() ) );
+                echo $OUTPUT->notification( get_string( 'unsupportedexport','qformat_xml',$QTYPES[$question->qtype]->local_name() ) );
             }
             $expout .= $data;
         }
index 7009f710694946764132879e2ce098e52d2f64e5..f2897453fb90f75cab10331be8a793a4371caa08 100644 (file)
             }
 
             echo "<hr />";
-            print_continue("edit.php?".($thispageurl->get_query_string(array('category'=>"{$qformat->category->id},{$qformat->category->contextid}"))));
+            echo $OUTPUT->continue_button("edit.php?".($thispageurl->get_query_string(array('category'=>"{$qformat->category->id},{$qformat->category->contextid}"))));
             echo $OUTPUT->footer();
             exit;
         }
index d1d30c072360b6f06eee83e9bdb9758cc76984a6..66bde3577c76ad79b66cfcb95f15157be43236d5 100644 (file)
@@ -213,7 +213,7 @@ if ($mform->is_cancelled()){
 
     if (($QTYPES[$question->qtype]->finished_edit_wizard($fromform)) || $movecontext){
         if ($inpopup) {
-            notify(get_string('changessaved'), '');
+            echo $OUTPUT->notification(get_string('changessaved'), '');
             close_window(3);
         } else {
             $nexturl = new moodle_url($returnurl);
index cb4a73d719a8505edc10b2b14c3a5efce08c79f4..bce8c961f2de8046af7b4046d284b4bd09217b87 100644 (file)
@@ -28,7 +28,7 @@ class question_calculated_qtype extends default_questiontype {
 
     function get_question_options(&$question) {
         // First get the datasets and default options
-         global $CFG, $DB;
+         global $CFG, $DB, $OUTPUT;
         if (!$question->options->answers = $DB->get_records_sql(
                                 "SELECT a.*, c.tolerance, c.tolerancetype, c.correctanswerlength, c.correctanswerformat " .
                                 "FROM {question_answers} a, " .
@@ -36,7 +36,7 @@ class question_calculated_qtype extends default_questiontype {
                                 "WHERE a.question = ? " .
                                 "AND   a.id = c.answer ".
                                 "ORDER BY a.id ASC", array($question->id))) {
-            notify('Error: Missing question answer for calculated question ' . $question->id . '!');
+            echo $OUTPUT->notification('Error: Missing question answer for calculated question ' . $question->id . '!');
             return false;
         }
 
@@ -267,9 +267,10 @@ class question_calculated_qtype extends default_questiontype {
     }
 
     function restore_session_and_responses(&$question, &$state) {
+        global $OUTPUT;
         if (!preg_match('~^dataset([0-9]+)[^-]*-(.*)$~',
                 $state->responses[''], $regs)) {
-            notify ("Wrongly formatted raw response answer " .
+            echo $OUTPUT->notification("Wrongly formatted raw response answer " .
                    "{$state->responses['']}! Could not restore session for " .
                    " question #{$question->id}.");
             $state->options->datasetitem = 1;
@@ -834,7 +835,7 @@ class question_calculated_qtype extends default_questiontype {
                                     . $form->calclength[$key+1];
                             break;
                         default:
-                            notify("Unexpected distribution ".$form->calcdistribution[$key+1]);
+                            echo $OUTPUT->notification("Unexpected distribution ".$form->calcdistribution[$key+1]);
                     }
                 }
             }
index 73957b50c80fa1eb45e8cb148d0d77654a68fbac..8b8ddd64961f2e2d1755249724c871a8e0c89685 100644 (file)
@@ -106,9 +106,9 @@ class question_match_qtype extends default_questiontype {
     }
 
     function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) {
-        global $DB;
+        global $DB, $OUTPUT;
         if (!$state->options->subquestions = $DB->get_records('question_match_sub', array('question' => $question->id), 'id ASC')) {
-            notify('Error: Missing subquestions!');
+            echo $OUTPUT->notification('Error: Missing subquestions!');
             return false;
         }
 
@@ -135,11 +135,11 @@ class question_match_qtype extends default_questiontype {
     }
 
     function restore_session_and_responses(&$question, &$state) {
-        global $DB;
+        global $DB, $OUTPUT;
         static $subquestions = array();
         if (!isset($subquestions[$question->id])){
             if (!$subquestions[$question->id] = $DB->get_records('question_match_sub', array('question' => $question->id), 'id ASC')) {
-               notify('Error: Missing subquestions!');
+               echo $OUTPUT->notification('Error: Missing subquestions!');
                return false;
             }
         }
index 178c5e92c3869dda16a8fbf6e4ce50377495bdd7..7cd6e655186ef486851c706e0831e06d80d29522 100644 (file)
@@ -24,13 +24,13 @@ class embedded_cloze_qtype extends default_questiontype {
     }
     
     function has_wildcards_in_responses($question, $subqid) {
-        global $QTYPES;
+        global $QTYPES, $OUTPUT;
         foreach ($question->options->questions as $subq){
             if ($subq->id == $subqid){
                 return $QTYPES[$subq->qtype]->has_wildcards_in_responses($subq, $subqid);
             }
         }
-        notify('Could not find sub question!');
+        echo $OUTPUT->notification('Could not find sub question!');
         return true;
     }
 
@@ -39,11 +39,11 @@ class embedded_cloze_qtype extends default_questiontype {
     }
 
     function get_question_options(&$question) {
-        global $QTYPES, $DB;
+        global $QTYPES, $DB, $OUTPUT;
 
         // Get relevant data indexed by positionkey from the multianswers table
         if (!$sequence = $DB->get_field('question_multianswer', 'sequence', array('question' => $question->id))) {
-            notify(get_string('noquestions','qtype_multianswer',$question->name));
+            echo $OUTPUT->notification(get_string('noquestions','qtype_multianswer',$question->name));
             $question->options->questions['1']= '';
             return true ;
         }
@@ -65,7 +65,7 @@ class embedded_cloze_qtype extends default_questiontype {
         if (isset($wrappedquestions) && is_array($wrappedquestions)){
             foreach ($wrappedquestions as $wrapped) {
                 if (!$QTYPES[$wrapped->qtype]->get_question_options($wrapped)) {
-                    notify("Unable to get options for questiontype {$wrapped->qtype} (id={$wrapped->id})");
+                    echo $OUTPUT->notification("Unable to get options for questiontype {$wrapped->qtype} (id={$wrapped->id})");
                 }else {
                 // for wrapped questions the maxgrade is always equal to the defaultgrade,
                 // there is no entry in the question_instances table for them
@@ -76,7 +76,7 @@ class embedded_cloze_qtype extends default_questiontype {
         }
         }
         if ($nbvaliquestion == 0 ) {
-            notify(get_string('noquestions','qtype_multianswer',$question->name));
+            echo $OUTPUT->notification(get_string('noquestions','qtype_multianswer',$question->name));
         }
 
         return true;
@@ -823,7 +823,7 @@ class embedded_cloze_qtype extends default_questiontype {
     }
 
     function restore_recode_answer($state, $restore) {
-        global $DB;
+        global $DB, $OUTPUT;
         //The answer is a comma separated list of hypen separated sequence number and answers. We may have to recode the answers
         $answer_field = "";
         $in_first = true;
@@ -842,7 +842,7 @@ class embedded_cloze_qtype extends default_questiontype {
             $wrappedquestionid = $sequence[$seqnum-1];
             // now we can find the question
             if (!$wrappedquestion = $DB->get_record('question', array('id' => $wrappedquestionid))) {
-                notify("Can't find the subquestion $wrappedquestionid that is used as part $seqnum in cloze question $state->question");
+                echo $OUTPUT->notification("Can't find the subquestion $wrappedquestionid that is used as part $seqnum in cloze question $state->question");
             }
             // For multichoice question we need to recode the answer
             if ($answer and $wrappedquestion->qtype == 'multichoice') {
index c96a7918ef918edb8b6f564dd9073667a9051fc7..fd2712dca93e2b5b9b0504f9801ba102573f1473 100644 (file)
@@ -19,17 +19,17 @@ class question_multichoice_qtype extends default_questiontype {
     }
 
     function get_question_options(&$question) {
-        global $DB;
+        global $DB, $OUTPUT;
         // Get additional information from database
         // and attach it to the question object
         if (!$question->options = $DB->get_record('question_multichoice', array('question' => $question->id))) {
-            notify('Error: Missing question options for multichoice question'.$question->id.'!');
+            echo $OUTPUT->notification('Error: Missing question options for multichoice question'.$question->id.'!');
             return false;
         }
 
         list ($usql, $params) = $DB->get_in_or_equal(explode(',', $question->options->answers));
         if (!$question->options->answers = $DB->get_records_select('question_answers', "id $usql", $params, 'id')) {
-           notify('Error: Missing question answers for multichoice question'.$question->id.'!');
+           echo $OUTPUT->notification('Error: Missing question answers for multichoice question'.$question->id.'!');
            return false;
         }
 
index ed3cf4a84e33bac6801d7ca306ed67e6a09e834e..e1ae906fcf722f1a0e5a25bc0168d6681a7e406f 100644 (file)
@@ -39,7 +39,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
         // Note: question_numerical is an extension of the answer table rather than
         //       the question table as is usually the case for qtype
         //       specific tables.
-        global $CFG, $DB;
+        global $CFG, $DB, $OUTPUT;
         if (!$question->options->answers = $DB->get_records_sql(
                                 "SELECT a.*, n.tolerance " .
                                 "FROM {question_answers} a, " .
@@ -47,7 +47,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
                                 "WHERE a.question = ? " .
                                 "    AND   a.id = n.answer " .
                                 "ORDER BY a.id ASC", array($question->id))) {
-            notify('Error: Missing question answer for numerical question ' . $question->id . '!');
+            echo $OUTPUT->notification('Error: Missing question answer for numerical question ' . $question->id . '!');
             return false;
         }
         $this->get_numerical_units($question);
index abf79ef754807da73c7702496fa1d227b4569722..93b91f5f31f8956e046bfe3ab29fb81a3223a727 100644 (file)
@@ -438,7 +438,7 @@ class default_questiontype {
     *                         specific information (it is passed by reference).
     */
     function get_question_options(&$question) {
-        global $CFG, $DB;
+        global $CFG, $DB, $OUTPUT;
 
         if (!isset($question->options)) {
             $question->options = new object;
@@ -453,7 +453,7 @@ class default_questiontype {
                     $question->options->$field = $extra_data->$field;
                 }
             } else {
-                notify("Failed to load question options from the table $question_extension_table for questionid " .
+                echo $OUTPUT->notification("Failed to load question options from the table $question_extension_table for questionid " .
                         $question->id);
                 return false;
             }
@@ -467,7 +467,7 @@ class default_questiontype {
                     FROM {question_answers} qa, {$answer_extension_table} qax
                     WHERE qa.questionid = ? AND qax.answerid = qa.id", array($question->id));
             if (!$question->options->answers) {
-                notify("Failed to load question answers from the table $answer_extension_table for questionid " .
+                echo $OUTPUT->notification("Failed to load question answers from the table $answer_extension_table for questionid " .
                         $question->id);
                 return false;
             }
@@ -1244,8 +1244,8 @@ class default_questiontype {
         /* This default implementation prints an error and must be overridden
         by all question type implementations, unless the default implementation
         of print_question has been overridden. */
-
-        notify('Error: Question formulation and input controls has not'
+        global $OUTPUT;
+        echo $OUTPUT->notification('Error: Question formulation and input controls has not'
                .'  been implemented for question type '.$this->name());
     }
 
index 0a148fe9fd0460eeb01d195fa424a8e60a60b7e2..5ddcb104486acba38195652763fc4a5fc221930e 100644 (file)
@@ -230,7 +230,7 @@ class random_qtype extends default_questiontype {
         /// From version 1.5 and later the question type random works like all
         /// the other question types in that it now only needs one response
         /// record per question.
-        global $QTYPES, $DB;
+        global $QTYPES, $DB, $OUTPUT;
         if (!preg_match('~^random([0-9]+)-(.*)$~', $state->responses[''], $answerregs)) {
             if (empty($state->responses[''])) {
                 // This is the case if there weren't enough questions available in the category.
@@ -241,12 +241,12 @@ class random_qtype extends default_questiontype {
             }
             // this must be an old-style state which stores only the id for the wrapped question
             if (!$wrappedquestion = $DB->get_record('question', array('id' => $state->responses['']))) {
-                notify("Can not find wrapped question {$state->responses['']}");
+                echo $OUTPUT->notification("Can not find wrapped question {$state->responses['']}");
             }
             // In the old model the actual response was stored in a separate entry in
             // the state table and fortunately there was only a single state per question
             if (!$state->responses[''] = $DB->get_field('question_states', 'answer', array('attempt' => $state->attempt, 'question' => $wrappedquestion->id))) {
-                notify("Wrapped state missing");
+                echo $OUTPUT->notification("Wrapped state missing");
             }
         } else {
             if (!$wrappedquestion = $DB->get_record('question', array('id' => $answerregs[1]))) {
index 9c0745575da32ede0eda620f55b8a86c170ad497..5f9bba05f3dd199f760d1c8de7667717586f1590 100644 (file)
@@ -28,9 +28,9 @@ class question_randomsamatch_qtype extends question_match_qtype {
     }
 
     function get_question_options(&$question) {
-        global $DB;
+        global $DB, $OUTPUT;
         if (!$question->options = $DB->get_record('question_randomsamatch', array('question' => $question->id))) {
-            notify('Error: Missing question options for random short answer question '.$question->id.'!');
+            echo $OUTPUT->notification('Error: Missing question options for random short answer question '.$question->id.'!');
             return false;
         }
 
@@ -80,7 +80,7 @@ class question_randomsamatch_qtype extends question_match_qtype {
         // 1. All questions that are explicitly assigned to the quiz
         // 2. All random questions
         // 3. All questions that are already chosen by an other random question
-        global $QTYPES;
+        global $QTYPES, $OUTPUT;
         if (!isset($cmoptions->questionsinuse)) {
             $cmoptions->questionsinuse = $cmoptions->questions;
         }
@@ -111,7 +111,7 @@ class question_randomsamatch_qtype extends question_match_qtype {
                  questions were deleted after this Random Short-Answer question was
                  created.";
             }
-            notify($errorstr);
+            echo $OUTPUT->notification($errorstr);
             $errorstr = '<span class="notifyproblem">' . $errorstr . '</span>';
         }
 
@@ -171,7 +171,7 @@ class question_randomsamatch_qtype extends question_match_qtype {
 
     function restore_session_and_responses(&$question, &$state) {
         global $DB;
-        global $QTYPES;
+        global $QTYPES, $OUTPUT;
         static $wrappedquestions = array();
         if (empty($state->responses[''])) {
             $question->questiontext = "Insufficient selection options are
@@ -191,12 +191,12 @@ class question_randomsamatch_qtype extends question_match_qtype {
                 $state->responses[$wqid] = $response[1];
                 if (!isset($wrappedquestions[$wqid])){
                     if (!$wrappedquestions[$wqid] = $DB->get_record('question', array('id' => $wqid))) {
-                        notify("Couldn't get question (id=$wqid)!");
+                        echo $OUTPUT->notification("Couldn't get question (id=$wqid)!");
                         return false;
                     }
                     if (!$QTYPES[$wrappedquestions[$wqid]->qtype]
                      ->get_question_options($wrappedquestions[$wqid])) {
-                        notify("Couldn't get question options (id=$response[0])!");
+                        echo $OUTPUT->notification("Couldn't get question options (id=$response[0])!");
                         return false;
                     }
     
@@ -217,7 +217,7 @@ class question_randomsamatch_qtype extends question_match_qtype {
 
                 if (!$QTYPES[$wrappedquestion->qtype]
                  ->restore_session_and_responses($wrappedquestion, $state)) {
-                    notify("Couldn't restore session of question (id=$response[0])!");
+                    echo $OUTPUT->notification("Couldn't restore session of question (id=$response[0])!");
                     return false;
                 }
                 $wrappedquestion->name_prefix = $question->name_prefix;
index 4306ee9d81831337360cb913d702fce9c4173c6c..db745801d61219014bb5b2dda9fb5b4ded8caed6 100644 (file)
@@ -82,16 +82,16 @@ class question_truefalse_qtype extends default_questiontype {
     * Loads the question type specific options for the question.
     */
     function get_question_options(&$question) {
-        global $DB;
+        global $DB, $OUTPUT;
         // Get additional information from database
         // and attach it to the question object
         if (!$question->options = $DB->get_record('question_truefalse', array('question' => $question->id))) {
-            notify('Error: Missing question options!');
+            echo $OUTPUT->notification('Error: Missing question options!');
             return false;
         }
         // Load the answers
         if (!$question->options->answers = $DB->get_records('question_answers', array('question' =>  $question->id), 'id ASC')) {
-           notify('Error: Missing question answers for truefalse question ' . $question->id . '!');
+           echo $OUTPUT->notification('Error: Missing question answers for truefalse question ' . $question->id . '!');
            return false;
         }