Skip to content
Browse files

The Quizzes page is given an "Edit questions" button that links to a …

…possibility to edit questions without opening a quiz.
  • Loading branch information...
1 parent 08c8012 commit 1e085edc4397ebe19049038444757e76e288d5a7 kaipe committed
Showing with 86 additions and 39 deletions.
  1. +1 −0 lang/en/quiz.php
  2. +3 −1 mod/quiz/category.php
  3. +38 −19 mod/quiz/edit.php
  4. +3 −1 mod/quiz/import.php
  5. +11 −2 mod/quiz/index.php
  6. +24 −14 mod/quiz/lib.php
  7. +3 −1 mod/quiz/multiple.php
  8. +3 −1 mod/quiz/question.php
View
1 lang/en/quiz.php
@@ -64,6 +64,7 @@
$string['editingrandomsamatch'] = 'Editing a Random Short-Answer Matching question';
$string['editingshortanswer'] = 'Editing a Short-Answer question';
$string['editingtruefalse'] = 'Editing a True/False question';
+$string['editquestions'] = 'Edit questions';
$string['false'] = 'False';
$string['feedback'] = 'Feedback';
$string['fileformat'] = 'File format';
View
4 mod/quiz/category.php
@@ -34,7 +34,9 @@
$strsavechanges = get_string("savechanges");
$strbacktoquiz = get_string("backtoquiz", "quiz");
- $streditingquiz = get_string("editingquiz", "quiz");
+ $streditingquiz = get_string(isset($modform->instance) ? "editingquiz"
+ : "editquestions",
+ "quiz");
$streditcategories = get_string("editcategories", "quiz");
print_header("$course->shortname: $streditcategories", "$course->shortname: $streditcategories",
View
57 mod/quiz/edit.php
@@ -5,6 +5,8 @@
require_login();
+ optional_variable($courseid);
+
if (empty($destination)) {
$destination = "";
}
@@ -19,6 +21,12 @@
$SESSION->modform = $modform; // Save the form in the current session
+ } else if ($courseid) { // Page retrieve through "Edit Questions" link - no quiz selected
+ $modform->course = $courseid;
+ unset($modform->instance);
+
+ $SESSION->modform = $modform; // Save the form in the current session
+
} else {
if (!isset($SESSION->modform)) {
error("You have used this page incorrectly!");
@@ -34,11 +42,13 @@
require_login($course->id);
- if (!isteacher($course->id)) {
+ if (!isteacheredit($course->id)) {
error("You can't modify this course!");
}
- if (empty($modform->grades)) { // Construct an array to hold all the grades.
+ if (isset($modform->instance)
+ && empty($modform->grades)) // Construct an array to hold all the grades.
+ {
$modform->grades = quiz_get_all_question_grades($modform->questions, $modform->instance);
}
@@ -149,7 +159,9 @@
$SESSION->modform = $modform;
- $strediting = get_string("editingquiz", "quiz");
+ $strediting = get_string(isset($modform->instance) ? "editingquiz"
+ : "editquestions",
+ "quiz");
$strname = get_string("name");
print_header("$course->shortname: $strediting", "$course->shortname: $strediting",
@@ -159,21 +171,23 @@
echo "<TABLE BORDER=0 WIDTH=\"100%\" CELLPADDING=2 CELLSPACING=0>";
echo "<TR><TD WIDTH=50% VALIGN=TOP>";
- print_simple_box_start("CENTER", "100%", $THEME->cellcontent2);
- print_heading($modform->name);
- quiz_print_question_list($modform->questions, $modform->grades);
- ?>
- <CENTER>
- <P>&nbsp;</P>
- <FORM NAME=theform METHOD=post ACTION=<?php echo $modform->destination ?>>
- <INPUT TYPE="hidden" NAME=course VALUE="<?php p($modform->course) ?>">
- <INPUT TYPE="submit" VALUE="<?php print_string("savequiz", "quiz") ?>">
- <INPUT type="submit" name=cancel value="<?php print_string("cancel") ?>">
- </FORM>
- </CENTER>
- <?php
- print_simple_box_end();
- echo "</TD><TD VALIGN=top WIDTH=50%>";
+ if (isset($modform->instance)) {
+ print_simple_box_start("CENTER", "100%", $THEME->cellcontent2);
+ print_heading($modform->name);
+ quiz_print_question_list($modform->questions, $modform->grades);
+ ?>
+ <CENTER>
+ <P>&nbsp;</P>
+ <FORM NAME=theform METHOD=post ACTION=<?php echo $modform->destination ?>>
+ <INPUT TYPE="hidden" NAME=course VALUE="<?php p($modform->course) ?>">
+ <INPUT TYPE="submit" VALUE="<?php print_string("savequiz", "quiz") ?>">
+ <INPUT type="submit" name=cancel value="<?php print_string("cancel") ?>">
+ </FORM>
+ </CENTER>
+ <?php
+ print_simple_box_end();
+ echo "</TD><TD VALIGN=top WIDTH=50%>";
+ }
print_simple_box_start("CENTER", "100%", $THEME->cellcontent2);
quiz_print_category_form($course, $modform->category);
print_simple_box_end();
@@ -181,10 +195,15 @@
print_spacer(5,1);
print_simple_box_start("CENTER", "100%", $THEME->cellcontent2);
- quiz_print_cat_question_list($modform->category);
+ quiz_print_cat_question_list($modform->category,
+ isset($modform->instance));
print_simple_box_end();
echo "</TD></TR>";
echo "</TABLE>";
+ if (false == isset($modform->instance)) {
+ print_continue("index.php?id=$modform->course");
+ }
+
print_footer($course);
?>
View
4 mod/quiz/import.php
@@ -21,7 +21,9 @@
error("Only the teacher can import quiz questions!");
}
- $streditingquiz = get_string("editingquiz", "quiz");
+ $streditingquiz = get_string(isset($modform->instance) ? "editingquiz"
+ : "editquestions",
+ "quiz");
$strimportquestions = get_string("importquestions", "quiz");
$strquestions = get_string("questions", "quiz");
View
13 mod/quiz/index.php
@@ -19,14 +19,23 @@
// Print the header
$strquizzes = get_string("modulenameplural", "quiz");
+ $streditquestions = isteacheredit($course->id)
+ ? "<form target=\"_parent\" method=\"get\" "
+ ." action=\"$CFG->wwwroot/mod/quiz/edit.php\">"
+ ."<input type=\"hidden\" name=\"courseid\" "
+ ." value=\"$course->id\" />"
+ ."<input type=\"submit\" "
+ ." value=\"".get_string("editquestions", "quiz")."\" /></form>"
+
+ : "";
$strquiz = get_string("modulename", "quiz");
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}
- print_header("$course->shortname: $strquizzes", "$course->fullname", "$navigation $strquizzes",
- "", "", true, "", navmenu($course));
+ print_header("$course->shortname: $strquizzes", "$course->fullname", "$navigation $strquizzes",
+ "", "", true, $streditquestions, navmenu($course));
// Get all the appropriate data
View
38 mod/quiz/lib.php
@@ -1273,7 +1273,7 @@ function quiz_print_question_list($questionlist, $grades) {
}
-function quiz_print_cat_question_list($categoryid) {
+function quiz_print_cat_question_list($categoryid, $quizselected=true) {
// Prints a form to choose categories
global $THEME, $QUIZ_QUESTION_TYPE;
@@ -1297,9 +1297,11 @@ function quiz_print_cat_question_list($categoryid) {
echo "<p align=center><b>";
print_string("selectcategoryabove", "quiz");
echo "</b></p>";
- echo "<p>";
- print_string("addingquestions", "quiz");
- echo "</p>";
+ if ($quizselected) {
+ echo "<p>";
+ print_string("addingquestions", "quiz");
+ echo "</p>";
+ }
return;
}
@@ -1343,20 +1345,26 @@ function quiz_print_cat_question_list($categoryid) {
return;
}
- $canedit = isteacher($category->course);
+ $canedit = isteacheredit($category->course);
echo "<FORM METHOD=post ACTION=edit.php>";
echo "<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=2 WIDTH=\"100%\">";
- echo "<TR><TH width=\"*\" NOWRAP>$strselect</TH><TH width=\"100%\" align=left NOWRAP>$strquestionname</TH><TH WIDTH=\"*\" NOWRAP>$strtype</TH>";
+ echo "<TR>";
+ if ($quizselected) {
+ echo "<TH width=\"*\" NOWRAP>$strselect</TH>";
+ }
+ echo "<TH width=\"100%\" align=left NOWRAP>$strquestionname</TH><TH WIDTH=\"*\" NOWRAP>$strtype</TH>";
if ($canedit) {
echo "<TH width=\"*\" NOWRAP>$stredit</TH>";
}
echo "</TR>";
foreach ($questions as $question) {
echo "<TR BGCOLOR=\"$THEME->cellcontent\">";
- echo "<TD ALIGN=CENTER>";
- echo "<INPUT TYPE=CHECKBOX NAME=q$question->id VALUE=\"1\">";
- echo "</TD>";
+ if ($quizselected) {
+ echo "<TD ALIGN=CENTER>";
+ echo "<INPUT TYPE=CHECKBOX NAME=q$question->id VALUE=\"1\">";
+ echo "</TD>";
+ }
echo "<TD>".$question->name."</TD>";
echo "<TD ALIGN=CENTER>";
quiz_print_question_icon($question);
@@ -1371,11 +1379,13 @@ function quiz_print_cat_question_list($categoryid) {
}
echo "</TR>";
}
- echo "<TR><TD COLSPAN=3>";
- echo "<INPUT TYPE=submit NAME=add VALUE=\"<< $straddselectedtoquiz\">";
- //echo "<INPUT TYPE=submit NAME=delete VALUE=\"XX Delete selected\">";
- echo "<INPUT type=button onclick=\"checkall()\" value=\"$strselectall\">";
- echo "</TD></TR>";
+ if ($quizselected) {
+ echo "<TR><TD COLSPAN=3>";
+ echo "<INPUT TYPE=submit NAME=add VALUE=\"<< $straddselectedtoquiz\">";
+ //echo "<INPUT TYPE=submit NAME=delete VALUE=\"XX Delete selected\">";
+ echo "<INPUT type=button onclick=\"checkall()\" value=\"$strselectall\">";
+ echo "</TD></TR>";
+ }
echo "</TABLE>";
echo "</FORM>";
}
View
4 mod/quiz/multiple.php
@@ -97,7 +97,9 @@
$strsavechanges = get_string("savechanges");
$strbacktoquiz = get_string("backtoquiz", "quiz");
- $streditingquiz = get_string("editingquiz", "quiz");
+ $streditingquiz = get_string(isset($modform->instance) ? "editingquiz"
+ : "editquestions",
+ "quiz");
$strcreatemultiple = get_string("createmultiple", "quiz");
print_header("$course->shortname: $strcreatemultiple", "$course->shortname: $strcreatemultiple",
View
4 mod/quiz/question.php
@@ -48,7 +48,9 @@
error("You can't modify these questions!");
}
- $streditingquiz = get_string("editingquiz", "quiz");
+ $streditingquiz = get_string(isset($modform->instance) ? "editingquiz"
+ : "editquestions",
+ "quiz");
$streditingquestion = get_string("editingquestion", "quiz");
print_header("$course->shortname: $streditingquestion", "$course->shortname: $streditingquestion",

0 comments on commit 1e085ed

Please sign in to comment.
Something went wrong with that request. Please try again.