Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34050: Lesson module: fixed matching answer format to use text

  • Loading branch information...
commit 58b72abc6af2f88eb8dafb4b89f9ec4c6dec79fb 1 parent ca48fe5
Joseph Rézeau authored rwijaya committed
Showing with 20 additions and 9 deletions.
  1. +6 −1 mod/lesson/locallib.php
  2. +14 −8 mod/lesson/pagetypes/matching.php
View
7 mod/lesson/locallib.php
@@ -2309,9 +2309,14 @@ public function properties() {
}
if (count($this->answers)>0) {
$count = 0;
+ $properties->qtype;
foreach ($this->answers as $answer) {
$properties->{'answer_editor['.$count.']'} = array('text'=>$answer->answer, 'format'=>$answer->answerformat);
- $properties->{'response_editor['.$count.']'} = array('text'=>$answer->response, 'format'=>$answer->responseformat);
+ if ($qtype != LESSON_PAGE_MATCHING) {
+ $properties->{'response_editor['.$count.']'} = array('text'=>$answer->response, 'format'=>$answer->responseformat);
+ } else {
+ $properties->{'response_editor['.$count.']'} = $answer->response;
+ }
$properties->{'jumpto['.$count.']'} = $answer->jumpto;
$properties->{'score['.$count.']'} = $answer->score;
$count++;
View
22 mod/lesson/pagetypes/matching.php
@@ -115,9 +115,9 @@ public function create_answers($properties) {
$answer->answer = $properties->answer_editor[$i]['text'];
$answer->answerformat = $properties->answer_editor[$i]['format'];
}
- if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i])) {
- $answer->response = $properties->response_editor[$i]['text'];
- $answer->responseformat = $properties->response_editor[$i]['format'];
+ if (!empty($properties->response_editor[$i])) {
+ $answer->response = $properties->response_editor[$i];
+ $answer->responseformat = 0;
}
if (isset($properties->jumpto[$i])) {
@@ -315,9 +315,9 @@ public function update($properties, $context = null, $maxbytes = null) {
$this->answers[$i]->answer = $properties->answer_editor[$i]['text'];
$this->answers[$i]->answerformat = $properties->answer_editor[$i]['format'];
}
- if (!empty($properties->response_editor[$i]) && is_array($properties->response_editor[$i])) {
- $this->answers[$i]->response = $properties->response_editor[$i]['text'];
- $this->answers[$i]->responseformat = $properties->response_editor[$i]['format'];
+ if (!empty($properties->response_editor[$i])) {
+ $this->answers[$i]->response = $properties->response_editor[$i];
+ $this->answers[$i]->responseformat = 0;
}
if (isset($properties->jumpto[$i])) {
@@ -473,12 +473,18 @@ public function custom_definition() {
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_response($i, get_string('matchesanswer','lesson'), ($i < 4));
+ $required = ($i < 4);
+ $label = get_string('matchesanswer','lesson');
+ $count = $i;
+ $this->_form->addElement('text', 'response_editor['.$count.']', $label, array('size'=>'50'));
+ $this->_form->setDefault('response_editor['.$count.']', '');
+ if ($required) {
+ $this->_form->addRule('response_editor['.$count.']', get_string('required'), 'required', null, 'client');
+ }
}
}
}
-
class lesson_display_answer_form_matching extends moodleform {
public function definition() {
Please sign in to comment.
Something went wrong with that request. Please try again.