|
|
|
|
@ -26,8 +26,8 @@ class ReadingComprehension extends UniqueAnswer |
|
|
|
|
1 => 50, |
|
|
|
|
2 => 100, |
|
|
|
|
3 => 175, |
|
|
|
|
4 => 250, |
|
|
|
|
5 => 400 |
|
|
|
|
4 => 300, |
|
|
|
|
5 => 600 |
|
|
|
|
]; |
|
|
|
|
/** |
|
|
|
|
* The number of words in the question description (which serves as the |
|
|
|
|
@ -56,75 +56,6 @@ class ReadingComprehension extends UniqueAnswer |
|
|
|
|
$this->isContent = $this->getIsContent(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function createAnswersForm($form) |
|
|
|
|
{ |
|
|
|
|
$form->addTextarea('text', get_lang('Text'), ['rows' => '15']); |
|
|
|
|
|
|
|
|
|
parent::createAnswersForm($form); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function processAnswersCreation($form) |
|
|
|
|
{ |
|
|
|
|
$text = $form->exportValue('text'); |
|
|
|
|
|
|
|
|
|
$objAnswer = new Answer($this->id); |
|
|
|
|
$objAnswer->createAnswer($text, false, null, 0, 0); |
|
|
|
|
|
|
|
|
|
$questionWeighting = $nbrGoodAnswers = 0; |
|
|
|
|
$correct = $form->getSubmitValue('correct'); |
|
|
|
|
$nb_answers = $form->getSubmitValue('nb_answers'); |
|
|
|
|
|
|
|
|
|
for ($i = 1; $i <= $nb_answers; $i++) { |
|
|
|
|
$answer = trim($form->getSubmitValue('answer[' . $i . ']')); |
|
|
|
|
$comment = trim($form->getSubmitValue('comment[' . $i . ']')); |
|
|
|
|
$weighting = trim($form->getSubmitValue('weighting[' . $i . ']')); |
|
|
|
|
$scenario = $form->getSubmitValue('scenario'); |
|
|
|
|
|
|
|
|
|
$try = $scenario['try' . $i]; |
|
|
|
|
$lp = $scenario['lp' . $i]; |
|
|
|
|
$destination = $scenario['destination' . $i]; |
|
|
|
|
$url = trim($scenario['url' . $i]); |
|
|
|
|
|
|
|
|
|
$goodAnswer = $correct == $i ? true : false; |
|
|
|
|
|
|
|
|
|
if ($goodAnswer) { |
|
|
|
|
$nbrGoodAnswers++; |
|
|
|
|
$weighting = abs($weighting); |
|
|
|
|
|
|
|
|
|
if ($weighting > 0) { |
|
|
|
|
$questionWeighting += $weighting; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($try)) { |
|
|
|
|
$try = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($lp)) { |
|
|
|
|
$lp = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($destination)) { |
|
|
|
|
$destination = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($url == '') { |
|
|
|
|
$url = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//1@@1;2;@@2;4;4;@@http://www.chamilo.org |
|
|
|
|
$dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url; |
|
|
|
|
$objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i, null, null, $dest); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// saves the answers into the data base |
|
|
|
|
$objAnswer->save(); |
|
|
|
|
|
|
|
|
|
// sets the total weighting of the question |
|
|
|
|
$this->updateWeighting($questionWeighting); |
|
|
|
|
$this->save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function displayReading($wordsCount, $turns, $text) |
|
|
|
|
{ |
|
|
|
|
$view = new Template('', false, false, false, true, false, false); |
|
|
|
|
@ -154,7 +85,7 @@ class ReadingComprehension extends UniqueAnswer |
|
|
|
|
$indexes = array_keys($words); |
|
|
|
|
|
|
|
|
|
$tagEnd = '</span>'; |
|
|
|
|
$tagStart = $tagEnd.'<span class="text-highlight">'; |
|
|
|
|
$tagStart = $tagEnd.'<span class="text-highlight blur">'; |
|
|
|
|
|
|
|
|
|
$turns = ceil( |
|
|
|
|
count($words) / $this->expectedWordsPerRefresh |
|
|
|
|
|