From ee6c93555f5029f0367988e7f0611617de745c43 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 31 Oct 2006 12:06:52 +0000 Subject: [PATCH] MDL-5811 - Quiz editing outputs nasty junk before print_header sometimes. Second attempt at fixing. I forgot to mention the bug number in the previous commit to mod/quiz/edit.php. Merged from MOODLE_17_STABLE. --- mod/quiz/edit.php | 22 ---------------------- question/question.php | 11 +++++++++-- question/type/editquestionend.html | 1 + question/type/questiontype.php | 2 +- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 43ddf57da6..138c6d5e67 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -38,15 +38,6 @@ $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 @@ -72,17 +63,6 @@ error('cmunknown'); } } else { - $scripttooutputafterprint_header = ' - -'; // 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") { " -> instance\">".format_string($modform->name).''. " -> $streditingquiz", "", "", true, $strupdatemodule); - echo $scripttooutputafterprint_header; $currenttab = 'edit'; $mode = 'editq'; @@ -358,7 +337,6 @@ if (self.name == "editquestion") { " -> instance\">".format_string($modform->name).''. " -> $streditingquiz", "", "", true, $strupdatemodule); - echo $scripttooutputafterprint_header; $currenttab = 'edit'; $mode = 'editq'; diff --git a/question/question.php b/question/question.php index f2bdcb778f..2ea69d08fb 100644 --- a/question/question.php +++ b/question/question.php @@ -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; @@ -249,7 +249,14 @@ // $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); + } } } diff --git a/question/type/editquestionend.html b/question/type/editquestionend.html index 1ba6ee4cd6..22300c9c6c 100644 --- a/question/type/editquestionend.html +++ b/question/type/editquestionend.html @@ -12,6 +12,7 @@ + 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&id='.$question->id, 'editquestion', $linktext, 450, 550, $stredit, '', true); } $generalfeedback = ''; -- 2.39.5