]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-5811 - Quiz editing outputs nasty junk before print_header sometimes. Second...
authortjhunt <tjhunt>
Tue, 31 Oct 2006 12:06:52 +0000 (12:06 +0000)
committertjhunt <tjhunt>
Tue, 31 Oct 2006 12:06:52 +0000 (12:06 +0000)
mod/quiz/edit.php
question/question.php
question/type/editquestionend.html
question/type/questiontype.php

index 43ddf57da6401e4a7dd21fa95bd54ca851268dd3..138c6d5e678854e93ee1223502edf4310c40dec6 100644 (file)
     $streditingquestions = get_string('editquestions', "quiz");
     $streditingquiz = get_string("editinga", "moodle", $strquiz);
 
-    // We might get here after editing a question in a popup window. 
-    // In which case we will want to close the window automatically.
-    // 
-    // Unfortunately, we can only detect this condition at the top of
-    // this file, but we should only output the JavaScript after print_header,
-    // which has to happen lower down the file. Therefore, we cache
-    // any necessary JavaScript in this variable.
-    $scripttooutputafterprint_header = '';
-
     if ($modform = data_submitted() and !empty($modform->course)) { // data submitted
 
         $SESSION->modform = $modform;    // Save the form in the current session
             error('cmunknown');
         }
     } else {
-        $scripttooutputafterprint_header = '<script type="text/javascript">
-<!--
-if (self.name == "editquestion") {
-    self.close();
-}
--->
-</script>
-<noscript>
-' . notify(get_string('pleaseclose', 'quiz'), 'notifyproblem', 'center', true) . '
-</noscript>
-';
         // no quiz or course was specified so we need to use the stored modform
         if (isset($SESSION->modform)) {
             $modform = $SESSION->modform;
@@ -320,7 +300,6 @@ if (self.name == "editquestion") {
                  " -> <a href=\"view.php?q=$modform->instance\">".format_string($modform->name).'</a>'.
                  " -> $streditingquiz", "", "",
                  true, $strupdatemodule);
-        echo $scripttooutputafterprint_header;
 
         $currenttab = 'edit';
         $mode = 'editq';
@@ -358,7 +337,6 @@ if (self.name == "editquestion") {
              " -> <a href=\"view.php?q=$modform->instance\">".format_string($modform->name).'</a>'.
              " -> $streditingquiz",
              "", "", true, $strupdatemodule);
-    echo $scripttooutputafterprint_header;
 
     $currenttab = 'edit';
     $mode = 'editq';
index f2bdcb778f6ff9798cd2032443088c976b4cbcf0..2ea69d08fbe7806d3908ea40bedbc4de4528d330 100644 (file)
@@ -26,7 +26,7 @@
 
     $qtype = optional_param('qtype', '', PARAM_FILE);
     $category = optional_param('category', 0, PARAM_INT);
-    
+    $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
     
     $CFG->pagepath = 'question/type/'.$qtype;
     
             //    $QTYPES[$question->qtype]->get_question_options($question);
             //    quiz_regrade_question_in_quizzes($question, $replaceinquiz);
             //}
-            redirect($SESSION->returnurl);
+
+            $strsaved = get_string('changessaved');
+            if ($inpopup) {
+                notify($strsaved, '');
+                close_window(3);
+            } else {
+                redirect($SESSION->returnurl, $strsaved);
+            }
         }
     }
 
index 1ba6ee4cd68207b785eb26c21c0192074aaf8381..22300c9c6c770f6015533e2f453e05dded98a40b 100644 (file)
@@ -12,6 +12,7 @@
       <input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>" />
       <input type="hidden" name="id" value="<?php p($question->id) ?>" />
       <input type="hidden" name="qtype" value="<?php p($question->qtype) ?>" />
+      <input type="hidden" name="inpopup" value="<?php echo optional_param('inpopup', 0, PARAM_INT) ?>" />
       <?php
       echo $hiddenfields;
       
index a150f5aa530b341384682ccc75321d531d19883c..064e814ae80a5f25a0f480910c35625a32ba6996 100644 (file)
@@ -534,7 +534,7 @@ class default_questiontype {
         if ($context && has_capability('moodle/question:manage', $context)) {
             $stredit = get_string('edit');
             $linktext = '<img src="'.$CFG->pixpath.'/t/edit.gif" border="0" alt="'.$stredit.'" />';
-            $editlink = link_to_popup_window('/question/question.php?id='.$question->id, $stredit, $linktext, 450, 550, $stredit, '', true);
+            $editlink = link_to_popup_window('/question/question.php?inpopup=1&amp;id='.$question->id, 'editquestion', $linktext, 450, 550, $stredit, '', true);
         }
 
         $generalfeedback = '';