Use overlib feedback on cloze-style questions
authormoodler <moodler>
Sun, 16 May 2004 03:14:03 +0000 (03:14 +0000)
committermoodler <moodler>
Sun, 16 May 2004 03:14:03 +0000 (03:14 +0000)
mod/quiz/attempt.php
mod/quiz/lib.php
mod/quiz/review.php

index 19c6f14ecfb608e99c61b56dde7e02bd7551eb42..5046524dab6578f57c560ee2c29bcb00f8a41a97 100644 (file)
@@ -66,6 +66,8 @@
                   <A HREF=\"view.php?id=$cm->id\">$quiz->name</A> -> $strattemptnum", 
                   "", "", true);
 
+    echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
+
 /// Check availability
 
     if ($quiz->attempts and $attempts and count($attempts) >= $quiz->attempts) {
index a73bc92220a466e1579d0f85d90d8201986ddf94..975bdf9f23abcc21a5d93e69ed58d3cbc2f0c39a 100644 (file)
@@ -602,6 +602,8 @@ function quiz_print_question($number, $question, $grade, $quizid,
 /// Prints a quiz question, any format
 /// $question is provided as an object
 
+    global $CFG, $THEME;
+
     $question->questiontextformat = isset($question->questiontextformat) ? $question->questiontextformat : NULL;
 
     if ($question->qtype == DESCRIPTION) {  // Special case question - has no answers etc
@@ -922,6 +924,8 @@ function quiz_print_question($number, $question, $grade, $quizid,
            // The regex will recognize text snippets of type {#X} 
            // where the X can be any text not containg } or white-space characters.
 
+           $strfeedback = get_string('feedback', 'quiz');
+
            while (ereg('\{#([^[:space:]}]*)}', $qtextremaining, $regs)) {
                $qtextsplits = explode($regs[0], $qtextremaining, 2);
                echo $qtextsplits[0];
@@ -957,11 +961,13 @@ function quiz_print_question($number, $question, $grade, $quizid,
                    case SHORTANSWER:
                    case NUMERICAL:
                        if (isset($feedback[$regs[1]-1])) {
-                           $title = " title=\"".s($feedback[$regs[1]-1])."\" ";
+                           $title = str_replace("'", "\\'", $feedback[$regs[1]-1] );
+                           $popup = " onmouseover=\"return overlib('$title', CAPTION, '$strfeedback', FGCOLOR, '$THEME->cellcontent');\" ".
+                                    " onmouseout=\"return nd();\" ";
                        } else {
-                           $title = "";
+                           $popup = '';
                        }
-                       echo " <input $style $title $inputname value=\"$actualresponse\" type=\"text\" size=\"12\" /> ";
+                       echo " <input $style $popup $inputname value=\"$actualresponse\" type=\"text\" size=\"12\" /> ";
                        break;
                    case MULTICHOICE:
                        $outputoptions = '';
@@ -977,10 +983,13 @@ function quiz_print_question($number, $question, $grade, $quizid,
                            $outputoptions .= "<option value=\"$answer->id\" $selected>$answer->answer</option>";
                        }
                        if ($feedbackitem) {
-                           echo "<select title=\"".s($feedbackitem)."\" $style $inputname>";
+                           $title = str_replace("'", "\\'", $feedbackitem);
+                           $popup = " onmouseover=\"return overlib('$title', CAPTION, '$strfeedback', FGCOLOR, '$THEME->cellcontent');\" ".
+                                    " onmouseout=\"return nd();\" ";
                        } else {
-                           echo "<select $style $inputname>";
+                           $popup = '';
                        }
+                       echo "<select $popup $style $inputname>";
                        echo $outputoptions;
                        echo '</select>';
                        break;
index bcc0f0ebb828583e6d4360267aa601328217e061..8665af476d0eeff53a7e468a293beff6b5c4d5d8 100644 (file)
@@ -80,6 +80,8 @@
                   -> <a href=\"view.php?id=$cm->id\">$quiz->name</a> -> $strreview", 
                  "", "", true);
 
+    echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // for overlib
+
     print_heading($quiz->name);