/** LESSON_MAX_EVENT_LENGTH = 432000 ; 5 days maximum */
define("LESSON_MAX_EVENT_LENGTH", "432000");
+/** Answer format is HTML */
+define("LESSON_ANSWER_HTML", "HTML");
//////////////////////////////////////////////////////////////////////////////////////
/// Any other lesson functions go here. Each of them must have a name that
* @param int $count The count of the element to add
* @param string $label, null means default
* @param bool $required
+ * @param string $format
* @return void
*/
- protected final function add_answer($count, $label = null, $required = false) {
+ protected final function add_answer($count, $label = null, $required = false, $format= '') {
if ($label === null) {
$label = get_string('answer', 'lesson');
}
- if ($this->qtype != 'multichoice' && $this->qtype != 'matching') {
- $this->_form->addElement('editor', 'answer_editor['.$count.']', $label,
- array('rows' => '4', 'columns' => '80'), array('noclean' => true));
- $this->_form->setDefault('answer_editor['.$count.']', array('text' => '', 'format' => FORMAT_MOODLE));
- } else {
+ if ($format == LESSON_ANSWER_HTML) {
$this->_form->addElement('editor', 'answer_editor['.$count.']', $label,
array('rows' => '4', 'columns' => '80'),
array('noclean' => true, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->_customdata['maxbytes']));
$this->_form->setType('answer_editor['.$count.']', PARAM_RAW);
$this->_form->setDefault('answer_editor['.$count.']', array('text' => '', 'format' => FORMAT_HTML));
+ } else {
+ $this->_form->addElement('editor', 'answer_editor['.$count.']', $label,
+ array('rows' => '4', 'columns' => '80'), array('noclean' => true));
+ $this->_form->setDefault('answer_editor['.$count.']', array('text' => '', 'format' => FORMAT_MOODLE));
}
if ($required) {
for ($i = 2; $i < $this->_customdata['lesson']->maxanswers+2; $i++) {
$this->_form->addElement('header', 'matchingpair'.($i-1), get_string('matchingpair', 'lesson', $i-1));
- $this->add_answer($i, null, ($i < 4));
+ $this->add_answer($i, null, ($i < 4), LESSON_ANSWER_HTML);
$required = ($i < 4);
$label = get_string('matchesanswer','lesson');
$count = $i;
for ($i = 0; $i < $this->_customdata['lesson']->maxanswers; $i++) {
$this->_form->addElement('header', 'answertitle'.$i, get_string('answer').' '.($i+1));
- $this->add_answer($i, null, ($i<2));
+ $this->add_answer($i, null, ($i<2), LESSON_ANSWER_HTML);
$this->add_response($i);
$this->add_jumpto($i, null, ($i == 0 ? LESSON_NEXTPAGE : LESSON_THISPAGE));
$this->add_score($i, null, ($i===0)?1:0);
public function custom_definition() {
$this->_form->addElement('header', 'answertitle0', get_string('correctresponse', 'lesson'));
- $this->add_answer(0, null, true);
+ $this->add_answer(0, null, true, LESSON_ANSWER_HTML);
$this->add_response(0);
$this->add_jumpto(0, get_string('correctanswerjump', 'lesson'), LESSON_NEXTPAGE);
$this->add_score(0, get_string('correctanswerscore', 'lesson'), 1);
$this->_form->addElement('header', 'answertitle1', get_string('wrongresponse', 'lesson'));
- $this->add_answer(1, null, true);
+ $this->add_answer(1, null, true, LESSON_ANSWER_HTML);
$this->add_response(1);
$this->add_jumpto(1, get_string('wronganswerjump', 'lesson'), LESSON_THISPAGE);
$this->add_score(1, get_string('wronganswerscore', 'lesson'), 0);
have been removed, this is now handled by the base class: lesson_page::update in
locallib.php and the exact same code is executed (it is also executed by the
lesson_page_type_cluster class that previously had no update function).
+* A fourth parameter (format) has been added to the add_answer() function
+ located as part of the lesson_add_page_form_base class. If specified with a value of 'LESSON_ANSWER_HTML'
+ then a rich html editor is generated. Otherwise an editor is created with Moodle Auto Format
=== Earlier changes ===