Permalink
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...
1 parent 1a87ac6 commit e2823d208abfc59457c2b2681003911268a92d2e mindforge committed Sep 16, 2005
@@ -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");
@@ -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");
@@ -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;
@@ -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");
@@ -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>

0 comments on commit e2823d2

Please sign in to comment.