]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9565 - Question preview links don't work in developer debug mode, and not XHTML...
authortjhunt <tjhunt>
Tue, 24 Apr 2007 16:59:32 +0000 (16:59 +0000)
committertjhunt <tjhunt>
Tue, 24 Apr 2007 16:59:32 +0000 (16:59 +0000)
lib/questionlib.php
mod/quiz/editlib.php
mod/quiz/locallib.php
mod/quiz/report/analysis/report.php
question/editlib.php
question/preview.php

index 4eb8df6e1821a968e46e8eac2f19940331edd3d6..1ce485b57f9b010288d0a4940e36267d482db8ca 100644 (file)
@@ -76,7 +76,7 @@ define("QUESTION_NUMANS_ADD", 3);
 /**
  * The options used when popping up a question preview window in Javascript.
  */
-define('QUESTION_PREVIEW_POPUP_OPTIONS', "'scrollbars=yes,resizable=yes,width=700,height=540'");
+define('QUESTION_PREVIEW_POPUP_OPTIONS', 'scrollbars=yes,resizable=yes,width=700,height=540');
 
 /**#@+
  * Option flags for ->optionflags
index 65c3f44298b9edbf000bf65d44950960abdff172..bbc3cc6c703d1ed2d1740dbd1adf734c621308b7 100644 (file)
@@ -275,11 +275,8 @@ function quiz_print_question_list($quiz, $allowdelete=true, $showbreaks=true, $r
         echo '</td><td align="center">';
 
         $context = $quiz->id ? '&amp;contextquiz='.$quiz->id : '';
-        $quiz_id = $quiz->id ? '&amp;quizid=' . $quiz->id : '';
         if ($question->qtype != 'random') {
-            echo "<a title=\"$strpreview\" href=\"javascript:void(0)\" onclick=\"openpopup('/question/preview.php?id=$qnum$quiz_id','questionpreview', " . 
-                    QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\">
-                    <img src=\"$CFG->pixpath/t/preview.gif\" class=\"iconsmall\" alt=\"$strpreview\" /></a>";
+            quiz_question_preview_button($quiz, $question);
         }
         if ($canedit) {
             echo "<a title=\"$stredit\" href=\"$CFG->wwwroot/question/question.php?id=$qnum$context\">
index 86b923a1c708896e86f72db87994a92ee322fc90..be2caf21bb8f70377f7401ddf1a285bd1bd12e93 100644 (file)
@@ -595,16 +595,17 @@ function quiz_upgrade_states($attempt) {
     }
 }
 
-// ULPGc ecastro
-function quiz_get_question_review($quiz, $question) {
-// returns a question icon
-    $qnum = $question->id;
+/**
+ * @param object $quiz the quiz
+ * @param object $question the question
+ * @return the HTML for a preview question icon.
+ */
+function quiz_question_preview_button($quiz, $question) {
+    global $CFG;
     $strpreview = get_string('previewquestion', 'quiz');
-    $context = $quiz->id ? '&amp;contextquiz='.$quiz->id : '';
-    $quiz_id = $quiz->id ? '&amp;quizid=' . $quiz->id : '';
-    return "<a title=\"$strpreview\" href=\"javascript:void(0)\" onclick=\"openpopup('/question/preview.php?id=$qnum$quiz_id','questionpreview', " .
-            QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\">
-            <img src=\"../../pix/t/preview.gif\" class=\"iconsmall\" alt=\"$strpreview\" /></a>";
+    return link_to_popup_window('/question/preview.php?id=' . $question->id . '&amp;quizid=' . $quiz->id, 'questionpreview',
+            "<img src=\"$CFG->pixpath/t/preview.gif\" class=\"iconsmall\" alt=\"$strpreview\" />",
+            0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS, true);
 }
 
 /**
index 984fc28deaa0c87b41fe3c063a60afd052d83bd7..be9f2fc8c0588ba3fd131ba2afc19bebdab990d8 100644 (file)
@@ -312,7 +312,7 @@ class quiz_report extends quiz_default_report {
             $qnumber = " (".link_to_popup_window('/question/question.php?id='.$qid,'editquestion', $qid, 450, 550, get_string('edit'), 'none', true ).") ";
             $qname = '<div class="qname">'.format_text($question->name." :  ", $question->questiontextformat, $format_options, $quiz->course).'</div>';
             $qicon = print_question_icon($question, true);
-            $qreview = quiz_get_question_review($quiz, $question);
+            $qreview = quiz_question_preview_button($quiz, $question);
             $qtext = format_text($question->questiontext, $question->questiontextformat, $format_options, $quiz->course);
             $qquestion = $qname."\n".$qtext."\n";
 
index d1df08ad9515f25ffc4448f060ef5a790d44cb11..4fe411a116e4d431bdfa6ec8db083c720a1ef619 100644 (file)
@@ -303,14 +303,14 @@ function question_list($course, $categoryid, $quizid=0,
         
         // add to quiz
         if ($editingquiz) {
-            echo "<a title=\"$straddtoquiz\" href=\"edit.php?addquestion=$question->id&amp;quizid=$quizid&amp;sesskey=$USER->sesskey\"><img
+            echo "<a title=\"$straddtoquiz\" href=\"$CFG->wwwroot/question/edit.php?addquestion=$question->id&amp;quizid=$quizid&amp;sesskey=$USER->sesskey\"><img
                   src=\"$CFG->pixpath/t/moveleft.gif\" alt=\"$straddtoquiz\" /></a>&nbsp;";
         }
         
         // preview
-        echo "<a title=\"$strpreview\" href=\"javascript:void();\" onclick=\"openpopup('/question/preview.php?id=$question->id&amp;quizid=$quizid','$strpreview', " .
-                QUESTION_PREVIEW_POPUP_OPTIONS . ", false)\"><img
-                src=\"$CFG->pixpath/t/preview.gif\" alt=\"$strpreview\" /></a>&nbsp;";
+        link_to_popup_window('/question/preview.php?id=' . $question->id . '&amp;quizid=' . $quizid, 'questionpreview',
+                "<img src=\"$CFG->pixpath/t/preview.gif\" class=\"iconsmall\" alt=\"$strpreview\" />",
+                0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS);
         
         // edit, hide, delete question, using question capabilities, not quiz capabilieies
         if ($canedit) {
@@ -318,10 +318,10 @@ function question_list($course, $categoryid, $quizid=0,
                     src=\"$CFG->pixpath/t/edit.gif\" alt=\"$stredit\" /></a>&nbsp;";
             // hide-feature
             if($question->hidden) {
-                echo "<a title=\"$strrestore\" href=\"edit.php?courseid=$course->id&amp;unhide=$question->id&amp;sesskey=$USER->sesskey\"><img
+                echo "<a title=\"$strrestore\" href=\"$CFG->wwwroot/question/edit.php?courseid=$course->id&amp;unhide=$question->id&amp;sesskey=$USER->sesskey\"><img
                         src=\"$CFG->pixpath/t/restore.gif\" alt=\"$strrestore\" /></a>";
             } else {
-                echo "<a title=\"$strdelete\" href=\"edit.php?courseid=$course->id&amp;deleteselected=$question->id&amp;q$question->id=1\"><img
+                echo "<a title=\"$strdelete\" href=\"$CFG->wwwroot/question/edit.php?courseid=$course->id&amp;deleteselected=$question->id&amp;q$question->id=1\"><img
                         src=\"$CFG->pixpath/t/delete.gif\" alt=\"$strdelete\" /></a>";
             }
         }
index 16ca53f5bc0022f30ab761b5b4ba6d71606a962c..430bc6d3660569ac4db255d9a9d515905f219b45 100644 (file)
         unset($SESSION->quizpreview);
         // Redirect to ourselves but with continue=1; prevents refreshing the page
         // from restarting an attempt (needed so that random questions don't change)
-        $quizid = $quizid ? '&amp;quizid=' . $quizid : '';
-        redirect($CFG->wwwroot . '/question/preview.php?id=' . $id . $quizid .
-         '&amp;continue=1');
+        $url = $CFG->wwwroot . '/question/preview.php?id=' . $id;
+        if ($quizid) {
+            $url .= '&amp;quizid=' . $quizid;
+        }
+        $url .= '&amp;continue=1';
+        redirect($url);
     }
 
     if (empty($quizid)) {
     }
 
     $strpreview = get_string('preview', 'quiz').' '.format_string($questions[$id]->name);
-    print_header($strpreview);
+    $questionlist = array($id);
+    $headtags = get_html_head_contributions($questionlist, $questions, $states[$historylength]);
+    print_header($strpreview, '', '', '', $headtags);
     print_heading($strpreview);
 
     if (!empty($quizid)) {