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);
}
}
// 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;
}
$subquestions[] = $subquestion->id;
}
- if (!empty($questiontext) && empty($answertext)) {
+ if ($questiontext != '' && $answertext == '') {
$result->notice = get_string('nomatchinganswer', 'quiz', $questiontext);
}
}
$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;
}
}
// 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,