MDL-38714 Lesson module: add setType for hidden and text inputs

This commit is contained in:
Rossiani Wijaya 2013-05-01 11:39:31 +08:00
parent cf5a3296c4
commit 747d5b1cf6
3 changed files with 11 additions and 2 deletions

View File

@ -722,6 +722,7 @@ abstract class lesson_add_page_form_base extends moodleform {
if ($this->_customdata['edit'] === true) { if ($this->_customdata['edit'] === true) {
$mform->addElement('hidden', 'edit', 1); $mform->addElement('hidden', 'edit', 1);
$mform->setType('edit', PARAM_BOOL);
$this->add_action_buttons(get_string('cancel'), get_string('savepage', 'lesson')); $this->add_action_buttons(get_string('cancel'), get_string('savepage', 'lesson'));
} else if ($this->qtype === 'questiontype') { } else if ($this->qtype === 'questiontype') {
$this->add_action_buttons(get_string('cancel'), get_string('addaquestionpage', 'lesson')); $this->add_action_buttons(get_string('cancel'), get_string('addaquestionpage', 'lesson'));
@ -761,10 +762,14 @@ abstract class lesson_add_page_form_base extends moodleform {
if ($label === null) { if ($label === null) {
$label = get_string("score", "lesson"); $label = get_string("score", "lesson");
} }
$elname = $name;
if (is_int($name)) { if (is_int($name)) {
$name = "score[$name]"; $name = "score[$name]";
$elname = 'score';
} }
$this->_form->addElement('text', $name, $label, array('size'=>5)); $this->_form->addElement('text', $name, $label, array('size'=>5));
// Temporary fix until MDL-38885 gets integrated.
$this->_form->setType($elname, PARAM_INT);
if ($value !== null) { if ($value !== null) {
$this->_form->setDefault($name, $value); $this->_form->setDefault($name, $value);
} }

View File

@ -477,6 +477,8 @@ class lesson_add_page_form_matching extends lesson_add_page_form_base {
$label = get_string('matchesanswer','lesson'); $label = get_string('matchesanswer','lesson');
$count = $i; $count = $i;
$this->_form->addElement('text', 'response_editor['.$count.']', $label, array('size'=>'50')); $this->_form->addElement('text', 'response_editor['.$count.']', $label, array('size'=>'50'));
// Temporary fix until MDL-38885 gets integrated.
$this->_form->setType('response_editor', PARAM_TEXT);
$this->_form->setDefault('response_editor['.$count.']', ''); $this->_form->setDefault('response_editor['.$count.']', '');
if ($required) { if ($required) {
$this->_form->addRule('response_editor['.$count.']', get_string('required'), 'required', null, 'client'); $this->_form->addRule('response_editor['.$count.']', get_string('required'), 'required', null, 'client');
@ -525,7 +527,8 @@ class lesson_display_answer_form_matching extends moodleform {
if ($hasattempt) { if ($hasattempt) {
$responseid = 'response_'.$answer->id; $responseid = 'response_'.$answer->id;
$mform->addElement('hidden', 'response['.$answer->id.']', htmlspecialchars(trim($answers[$useranswers[$i]]->response))); $mform->addElement('hidden', 'response['.$answer->id.']', htmlspecialchars(trim($answers[$useranswers[$i]]->response)));
$mform->setType('response['.$answer->id.']', PARAM_TEXT); // Temporary fixed until MDL-38885 gets integrated
$mform->setType('response', PARAM_TEXT);
} }
$mform->addElement('select', $responseid, format_text($answer->answer,$answer->answerformat,$options), $responseoptions, $disabled); $mform->addElement('select', $responseid, format_text($answer->answer,$answer->answerformat,$options), $responseoptions, $disabled);
$mform->setType($responseid, PARAM_TEXT); $mform->setType($responseid, PARAM_TEXT);

View File

@ -553,7 +553,8 @@ class lesson_display_answer_form_multichoice_multianswer extends moodleform {
if ($hasattempt && in_array($answer->id, $useranswers)) { if ($hasattempt && in_array($answer->id, $useranswers)) {
$answerid = 'answer_'.$answer->id; $answerid = 'answer_'.$answer->id;
$mform->addElement('hidden', 'answer['.$answer->id.']', $answer->answer); $mform->addElement('hidden', 'answer['.$answer->id.']', $answer->answer);
$mform->setType('answer['.$answer->id.']', PARAM_TEXT); // Temporary fix until MDL-38885 gets integrated.
$mform->setType('answer', PARAM_TEXT);
$mform->setDefault($answerid, true); $mform->setDefault($answerid, true);
$mform->setDefault('answer['.$answer->id.']', true); $mform->setDefault('answer['.$answer->id.']', true);
} }