Skip to content

Commit

Permalink
Fix issue for speed calculation in READING_SPEED question type and fi…
Browse files Browse the repository at this point in the history
…netune display - refs #1896
  • Loading branch information
ywarnier committed Apr 29, 2017
1 parent 34cef4c commit 5ffb16c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions main/exercise/ReadingSpeed.php
Expand Up @@ -44,7 +44,7 @@ class ReadingSpeed extends UniqueAnswer
* Refresh delay in seconds
* @var int
*/
public $refreshTime = 5;
public $refreshTime = 3;

/**
* Constructor
Expand All @@ -54,10 +54,6 @@ public function __construct()
parent::__construct();
$this->type = READING_SPEED;
$this->isContent = $this->getIsContent();
// Refresh is set to 5s, but speed is in words per minute
$wordsPerSecond = $this->speeds[$this->level] / 60;
$this->expectedWordsPerRefresh = intval($wordsPerSecond * $this->refreshTime);

}

public function createAnswersForm($form)
Expand Down Expand Up @@ -145,9 +141,16 @@ private function displayReading($wordsCount, $turns, $text)

public function processText($text)
{
//recalulate the expected words count
$this->expectedCount = $this->speeds[$this->level];
// Refresh is set to 5s, but speed is in words per minute
error_log($this->getLevel().' '.$this->speeds[$this->level]);
$wordsPerSecond = $this->speeds[$this->level] / 60;
$this->expectedWordsPerRefresh = intval($wordsPerSecond * $this->refreshTime);

if (empty($text)) {
// We have an issue here... how do we treat this case?
// For now, let's define a default case
$text = get_lang('NoExercise');
}
$words = str_word_count($text, 2, '0..9');
$indexes = array_keys($words);

Expand Down
2 changes: 1 addition & 1 deletion main/template/default/exercise/reading_speed.tpl
Expand Up @@ -13,7 +13,7 @@
color: rgba(0, 0, 0, 1);
}
.text-highlight.border {
color: #888;
color: #bbb;
}
</style>

Expand Down

0 comments on commit 5ffb16c

Please sign in to comment.