Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/exercise/freeanswer.class.php

67 lines
1.8 KiB

<?php
/* For licensing terms, see /license.txt */
/**
* File containing the FreeAnswer class.
* This class allows to instantiate an object of type FREE_ANSWER,
* extending the class question
* @package chamilo.exercise
* @author Eric Marguin
*/
class FreeAnswer extends Question
{
public static $typePicture = 'open_answer.png';
public static $explanationLangVar = 'FreeAnswer';
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->type = FREE_ANSWER;
$this->isContent = $this->getIsContent();
}
/**
* @inheritdoc
*/
public function createAnswersForm($form)
{
$form->addElement('text', 'weighting', get_lang('Weighting'));
global $text, $class;
// setting the save button here and not in the question class.php
$form->addButtonSave($text, 'submitQuestion');
if (!empty($this->id)) {
$form->setDefaults(['weighting' => float_format($this->weighting, 1)]);
} else {
if ($this->isContent == 1) {
$form->setDefaults(['weighting' => '10']);
}
}
}
/**
* @inheritdoc
*/
public function processAnswersCreation($form, $exercise)
{
$this->weighting = $form->getSubmitValue('weighting');
$this->save($exercise);
}
/**
* @inheritdoc
*/
public function return_header($exercise, $counter = null, $score = [])
{
$score['revised'] = $this->isQuestionWaitingReview($score);
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'" >
<tr>
<th>' . get_lang("Answer").'</th>
</tr>';
return $header;
}
}