Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

As discussed in the thread http://moodle.org/mod/forum/discuss.php?d=…

…30628 (and others) the limitation to 10 answers in a question is problematic for some users.

From this commit onwards match, multichoice and shortanswer questiontypes will
(a) display all defined answers (e.g. from an import with more than 10 answers) and
(b) to always display at least one empty answer field.
  • Loading branch information...
commit e2823d208abfc59457c2b2681003911268a92d2e 1 parent 1a87ac6
mindforge authored
View
31 mod/quiz/questiontypes/match/editquestion.php
@@ -6,24 +6,25 @@
$oldsubquestions = get_records_list("quiz_match_sub", "id", $options->subquestions);
}
}
- if (empty($subquestions) and empty($subanswers)) {
- $subquestions = array();
- $subanswers = array();
- if (!empty($oldsubquestions)) {
- foreach ($oldsubquestions as $oldsubquestion) {
- $subquestions[] = $oldsubquestion->questiontext; // insert questions into slots
- $subanswers[] = $oldsubquestion->answertext; // insert answers into slots
- }
- }
- $i = count($subquestions);
- $limit = QUIZ_MAX_NUMBER_ANSWERS;
- $limit = $limit <= $i ? $i+1 : $limit;
- for (; $i < $limit; $i++) {
- $subquestions[] = ""; // Make question slots, default as blank
- $subanswers[] = ""; // Make answer slots, default as blank
+ $subquestions = array();
+ $subanswers = array();
+
+ if (!empty($oldsubquestions)) {
+ foreach ($oldsubquestions as $oldsubquestion) {
+ $subquestions[] = $oldsubquestion->questiontext; // insert questions into slots
+ $subanswers[] = $oldsubquestion->answertext; // insert answers into slots
}
}
+
+ $i = count($subquestions);
+ $limit = QUIZ_MAX_NUMBER_ANSWERS;
+ $limit = $limit <= $i ? $i+1 : $limit;
+ for (; $i < $limit; $i++) {
+ $subquestions[] = ""; // Make question slots, default as blank
+ $subanswers[] = ""; // Make answer slots, default as blank
+ }
+
print_heading_with_help(get_string("editingmatch", "quiz"), "match", "quiz");
require("$CFG->dirroot/mod/quiz/questiontypes/match/match.html");
View
16 mod/quiz/questiontypes/multichoice/editquestion.php
@@ -9,16 +9,20 @@
$answersraw = get_records_list("quiz_answers", "id", $options->answers);
}
- for ($i=0 ; $i < QUIZ_MAX_NUMBER_ANSWERS ; $i++) {
- $answers[] = ""; // Make answer slots, default as blank
- }
+
+ $answers = array();
if (!empty($answersraw)) {
- $i=0;
foreach ($answersraw as $answer) {
- $answers[$i] = $answer; // insert answers into slots
- $i++;
+ $answers[] = $answer; // insert answers into slots
}
}
+
+ $i = count($answers);
+ $limit = QUIZ_MAX_NUMBER_ANSWERS;
+ $limit = $limit <= $i ? $i+1 : $limit;
+ for (; $i < $limit; $i++) {
+ $answers[] = ""; // Make answer slots, default as blank
+ }
print_heading_with_help(get_string("editingmultichoice", "quiz"), "multichoice", "quiz");
require("$CFG->dirroot/mod/quiz/questiontypes/multichoice/multichoice.html");
View
2  mod/quiz/questiontypes/multichoice/multichoice.html
@@ -96,7 +96,7 @@
</tr>
<?php
- for ($i=1; $i<=QUIZ_MAX_NUMBER_ANSWERS; $i++) {
+ for ($i=1; $i<=count($answers); $i++) {
if (!isset($answers[$i-1]->fraction)) {
$answers[$i-1]->answer = '';
$answers[$i-1]->fraction = 0;
View
17 mod/quiz/questiontypes/shortanswer/editquestion.php
@@ -7,16 +7,21 @@
if (!empty($options->answers)) {
$answersraw = get_records_list("quiz_answers", "id", $options->answers);
}
- for ($i=0 ; $i < QUIZ_MAX_NUMBER_ANSWERS ; $i++) {
- $answers[] = ""; // Make answer slots, default as blank
- }
+
+ $answers = array();
if (!empty($answersraw)) {
- $i=0;
foreach ($answersraw as $answer) {
- $answers[$i] = $answer; // insert answers into slots
- $i++;
+ $answers[] = $answer; // insert answers into slots
}
}
+
+ $i = count($answers);
+ $limit = QUIZ_MAX_NUMBER_ANSWERS;
+ $limit = $limit <= $i ? $i+1 : $limit;
+ for (; $i < $limit; $i++) {
+ $answers[] = ""; // Make answer slots, default as blank
+ }
+
print_heading_with_help(get_string("editingshortanswer", "quiz"), "shortanswer", "quiz");
require("$CFG->dirroot/mod/quiz/questiontypes/shortanswer/shortanswer.html");
View
2  mod/quiz/questiontypes/shortanswer/shortanswer.html
@@ -88,7 +88,7 @@
</td>
</tr>
<?php
- for ($i=1; $i<=QUIZ_MAX_NUMBER_ANSWERS; $i++) {
+ for ($i=1; $i<=count($answers); $i++) {
?>
<tr valign="top">
<td align="right"><b><?php echo get_string("answer", "quiz")." $i"; ?>:</b></td>
Please sign in to comment.
Something went wrong with that request. Please try again.