From d84d379e97ff54fa826d8c7c6d69d496904f9247 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 31 Oct 2006 10:47:34 +0000 Subject: [PATCH] Fix junk being output before print_header, which happened sometimes. Merged from MOODLE_17_STABLE. --- mod/quiz/edit.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 80b3b2b05d..43ddf57da6 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -38,6 +38,15 @@ $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 @@ -63,24 +72,17 @@ error('cmunknown'); } } else { - // we might get here after editing a question in - // a popup window. So close window automatically. - // - // But we certainly should not be doing this before - // print_header, since it throws browsers into quirks mode. - // Unfortunately there is no easy fix. Bug #5811 covers this. -?> - -modform)) { $modform = $SESSION->modform; @@ -318,6 +320,7 @@ if (self.name == 'editquestion') { " -> instance\">".format_string($modform->name).''. " -> $streditingquiz", "", "", true, $strupdatemodule); + echo $scripttooutputafterprint_header; $currenttab = 'edit'; $mode = 'editq'; @@ -355,6 +358,7 @@ if (self.name == 'editquestion') { " -> instance\">".format_string($modform->name).''. " -> $streditingquiz", "", "", true, $strupdatemodule); + echo $scripttooutputafterprint_header; $currenttab = 'edit'; $mode = 'editq'; -- 2.39.5