Browse Source

Hide question description in results of READING_COMPREHENSION question type and fix issue not showing results table - refs #1896

Yannick Warnier 7 years ago
parent
commit
abfea6f87a

+ 4 - 3
main/exercise/ReadingComprehension.php

@@ -34,7 +34,7 @@ class ReadingComprehension extends UniqueAnswer
      * text to read)
      * @var int $wordsCount
      */
-    private $wordsCount = 0;
+    public $wordsCount = 0;
     /**
      * Number of words expected to show per refresh
      * @var int
@@ -86,9 +86,10 @@ class ReadingComprehension extends UniqueAnswer
 
         $tagEnd = '</span>';
         $tagStart = $tagEnd.'<span class="text-highlight blur">';
+        $this->wordsCount = count($words);
 
         $turns = ceil(
-            count($words) / $this->expectedWordsPerRefresh
+            $this->wordsCount / $this->expectedWordsPerRefresh
         );
 
         $firstIndex = $indexes[0];
@@ -110,6 +111,6 @@ class ReadingComprehension extends UniqueAnswer
         $text = substr_replace($text, '', $pos, strlen($tagEnd));
         $text .= $tagEnd;
 
-        $this->displayReading(count($words), $turns, $text);
+        $this->displayReading($this->wordsCount, $turns, $text);
     }
 }

+ 2 - 1
main/exercise/exercise.class.php

@@ -4205,7 +4205,8 @@ class Exercise
                                     UNIQUE_ANSWER_NO_OPTION,
                                     MULTIPLE_ANSWER,
                                     MULTIPLE_ANSWER_COMBINATION,
-                                    GLOBAL_MULTIPLE_ANSWER
+                                    GLOBAL_MULTIPLE_ANSWER,
+                                    READING_COMPREHENSION,
                                 )
                             )
                         ) {

+ 2 - 0
main/exercise/exercise_show.php

@@ -396,6 +396,8 @@ foreach ($questionList as $questionId) {
             //no break
         case DRAGGABLE:
             //no break
+        case READING_COMPREHENSION:
+            //no break
         case MATCHING_DRAGGABLE:
             $question_result = $objExercise->manage_answer(
                 $id,

+ 12 - 1
main/exercise/question.class.php

@@ -1869,6 +1869,7 @@ abstract class Question
      * @param string $feedback_type
      * @param int $counter
      * @param float $score
+     * @return string HTML string with the header of the question (before the answers table)
      */
     function return_header($feedback_type = null, $counter = null, $score = null)
     {
@@ -1907,7 +1908,17 @@ abstract class Question
             "<div class=\"rib rib-$class\"><h3>$score_label</h3></div> <h4>{$score['result']}</h4>",
             array('class' => 'ribbon')
         );
-        $header .= Display::div($this->description, array('class' => 'question_description'));
+        if ($this->type != READING_COMPREHENSION) {
+            // Do not show the description (the text to read) if the question is of type READING_COMPREHENSION
+            $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);
+            } else {
+                $message = Display::div(get_lang('ReadingQuestionCongratsSpeedXNotReachedForYWords'), $this->speeds[$this->level], $this->wordsCount);
+            }
+            $header .= $message;
+        }
 
         return $header;
     }