Fix result messages for READING_COMPREHENSION question type - refs #1896

pull/2487/head
Yannick Warnier 9 years ago
parent e68a6001c3
commit da4f463432
  1. 9
      main/exercise/ReadingComprehension.php
  2. 6
      main/exercise/question.class.php

@ -113,4 +113,13 @@ class ReadingComprehension extends UniqueAnswer
$this->displayReading($this->wordsCount, $turns, $text);
}
/**
* Returns total count of words of the text to read
* @return int
*/
public function getWordsCount() {
$words = str_word_count($this->selectDescription(), 2, '0..9');
$this->wordsCount = count($words);
return $this->wordsCount;
}
}

@ -1913,11 +1913,11 @@ abstract class Question
$header .= Display::div($this->description, array('class' => 'question_description'));
} else {
if ($score['pass'] == true) {
$message = Display::div(get_lang('ReadingQuestionCongratsSpeedXReachedForYWords'), $this->speeds[$this->level], $this->wordsCount);
$message = Display::div(sprintf(get_lang('ReadingQuestionCongratsSpeedXReachedForYWords'), $this->speeds[$this->level], $this->getWordsCount()));
} else {
$message = Display::div(get_lang('ReadingQuestionCongratsSpeedXNotReachedForYWords'), $this->speeds[$this->level], $this->wordsCount);
$message = Display::div(sprintf(get_lang('ReadingQuestionCongratsSpeedXNotReachedForYWords'), $this->speeds[$this->level], $this->getWordsCount()));
}
$header .= $message;
$header .= $message.'<br />';
}
return $header;

Loading…
Cancel
Save