]> git.mjollnir.org Git - moodle.git/commitdiff
It is now possible to base new questions on existing ones, see get_string('editingque...
authorgustav_delius <gustav_delius>
Wed, 19 Jan 2005 09:50:33 +0000 (09:50 +0000)
committergustav_delius <gustav_delius>
Wed, 19 Jan 2005 09:50:33 +0000 (09:50 +0000)
lang/en/quiz.php
mod/quiz/locallib.php
mod/quiz/question.php
pix/t/copy.gif [new file with mode: 0644]

index fa278d6e7162e1b289229c96b299561ef3eb01db..d746ad0795bd4fedc21c77812f9761e1af7eff1b 100644 (file)
@@ -53,6 +53,8 @@ $string['choices'] = 'Available choices';
 $string['choosedatasetproperties'] = 'Choose dataset properties';
 $string['close'] = 'Close preview';
 $string['confirmstartattempt'] = 'The Quiz has a time limit. Are you sure that you wish to start?';
+$string['copyingfrom'] = 'Creating a copy of the question \'$a\'';
+$string['copyingquestion'] = 'Copying a question';
 $string['correctanswer'] = 'Correct answer';
 $string['correctanswerformula'] = 'Correct Answer Formula';
 $string['correctanswerlength'] = 'Significant Figures';
index f6e0d4b572e73b22381c876da96f22451fae819d..64e927cc127cc88a6ac764a2112ca9aaafa73eb4 100644 (file)
@@ -1197,6 +1197,7 @@ function quiz_print_cat_question_list($categoryid, $quizselected=true, $recurse=
     $strquestionname = get_string("questionname", "quiz");
     $strdelete = get_string("delete");
     $stredit = get_string("edit");
+    $strcopy = get_string("copy");
     $straddselectedtoquiz = get_string("addselectedtoquiz", "quiz");
     $strtype = get_string("type", "quiz");
     $strcreatemultiple = get_string("createmultiple", "quiz");
@@ -1296,7 +1297,9 @@ function quiz_print_cat_question_list($categoryid, $quizselected=true, $recurse=
                 echo "<a title=\"$strpreview\" href=\"#\" onClick=\"openpopup('/mod/quiz/preview.php?id=$question->id','$strpreview','scrollbars=yes,resizable=yes,width=700,height=480', false)\"><img
                       src=\"../../pix/t/preview.gif\" border=\"0\" alt=\"$strpreview\" /></a>&nbsp;";
                 echo "<a title=\"$stredit\" href=\"question.php?id=$question->id\"><img
-                     src=\"../../pix/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a>";
+                     src=\"../../pix/t/edit.gif\" border=\"0\" alt=\"$stredit\" /></a>&nbsp;";
+                echo "<a title=\"$strcopy\" href=\"question.php?id=$question->id&amp;copy=true\"><img
+                     src=\"../../pix/t/copy.gif\" border=\"0\" alt=\"$strcopy\" /></a>";
             echo "</td>\n";
         }
         echo "</tr>\n";
index 3d5431e3930f5d1890d726fbc231404d69ad10d6..17bceee787a225dca5ba5d38e23ae7fe606e2733 100644 (file)
@@ -9,6 +9,8 @@
 
     optional_variable($qtype);
     optional_variable($category);
+    
+    optional_variable($copy, false); // true if a copy of the question should be created
 
     if ($id) {
         if (! $question = get_record("quiz_questions", "id", $id)) {
@@ -55,7 +57,7 @@
     }
 
     $strquizzes = get_string('modulenameplural', 'quiz');
-    $streditingquestion = get_string('editingquestion', 'quiz');
+    $streditingquestion = ($copy) ? get_string('copyingquestion', 'quiz') : get_string('editingquestion', 'quiz');
     if (isset($SESSION->modform->instance)) {
         $strediting = '<a href="edit.php">'.get_string('editingquiz', 'quiz').'</a> -> '.
             $streditingquestion;
@@ -64,7 +66,7 @@
             get_string("editquestions", "quiz").'</a> -> '.$streditingquestion;
     }
 
-    print_header_simple("$streditingquestion", "$streditingquestion",
+    print_header_simple("$streditingquestion", "",
                  "<a href=\"$CFG->wwwroot/mod/quiz/index.php?id=$course->id\">$strquizzes</a>".
                   " -> ".$strediting);
 
     } else {
         $defaultformat = FORMAT_MOODLE;
     }
+    
+    if ($copy) {
+        print_heading(get_string('copyingfrom', 'quiz', $question->name));
+        // clear question id so that the data is saved to a new question
+        $question->id = '';
+        $question->name .= '_copy';
+    }
 
     require('questiontypes/'.$QUIZ_QTYPES[$qtype]->name().'/editquestion.php');
 
diff --git a/pix/t/copy.gif b/pix/t/copy.gif
new file mode 100644 (file)
index 0000000..b38e0d0
Binary files /dev/null and b/pix/t/copy.gif differ