Permalink
Browse files

Merged changes from 1.5

  • Loading branch information...
1 parent 3861020 commit 943ccdb7df95afa022b972753225b8115b8cc108 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");
@@ -76,7 +76,7 @@
</td>
</tr>
<?php
- for ($i=1; $i<=QUIZ_MAX_NUMBER_ANSWERS; $i++) {
+ for ($i=1; $i <= count($subquestions); $i++) {
?>
<tr valign="top">
<td align="right"><b><?php echo get_string("question", "quiz")." $i"; ?> :</b></td>
@@ -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 943ccdb

Please sign in to comment.