From 51c72ecaa531110870844d5504749321f38f1e0e Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Mon, 13 May 2013 16:11:40 +0800 Subject: [PATCH] MDL-39369: Lesson module: fix setType() properly --- mod/lesson/locallib.php | 6 ++---- mod/lesson/pagetypes/matching.php | 3 +-- mod/lesson/pagetypes/multichoice.php | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index c043fe097617a..314e4c78a0e90 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -762,14 +762,12 @@ protected final function add_score($name, $label=null, $value=null) { if ($label === null) { $label = get_string("score", "lesson"); } - $elname = $name; + if (is_int($name)) { $name = "score[$name]"; - $elname = 'score'; } $this->_form->addElement('text', $name, $label, array('size'=>5)); - // Temporary fix until MDL-38885 gets integrated. - $this->_form->setType($elname, PARAM_INT); + $this->_form->setType($name, PARAM_INT); if ($value !== null) { $this->_form->setDefault($name, $value); } diff --git a/mod/lesson/pagetypes/matching.php b/mod/lesson/pagetypes/matching.php index 83c175a31e5b0..6a32473eb8877 100644 --- a/mod/lesson/pagetypes/matching.php +++ b/mod/lesson/pagetypes/matching.php @@ -477,8 +477,7 @@ public function custom_definition() { $label = get_string('matchesanswer','lesson'); $count = $i; $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->setType('response_editor['.$count.']', PARAM_TEXT); $this->_form->setDefault('response_editor['.$count.']', ''); if ($required) { $this->_form->addRule('response_editor['.$count.']', get_string('required'), 'required', null, 'client'); diff --git a/mod/lesson/pagetypes/multichoice.php b/mod/lesson/pagetypes/multichoice.php index 9025f921f4416..8b914dd4e728e 100644 --- a/mod/lesson/pagetypes/multichoice.php +++ b/mod/lesson/pagetypes/multichoice.php @@ -553,8 +553,7 @@ public function definition() { if ($hasattempt && in_array($answer->id, $useranswers)) { $answerid = 'answer_'.$answer->id; $mform->addElement('hidden', 'answer['.$answer->id.']', $answer->answer); - // Temporary fix until MDL-38885 gets integrated. - $mform->setType('answer', PARAM_TEXT); + $mform->setType('answer['.$answer->id.']', PARAM_TEXT); $mform->setDefault($answerid, true); $mform->setDefault('answer['.$answer->id.']', true); }