MDL-11708 - Zero answers are not allowed in Matching questions - sometimes I hate PHP. Merged from MOODLE_18_STABLE.

This commit is contained in:
tjhunt 2007-10-22 16:57:19 +00:00
parent 9b75adc2e3
commit ebf83e2c6f
2 changed files with 6 additions and 6 deletions

View File

@ -78,10 +78,10 @@ class question_edit_match_form extends question_edit_form {
foreach ($questions as $key => $question){
$trimmedquestion = trim($question);
$trimmedanswer = trim($answers[$key]);
if (!empty($trimmedanswer) && !empty($trimmedquestion)){
if ($trimmedanswer != '' && $trimmedquestion != ''){
$questioncount++;
}
if (!empty($trimmedquestion) && empty($trimmedanswer)){
if ($trimmedquestion != '' && $trimmedanswer == ''){
$errors['subanswers['.$key.']'] = get_string('nomatchinganswerforq', 'qtype_match', $trimmedquestion);
}
}

View File

@ -34,7 +34,7 @@ class question_match_qtype extends default_questiontype {
// Insert all the new question+answer pairs
foreach ($question->subquestions as $key => $questiontext) {
$answertext = $question->subanswers[$key];
if (!empty($questiontext) or !empty($answertext)) {
if ($questiontext != '' || $answertext != '') {
if ($subquestion = array_shift($oldsubquestions)) { // Existing answer, so reuse it
$subquestion->questiontext = $questiontext;
$subquestion->answertext = $answertext;
@ -59,7 +59,7 @@ class question_match_qtype extends default_questiontype {
}
$subquestions[] = $subquestion->id;
}
if (!empty($questiontext) && empty($answertext)) {
if ($questiontext != '' && $answertext == '') {
$result->notice = get_string('nomatchinganswer', 'quiz', $questiontext);
}
}
@ -223,7 +223,7 @@ class question_match_qtype extends default_questiontype {
$responses = array();
foreach ($state->options->subquestions as $sub) {
foreach ($sub->options->answers as $answer) {
if (1 == $answer->fraction && $sub->questiontext) {
if (1 == $answer->fraction && $sub->questiontext != '') {
$responses[$sub->id] = $answer->id;
}
}
@ -272,7 +272,7 @@ class question_match_qtype extends default_questiontype {
// Print the input controls
foreach ($subquestions as $key => $subquestion) {
if ($subquestion->questiontext) {
if ($subquestion->questiontext != '') {
// Subquestion text:
$a = new stdClass;
$a->text = $this->format_text($subquestion->questiontext,