From da4f4634320e4a68af12e37735806123b2bfafd2 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sat, 29 Apr 2017 19:32:05 -0500 Subject: [PATCH] Fix result messages for READING_COMPREHENSION question type - refs #1896 --- main/exercise/ReadingComprehension.php | 9 +++++++++ main/exercise/question.class.php | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/main/exercise/ReadingComprehension.php b/main/exercise/ReadingComprehension.php index 633c85754c..df8ca67356 100755 --- a/main/exercise/ReadingComprehension.php +++ b/main/exercise/ReadingComprehension.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; + } } diff --git a/main/exercise/question.class.php b/main/exercise/question.class.php index da34aa04da..86156e8fda 100755 --- a/main/exercise/question.class.php +++ b/main/exercise/question.class.php @@ -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.'
'; } return $header;