mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-11708 - Zero answers are not allowed in Matching questions - sometimes I hate PHP. Merged from MOODLE_18_STABLE.
This commit is contained in:
parent
9b75adc2e3
commit
ebf83e2c6f
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user