Skip to content

Commit

Permalink
MDL-39369: Lesson module: fix setType() properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Rossiani Wijaya committed Jun 13, 2013
1 parent 1430866 commit 51c72ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions mod/lesson/locallib.php
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions mod/lesson/pagetypes/matching.php
Expand Up @@ -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');
Expand Down
3 changes: 1 addition & 2 deletions mod/lesson/pagetypes/multichoice.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit 51c72ec

Please sign in to comment.