';
+ $qdata->options->incorrectfeedbackformat = FORMAT_MOODLE;
$qdata->options->answers = array(
- new question_answer('Alpha', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}'),
- new question_answer('Beta', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}'),
- new question_answer('Gamma', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}'),
+ 13 => new question_answer(13, 'Alpha', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE),
+ 14 => new question_answer(14, 'Beta', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE),
+ 15 => new question_answer(15, 'Gamma', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}', FORMAT_MOODLE),
);
$qdata->hints = array(
- new question_hint_with_parts('Try again.', true, false),
- new question_hint_with_parts('These are the first three letters of the Greek alphabet.', true, true),
+ 1 => new question_hint_with_parts(1, 'Try again.', FORMAT_MOODLE, true, false),
+ 2 => new question_hint_with_parts(2, 'These are the first three letters of the Greek alphabet.', FORMAT_MOODLE, true, true),
);
$exporter = new qformat_xml();
@@ -423,20 +429,20 @@ class qtype_ddwtos_test extends UnitTestCase {
Put these in order: [[1]], [[2]], [[3]].
-
+ The answer is Alpha, Beta, Gamma.30.333333301
-
+ Your answer is correct.]]>
-
+ Your answer is partially correct.]]>
-
+ Your answer is incorrect.]]>
@@ -453,11 +459,11 @@ class qtype_ddwtos_test extends UnitTestCase {
1
-
+ Try again.
-
+ These are the first three letters of the Greek alphabet.
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 4a0f2820fc9..9b6f42549f7 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -57,8 +57,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts('This is the first hint.', false, false),
- new question_hint_with_parts('This is the second hint.', true, true),
+ 13 => new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
+ 14 => new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
From 08c1d356eb4248e375c17f97b5b1e1f39e4a1172 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Tue, 1 Feb 2011 11:40:29 +0000
Subject: [PATCH 003/208] MDL-47494 ddimageortext: Now all the unit tests for
the the ddwtos and gapselect qtypes pass.
---
.../ddimageortext/lang/en/qtype_ddwtos.php | 27 ++++++++++++++++++-
.../simpletest/testwalkthrough.php | 21 +++++++--------
question/type/ddimageortext/version.php | 4 +--
3 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/question/type/ddimageortext/lang/en/qtype_ddwtos.php b/question/type/ddimageortext/lang/en/qtype_ddwtos.php
index 34b17378121..aabe3852384 100755
--- a/question/type/ddimageortext/lang/en/qtype_ddwtos.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddwtos.php
@@ -1,10 +1,35 @@
.
+
+
+/**
+ * Language strings for the select missing words question type.
+ *
+ * @package qtype
+ * @subpackage gapselect
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
$string['addingddwtos'] = 'Adding drag and drop: words in text';
$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices';
$string['answer'] = 'Answer';
-$string['correctansweris'] = 'The correct answer is: $a';
+$string['correctansweris'] = 'The correct answer is: {$a}';
$string['ddwtos'] = 'Drag and drop: words in text';
$string['ddwtos_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.';
$string['ddwtossummary'] = 'Missing words in some text are filled in using drag-and-drop.';
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 9b6f42549f7..4b613e70160 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -57,8 +57,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- 13 => new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
- 14 => new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
+ new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
+ new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
@@ -332,8 +332,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts('This is the first hint.', true, true),
- new question_hint_with_parts('This is the second hint.', true, true),
+ new question_hint_with_parts(1, 'This is the first hint.', FORMAT_MOODLE, true, true),
+ new question_hint_with_parts(2, 'This is the second hint.', FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 9);
@@ -469,8 +469,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts('This is the first hint.', false, false),
- new question_hint_with_parts('This is the second hint.', true, true),
+ new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false),
+ new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
@@ -520,8 +520,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts('This is the first hint.', false, false),
- new question_hint_with_parts('This is the second hint.', true, true),
+ new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false),
+ new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
@@ -571,8 +571,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts('This is the first hint.', false, true),
- new question_hint_with_parts('This is the second hint.', true, true),
+ new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true),
+ new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
@@ -675,6 +675,5 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
$this->get_contains_correct_expectation(),
new PatternExpectation('/' . preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/'));
-
}
}
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index 243100003cd..ad42b28bb9e 100755
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -1,4 +1,4 @@
version = 2010042800;
-$plugin->requires = 2007101000;
+$plugin->version = 2011020100;
+$plugin->requires = 2011011200;
From 428b36687dd19a721ae2d95650272db7f23d5710 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Tue, 1 Feb 2011 23:44:40 +0000
Subject: [PATCH 004/208] MDL-47494 ddimageortext: ddwtos and gapselect qtypes
now very nearly work.
Todo rendering questions with files, and ddwtos javascript.
---
question/type/ddimageortext/db/install.xml | 11 ++-
question/type/ddimageortext/db/upgrade.php | 83 ------------------
.../type/ddimageortext/edit_ddwtos_form.php | 33 ++-----
.../type/ddimageortext/{ => pix}/icon.gif | Bin
question/type/ddimageortext/questiontype.php | 2 +-
5 files changed, 17 insertions(+), 112 deletions(-)
delete mode 100755 question/type/ddimageortext/db/upgrade.php
rename question/type/ddimageortext/{ => pix}/icon.gif (100%)
diff --git a/question/type/ddimageortext/db/install.xml b/question/type/ddimageortext/db/install.xml
index 065853d37b1..50dbefe8a09 100755
--- a/question/type/ddimageortext/db/install.xml
+++ b/question/type/ddimageortext/db/install.xml
@@ -9,10 +9,13 @@
-
-
-
-
+
+
+
+
+
+
+
diff --git a/question/type/ddimageortext/db/upgrade.php b/question/type/ddimageortext/db/upgrade.php
deleted file mode 100755
index 91d665a1685..00000000000
--- a/question/type/ddimageortext/db/upgrade.php
+++ /dev/null
@@ -1,83 +0,0 @@
-question = $ddanswer->questionid;
- $answer->answer = addslashes($ddanswer->answer);
- $answer->fraction = 1;
-
- $feedback = new stdClass;
- $feedback->draggroup = $ddanswer->draggroup;
- $feedback->infinite = $ddanswer->infinite;
- $answer->feedback = serialize($feedback);
-
- if(!insert_record('question_answers', $answer)){
- notify('move_question_ddanswers_to_question_answers(): cannot insert row into question_answer table.');
- return false;
- }
- }
- }
-
- // Drop table
- $result = $result && drop_table($table);
- }
-
- if ($result && $oldversion < 2010042800) {
-
- /// Rename field correctresponsesfeedback on table question_ddwtos to shownumcorrect
- $table = new XMLDBTable('question_ddwtos');
- $field = new XMLDBField('correctresponsesfeedback');
- $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'incorrectfeedback');
-
- /// Launch rename field correctresponsesfeedback
- $result = $result && rename_field($table, $field, 'shownumcorrect');
- }
-
- return $result;
-}
diff --git a/question/type/ddimageortext/edit_ddwtos_form.php b/question/type/ddimageortext/edit_ddwtos_form.php
index e04351c8e14..222aaf08fcd 100755
--- a/question/type/ddimageortext/edit_ddwtos_form.php
+++ b/question/type/ddimageortext/edit_ddwtos_form.php
@@ -34,36 +34,21 @@ require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base {
-
function qtype() {
return 'ddwtos';
}
- protected function default_values_from_feedback_field($feedback, $key){
- $feedback = unserialize($feedback);
- $draggroup = $feedback->draggroup;
- $infinite = $feedback->infinite;
-
- $default_values = array();
- $default_values['choices['.$key.'][draggroup]'] = $draggroup;
- $default_values['choices['.$key.'][infinite]'] = $infinite;
- return $default_values;
+ protected function data_preprocessing_choice($question, $answer, $key) {
+ $question = parent::data_preprocessing_choice($question, $answer, $key);
+ $options = unserialize($answer->feedback);
+ $question->choices[$key]['choicegroup'] = $options->draggroup;
+ $question->choices[$key]['infinite'] = $options->infinite;
+ return $question;
}
- protected function repeated_options(){
- $repeatedoptions = array();
- $repeatedoptions['draggroup']['default'] = '1';
- $repeatedoptions['infinite']['default'] = 0;
- return $repeatedoptions;
- }
-
- protected function choice_group(&$mform, $grouparray){
- $options = array();
- for ($i = 1; $i <= 8; $i += 1) {
- $options[$i] = $i;
- }
- $grouparray[] =& $mform->createElement('select', 'draggroup', get_string('group', 'qtype_ddwtos'), $options);
- $grouparray[] =& $mform->createElement('checkbox', 'infinite', ' ', get_string('infinite', 'qtype_ddwtos'), null, array('size'=>1, 'class'=>'tweakcss'));
+ protected function choice_group($mform) {
+ $grouparray = parent::choice_group($mform);
+ $grouparray[] = $mform->createElement('checkbox', 'infinite', ' ', get_string('infinite', 'qtype_ddwtos'), null, array('size'=>1, 'class'=>'tweakcss'));
return $grouparray;
}
}
diff --git a/question/type/ddimageortext/icon.gif b/question/type/ddimageortext/pix/icon.gif
similarity index 100%
rename from question/type/ddimageortext/icon.gif
rename to question/type/ddimageortext/pix/icon.gif
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index 94d121a634b..e360fcc15fb 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -48,7 +48,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
protected function choice_options_to_feedback($choice){
$output = new stdClass;
- $output->draggroup = $choice['draggroup'];
+ $output->draggroup = $choice['choicegroup'];
$output->infinite = !empty($choice['infinite']);
return serialize($output);
}
From 303bf0190248fdc18e0382ab1fe64512da21cf93 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 2 Feb 2011 19:03:38 +0000
Subject: [PATCH 005/208] MDL-47494 ddimageortext: Finish making ddwtos work,
mostly. Also various other JS fixes.
This JavaScript really needs to be rewritten to use YUI3.
---
question/type/ddimageortext/renderer.php | 4 +++-
question/type/ddimageortext/styles.css | 9 ++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index 8f4362fed1b..8be3eeaef5a 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -127,7 +127,9 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren
public function head_code(question_attempt $qa) {
- require_js(array('yui_dom-event', 'yui_dragdrop'));
+ $this->page->requires->yui2_lib('dom');
+ $this->page->requires->yui2_lib('event');
+ $this->page->requires->yui2_lib('dragdrop');
return parent::head_code($qa);
}
diff --git a/question/type/ddimageortext/styles.css b/question/type/ddimageortext/styles.css
index 991b59e5788..8a84a09b149 100755
--- a/question/type/ddimageortext/styles.css
+++ b/question/type/ddimageortext/styles.css
@@ -1,13 +1,16 @@
.que.ddwtos .qtext {
- line-height:2em;
- margin-top: 1px;
+ line-height: 2em;
margin-bottom: 0.5em;
display: block;
}
+.que.ddwtos .qtext * {
+ line-height: 2em;
+}
+
.que.ddwtos .answercontainer {
line-height: 2em;
- margin-bottom:1em;
+ margin-bottom: 1em;
display: block;
}
From 7368987a5f7d3c5b3b1c4ef6c61266646f105370 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 9 Feb 2011 20:33:51 +0000
Subject: [PATCH 006/208] MDL-47494 ddimageortext: Images in questions now work
in quiz attempts.
---
question/type/ddimageortext/simpletest/testquestiontype.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index f8bfa87e9c6..4ef6567c5b5 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -62,6 +62,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$dd = new stdClass;
$dd->id = 0;
$dd->category = 0;
+ $dd->contextid = 0;
$dd->parent = 0;
$dd->questiontextformat = FORMAT_HTML;
$dd->generalfeedbackformat = FORMAT_HTML;
From 3919f482a72d73d40d4814338afe864d9a32a020 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Mon, 21 Feb 2011 18:10:19 +0000
Subject: [PATCH 007/208] MDL-47494 ddimageortext: Fix new stdClass ->
stdClass(), and trailing whitespace.
---
question/type/ddimageortext/questiontype.php | 4 ++--
.../type/ddimageortext/simpletest/testquestiontype.php | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index e360fcc15fb..e5078dd6be0 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -47,7 +47,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
}
protected function choice_options_to_feedback($choice){
- $output = new stdClass;
+ $output = new stdClass();
$output->draggroup = $choice['choicegroup'];
$output->infinite = !empty($choice['infinite']);
return serialize($output);
@@ -174,7 +174,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
$mul_info = $ddwtos[$i];
//Now, build the question_ddwtos record structure
- $ddwtos = new stdClass;
+ $ddwtos = new stdClass();
$ddwtos->questionid = $new_question_id;
$ddwtos->shuffleanswers = isset($mul_info['#']['SHUFFLEANSWERS']['0']['#'])?backup_todb($mul_info['#']['SHUFFLEANSWERS']['0']['#']):'';
if (array_key_exists("CORRECTFEEDBACK", $mul_info['#'])) {
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index 4ef6567c5b5..dca047ed47a 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -59,7 +59,7 @@ class qtype_ddwtos_test extends UnitTestCase {
protected function get_test_question_data() {
global $USER;
- $dd = new stdClass;
+ $dd = new stdClass();
$dd->id = 0;
$dd->category = 0;
$dd->contextid = 0;
@@ -196,7 +196,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'ddwtos');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'ddwtos';
$expectedq->name = 'A drag-and-drop question';
$expectedq->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
@@ -345,7 +345,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$q = $importer->try_importing_using_qtypes(
$xmldata['question'], null, null, 'ddwtos');
- $expectedq = new stdClass;
+ $expectedq = new stdClass();
$expectedq->qtype = 'ddwtos';
$expectedq->name = 'QDandD1 Base definition';
$expectedq->questiontext = '
Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.
At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]] mol litre-1 and pH values [[9]] than [[6]].
';
@@ -385,7 +385,7 @@ class qtype_ddwtos_test extends UnitTestCase {
}
public function test_xml_export() {
- $qdata = new stdClass;
+ $qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
$qdata->qtype = 'ddwtos';
From c205413ad932b4316200674219f78780e20542eb Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Tue, 22 Feb 2011 19:59:12 +0000
Subject: [PATCH 008/208] MDL-47494 ddimageortext: Add @package and GPL
boiler-plate to files in /question.
---
question/type/ddimageortext/script.js | 22 +++++++++++++++++++---
question/type/ddimageortext/version.php | 24 ++++++++++++++++++++++++
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/question/type/ddimageortext/script.js b/question/type/ddimageortext/script.js
index 0f0a4807959..f2c47e5a48c 100755
--- a/question/type/ddimageortext/script.js
+++ b/question/type/ddimageortext/script.js
@@ -1,11 +1,27 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
/**
* JavaScript objects, functions as well as usage of some YUI library for
* enabling drag and drop interaction for dran-anddrop words into sentences
* (ddwtos)
*
- * @package qtype_ddwtos
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
//global variables
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index ad42b28bb9e..19bbecdec14 100755
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -1,4 +1,28 @@
.
+
+/**
+ * Version information for the drag-and-drop words into sentences question type.
+ *
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
$plugin->version = 2011020100;
$plugin->requires = 2011011200;
From 5b4602d26750b97c4302941b73c3dbf5fb66e61a Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 23 Feb 2011 13:38:16 +0000
Subject: [PATCH 009/208] MDL-47494 ddimageortext: Fix @package names and
PHPdoc layout.
---
.../type/ddimageortext/edit_ddwtos_form.php | 13 +++++++------
.../type/ddimageortext/lang/en/qtype_ddwtos.php | 11 ++++-------
question/type/ddimageortext/question.php | 17 +++++++++--------
question/type/ddimageortext/questiontype.php | 14 +++++++-------
question/type/ddimageortext/renderer.php | 13 +++++++------
.../type/ddimageortext/simpletest/helper.php | 14 +++++++++++---
.../ddimageortext/simpletest/testquestion.php | 13 +++++++------
.../simpletest/testquestiontype.php | 12 ++++++------
.../simpletest/testwalkthrough.php | 17 +++++++++++------
9 files changed, 69 insertions(+), 55 deletions(-)
diff --git a/question/type/ddimageortext/edit_ddwtos_form.php b/question/type/ddimageortext/edit_ddwtos_form.php
index 222aaf08fcd..9be4ef36df4 100755
--- a/question/type/ddimageortext/edit_ddwtos_form.php
+++ b/question/type/ddimageortext/edit_ddwtos_form.php
@@ -15,23 +15,24 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Defines the editing form for the drag-and-drop words into sentences question type.
*
- * @package qtype_ddwtos
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+
require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
/**
* Drag-and-drop words into sentences editing form definition.
*
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base {
function qtype() {
diff --git a/question/type/ddimageortext/lang/en/qtype_ddwtos.php b/question/type/ddimageortext/lang/en/qtype_ddwtos.php
index aabe3852384..9ea3e7d918f 100755
--- a/question/type/ddimageortext/lang/en/qtype_ddwtos.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddwtos.php
@@ -15,17 +15,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
- * Language strings for the select missing words question type.
*
- * @package qtype
- * @subpackage gapselect
- * @copyright 2011 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
$string['addingddwtos'] = 'Adding drag and drop: words in text';
$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices';
$string['answer'] = 'Answer';
diff --git a/question/type/ddimageortext/question.php b/question/type/ddimageortext/question.php
index 18a9911cc0b..191c04e3832 100755
--- a/question/type/ddimageortext/question.php
+++ b/question/type/ddimageortext/question.php
@@ -19,9 +19,10 @@
/**
* Drag-and-drop words into sentences question definition class.
*
- * @package qtype_ddwtos
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->dirroot . '/question/type/gapselect/questionbase.php');
@@ -29,19 +30,19 @@ require_once($CFG->dirroot . '/question/type/gapselect/questionbase.php');
/**
* Represents a drag-and-drop words into sentences question.
*
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_question extends qtype_gapselect_question_base {
-//is actually exactly the same.
+ // Is actually exactly the same.
}
/**
* Represents one of the choices (draggable boxes).
*
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_choice {
public $text;
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index e5078dd6be0..fcbc0d6a2f8 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -15,27 +15,27 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Question type class for the drag-and-drop words into sentences question type.
*
- * @package qtype_ddwtos
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->dirroot . '/question/engine/lib.php');
require_once($CFG->dirroot . '/question/format/xml/format.php');
-
require_once($CFG->dirroot . '/question/type/gapselect/questiontypebase.php');
+
/**
* The drag-and-drop words into sentences question type class.
*
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos extends qtype_gapselect_base {
protected function choice_group_key(){
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index 8be3eeaef5a..fc1a5b2a9b7 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -15,23 +15,24 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Drag-and-drop words into sentences question renderer class.
*
- * @package qtype_ddwtos
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+
require_once($CFG->dirroot . '/question/type/gapselect/rendererbase.php');
/**
* Generates the output for drag-and-drop words into sentences questions.
*
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_renderer {
diff --git a/question/type/ddimageortext/simpletest/helper.php b/question/type/ddimageortext/simpletest/helper.php
index 7b814808bb5..2ee3d142df0 100755
--- a/question/type/ddimageortext/simpletest/helper.php
+++ b/question/type/ddimageortext/simpletest/helper.php
@@ -15,13 +15,21 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * Test helpers for the drag-and-drop words into sentences question type.
+ *
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
/**
* Test helper class for the drag-and-drop words into sentences question type.
*
- * @package qtype_ddwtos
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_test_helper {
/**
diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php
index db8ae7c9166..2cc02432c34 100755
--- a/question/type/ddimageortext/simpletest/testquestion.php
+++ b/question/type/ddimageortext/simpletest/testquestion.php
@@ -15,15 +15,16 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Unit tests for the drag-and-drop words into sentences question definition class.
*
- * @package qtype_ddwtos
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
@@ -31,8 +32,8 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
/**
* Unit tests for the matching question definition class.
*
- * @copyright 2009 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2009 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_question_test extends UnitTestCase {
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index dca047ed47a..3311e12ebff 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -15,13 +15,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Unit tests for the drag-and-drop words into sentences question definition class.
*
- * @package qtype_ddwtos
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -32,8 +32,8 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
/**
* Unit tests for the drag-and-drop words into sentences question definition class.
*
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddwtos_test extends UnitTestCase {
/** @var qtype_ddwtos instance of the question type class to test. */
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 4b613e70160..4b7ec380458 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -15,14 +15,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
- * This file contains tests that walks a question through the interactive
- * behaviour.
+ * Unit tests for the drag-and-drop words into sentences question type.
*
- * @package qtype_ddwtos
- * @copyright 2010 The Open University
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package qtype
+ * @subpackage ddwtos
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -30,6 +29,12 @@ require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
+/**
+ * Unit tests for the drag-and-drop words into sentences question type.
+ *
+ * @copyright 2010 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
protected function get_contains_drop_box_expectation($place, $group, $readonly, $stateclass = '0') {
From 425362802e55077a4c2fbc18039cc39e3bfb41ae Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 23 Feb 2011 15:03:35 +0000
Subject: [PATCH 010/208] MDL-47494 ddimageortext: Add missing
defined('MOODLE_INTERNAL') || die();
---
question/type/ddimageortext/edit_ddwtos_form.php | 2 ++
question/type/ddimageortext/question.php | 5 ++++-
question/type/ddimageortext/questiontype.php | 2 ++
question/type/ddimageortext/renderer.php | 2 ++
question/type/ddimageortext/simpletest/helper.php | 3 +++
question/type/ddimageortext/simpletest/testquestion.php | 2 ++
question/type/ddimageortext/simpletest/testquestiontype.php | 2 ++
question/type/ddimageortext/simpletest/testwalkthrough.php | 2 ++
question/type/ddimageortext/version.php | 2 ++
9 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/question/type/ddimageortext/edit_ddwtos_form.php b/question/type/ddimageortext/edit_ddwtos_form.php
index 9be4ef36df4..f840a6ef919 100755
--- a/question/type/ddimageortext/edit_ddwtos_form.php
+++ b/question/type/ddimageortext/edit_ddwtos_form.php
@@ -25,6 +25,8 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
diff --git a/question/type/ddimageortext/question.php b/question/type/ddimageortext/question.php
index 191c04e3832..6861858bbf3 100755
--- a/question/type/ddimageortext/question.php
+++ b/question/type/ddimageortext/question.php
@@ -15,7 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-
/**
* Drag-and-drop words into sentences question definition class.
*
@@ -25,8 +24,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->dirroot . '/question/type/gapselect/questionbase.php');
+
/**
* Represents a drag-and-drop words into sentences question.
*
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index fcbc0d6a2f8..aa03abee0f5 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -25,6 +25,8 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->dirroot . '/question/engine/lib.php');
require_once($CFG->dirroot . '/question/format/xml/format.php');
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index fc1a5b2a9b7..9c127b6fc27 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -25,6 +25,8 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->dirroot . '/question/type/gapselect/rendererbase.php');
diff --git a/question/type/ddimageortext/simpletest/helper.php b/question/type/ddimageortext/simpletest/helper.php
index 2ee3d142df0..37f28439bc6 100755
--- a/question/type/ddimageortext/simpletest/helper.php
+++ b/question/type/ddimageortext/simpletest/helper.php
@@ -25,6 +25,9 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
+
/**
* Test helper class for the drag-and-drop words into sentences question type.
*
diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php
index 2cc02432c34..00329ff3c6c 100755
--- a/question/type/ddimageortext/simpletest/testquestion.php
+++ b/question/type/ddimageortext/simpletest/testquestion.php
@@ -25,6 +25,8 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index 3311e12ebff..1fe729aa416 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -25,6 +25,8 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 4b7ec380458..38ead171d94 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -25,6 +25,8 @@
*/
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index 19bbecdec14..94b1fbeabdf 100755
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -24,5 +24,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+defined('MOODLE_INTERNAL') || die();
+
$plugin->version = 2011020100;
$plugin->requires = 2011011200;
From 453aded6c2e95e121a742c38043102472759cf1e Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 23 Feb 2011 18:53:50 +0000
Subject: [PATCH 011/208] MDL-47494 ddimageortext: Massively reduce the number
of references to quiz in the question code.
This mostly involves moving lang strings around, but I don't have time to do an AMOS script now.
---
question/type/ddimageortext/script.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/question/type/ddimageortext/script.js b/question/type/ddimageortext/script.js
index f2c47e5a48c..bf84942f3a7 100755
--- a/question/type/ddimageortext/script.js
+++ b/question/type/ddimageortext/script.js
@@ -30,12 +30,12 @@ var ddwtos_currentzindex = 10;
/*
* The way it seems to be, if there are more than one of this type of question
- * in a quiz, then this file is shared between them. Therefore it has to cope
+ * on a page, then this file is shared between them. Therefore it has to cope
* with ALL the questions of this type on the page.
*/
(function() {
- // start of App object SHARED BY ALL QUESTIONS OF THIS TYPE IN THE QUIZ /////
+ // start of App object by all questions of this type on a page.
YAHOO.example.DDApp = {
init : function() {
var questionspans = YAHOO.util.Dom.getElementsByClassName("ddwtos_questionid_for_javascript");
@@ -43,7 +43,7 @@ var ddwtos_currentzindex = 10;
// we need this loop in case of more than one of this qtype on one page
for (var i = 0; i < questionspans.length; i++) {
// The Questions object should now contain a QuestionDataObject
- //object for each question of this type in the quiz.
+ // object for each question of this type on the page.
Questions[questionspans[i].id] = new QuestionDataObject(questionspans[i].id);
}
From 81f5dc53f132976531bc5e151c765f98c36eb572 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Thu, 24 Feb 2011 19:12:42 +0000
Subject: [PATCH 012/208] MDL-47494 ddimageortext: Split
question_definition::init_first_step into start_attempt and
apply_attempt_state.
---
.../ddimageortext/simpletest/testquestion.php | 32 +++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php
index 00329ff3c6c..9bce14087fa 100755
--- a/question/type/ddimageortext/simpletest/testquestion.php
+++ b/question/type/ddimageortext/simpletest/testquestion.php
@@ -55,7 +55,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_summarise_response() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual('{quick} {fox} {lazy}',
$dd->summarise_response(array('p1' => '1', 'p2' => '1', 'p3' => '1')));
@@ -64,7 +64,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_summarise_response_maths() {
$dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual('{+} {-} {+} {-}',
$dd->summarise_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')));
@@ -83,7 +83,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_right_choice_for() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(1, $dd->get_right_choice_for(1));
$this->assertEqual(1, $dd->get_right_choice_for(2));
@@ -92,7 +92,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_right_choice_for_maths() {
$dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(1, $dd->get_right_choice_for(1));
$this->assertEqual(2, $dd->get_right_choice_for(2));
@@ -101,7 +101,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_clear_wrong_from_response() {
$dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$initialresponse = array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1');
$this->assertEqual(array('p1' => '1', 'p2' => '0', 'p3' => '1', 'p4' => '0'),
@@ -111,7 +111,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_num_parts_right() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array(2, 3),
$dd->get_num_parts_right(array('p1' => '1', 'p2' => '1', 'p3' => '2')));
@@ -122,7 +122,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_num_parts_right_maths() {
$dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array(2, 4),
$dd->get_num_parts_right(array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1')));
@@ -130,7 +130,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_expected_data() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT),
$dd->get_expected_data());
@@ -139,7 +139,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_correct_response() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array('p1' => '1', 'p2' => '1', 'p3' => '1'),
$dd->get_correct_response());
@@ -148,7 +148,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_correct_response_maths() {
$dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'),
$dd->get_correct_response());
@@ -156,7 +156,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_is_same_response() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertTrue($dd->is_same_response(
array(),
@@ -180,7 +180,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_is_complete_response() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertFalse($dd->is_complete_response(array()));
$this->assertFalse($dd->is_complete_response(
@@ -192,7 +192,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_is_gradable_response() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertFalse($dd->is_gradable_response(array()));
$this->assertFalse($dd->is_gradable_response(
@@ -207,7 +207,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_grading() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array(1, question_state::$gradedright),
$dd->grade_response(array('p1' => '1', 'p2' => '1', 'p3' => '1')));
@@ -220,7 +220,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_grading_maths() {
$dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array(1, question_state::$gradedright),
$dd->grade_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')));
@@ -233,7 +233,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_classify_response() {
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->shufflechoices = false;
- $dd->init_first_step(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step());
$this->assertEqual(array(
1 => new question_classified_response(1, 'quick', 1),
From 01bac81a41f679fab02b70adeeee459ee7948ab6 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Mon, 28 Feb 2011 10:49:20 +0000
Subject: [PATCH 013/208] MDL-47494 ddimageortext: Update quiz and questions
backup and restore.
This does not include user data yet, and it needs more testing.
---
.../backup_qtype_ddwtos_plugin.class.php | 84 +++++++++++
.../restore_qtype_ddwtos_plugin.class.php | 136 ++++++++++++++++++
2 files changed, 220 insertions(+)
create mode 100755 question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
create mode 100755 question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
new file mode 100755
index 00000000000..a86b6b33655
--- /dev/null
+++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
@@ -0,0 +1,84 @@
+.
+
+/**
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+
+/**
+ * Provides the information to backup ddwtos questions
+ *
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class backup_qtype_ddwtos_plugin extends backup_qtype_plugin {
+
+ /**
+ * Returns the qtype information to attach to question element
+ */
+ protected function define_question_plugin_structure() {
+
+ // Define the virtual plugin element with the condition to fulfill
+ $plugin = $this->get_plugin_element(null, '../../qtype', 'ddwtos');
+
+ // Create one standard named plugin element (the visible container)
+ $pluginwrapper = new backup_nested_element($this->get_recommended_name());
+
+ // connect the visible container ASAP
+ $plugin->add_child($pluginwrapper);
+
+ // This qtype uses standard question_answers, add them here
+ // to the tree before any other information that will use them
+ $this->add_question_question_answers($pluginwrapper);
+
+ // Now create the qtype own structures
+ $ddwtos = new backup_nested_element('ddwtos', array('id'), array(
+ 'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
+ 'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
+ 'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));
+
+ // Now the own qtype tree
+ $pluginwrapper->add_child($ddwtos);
+
+ // set source to populate the data
+ $ddwtos->set_source_table('question_ddwtos', array('questionid' => backup::VAR_PARENTID));
+
+ // don't need to annotate ids nor files
+
+ return $plugin;
+ }
+
+ /**
+ * Returns one array with filearea => mappingname elements for the qtype
+ *
+ * Used by {@link get_components_and_fileareas} to know about all the qtype
+ * files to be processed both in backup and restore.
+ */
+ public static function get_qtype_fileareas() {
+ return array(
+ 'correctfeedback' => 'question_created',
+ 'partiallycorrectfeedback' => 'question_created',
+ 'incorrectfeedback' => 'question_created');
+ }
+}
diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
new file mode 100755
index 00000000000..786ec45e5cd
--- /dev/null
+++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
@@ -0,0 +1,136 @@
+.
+
+/**
+ * @package moodlecore
+ * @subpackage backup-moodle2
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+
+defined('MOODLE_INTERNAL') || die();
+
+
+/**
+ * restore plugin class that provides the necessary information
+ * needed to restore one ddwtos qtype plugin
+ *
+ * @copyright 2011 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
+
+ /**
+ * Returns the paths to be handled by the plugin at question level
+ */
+ protected function define_question_plugin_structure() {
+
+ $paths = array();
+
+ // This qtype uses question_answers, add them
+ $this->add_question_question_answers($paths);
+
+ // Add own qtype stuff
+ $elename = 'ddwtos';
+ $elepath = $this->get_pathfor('/ddwtos'); // we used get_recommended_name() so this works
+ $paths[] = new restore_path_element($elename, $elepath);
+
+
+ return $paths; // And we return the interesting paths
+ }
+
+ /**
+ * Process the qtype/ddwtos element
+ */
+ public function process_ddwtos($data) {
+ global $DB;
+
+ $data = (object)$data;
+ $oldid = $data->id;
+
+ // Detect if the question is created or mapped
+ $oldquestionid = $this->get_old_parentid('question');
+ $newquestionid = $this->get_new_parentid('question');
+ $questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;
+
+ // If the question has been created by restore, we need to create its question_ddwtos too
+ if ($questioncreated) {
+ // Adjust some columns
+ $data->questionid = $newquestionid;
+ // Insert record
+ $newitemid = $DB->insert_record('question_ddwtos', $data);
+ // Create mapping (needed for decoding links)
+ $this->set_mapping('question_ddwtos', $oldid, $newitemid);
+ } else {
+ // Nothing to remap if the question already existed
+ }
+ }
+
+ /**
+ * Given one question_states record, return the answer
+ * recoded pointing to all the restored stuff for ddwtos questions
+ *
+ * answer are two (hypen speparated) lists of comma separated question_answers
+ * the first to specify the order of the answers and the second to specify the
+ * responses. Note the order list (the first one) can be optional
+ */
+ public function recode_state_answer($state) {
+ $answer = $state->answer;
+ $orderarr = array();
+ $responsesarr = array();
+ $lists = explode(':', $answer);
+ // if only 1 list, answer is missing the order list, adjust
+ if (count($lists) == 1) {
+ $lists[1] = $lists[0]; // here we have the responses
+ $lists[0] = ''; // here we have the order
+ }
+ // Map order
+ foreach (explode(',', $lists[0]) as $id) {
+ if (!empty($id) && $newid = $this->get_mappingid('question_answer', $id)) {
+ $orderarr[] = $newid;
+ }
+ }
+ // Map responses
+ foreach (explode(',', $lists[1]) as $id) {
+ if (!empty($id) && $newid = $this->get_mappingid('question_answer', $id)) {
+ $responsesarr[] = $newid;
+ }
+ }
+ // Build the final answer, if not order, only responses
+ $result = '';
+ if (empty($orderarr)) {
+ $result = implode(',', $responsesarr);
+ } else {
+ $result = implode(',', $orderarr) . ':' . implode(',', $responsesarr);
+ }
+ return $result;
+ }
+
+ /**
+ * Return the contents of this qtype to be processed by the links decoder
+ */
+ static public function define_decode_contents() {
+
+ $contents = array();
+
+ $fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
+ $contents[] = new restore_decode_content('question_ddwtos', $fields, 'question_ddwtos');
+
+ return $contents;
+ }
+}
From c9826b0a304b87d9b4276fa0fa9403192001c9b8 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 23 Mar 2011 14:27:22 +0000
Subject: [PATCH 014/208] MDL-47494 ddimageortext: Question import, support for
files in hints.
Also fix some minor bugs and unit tests.
---
question/type/ddimageortext/questiontype.php | 4 +-
.../simpletest/testquestiontype.php | 37 +++++++++++--------
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index aa03abee0f5..3bda33afea6 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -86,7 +86,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
foreach ($data['#']['dragbox'] as $dragboxxml) {
$question->choices[] = array(
'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true),
- 'draggroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1),
+ 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1),
'infinite' => array_key_exists('infinite', $dragboxxml['#']),
);
}
@@ -98,7 +98,7 @@ class qtype_ddwtos extends qtype_gapselect_base {
$options = unserialize(stripslashes($ans->feedback['text']));
$question->choices[] = array(
'answer' => $ans->answer,
- 'draggroup' => $options->draggroup,
+ 'choicegroup' => $options->draggroup,
'infinite' => $options->infinite,
);
}
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index 1fe729aa416..ee8dc7883fc 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -215,12 +215,14 @@ class qtype_ddwtos_test extends UnitTestCase {
$expectedq->incorrectfeedback = array('text' => '
',
+ 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->choices = array(
array('answer' => 'Alpha', 'choicegroup' => 1, 'infinite' => false),
@@ -222,7 +232,8 @@ class qtype_ddwtos_test extends UnitTestCase {
$expectedq->hint = array(
array('text' => 'Try again.', 'format' => FORMAT_MOODLE, 'files' => array()),
- array('text' => 'These are the first three letters of the Greek alphabet.', 'format' => FORMAT_MOODLE, 'files' => array()));
+ array('text' => 'These are the first three letters of the Greek alphabet.',
+ 'format' => FORMAT_MOODLE, 'files' => array()));
$expectedq->hintshownumcorrect = array(true, true);
$expectedq->hintclearwrong = array(false, true);
@@ -235,11 +246,19 @@ class qtype_ddwtos_test extends UnitTestCase {
QDandD1 Base definition
- <p>Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.</p> <p>At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> <!--DONOTCLEAN-->
+ <p>Drag and drop the words from the list below to fill the blank spaces ' .
+ 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' .
+ 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' .
+ 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' .
+ '<!--DONOTCLEAN-->
- <p>At 25 °C all aqueous basic solutions have hydrogen ion concentrations less than 10<sup>−7</sup> mol litre<sup>−1</sup> and pH values greater than 7.</p> <p>See Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p>
+ <p>At 25 °C all aqueous basic solutions have hydrogen ion ' .
+ 'concentrations less than 10<sup>−7</sup> mol ' .
+ 'litre<sup>−1</sup> and pH values greater than 7.</p> ' .
+ '<p>See Section 9 of S103 <em class="italic">Discovering ' .
+ 'Science</em> Block 8.</p>10.33
@@ -332,7 +351,8 @@ class qtype_ddwtos_test extends UnitTestCase {
10
- You may wish to read Section 9 of <em class="italic">Discovering Science</em> Block 8.
+ You may wish to read Section 9 of <em ' .
+ 'class="italic">Discovering Science</em> Block 8.
@@ -352,36 +372,57 @@ class qtype_ddwtos_test extends UnitTestCase {
$expectedq = new stdClass();
$expectedq->qtype = 'ddwtos';
$expectedq->name = 'QDandD1 Base definition';
- $expectedq->questiontext = '
Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.
At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]] mol litre-1 and pH values [[9]] than [[6]].
';
+ $expectedq->questiontext = '
Drag and drop the words from the list below ' .
+ 'to fill the blank spaces and correctly complete the sentence.
' .
+ '
At 25°C all aqueous basic solutions have [[1]] ion concentrations ' .
+ 'less than [[8]] mol litre-1 and pH values [[9]] than [[6]].
At 25 °C all aqueous basic solutions have hydrogen ion concentrations less than 10−7 mol litre−1 and pH values greater than 7.
See Section 9 of S103 Discovering Science Block 8.
';
+ $expectedq->generalfeedback = '
At 25 °C all aqueous basic solutions ' .
+ 'have hydrogen ion concentrations less than 10−7 ' .
+ 'mol litre−1 and pH values greater than 7.
See ' .
+ 'Section 9 of S103 Discovering Science Block 8.
';
$expectedq->defaultmark = 1;
$expectedq->length = 1;
$expectedq->penalty = 0.3333333;
$expectedq->shuffleanswers = 0;
- $expectedq->correctfeedback = array('text' => 'Your answer is correct.', 'format' => FORMAT_MOODLE, 'files' => array());
- $expectedq->partiallycorrectfeedback = array('text' => 'Your answer is partially correct.', 'format' => FORMAT_MOODLE, 'files' => array());
+ $expectedq->correctfeedback = array('text' => 'Your answer is correct.',
+ 'format' => FORMAT_MOODLE, 'files' => array());
+ $expectedq->partiallycorrectfeedback = array(
+ 'text' => 'Your answer is partially correct.',
+ 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->shownumcorrect = true;
- $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', 'format' => FORMAT_MOODLE, 'files' => array());
+ $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.',
+ 'format' => FORMAT_MOODLE, 'files' => array());
$expectedq->choices = array(
- array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
- array('answer' => array('text' => 'positive', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
- array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
- array('answer' => array('text' => 'negative', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
- array('answer' => array('text' => '107', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
- array('answer' => array('text' => '7', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
- array('answer' => array('text' => '1', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
- array('answer' => array('text' => '10-7', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
- array('answer' => array('text' => 'greater', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 3, 'infinite' => false),
- array('answer' => array('text' => 'less', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 3, 'infinite' => false),
+ array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => 'positive', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => 'negative', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 1, 'infinite' => false),
+ array('answer' => array('text' => '107', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => '7', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => '1', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => '10-7', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 2, 'infinite' => false),
+ array('answer' => array('text' => 'greater', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 3, 'infinite' => false),
+ array('answer' => array('text' => 'less', 'format' => FORMAT_MOODLE,
+ 'files' => array()), 'choicegroup' => 3, 'infinite' => false),
);
- $expectedq->hint = array(
- array('text' => 'You may wish to read Section 9 of Discovering Science Block 8.',
+ $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' .
+ 'Discovering Science Block 8.',
'format' => FORMAT_HTML, 'files' => array()),
- array('text' => 'Any incorrect choices will be removed before your final try.',
+ array('text' => 'Any incorrect choices will be removed before your final try.',
'format' => FORMAT_HTML, 'files' => array()),
);
$expectedq->hintshownumcorrect = array(true, true);
@@ -416,14 +457,22 @@ class qtype_ddwtos_test extends UnitTestCase {
$qdata->options->incorrectfeedbackformat = FORMAT_MOODLE;
$qdata->options->answers = array(
- 13 => new question_answer(13, 'Alpha', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE),
- 14 => new question_answer(14, 'Beta', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE),
- 15 => new question_answer(15, 'Gamma', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}', FORMAT_MOODLE),
+ 13 => new question_answer(13, 'Alpha', 0,
+ 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}',
+ FORMAT_MOODLE),
+ 14 => new question_answer(14, 'Beta', 0,
+ 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}',
+ FORMAT_MOODLE),
+ 15 => new question_answer(15, 'Gamma', 0,
+ 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}',
+ FORMAT_MOODLE),
);
$qdata->hints = array(
1 => new question_hint_with_parts(1, 'Try again.', FORMAT_MOODLE, true, false),
- 2 => new question_hint_with_parts(2, 'These are the first three letters of the Greek alphabet.', FORMAT_MOODLE, true, true),
+ 2 => new question_hint_with_parts(2,
+ 'These are the first three letters of the Greek alphabet.',
+ FORMAT_MOODLE, true, true),
);
$exporter = new qformat_xml();
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 38ead171d94..79421f3d88d 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -39,7 +39,8 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
*/
class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
- protected function get_contains_drop_box_expectation($place, $group, $readonly, $stateclass = '0') {
+ protected function get_contains_drop_box_expectation($place, $group, $readonly,
+ $stateclass = '0') {
$qa = $this->quba->get_question_attempt($this->slot);
$expectedattrs = array(
@@ -77,9 +78,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -95,9 +99,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '2'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '2'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '2'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation(),
@@ -117,7 +124,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_submit_button_expectation(false),
$this->get_contains_try_again_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
- new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
+ new PatternExpectation('/' .
+ preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
$this->get_contains_hint_expectation('This is the first hint'));
// Do try again.
@@ -130,9 +138,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '2'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '2'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '2'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation(),
@@ -175,9 +186,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_feedback_expectation());
// Save a partial answer.
@@ -190,9 +204,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '2'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -206,9 +223,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '1'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -249,9 +269,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
$this->check_step_count(1);
@@ -266,9 +289,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
$this->check_step_count(1);
@@ -299,9 +325,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -315,9 +344,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -339,8 +371,10 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts(1, 'This is the first hint.', FORMAT_MOODLE, true, true),
- new question_hint_with_parts(2, 'This is the second hint.', FORMAT_MOODLE, true, true),
+ new question_hint_with_parts(1, 'This is the first hint.',
+ FORMAT_MOODLE, true, true),
+ new question_hint_with_parts(2, 'This is the second hint.',
+ FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 9);
@@ -354,9 +388,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -376,18 +413,23 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_submit_button_expectation(false),
$this->get_contains_try_again_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
- new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
+ new PatternExpectation('/' .
+ preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
$this->get_contains_hint_expectation('This is the first hint'),
$this->get_contains_num_parts_correct(2),
$this->get_contains_standard_partiallycorrect_combined_feedback_expectation(),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'));
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'));
// Check that extract responses will return the reset data.
$prefix = $this->quba->get_field_prefix($this->slot);
$this->assertEqual(array('p1' => '1', 'p2' => '1'),
- $this->quba->extract_responses($this->slot, array($prefix . 'p1' => '1', $prefix . 'p2' => '1', '-tryagain' => 1)));
+ $this->quba->extract_responses($this->slot,
+ array($prefix . 'p1' => '1', $prefix . 'p2' => '1', '-tryagain' => 1)));
// Do try again.
$this->process_submission(array('p1' => '1', 'p2' => '1', '-tryagain' => 1));
@@ -399,9 +441,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_correctness_expectation(),
@@ -422,13 +467,17 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_submit_button_expectation(false),
$this->get_contains_try_again_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
- new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
+ new PatternExpectation('/' .
+ preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
$this->get_contains_hint_expectation('This is the second hint'),
$this->get_contains_num_parts_correct(2),
$this->get_contains_standard_partiallycorrect_combined_feedback_expectation(),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1'));
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '1'));
// Do try again.
$this->process_submission(array('p1' => '1', 'p3' => '1', '-tryagain' => 1));
@@ -440,9 +489,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '1'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_correctness_expectation(),
@@ -466,9 +518,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_no_hint_visible_expectation(),
$this->get_does_not_contain_num_parts_correct(),
$this->get_contains_standard_correct_combined_feedback_expectation(),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1'));
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '1'));
}
public function test_interactive_correct_no_submit() {
@@ -476,8 +531,10 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false),
- new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
+ new question_hint_with_parts(23, 'This is the first hint.',
+ FORMAT_MOODLE, false, false),
+ new question_hint_with_parts(24, 'This is the second hint.',
+ FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
@@ -489,9 +546,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -527,8 +587,10 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
// Create a drag-and-drop question.
$dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
$dd->hints = array(
- new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false),
- new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
+ new question_hint_with_parts(23, 'This is the first hint.',
+ FORMAT_MOODLE, false, false),
+ new question_hint_with_parts(24, 'This is the second hint.',
+ FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'interactive', 3);
@@ -540,9 +602,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -592,9 +657,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -625,9 +693,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(2),
@@ -647,9 +718,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
$this->get_does_not_contain_feedback_expectation());
// Save a partial answer.
@@ -662,9 +736,15 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
$this->get_contains_drop_box_expectation('p3', 3, false),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', $dd->get_right_choice_for(1)),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', $dd->get_right_choice_for(2)),
- $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', $dd->get_right_choice_for(3)),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1',
+ $dd->get_right_choice_for(1)),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2',
+ $dd->get_right_choice_for(2)),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3',
+ $dd->get_right_choice_for(3)),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -681,6 +761,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
$this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
$this->get_contains_correct_expectation(),
- new PatternExpectation('/' . preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/'));
+ new PatternExpectation('/' .
+ preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/'));
}
}
From 46b0a9735c5cd2d6ff33b8f5f23af8293cabce55 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Tue, 29 Mar 2011 16:29:54 +0100
Subject: [PATCH 017/208] MDL-47494 ddimageortext: Better way of handling the
creation of test questions for different question types.
---
.../type/ddimageortext/simpletest/helper.php | 10 +++--
.../ddimageortext/simpletest/testquestion.php | 40 +++++++++----------
.../simpletest/testquestiontype.php | 4 +-
.../simpletest/testwalkthrough.php | 18 ++++-----
4 files changed, 38 insertions(+), 34 deletions(-)
diff --git a/question/type/ddimageortext/simpletest/helper.php b/question/type/ddimageortext/simpletest/helper.php
index 37f28439bc6..d988693ac72 100755
--- a/question/type/ddimageortext/simpletest/helper.php
+++ b/question/type/ddimageortext/simpletest/helper.php
@@ -34,11 +34,15 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_test_helper {
+class qtype_ddwtos_test_helper extends question_test_helper {
+ public function get_test_questions() {
+ return array('fox', 'maths');
+ }
+
/**
* @return qtype_ddwtos_question
*/
- public static function make_a_ddwtos_question() {
+ public function make_ddwtos_question_fox() {
question_bank::load_question_definition_classes('ddwtos');
$dd = new qtype_ddwtos_question();
@@ -75,7 +79,7 @@ class qtype_ddwtos_test_helper {
/**
* @return qtype_ddwtos_question
*/
- public static function make_a_maths_ddwtos_question() {
+ public function make_ddwtos_question_maths() {
question_bank::load_question_definition_classes('ddwtos');
$dd = new qtype_ddwtos_question();
diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php
index a32cfda3375..2a5103024a0 100755
--- a/question/type/ddimageortext/simpletest/testquestion.php
+++ b/question/type/ddimageortext/simpletest/testquestion.php
@@ -40,21 +40,21 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_question_summary() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$this->assertEqual('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' .
'[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}',
$dd->get_question_summary());
}
public function test_get_question_summary_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$this->assertEqual('Fill in the operators to make this equation work: ' .
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}',
$dd->get_question_summary());
}
public function test_summarise_response() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -63,7 +63,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_summarise_response_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -72,17 +72,17 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_random_guess_score() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$this->assertEqual(0.5, $dd->get_random_guess_score());
}
public function test_get_random_guess_score_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$this->assertEqual(0.25, $dd->get_random_guess_score());
}
public function test_get_right_choice_for() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -91,7 +91,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_right_choice_for_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -100,7 +100,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_clear_wrong_from_response() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -110,7 +110,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_num_parts_right() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -121,7 +121,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_num_parts_right_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -131,7 +131,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_expected_data() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->start_attempt(new question_attempt_step());
$this->assertEqual(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT),
@@ -139,7 +139,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_correct_response() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -148,7 +148,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_correct_response_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -157,7 +157,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_is_same_response() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->start_attempt(new question_attempt_step());
$this->assertTrue($dd->is_same_response(
@@ -181,7 +181,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
array('p1' => '1', 'p2' => '2', 'p3' => '2')));
}
public function test_is_complete_response() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->start_attempt(new question_attempt_step());
$this->assertFalse($dd->is_complete_response(array()));
@@ -193,7 +193,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_is_gradable_response() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->start_attempt(new question_attempt_step());
$this->assertFalse($dd->is_gradable_response(array()));
@@ -207,7 +207,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_grading() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -220,7 +220,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_grading_maths() {
- $dd = qtype_ddwtos_test_helper::make_a_maths_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
@@ -233,7 +233,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_classify_response() {
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step());
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index e87315c6e70..42e4d17ec77 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -56,7 +56,7 @@ class qtype_ddwtos_test extends UnitTestCase {
/**
* @return object the data to construct a question like
- * {@link qtype_ddwtos_test_helper::make_a_ddwtos_question()}.
+ * {@link qtype_ddwtos_test_helper::make_ddwtos_question_fox()}.
*/
protected function get_test_question_data() {
global $USER;
@@ -117,7 +117,7 @@ class qtype_ddwtos_test extends UnitTestCase {
public function test_initialise_question_instance() {
$qdata = $this->get_test_question_data();
- $expected = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $expected = test_question_maker::make_question('ddwtos');
$expected->stamp = $qdata->stamp;
$expected->version = $qdata->version;
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 79421f3d88d..11adf6388b0 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -63,7 +63,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_behaviour() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->hints = array(
new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
@@ -175,7 +175,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_deferred_feedback() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
@@ -258,7 +258,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_deferred_feedback_unanswered() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
@@ -314,7 +314,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_deferred_feedback_partial_answer() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
@@ -369,7 +369,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_grading() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->hints = array(
new question_hint_with_parts(1, 'This is the first hint.',
FORMAT_MOODLE, true, true),
@@ -529,7 +529,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_correct_no_submit() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->hints = array(
new question_hint_with_parts(23, 'This is the first hint.',
FORMAT_MOODLE, false, false),
@@ -585,7 +585,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_partial_no_submit() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->hints = array(
new question_hint_with_parts(23, 'This is the first hint.',
FORMAT_MOODLE, false, false),
@@ -641,7 +641,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_no_right_clears() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$dd->hints = array(
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true),
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
@@ -708,7 +708,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_display_of_right_answer_when_shuffled() {
// Create a drag-and-drop question.
- $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question();
+ $dd = test_question_maker::make_question('ddwtos');
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
// Check the initial state.
From 332641ac7243ae67ab9b7dd7a0afb852a8651e25 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 27 Apr 2011 18:00:14 +0100
Subject: [PATCH 018/208] MDL-47494 ddimageortext: numerical qtype: assorted
changes
1. database upgrade to merge instructions into the questiontext field,
and remove the UNITDISPLAY option.
2. Changes to the validation in deferred feedback mode, so students
are warned about incomplete answers.
3. Using this to wark students if they enter an answer that is not
recognised as a number.
---
question/type/ddimageortext/simpletest/testwalkthrough.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index 11adf6388b0..1435dd1e0f5 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -198,7 +198,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->process_submission(array('p1' => '1', 'p2' => '2'));
// Verify.
- $this->check_current_state(question_state::$todo);
+ $this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
@@ -338,7 +338,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
$this->process_submission(array('p1' => '1', 'p2' => '0', 'p3' => '0'));
// Verify.
- $this->check_current_state(question_state::$todo);
+ $this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
From f32281ebf6e41e10b0183f1f49b27166911ac896 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Thu, 5 May 2011 21:26:25 +0100
Subject: [PATCH 019/208] MDL-47494 ddimageortext: Finished backup and restore
of attempt data. Yay
---
.../restore_qtype_ddwtos_plugin.class.php | 40 -------------------
1 file changed, 40 deletions(-)
diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
index ddf034ff12b..51981fa96f1 100755
--- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
@@ -78,46 +78,6 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
}
}
- /**
- * Given one question_states record, return the answer
- * recoded pointing to all the restored stuff for ddwtos questions
- *
- * answer are two (hypen speparated) lists of comma separated question_answers
- * the first to specify the order of the answers and the second to specify the
- * responses. Note the order list (the first one) can be optional
- */
- public function recode_state_answer($state) {
- $answer = $state->answer;
- $orderarr = array();
- $responsesarr = array();
- $lists = explode(':', $answer);
- // if only 1 list, answer is missing the order list, adjust
- if (count($lists) == 1) {
- $lists[1] = $lists[0]; // here we have the responses
- $lists[0] = ''; // here we have the order
- }
- // Map order
- foreach (explode(',', $lists[0]) as $id) {
- if (!empty($id) && $newid = $this->get_mappingid('question_answer', $id)) {
- $orderarr[] = $newid;
- }
- }
- // Map responses
- foreach (explode(',', $lists[1]) as $id) {
- if (!empty($id) && $newid = $this->get_mappingid('question_answer', $id)) {
- $responsesarr[] = $newid;
- }
- }
- // Build the final answer, if not order, only responses
- $result = '';
- if (empty($orderarr)) {
- $result = implode(',', $responsesarr);
- } else {
- $result = implode(',', $orderarr) . ':' . implode(',', $responsesarr);
- }
- return $result;
- }
-
/**
* Return the contents of this qtype to be processed by the links decoder
*/
From bc4f8bcb79e2b07e34c5034af8b01b4ba3ec784b Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Thu, 12 May 2011 23:18:47 +0100
Subject: [PATCH 020/208] MDL-47494 ddimageortext: MDL-27408 update all
question and quiz plugin version.php files.
---
question/type/ddimageortext/version.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index 94b1fbeabdf..3b9e628090c 100755
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -26,5 +26,5 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2011020100;
-$plugin->requires = 2011011200;
+$plugin->version = 2011051200;
+$plugin->requires = 2011051212;
From fa4a86a3e5d446c1cedeb78101c7bbad64f1ebeb Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Sat, 14 May 2011 22:53:25 +0100
Subject: [PATCH 021/208] MDL-47494 ddimageortext: Fix some more codechecker
issues.
---
.../backup/moodle2/backup_qtype_ddwtos_plugin.class.php | 1 -
.../backup/moodle2/restore_qtype_ddwtos_plugin.class.php | 1 -
question/type/ddimageortext/edit_ddwtos_form.php | 1 -
question/type/ddimageortext/lang/en/qtype_ddwtos.php | 1 -
question/type/ddimageortext/question.php | 1 -
question/type/ddimageortext/questiontype.php | 1 -
question/type/ddimageortext/renderer.php | 1 -
question/type/ddimageortext/simpletest/helper.php | 1 -
question/type/ddimageortext/simpletest/testquestion.php | 1 -
question/type/ddimageortext/simpletest/testquestiontype.php | 1 -
question/type/ddimageortext/simpletest/testwalkthrough.php | 1 -
question/type/ddimageortext/version.php | 1 -
12 files changed, 12 deletions(-)
diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
index a86b6b33655..89cb186f836 100755
--- a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
@@ -1,5 +1,4 @@
Date: Sun, 15 May 2011 23:07:56 +0100
Subject: [PATCH 022/208] MDL-47494 ddimageortext: Add a readme file.
---
question/type/ddimageortext/README.txt | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 question/type/ddimageortext/README.txt
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
new file mode 100644
index 00000000000..5a8629c0845
--- /dev/null
+++ b/question/type/ddimageortext/README.txt
@@ -0,0 +1,11 @@
+Drag-and-drop, words to sentences question type
+
+This question type requires that gapselect question type
+https://github.com/timhunt/moodle-qtype_gapselect/
+to be installed in order to work.
+
+This question type was originally the work of Mahmoud Kassaei at
+the Open University (http://www.open.ac.uk/).
+It was updated to work with the Moodle 2.1 question engine by Tim Hunt.
+It was then refactored extenstively by Jamie Pratt (http://jamiep.org/)
+as part of creating the gapselect question type.
From 47b5deb6aed2e1aac1112a040db37e23d8a449d0 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Mon, 16 May 2011 05:01:14 -0700
Subject: [PATCH 023/208] MDL-47494 ddimageortext: Updated the readme file to
add install instructions.
---
question/type/ddimageortext/README.txt | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
index 5a8629c0845..dc15e0fe630 100644
--- a/question/type/ddimageortext/README.txt
+++ b/question/type/ddimageortext/README.txt
@@ -9,3 +9,15 @@ the Open University (http://www.open.ac.uk/).
It was updated to work with the Moodle 2.1 question engine by Tim Hunt.
It was then refactored extenstively by Jamie Pratt (http://jamiep.org/)
as part of creating the gapselect question type.
+
+
+This question type is compatible with Moodle 2.1+.
+
+To install using git, type this command in the root of your Moodle install
+ git clone git://github.com/timhunt/moodle-qtype_ddwtos.git question/type/ddwtos
+Then add question/type/ddwtosto your git ignore.
+
+Alternatively, download the zip from
+ https://github.com/timhunt/moodle-qtype_ddwtos/zipball/master
+unzip it into the question/type folder, and then rename the new folder to
+ddwtos.
From a8448b3f797b3fd4d1b6467e85862756bdba2aa4 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Thu, 26 May 2011 22:08:03 +0100
Subject: [PATCH 024/208] MDL-47494 ddimageortext: Implement the new variants
handling.
---
.../ddimageortext/simpletest/testquestion.php | 32 +++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php
index c7f27d76db6..58fea4279cf 100755
--- a/question/type/ddimageortext/simpletest/testquestion.php
+++ b/question/type/ddimageortext/simpletest/testquestion.php
@@ -55,7 +55,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_summarise_response() {
$dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual('{quick} {fox} {lazy}',
$dd->summarise_response(array('p1' => '1', 'p2' => '1', 'p3' => '1')));
@@ -64,7 +64,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_summarise_response_maths() {
$dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual('{+} {-} {+} {-}',
$dd->summarise_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')));
@@ -83,7 +83,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_right_choice_for() {
$dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(1, $dd->get_right_choice_for(1));
$this->assertEqual(1, $dd->get_right_choice_for(2));
@@ -92,7 +92,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_right_choice_for_maths() {
$dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(1, $dd->get_right_choice_for(1));
$this->assertEqual(2, $dd->get_right_choice_for(2));
@@ -101,7 +101,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_clear_wrong_from_response() {
$dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$initialresponse = array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1');
$this->assertEqual(array('p1' => '1', 'p2' => '0', 'p3' => '1', 'p4' => '0'),
@@ -111,7 +111,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_num_parts_right() {
$dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(2, 3),
$dd->get_num_parts_right(array('p1' => '1', 'p2' => '1', 'p3' => '2')));
@@ -122,7 +122,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_num_parts_right_maths() {
$dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(2, 4),
$dd->get_num_parts_right(array(
@@ -131,7 +131,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_expected_data() {
$dd = test_question_maker::make_question('ddwtos');
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT),
$dd->get_expected_data());
@@ -140,7 +140,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_correct_response() {
$dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array('p1' => '1', 'p2' => '1', 'p3' => '1'),
$dd->get_correct_response());
@@ -149,7 +149,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_get_correct_response_maths() {
$dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'),
$dd->get_correct_response());
@@ -157,7 +157,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_is_same_response() {
$dd = test_question_maker::make_question('ddwtos');
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertTrue($dd->is_same_response(
array(),
@@ -181,7 +181,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_is_complete_response() {
$dd = test_question_maker::make_question('ddwtos');
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertFalse($dd->is_complete_response(array()));
$this->assertFalse($dd->is_complete_response(
@@ -193,7 +193,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_is_gradable_response() {
$dd = test_question_maker::make_question('ddwtos');
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertFalse($dd->is_gradable_response(array()));
$this->assertFalse($dd->is_gradable_response(
@@ -208,7 +208,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_grading() {
$dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(1, question_state::$gradedright),
$dd->grade_response(array('p1' => '1', 'p2' => '1', 'p3' => '1')));
@@ -221,7 +221,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_grading_maths() {
$dd = test_question_maker::make_question('ddwtos', 'maths');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(1, question_state::$gradedright),
$dd->grade_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')));
@@ -234,7 +234,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
public function test_classify_response() {
$dd = test_question_maker::make_question('ddwtos');
$dd->shufflechoices = false;
- $dd->start_attempt(new question_attempt_step());
+ $dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(
1 => new question_classified_response(1, 'quick', 1),
From 339481f106da4414bd130de4d16572a2240c6d88 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Tue, 21 Jun 2011 19:37:24 +0700
Subject: [PATCH 025/208] MDL-47494 ddimageortext: NOBUG new README.txt for new
question type ddimagetoimage - Darg and Drop Image to Image. I forked the
existing ddwtos question type which has a lot in common with this new
question type to give me a quick start setting up the needed infrastructure
for a Moodle question type plug in.
---
question/type/ddimageortext/README.txt | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
index dc15e0fe630..def8b611eb4 100644
--- a/question/type/ddimageortext/README.txt
+++ b/question/type/ddimageortext/README.txt
@@ -1,23 +1,18 @@
-Drag-and-drop, words to sentences question type
+A drag-and-drop, images to images question type
This question type requires that gapselect question type
https://github.com/timhunt/moodle-qtype_gapselect/
to be installed in order to work.
-This question type was originally the work of Mahmoud Kassaei at
-the Open University (http://www.open.ac.uk/).
-It was updated to work with the Moodle 2.1 question engine by Tim Hunt.
-It was then refactored extenstively by Jamie Pratt (http://jamiep.org/)
-as part of creating the gapselect question type.
-
+This question type was written by Jamie Pratt (http://jamiep.org/).
This question type is compatible with Moodle 2.1+.
To install using git, type this command in the root of your Moodle install
- git clone git://github.com/timhunt/moodle-qtype_ddwtos.git question/type/ddwtos
-Then add question/type/ddwtosto your git ignore.
+ git clone git://github.com/jamiepratt/moodle-qtype_ddimagetoimage.git question/type/ddimagetoimage
+Then add question/type/ddimagetoimage to your git ignore.
Alternatively, download the zip from
- https://github.com/timhunt/moodle-qtype_ddwtos/zipball/master
+ https://github.com/jamiepratt/moodle-qtype_ddimagetoimage/zipball/master
unzip it into the question/type folder, and then rename the new folder to
-ddwtos.
+ddimagetoimage.
From a70985115572cc20966ec716bab059188d85d146 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Tue, 21 Jun 2011 19:45:14 +0700
Subject: [PATCH 026/208] MDL-47494 ddimageortext: NOBUG search and replace for
ddwtos, replaced with ddimagetoimage
---
.../backup_qtype_ddwtos_plugin.class.php | 12 ++---
.../restore_qtype_ddwtos_plugin.class.php | 20 ++++----
question/type/ddimageortext/db/install.xml | 4 +-
.../type/ddimageortext/edit_ddwtos_form.php | 8 ++--
.../ddimageortext/lang/en/qtype_ddwtos.php | 12 ++---
question/type/ddimageortext/question.php | 6 +--
question/type/ddimageortext/questiontype.php | 10 ++--
question/type/ddimageortext/renderer.php | 6 +--
question/type/ddimageortext/script.js | 10 ++--
.../type/ddimageortext/simpletest/helper.php | 44 +++++++++---------
.../ddimageortext/simpletest/testquestion.php | 46 +++++++++----------
.../simpletest/testquestiontype.php | 34 +++++++-------
.../simpletest/testwalkthrough.php | 24 +++++-----
question/type/ddimageortext/styles.css | 36 +++++++--------
question/type/ddimageortext/version.php | 2 +-
15 files changed, 137 insertions(+), 137 deletions(-)
diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
index 89cb186f836..95dbc936292 100755
--- a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddwtos_plugin.class.php
@@ -26,12 +26,12 @@ defined('MOODLE_INTERNAL') || die();
/**
- * Provides the information to backup ddwtos questions
+ * Provides the information to backup ddimagetoimage questions
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class backup_qtype_ddwtos_plugin extends backup_qtype_plugin {
+class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
/**
* Returns the qtype information to attach to question element
@@ -39,7 +39,7 @@ class backup_qtype_ddwtos_plugin extends backup_qtype_plugin {
protected function define_question_plugin_structure() {
// Define the virtual plugin element with the condition to fulfill
- $plugin = $this->get_plugin_element(null, '../../qtype', 'ddwtos');
+ $plugin = $this->get_plugin_element(null, '../../qtype', 'ddimagetoimage');
// Create one standard named plugin element (the visible container)
$pluginwrapper = new backup_nested_element($this->get_recommended_name());
@@ -52,16 +52,16 @@ class backup_qtype_ddwtos_plugin extends backup_qtype_plugin {
$this->add_question_question_answers($pluginwrapper);
// Now create the qtype own structures
- $ddwtos = new backup_nested_element('ddwtos', array('id'), array(
+ $ddimagetoimage = new backup_nested_element('ddimagetoimage', array('id'), array(
'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));
// Now the own qtype tree
- $pluginwrapper->add_child($ddwtos);
+ $pluginwrapper->add_child($ddimagetoimage);
// set source to populate the data
- $ddwtos->set_source_table('question_ddwtos', array('questionid' => backup::VAR_PARENTID));
+ $ddimagetoimage->set_source_table('question_ddimagetoimage', array('questionid' => backup::VAR_PARENTID));
// don't need to annotate ids nor files
diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
index 48fd9695bef..361c06da75a 100755
--- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php
@@ -27,12 +27,12 @@ defined('MOODLE_INTERNAL') || die();
/**
* restore plugin class that provides the necessary information
- * needed to restore one ddwtos qtype plugin
+ * needed to restore one ddimagetoimage qtype plugin
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
+class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
/**
* Returns the paths to be handled by the plugin at question level
@@ -45,17 +45,17 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
$this->add_question_question_answers($paths);
// Add own qtype stuff
- $elename = 'ddwtos';
- $elepath = $this->get_pathfor('/ddwtos'); // we used get_recommended_name() so this works
+ $elename = 'ddimagetoimage';
+ $elepath = $this->get_pathfor('/ddimagetoimage'); // we used get_recommended_name() so this works
$paths[] = new restore_path_element($elename, $elepath);
return $paths; // And we return the interesting paths
}
/**
- * Process the qtype/ddwtos element
+ * Process the qtype/ddimagetoimage element
*/
- public function process_ddwtos($data) {
+ public function process_ddimagetoimage($data) {
global $DB;
$data = (object)$data;
@@ -66,14 +66,14 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
$newquestionid = $this->get_new_parentid('question');
$questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;
- // If the question has been created by restore, we need to create its question_ddwtos too
+ // If the question has been created by restore, we need to create its question_ddimagetoimage too
if ($questioncreated) {
// Adjust some columns
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record('question_ddwtos', $data);
+ $newitemid = $DB->insert_record('question_ddimagetoimage', $data);
// Create mapping (needed for decoding links)
- $this->set_mapping('question_ddwtos', $oldid, $newitemid);
+ $this->set_mapping('question_ddimagetoimage', $oldid, $newitemid);
}
}
@@ -85,7 +85,7 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin {
$contents = array();
$fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
- $contents[] = new restore_decode_content('question_ddwtos', $fields, 'question_ddwtos');
+ $contents[] = new restore_decode_content('question_ddimagetoimage', $fields, 'question_ddimagetoimage');
return $contents;
}
diff --git a/question/type/ddimageortext/db/install.xml b/question/type/ddimageortext/db/install.xml
index 50dbefe8a09..2b1a00faa37 100755
--- a/question/type/ddimageortext/db/install.xml
+++ b/question/type/ddimageortext/db/install.xml
@@ -1,10 +1,10 @@
-
-
+
diff --git a/question/type/ddimageortext/edit_ddwtos_form.php b/question/type/ddimageortext/edit_ddwtos_form.php
index 5f30792e4a9..5d79f618782 100755
--- a/question/type/ddimageortext/edit_ddwtos_form.php
+++ b/question/type/ddimageortext/edit_ddwtos_form.php
@@ -18,7 +18,7 @@
* Defines the editing form for the drag-and-drop words into sentences question type.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -35,9 +35,9 @@ require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base {
+class qtype_ddimagetoimage_edit_form extends qtype_gapselect_edit_form_base {
public function qtype() {
- return 'ddwtos';
+ return 'ddimagetoimage';
}
protected function data_preprocessing_choice($question, $answer, $key) {
@@ -51,7 +51,7 @@ class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base {
protected function choice_group($mform) {
$grouparray = parent::choice_group($mform);
$grouparray[] = $mform->createElement('checkbox', 'infinite', ' ',
- get_string('infinite', 'qtype_ddwtos'), null,
+ get_string('infinite', 'qtype_ddimagetoimage'), null,
array('size' => 1, 'class' => 'tweakcss'));
return $grouparray;
}
diff --git a/question/type/ddimageortext/lang/en/qtype_ddwtos.php b/question/type/ddimageortext/lang/en/qtype_ddwtos.php
index 44759253472..c7c55dd9e1a 100755
--- a/question/type/ddimageortext/lang/en/qtype_ddwtos.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddwtos.php
@@ -17,18 +17,18 @@
/**
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['addingddwtos'] = 'Adding drag and drop: words in text';
+$string['addingddimagetoimage'] = 'Adding drag and drop: words in text';
$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices';
$string['answer'] = 'Answer';
$string['correctansweris'] = 'The correct answer is: {$a}';
-$string['ddwtos'] = 'Drag and drop: words in text';
-$string['ddwtos_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.';
-$string['ddwtossummary'] = 'Missing words in some text are filled in using drag-and-drop.';
-$string['editingddwtos'] = 'Editing drag and drop: words in text';
+$string['ddimagetoimage'] = 'Drag and drop: words in text';
+$string['ddimagetoimage_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.';
+$string['ddimagetoimagesummary'] = 'Missing words in some text are filled in using drag-and-drop.';
+$string['editingddimagetoimage'] = 'Editing drag and drop: words in text';
$string['infinite'] = 'Infinite';
$string['pleaseputananswerineachbox'] = 'Please put an answer in each box.';
diff --git a/question/type/ddimageortext/question.php b/question/type/ddimageortext/question.php
index 25e3fe4d9a9..9476ab94a0b 100755
--- a/question/type/ddimageortext/question.php
+++ b/question/type/ddimageortext/question.php
@@ -18,7 +18,7 @@
* Drag-and-drop words into sentences question definition class.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -35,7 +35,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/questionbase.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_question extends qtype_gapselect_question_base {
+class qtype_ddimagetoimage_question extends qtype_gapselect_question_base {
// Is actually exactly the same.
}
@@ -46,7 +46,7 @@ class qtype_ddwtos_question extends qtype_gapselect_question_base {
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_choice {
+class qtype_ddimagetoimage_choice {
public $text;
public $draggroup;
public $isinfinite;
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index 8b46966a759..8c67a4ca821 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -18,7 +18,7 @@
* Question type class for the drag-and-drop words into sentences question type.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/questiontypebase.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos extends qtype_gapselect_base {
+class qtype_ddimagetoimage extends qtype_gapselect_base {
protected function choice_group_key() {
return 'draggroup';
}
@@ -61,17 +61,17 @@ class qtype_ddwtos extends qtype_gapselect_base {
protected function make_choice($choicedata) {
$options = unserialize($choicedata->feedback);
- return new qtype_ddwtos_choice(
+ return new qtype_ddimagetoimage_choice(
$choicedata->answer, $options->draggroup, $options->infinite);
}
public function import_from_xml($data, $question, $format, $extra=null) {
- if (!isset($data['@']['type']) || $data['@']['type'] != 'ddwtos') {
+ if (!isset($data['@']['type']) || $data['@']['type'] != 'ddimagetoimage') {
return false;
}
$question = $format->import_headers($data);
- $question->qtype = 'ddwtos';
+ $question->qtype = 'ddimagetoimage';
$question->shuffleanswers = $format->trans_single(
$format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1));
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index e04716366fc..74750609547 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -18,7 +18,7 @@
* Drag-and-drop words into sentences question renderer class.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -35,10 +35,10 @@ require_once($CFG->dirroot . '/question/type/gapselect/rendererbase.php');
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_renderer {
+class qtype_ddimagetoimage_renderer extends qtype_elements_embedded_in_question_text_renderer {
protected function qtext_classname() {
- return 'qtext ddwtos_questionid_for_javascript';
+ return 'qtext ddimagetoimage_questionid_for_javascript';
}
protected function post_qtext_elements(question_attempt $qa,
diff --git a/question/type/ddimageortext/script.js b/question/type/ddimageortext/script.js
index 8e5f2d38980..542e7ac2f4e 100755
--- a/question/type/ddimageortext/script.js
+++ b/question/type/ddimageortext/script.js
@@ -16,16 +16,16 @@
/**
* JavaScript objects, functions as well as usage of some YUI library for
* enabling drag and drop interaction for dran-anddrop words into sentences
- * (ddwtos)
+ * (ddimagetoimage)
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
//global variables
-var ddwtos_currentzindex = 10;
+var ddimagetoimage_currentzindex = 10;
/*
@@ -38,7 +38,7 @@ var ddwtos_currentzindex = 10;
// start of App object by all questions of this type on a page.
YAHOO.example.DDApp = {
init : function() {
- var questionspans = YAHOO.util.Dom.getElementsByClassName("ddwtos_questionid_for_javascript");
+ var questionspans = YAHOO.util.Dom.getElementsByClassName("ddimagetoimage_questionid_for_javascript");
// we need this loop in case of more than one of this qtype on one page
for (var i = 0; i < questionspans.length; i++) {
@@ -108,7 +108,7 @@ var ddwtos_currentzindex = 10;
//Abstract method called after a drag/drop object is clicked and the drag or mousedown time thresholds have beeen met.
startDrag : function(x, y) {
- YAHOO.util.Dom.setStyle(this.getEl(), "zIndex", ddwtos_currentzindex++);
+ YAHOO.util.Dom.setStyle(this.getEl(), "zIndex", ddimagetoimage_currentzindex++);
YAHOO.util.Dom.removeClass(this.getEl(), 'placed');
if (is_infinite(this.getEl()) && !this.slot){
diff --git a/question/type/ddimageortext/simpletest/helper.php b/question/type/ddimageortext/simpletest/helper.php
index 50e244f4157..317a217fc8c 100755
--- a/question/type/ddimageortext/simpletest/helper.php
+++ b/question/type/ddimageortext/simpletest/helper.php
@@ -18,7 +18,7 @@
* Test helpers for the drag-and-drop words into sentences question type.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -33,24 +33,24 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_test_helper extends question_test_helper {
+class qtype_ddimagetoimage_test_helper extends question_test_helper {
public function get_test_questions() {
return array('fox', 'maths');
}
/**
- * @return qtype_ddwtos_question
+ * @return qtype_ddimagetoimage_question
*/
- public function make_ddwtos_question_fox() {
- question_bank::load_question_definition_classes('ddwtos');
- $dd = new qtype_ddwtos_question();
+ public function make_ddimagetoimage_question_fox() {
+ question_bank::load_question_definition_classes('ddimagetoimage');
+ $dd = new qtype_ddimagetoimage_question();
test_question_maker::initialise_a_question($dd);
$dd->name = 'Drag-and-drop words into sentences question';
$dd->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
$dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
- $dd->qtype = question_bank::get_qtype('ddwtos');
+ $dd->qtype = question_bank::get_qtype('ddimagetoimage');
$dd->shufflechoices = true;
@@ -58,14 +58,14 @@ class qtype_ddwtos_test_helper extends question_test_helper {
$dd->choices = array(
1 => array(
- 1 => new qtype_ddwtos_choice('quick', 1),
- 2 => new qtype_ddwtos_choice('slow', 1)),
+ 1 => new qtype_ddimagetoimage_choice('quick', 1),
+ 2 => new qtype_ddimagetoimage_choice('slow', 1)),
2 => array(
- 1 => new qtype_ddwtos_choice('fox', 2),
- 2 => new qtype_ddwtos_choice('dog', 2)),
+ 1 => new qtype_ddimagetoimage_choice('fox', 2),
+ 2 => new qtype_ddimagetoimage_choice('dog', 2)),
3 => array(
- 1 => new qtype_ddwtos_choice('lazy', 3),
- 2 => new qtype_ddwtos_choice('assiduous', 3)),
+ 1 => new qtype_ddimagetoimage_choice('lazy', 3),
+ 2 => new qtype_ddimagetoimage_choice('assiduous', 3)),
);
$dd->places = array(1 => 1, 2 => 2, 3 => 3);
@@ -76,11 +76,11 @@ class qtype_ddwtos_test_helper extends question_test_helper {
}
/**
- * @return qtype_ddwtos_question
+ * @return qtype_ddimagetoimage_question
*/
- public function make_ddwtos_question_maths() {
- question_bank::load_question_definition_classes('ddwtos');
- $dd = new qtype_ddwtos_question();
+ public function make_ddimagetoimage_question_maths() {
+ question_bank::load_question_definition_classes('ddimagetoimage');
+ $dd = new qtype_ddimagetoimage_question();
test_question_maker::initialise_a_question($dd);
@@ -88,7 +88,7 @@ class qtype_ddwtos_test_helper extends question_test_helper {
$dd->questiontext = 'Fill in the operators to make this equation work: ' .
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
$dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
- $dd->qtype = question_bank::get_qtype('ddwtos');
+ $dd->qtype = question_bank::get_qtype('ddimagetoimage');
$dd->shufflechoices = true;
@@ -96,10 +96,10 @@ class qtype_ddwtos_test_helper extends question_test_helper {
$dd->choices = array(
1 => array(
- 1 => new qtype_ddwtos_choice('+', 1, true),
- 2 => new qtype_ddwtos_choice('-', 1, true),
- 3 => new qtype_ddwtos_choice('*', 1, true),
- 4 => new qtype_ddwtos_choice('/', 1, true),
+ 1 => new qtype_ddimagetoimage_choice('+', 1, true),
+ 2 => new qtype_ddimagetoimage_choice('-', 1, true),
+ 3 => new qtype_ddimagetoimage_choice('*', 1, true),
+ 4 => new qtype_ddimagetoimage_choice('/', 1, true),
));
$dd->places = array(1 => 1, 2 => 1, 3 => 1, 4 => 1);
diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php
index 58fea4279cf..bdee7b892e3 100755
--- a/question/type/ddimageortext/simpletest/testquestion.php
+++ b/question/type/ddimageortext/simpletest/testquestion.php
@@ -18,7 +18,7 @@
* Unit tests for the drag-and-drop words into sentences question definition class.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -27,7 +27,7 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
-require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
+require_once($CFG->dirroot . '/question/type/ddimagetoimage/simpletest/helper.php');
/**
@@ -36,24 +36,24 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_question_test extends UnitTestCase {
+class qtype_ddimagetoimage_question_test extends UnitTestCase {
public function test_get_question_summary() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$this->assertEqual('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' .
'[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}',
$dd->get_question_summary());
}
public function test_get_question_summary_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$this->assertEqual('Fill in the operators to make this equation work: ' .
'7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3; [[1]] -> {+ / - / * / /}',
$dd->get_question_summary());
}
public function test_summarise_response() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -62,7 +62,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_summarise_response_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -71,17 +71,17 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_random_guess_score() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$this->assertEqual(0.5, $dd->get_random_guess_score());
}
public function test_get_random_guess_score_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$this->assertEqual(0.25, $dd->get_random_guess_score());
}
public function test_get_right_choice_for() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -90,7 +90,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_right_choice_for_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -99,7 +99,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_clear_wrong_from_response() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -109,7 +109,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_num_parts_right() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -120,7 +120,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_num_parts_right_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -130,7 +130,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_expected_data() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array('p1' => PARAM_INT, 'p2' => PARAM_INT, 'p3' => PARAM_INT),
@@ -138,7 +138,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_correct_response() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -147,7 +147,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_get_correct_response_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -156,7 +156,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_is_same_response() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertTrue($dd->is_same_response(
@@ -180,7 +180,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
array('p1' => '1', 'p2' => '2', 'p3' => '2')));
}
public function test_is_complete_response() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertFalse($dd->is_complete_response(array()));
@@ -192,7 +192,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_is_gradable_response() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertFalse($dd->is_gradable_response(array()));
@@ -206,7 +206,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_grading() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -219,7 +219,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_grading_maths() {
- $dd = test_question_maker::make_question('ddwtos', 'maths');
+ $dd = test_question_maker::make_question('ddimagetoimage', 'maths');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
@@ -232,7 +232,7 @@ class qtype_ddwtos_question_test extends UnitTestCase {
}
public function test_classify_response() {
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php
index 34c41f87889..78c42a87582 100755
--- a/question/type/ddimageortext/simpletest/testquestiontype.php
+++ b/question/type/ddimageortext/simpletest/testquestiontype.php
@@ -18,7 +18,7 @@
* Unit tests for the drag-and-drop words into sentences question definition class.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -27,7 +27,7 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
-require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
+require_once($CFG->dirroot . '/question/type/ddimagetoimage/simpletest/helper.php');
/**
@@ -36,12 +36,12 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_test extends UnitTestCase {
- /** @var qtype_ddwtos instance of the question type class to test. */
+class qtype_ddimagetoimage_test extends UnitTestCase {
+ /** @var qtype_ddimagetoimage instance of the question type class to test. */
protected $qtype;
public function setUp() {
- $this->qtype = question_bank::get_qtype('ddwtos');;
+ $this->qtype = question_bank::get_qtype('ddimagetoimage');;
}
public function tearDown() {
@@ -55,7 +55,7 @@ class qtype_ddwtos_test extends UnitTestCase {
/**
* @return object the data to construct a question like
- * {@link qtype_ddwtos_test_helper::make_ddwtos_question_fox()}.
+ * {@link qtype_ddimagetoimage_test_helper::make_ddimagetoimage_question_fox()}.
*/
protected function get_test_question_data() {
global $USER;
@@ -81,7 +81,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$dd->name = 'Drag-and-drop words into sentences question';
$dd->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
$dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
- $dd->qtype = 'ddwtos';
+ $dd->qtype = 'ddimagetoimage';
$dd->options->shuffleanswers = true;
@@ -106,7 +106,7 @@ class qtype_ddwtos_test extends UnitTestCase {
}
public function test_name() {
- $this->assertEqual($this->qtype->name(), 'ddwtos');
+ $this->assertEqual($this->qtype->name(), 'ddimagetoimage');
}
public function test_can_analyse_responses() {
@@ -116,7 +116,7 @@ class qtype_ddwtos_test extends UnitTestCase {
public function test_initialise_question_instance() {
$qdata = $this->get_test_question_data();
- $expected = test_question_maker::make_question('ddwtos');
+ $expected = test_question_maker::make_question('ddimagetoimage');
$expected->stamp = $qdata->stamp;
$expected->version = $qdata->version;
@@ -150,7 +150,7 @@ class qtype_ddwtos_test extends UnitTestCase {
}
public function test_xml_import() {
- $xml = '
+ $xml = ' A drag-and-drop question
@@ -201,10 +201,10 @@ class qtype_ddwtos_test extends UnitTestCase {
$importer = new qformat_xml();
$q = $importer->try_importing_using_qtypes(
- $xmldata['question'], null, null, 'ddwtos');
+ $xmldata['question'], null, null, 'ddimagetoimage');
$expectedq = new stdClass();
- $expectedq->qtype = 'ddwtos';
+ $expectedq->qtype = 'ddimagetoimage';
$expectedq->name = 'A drag-and-drop question';
$expectedq->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
$expectedq->questiontextformat = FORMAT_MOODLE;
@@ -240,7 +240,7 @@ class qtype_ddwtos_test extends UnitTestCase {
}
public function test_xml_import_legacy() {
- $xml = '
+ $xml = ' QDandD1 Base definition
@@ -366,10 +366,10 @@ class qtype_ddwtos_test extends UnitTestCase {
$importer = new qformat_xml();
$q = $importer->try_importing_using_qtypes(
- $xmldata['question'], null, null, 'ddwtos');
+ $xmldata['question'], null, null, 'ddimagetoimage');
$expectedq = new stdClass();
- $expectedq->qtype = 'ddwtos';
+ $expectedq->qtype = 'ddimagetoimage';
$expectedq->name = 'QDandD1 Base definition';
$expectedq->questiontext = '
Drag and drop the words from the list below ' .
'to fill the blank spaces and correctly complete the sentence.
' .
@@ -435,7 +435,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$qdata = new stdClass();
$qdata->id = 123;
$qdata->contextid = 0;
- $qdata->qtype = 'ddwtos';
+ $qdata->qtype = 'ddimagetoimage';
$qdata->name = 'A drag-and-drop question';
$qdata->questiontext = 'Put these in order: [[1]], [[2]], [[3]].';
$qdata->questiontextformat = FORMAT_MOODLE;
@@ -478,7 +478,7 @@ class qtype_ddwtos_test extends UnitTestCase {
$xml = $exporter->writequestion($qdata);
$expectedxml = '
-
+ A drag-and-drop question
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index a296640bace..bbbdf4118eb 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -18,7 +18,7 @@
* Unit tests for the drag-and-drop words into sentences question type.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -27,7 +27,7 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/question/engine/simpletest/helpers.php');
-require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
+require_once($CFG->dirroot . '/question/type/ddimagetoimage/simpletest/helper.php');
/**
@@ -36,7 +36,7 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php');
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
+class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_base {
protected function get_contains_drop_box_expectation($place, $group, $readonly,
$stateclass = '0') {
@@ -62,7 +62,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_behaviour() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->hints = array(
new question_hint_with_parts(13, 'This is the first hint.', FORMAT_HTML, false, false),
new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
@@ -174,7 +174,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_deferred_feedback() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
@@ -257,7 +257,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_deferred_feedback_unanswered() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
@@ -313,7 +313,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_deferred_feedback_partial_answer() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
@@ -368,7 +368,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_grading() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->hints = array(
new question_hint_with_parts(1, 'This is the first hint.',
FORMAT_MOODLE, true, true),
@@ -528,7 +528,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_correct_no_submit() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->hints = array(
new question_hint_with_parts(23, 'This is the first hint.',
FORMAT_MOODLE, false, false),
@@ -584,7 +584,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_partial_no_submit() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->hints = array(
new question_hint_with_parts(23, 'This is the first hint.',
FORMAT_MOODLE, false, false),
@@ -640,7 +640,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_interactive_no_right_clears() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$dd->hints = array(
new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, true),
new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true),
@@ -707,7 +707,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
public function test_display_of_right_answer_when_shuffled() {
// Create a drag-and-drop question.
- $dd = test_question_maker::make_question('ddwtos');
+ $dd = test_question_maker::make_question('ddimagetoimage');
$this->start_attempt_at_question($dd, 'deferredfeedback', 3);
// Check the initial state.
diff --git a/question/type/ddimageortext/styles.css b/question/type/ddimageortext/styles.css
index 8a84a09b149..4b26ec74d81 100755
--- a/question/type/ddimageortext/styles.css
+++ b/question/type/ddimageortext/styles.css
@@ -1,70 +1,70 @@
-.que.ddwtos .qtext {
+.que.ddimagetoimage .qtext {
line-height: 2em;
margin-bottom: 0.5em;
display: block;
}
-.que.ddwtos .qtext * {
+.que.ddimagetoimage .qtext * {
line-height: 2em;
}
-.que.ddwtos .answercontainer {
+.que.ddimagetoimage .answercontainer {
line-height: 2em;
margin-bottom: 1em;
display: block;
}
-.que.ddwtos .answertext {
+.que.ddimagetoimage .answertext {
padding-bottom: 0.5em;
}
-.que.ddwtos .slot {
+.que.ddimagetoimage .slot {
display: inline-block;
text-align: center;
border: 1px solid #000000;
}
-.que.ddwtos .player {
+.que.ddimagetoimage .player {
display: inline-block;
text-align: center;
cursor: move;
border: 1px solid #000000;
}
-.que.ddwtos .player.placed { /* Lets the focus rectangle be visible in IE. */
+.que.ddimagetoimage .player.placed { /* Lets the focus rectangle be visible in IE. */
background: transparent;
}
-.que.ddwtos .readonly {
+.que.ddimagetoimage .readonly {
cursor: default;
}
-.que.ddwtos span.incorrect {
+.que.ddimagetoimage span.incorrect {
background-color: #faa;
}
-.que.ddwtos span.correct {
+.que.ddimagetoimage span.correct {
background-color: #afa;
}
-.que.ddwtos .group1 {
+.que.ddimagetoimage .group1 {
background-color: #FFFFFF;
}
-.que.ddwtos .group2 {
+.que.ddimagetoimage .group2 {
background-color: #DCDCDC;
}
-.que.ddwtos .group3 {
+.que.ddimagetoimage .group3 {
background-color: #B0C4DE;
}
-.que.ddwtos .group4 {
+.que.ddimagetoimage .group4 {
background-color: #D8BFD8;
}
-.que.ddwtos .group5 {
+.que.ddimagetoimage .group5 {
background-color: #87CEFA;
}
-.que.ddwtos .group6 {
+.que.ddimagetoimage .group6 {
background-color: #DAA520;
}
-.que.ddwtos .group7 {
+.que.ddimagetoimage .group7 {
background-color: #FFD700;
}
-.que.ddwtos .group8 {
+.que.ddimagetoimage .group8 {
background-color: #F0E68C;
}
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index 036d05ab489..a15d0944567 100755
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -18,7 +18,7 @@
* Version information for the drag-and-drop words into sentences question type.
*
* @package qtype
- * @subpackage ddwtos
+ * @subpackage ddimagetoimage
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
From 1d41020572be17bf07e66cc7976d9c2dd65096ff Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 23 Jun 2011 14:57:35 +0700
Subject: [PATCH 027/208] MDL-47494 ddimageortext: NOBUG db structure for this
question type.
---
question/type/ddimageortext/db/install.xml | 33 ++++++++++++++++++----
1 file changed, 28 insertions(+), 5 deletions(-)
diff --git a/question/type/ddimageortext/db/install.xml b/question/type/ddimageortext/db/install.xml
index 2b1a00faa37..dd603bf532b 100755
--- a/question/type/ddimageortext/db/install.xml
+++ b/question/type/ddimageortext/db/install.xml
@@ -1,14 +1,14 @@
-
-
+
-
-
-
+
+
+
@@ -22,5 +22,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From b0a8a7ebbd8164d68b62ef5a17840b31a3f55a9f Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 23 Jun 2011 14:58:20 +0700
Subject: [PATCH 028/208] MDL-47494 ddimageortext: NOBUG adding a TODO.txt to
track tasks.
---
question/type/ddimageortext/TODO.txt | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 question/type/ddimageortext/TODO.txt
diff --git a/question/type/ddimageortext/TODO.txt b/question/type/ddimageortext/TODO.txt
new file mode 100644
index 00000000000..7c6564c25a1
--- /dev/null
+++ b/question/type/ddimageortext/TODO.txt
@@ -0,0 +1,16 @@
+Question authoring form fields 2 hours
+Display Image in authoring form
+Calculation of size of drop zones
+Calculate size of images, server side and save the sizes upon image upload
+Display of drop zones on authoring form 4 hours
+Question instance saving 2 hours
+Question instance loading 2 hours
+Question rendering code 6 hours
+- correctly position images
+- make images draggable
+- react to drop of images
+- write position that images where dropped to in hidden fields
+- grade question parts based on where images dragged to
+- have position of images at start respond to saved state
+
+Testing and debugging for cross browser compatibility 4 hours
From 943b33da7e83cc6911bfead1815602278fa4a0eb Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 23 Jun 2011 15:06:56 +0700
Subject: [PATCH 029/208] MDL-47494 ddimageortext: NOBUG changing file names to
qtype name
---
.../{edit_ddwtos_form.php => edit_ddimagetoimage_form.php} | 0
.../lang/en/{qtype_ddwtos.php => qtype_ddimagetoimage.php} | 0
2 files changed, 0 insertions(+), 0 deletions(-)
rename question/type/ddimageortext/{edit_ddwtos_form.php => edit_ddimagetoimage_form.php} (100%)
mode change 100755 => 100644
rename question/type/ddimageortext/lang/en/{qtype_ddwtos.php => qtype_ddimagetoimage.php} (100%)
mode change 100755 => 100644
diff --git a/question/type/ddimageortext/edit_ddwtos_form.php b/question/type/ddimageortext/edit_ddimagetoimage_form.php
old mode 100755
new mode 100644
similarity index 100%
rename from question/type/ddimageortext/edit_ddwtos_form.php
rename to question/type/ddimageortext/edit_ddimagetoimage_form.php
diff --git a/question/type/ddimageortext/lang/en/qtype_ddwtos.php b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
old mode 100755
new mode 100644
similarity index 100%
rename from question/type/ddimageortext/lang/en/qtype_ddwtos.php
rename to question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
From e79dad73e185357ab473a2630fc6d15708f5469a Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 30 Jun 2011 16:43:33 +0700
Subject: [PATCH 030/208] MDL-47494 ddimageortext: NOBUG completed most of the
basics of the question editing form and saving of data in database.
---
question/type/ddimageortext/README.txt | 3 +
question/type/ddimageortext/db/install.xml | 20 +-
.../edit_ddimagetoimage_form.php | 234 ++++++++++++++++--
.../lang/en/qtype_ddimagetoimage.php | 23 +-
question/type/ddimageortext/questiontype.php | 132 +++++-----
5 files changed, 309 insertions(+), 103 deletions(-)
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
index def8b611eb4..5fbeb377a09 100644
--- a/question/type/ddimageortext/README.txt
+++ b/question/type/ddimageortext/README.txt
@@ -8,6 +8,9 @@ This question type was written by Jamie Pratt (http://jamiep.org/).
This question type is compatible with Moodle 2.1+.
+Requires this fix : MDL-28099
+filepicker form element does not work with element names with an index such as image[0]
+
To install using git, type this command in the root of your Moodle install
git clone git://github.com/jamiepratt/moodle-qtype_ddimagetoimage.git question/type/ddimagetoimage
Then add question/type/ddimagetoimage to your git ignore.
diff --git a/question/type/ddimageortext/db/install.xml b/question/type/ddimageortext/db/install.xml
index dd603bf532b..6ab689a2b2e 100755
--- a/question/type/ddimageortext/db/install.xml
+++ b/question/type/ddimageortext/db/install.xml
@@ -1,5 +1,5 @@
-
@@ -24,25 +24,31 @@
-
-
+
+
+
+
-
+
+
-
-
+
+
+
+
-
+
+
diff --git a/question/type/ddimageortext/edit_ddimagetoimage_form.php b/question/type/ddimageortext/edit_ddimagetoimage_form.php
index 5d79f618782..0c43a7ed611 100644
--- a/question/type/ddimageortext/edit_ddimagetoimage_form.php
+++ b/question/type/ddimageortext/edit_ddimagetoimage_form.php
@@ -15,7 +15,7 @@
// along with Moodle. If not, see .
/**
- * Defines the editing form for the drag-and-drop words into sentences question type.
+ * Defines the editing form for the drag-and-drop images onto images question type.
*
* @package qtype
* @subpackage ddimagetoimage
@@ -23,36 +23,238 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
-
-
/**
- * Drag-and-drop words into sentences editing form definition.
+ * Drag-and-drop images onto images editing form definition.
*
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddimagetoimage_edit_form extends qtype_gapselect_edit_form_base {
+class qtype_ddimagetoimage_edit_form extends question_edit_form {
+ const MAX_GROUPS = 8;
+ const START_NUM_IMAGES = 6;
+ const ADD_NUM_IMAGES = 3;
+
public function qtype() {
return 'ddimagetoimage';
}
- protected function data_preprocessing_choice($question, $answer, $key) {
- $question = parent::data_preprocessing_choice($question, $answer, $key);
- $options = unserialize($answer->feedback);
- $question->choices[$key]['choicegroup'] = $options->draggroup;
- $question->choices[$key]['infinite'] = $options->infinite;
- return $question;
+ /**
+ *
+ * Options shared by all file pickers in the form.
+ */
+ public static function file_picker_options() {
+ $filepickeroptions = array();
+ $filepickeroptions['accepted_types'] = array('web_image');
+ $filepickeroptions['maxbytes'] = 0;
+ $filepickeroptions['maxfiles'] = 1;
+ $filepickeroptions['subdirs'] = 0;
+ return $filepickeroptions;
}
- protected function choice_group($mform) {
- $grouparray = parent::choice_group($mform);
+ protected function get_drag_image_repeats() {
+ $countimages = 0;
+ if (isset($this->question->id)) {
+ foreach ($this->question->options->drags as $drag) {
+ $countimages = max($countimages, $drag->no);
+ }
+ }
+ if ($this->question->formoptions->repeatelements) {
+ $imagerepeatsatstart = max(self::START_NUM_IMAGES, $countimages + self::ADD_NUM_IMAGES);
+ } else {
+ $imagerepeatsatstart = $countimages;
+ }
+ $imagerepeats = optional_param('noimages', $imagerepeatsatstart, PARAM_INT);
+ $addfields = optional_param('addimages', '', PARAM_TEXT);
+ if (!empty($addfields)){
+ $imagerepeats += self::ADD_NUM_IMAGES;
+ }
+ return array($imagerepeatsatstart, $imagerepeats);
+ }
+
+ /**
+ * definition_inner adds all specific fields to the form.
+ * @param object $mform (the form being built).
+ */
+ protected function definition_inner($mform) {
+ $mform->addElement('filepicker', 'bgimage', get_string('bgimage', 'qtype_ddimagetoimage'),
+ null, self::file_picker_options());
+
+ list($imagerepeatsatstart, $imagerepeats) = $this->get_drag_image_repeats();
+ $this->definition_drop_zones($mform, $imagerepeats);
+ $mform->addElement('checkbox', 'shuffleanswers', ' ',
+ get_string('shuffleimages', 'qtype_ddimagetoimage'));
+ $mform->setDefault('shuffleanswers', 0);
+ $mform->closeHeaderBefore('shuffleanswers');
+ //add the draggable image fields to the form
+ $this->definition_draggable_images($mform, $imagerepeatsatstart);
+
+ $this->add_combined_feedback_fields(true);
+ $this->add_interactive_settings(true, true);
+ }
+
+ protected function definition_drop_zones($mform, $imagerepeats) {
+ $mform->addElement('header', 'dropzoneheader',
+ get_string('dropzoneheader', 'qtype_ddimagetoimage'));
+
+ $countdropzones = 0;
+ if (isset($this->question->id)) {
+ foreach ($this->question->options->drops as $drop) {
+ $countdropzones = max($countdropzones, $drop->no);
+ }
+ }
+ if ($this->question->formoptions->repeatelements) {
+ $dropzonerepeatsatstart = max(self::START_NUM_IMAGES,
+ $countdropzones + self::ADD_NUM_IMAGES);
+ } else {
+ $dropzonerepeatsatstart = $countdropzones;
+ }
+
+ $this->repeat_elements($this->drop_zone($mform, $imagerepeats), $dropzonerepeatsatstart,
+ $this->drop_zones_repeated_options(),
+ 'nodropzone', 'adddropzone', self::ADD_NUM_IMAGES,
+ get_string('addmoredropzones', 'qtype_ddimagetoimage'));
+ }
+
+ protected function drop_zone($mform, $imagerepeats) {
+ $dropzoneitem = array();
+
+
+ $grouparray = array();
+ $grouparray[] = $mform->createElement('static', 'xleftlabel', '',
+ ' '.get_string('xleft', 'qtype_ddimagetoimage').' ');
+ $grouparray[] = $mform->createElement('text', 'xleft',
+ get_string('xleft', 'qtype_ddimagetoimage'),
+ array('size'=>5, 'class'=>'tweakcss'));
+ $mform->setType('xleft', PARAM_NOTAGS);
+ $grouparray[] = $mform->createElement('static', 'ytoplabel', '',
+ ' '.get_string('ytop', 'qtype_ddimagetoimage').' ');
+ $grouparray[] = $mform->createElement('text', 'ytop',
+ get_string('ytop', 'qtype_ddimagetoimage'),
+ array('size'=>5, 'class'=>'tweakcss'));
+ $mform->setType('ytop', PARAM_NOTAGS);
+ $options = array();
+
+ for ($i = 1; $i <= $imagerepeats; $i += 1) {
+ $options[$i] = $i;
+ }
+ $grouparray[] = $mform->createElement('static', '', '', ' ' .
+ get_string('draggableimage', 'qtype_ddimagetoimage').' ');
+ $grouparray[] = $mform->createElement('select', 'choice',
+ get_string('draggableimage', 'qtype_ddimagetoimage'), $options);
+ $grouparray[] = $mform->createElement('static', '', '', ' ' .
+ get_string('label', 'qtype_ddimagetoimage').' ');
+ $grouparray[] = $mform->createElement('text', 'droplabel',
+ get_string('label', 'qtype_ddimagetoimage'),
+ array('size'=>10, 'class'=>'tweakcss'));
+ $mform->setType('droplabel', PARAM_NOTAGS);
+ $dropzone = $mform->createElement('group', 'drops',
+ get_string('dropzone', 'qtype_ddimagetoimage', '{no}'), $grouparray);
+ return array($dropzone);
+ }
+
+ protected function drop_zones_repeated_options() {
+ $repeatedoptions = array();
+ $repeatedoptions['choicegroup']['default'] = '1';
+ return $repeatedoptions;
+ }
+
+ protected function definition_draggable_images($mform, $imagerepeatsatstart) {
+
+ $this->repeat_elements($this->draggable_image($mform), $imagerepeatsatstart,
+ $this->draggable_images_repeated_options(),
+ 'noimages', 'addimages', self::ADD_NUM_IMAGES,
+ get_string('addmoreimages', 'qtype_ddimagetoimage'));
+ }
+
+ protected function draggable_image($mform) {
+ $draggableimageitem = array();
+
+ $draggableimageitem[] = $mform->createElement('header', 'draggableimageheader',
+ get_string('draggableimageheader', 'qtype_ddimagetoimage', '{no}'));
+ $draggableimageitem[] = $mform->createElement('filepicker', 'dragitem', '', null,
+ self::file_picker_options());
+
+ $grouparray = array();
+ $grouparray[] = $mform->createElement('text', 'draglabel',
+ get_string('label', 'qtype_ddimagetoimage'),
+ array('size'=>30, 'class'=>'tweakcss'));
+ $mform->setType('draglabel', PARAM_NOTAGS);
+ $options = array();
+ for ($i = 1; $i <= self::MAX_GROUPS; $i += 1) {
+ $options[$i] = $i;
+ }
+ $grouparray[] = $mform->createElement('static', '', '', ' ' .
+ get_string('group', 'qtype_gapselect').' ');
+ $grouparray[] = $mform->createElement('select', 'draggroup',
+ get_string('group', 'qtype_gapselect'), $options);
$grouparray[] = $mform->createElement('checkbox', 'infinite', ' ',
get_string('infinite', 'qtype_ddimagetoimage'), null,
array('size' => 1, 'class' => 'tweakcss'));
- return $grouparray;
+ $draggableimageitem[] = $mform->createElement('group', 'drags',
+ get_string('label', 'qtype_ddimagetoimage'), $grouparray);
+ return $draggableimageitem;
}
+
+ protected function draggable_images_repeated_options() {
+ $repeatedoptions = array();
+ $repeatedoptions['draggroup']['default'] = '1';
+ return $repeatedoptions;
+ }
+
+ public function data_preprocessing($question) {
+
+ $question = parent::data_preprocessing($question);
+ $question = $this->data_preprocessing_combined_feedback($question, true);
+ $question = $this->data_preprocessing_hints($question, true, true);
+
+ if (!empty($question->options)) {
+ $question->shuffleanswers = $question->options->shuffleanswers;
+ $question->drags = array();
+ foreach ($question->options->drags as $drag) {
+ $dragindex = $drag->no -1;
+ $question->drags[$dragindex] = array();
+ $question->drags[$dragindex]['draglabel'] = $drag->label;
+ $question->drags[$dragindex]['infinite'] = $drag->infinite;
+ $question->drags[$dragindex]['draggroup'] = $drag->draggroup;
+ }
+ list(, $imagerepeats) = $this->get_drag_image_repeats();
+ for ($imageindex = 0; $imageindex < $imagerepeats; $imageindex++) {
+ $draftitemid = file_get_submitted_draft_itemid("dragitem[$imageindex]");
+ //numbers not allowed in filearea name
+ $filearea = str_replace(range('0', '9'), range('a', 'j'), "drag_$imageindex");
+ file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimagetoimage',
+ $filearea, !empty($question->id) ? (int) $question->id : null,
+ self::file_picker_options());
+ $question->dragitem[$imageindex] = $draftitemid;
+ }
+ $question->drops = array();
+ foreach ($question->options->drops as $drop) {
+ $question->drops[$drop->no -1] = array();
+ $question->drops[$drop->no -1]['choice'] = $drop->choice;
+ $question->drops[$drop->no -1]['droplabel'] = $drop->label;
+ $question->drops[$drop->no -1]['xleft'] = $drop->xleft;
+ $question->drops[$drop->no -1]['ytop'] = $drop->ytop;
+ }
+ }
+
+ $draftitemid = file_get_submitted_draft_itemid('bgimage');
+ file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimagetoimage',
+ 'bgimage', !empty($question->id) ? (int) $question->id : null,
+ self::file_picker_options());
+ $question->bgimage = $draftitemid;
+ error_log(print_r(array('mform' => $this), true));
+ error_log(print_r(compact('question'), true));
+ return $question;
+ }
+
+ public function validation($data, $files) {
+ $errors = parent::validation($data, $files);
+
+ return $errors;
+ }
+
+
+
}
diff --git a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
index c7c55dd9e1a..d836df9f9c2 100644
--- a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
@@ -22,13 +22,22 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['addingddimagetoimage'] = 'Adding drag and drop: words in text';
-$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices';
+$string['addingddimagetoimage'] = 'Adding drag and drop: images onto images';
+$string['addmoredropzones'] = 'Blanks for {no} More Drop Zones';
+$string['addmoreimages'] = 'Blanks for {no} More Draggable Images';
$string['answer'] = 'Answer';
+$string['bgimage'] = 'Background Image';
$string['correctansweris'] = 'The correct answer is: {$a}';
-$string['ddimagetoimage'] = 'Drag and drop: words in text';
-$string['ddimagetoimage_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.';
-$string['ddimagetoimagesummary'] = 'Missing words in some text are filled in using drag-and-drop.';
-$string['editingddimagetoimage'] = 'Editing drag and drop: words in text';
+$string['ddimagetoimage'] = 'Drag and drop: images onto images';
+$string['ddimagetoimage_help'] = 'Select a background image file, select a number of draggable images and define the drop zones on the background image to which they must be dragged.';
+$string['ddimagetoimagesummary'] = 'Images are dragged and dropped into drop zones on a background image.';
+$string['draggableimage'] = 'Draggable image';
+$string['draggableimageheader'] = 'Draggable image {$a}';
+$string['dropzone'] = 'Drop zone {$a}';
+$string['dropzoneheader'] = 'Drop zones';
+$string['editingddimagetoimage'] = 'Editing drag and drop: images onto images';
$string['infinite'] = 'Infinite';
-$string['pleaseputananswerineachbox'] = 'Please put an answer in each box.';
+$string['label'] = 'Label';
+$string['shuffleimages'] = 'Shuffle Draggable Images';
+$string['xleft'] = 'Left';
+$string['ytop'] = 'Top';
\ No newline at end of file
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index 8c67a4ca821..889a92a105d 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -38,7 +38,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/questiontypebase.php');
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class qtype_ddimagetoimage extends qtype_gapselect_base {
+class qtype_ddimagetoimage extends question_type {
protected function choice_group_key() {
return 'draggroup';
}
@@ -47,89 +47,75 @@ class qtype_ddimagetoimage extends qtype_gapselect_base {
return array('gapselect');
}
- protected function choice_options_to_feedback($choice) {
- $output = new stdClass();
- $output->draggroup = $choice['choicegroup'];
- $output->infinite = !empty($choice['infinite']);
- return serialize($output);
+ public function get_question_options($question) {
+ global $DB;
+ $question->options = $DB->get_record('qtype_ddimagetoimage',
+ array('questionid' => $question->id), '*', MUST_EXIST);
+ $question->options->drags = $DB->get_records('qtype_ddimagetoimage_drags',
+ array('questionid' => $question->id), 'no ASC', '*');
+ $question->options->drops = $DB->get_records('qtype_ddimagetoimage_drops',
+ array('questionid' => $question->id), 'no ASC', '*');
+ parent::get_question_options($question);
}
- protected function feedback_to_choice_options($feedback) {
- $feedbackobj = unserialize($feedback);
- return array('draggroup' => $feedbackobj->draggroup, 'infinite' => $feedbackobj->infinite);
- }
+ public function save_question_options($formdata) {
+ global $DB;
+ $context = $formdata->context;
- protected function make_choice($choicedata) {
- $options = unserialize($choicedata->feedback);
- return new qtype_ddimagetoimage_choice(
- $choicedata->answer, $options->draggroup, $options->infinite);
- }
-
- public function import_from_xml($data, $question, $format, $extra=null) {
- if (!isset($data['@']['type']) || $data['@']['type'] != 'ddimagetoimage') {
- return false;
+ $options = $DB->get_record('qtype_ddimagetoimage', array('questionid' => $formdata->id));
+ if (!$options) {
+ $options = new stdClass();
+ $options->questionid = $formdata->id;
+ $options->correctfeedback = '';
+ $options->partiallycorrectfeedback = '';
+ $options->incorrectfeedback = '';
+ $options->id = $DB->insert_record('qtype_ddimagetoimage', $options);
}
- $question = $format->import_headers($data);
- $question->qtype = 'ddimagetoimage';
-
- $question->shuffleanswers = $format->trans_single(
- $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1));
-
- if (!empty($data['#']['dragbox'])) {
- // Modern XML format.
- $dragboxes = $data['#']['dragbox'];
- $question->answer = array();
- $question->draggroup = array();
- $question->infinite = array();
-
- foreach ($data['#']['dragbox'] as $dragboxxml) {
- $question->choices[] = array(
- 'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true),
- 'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1),
- 'infinite' => array_key_exists('infinite', $dragboxxml['#']),
- );
+ $options->shuffleanswers = !empty($formdata->shuffleanswers);
+ $options = $this->save_combined_feedback_helper($options, $formdata, $context, true);
+ $this->save_hints($formdata, true);
+ $DB->update_record('qtype_ddimagetoimage', $options);
+ $DB->delete_records('qtype_ddimagetoimage_drops', array('questionid' => $formdata->id));
+ foreach (array_keys($formdata->drops) as $dropno){
+ if ($formdata->drops[$dropno]['xleft'] == ''){
+ continue;
}
+ $drop = new stdClass();
+ $drop->questionid = $formdata->id;
+ $drop->no = $dropno + 1;
+ $drop->xleft = $formdata->drops[$dropno]['xleft'];
+ $drop->ytop = $formdata->drops[$dropno]['ytop'];
+ $drop->choice = $formdata->drops[$dropno]['choice'];
+ $drop->label = $formdata->drops[$dropno]['droplabel'];
- } else {
- // Legacy format containing PHP serialisation.
- foreach ($data['#']['answer'] as $answerxml) {
- $ans = $format->import_answer($answerxml);
- $options = unserialize(stripslashes($ans->feedback['text']));
- $question->choices[] = array(
- 'answer' => $ans->answer,
- 'choicegroup' => $options->draggroup,
- 'infinite' => $options->infinite,
- );
+ $DB->insert_record('qtype_ddimagetoimage_drops', $drop);
+ }
+
+ $DB->delete_records('qtype_ddimagetoimage_drags', array('questionid' => $formdata->id));
+ foreach (array_keys($formdata->drags) as $dragno){
+ $info = file_get_draft_area_info($formdata->dragitem[$dragno]);
+ if ($info['filecount'] > 0) {
+ //numbers not allowed in filearea name
+ $filearea = str_replace(range('0', '9'), range('a', 'j'), "drag_$dragno");
+ file_save_draft_area_files($formdata->dragitem[$dragno], $formdata->context->id,
+ 'qtype_ddimagetoimage', $filearea, $formdata->id,
+ array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
+ $drag = new stdClass();
+ $drag->questionid = $formdata->id;
+ $drag->no = $dragno + 1;
+ $drag->draggroup = $formdata->drags[$dragno]['draggroup'];
+ $drag->infinite = empty($formdata->drags[$dragno]['infinite'])? 0 : 1;
+ $drag->label = $formdata->drags[$dragno]['draglabel'];
+
+ $DB->insert_record('qtype_ddimagetoimage_drags', $drag);
}
}
- $format->import_combined_feedback($question, $data, true);
- $format->import_hints($question, $data, true);
-
- return $question;
+ file_save_draft_area_files($formdata->bgimage, $formdata->context->id,
+ 'qtype_ddimagetoimage', 'bgimage', $formdata->id,
+ array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1));
}
- public function export_to_xml($question, $format, $extra = null) {
- $output = '';
- $output .= ' ' . $question->options->shuffleanswers .
- "\n";
-
- $output .= $format->write_combined_feedback($question->options);
-
- foreach ($question->options->answers as $answer) {
- $options = unserialize($answer->feedback);
-
- $output .= " \n";
- $output .= $format->writetext($answer->answer, 3);
- $output .= " {$options->draggroup}\n";
- if ($options->infinite) {
- $output .= " \n";
- }
- $output .= " \n";
- }
-
- return $output;
- }
}
From 0fe992a97dc71a47b3e84cb4260dce1c1dbdd580 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Fri, 22 Jul 2011 16:25:14 +0700
Subject: [PATCH 031/208] MDL-47494 ddimageortext: NOBUG made a lot of progress
with javascript necessary for question editing form and question attempt UI.
---
.../edit_ddimagetoimage_form.php | 56 ++++++++++++++-----
.../lang/en/qtype_ddimagetoimage.php | 3 +
question/type/ddimageortext/renderer.php | 15 +----
question/type/ddimageortext/styles.css | 31 ++++++++++
4 files changed, 78 insertions(+), 27 deletions(-)
diff --git a/question/type/ddimageortext/edit_ddimagetoimage_form.php b/question/type/ddimageortext/edit_ddimagetoimage_form.php
index 0c43a7ed611..bf34edb813d 100644
--- a/question/type/ddimageortext/edit_ddimagetoimage_form.php
+++ b/question/type/ddimageortext/edit_ddimagetoimage_form.php
@@ -46,7 +46,8 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
*/
public static function file_picker_options() {
$filepickeroptions = array();
- $filepickeroptions['accepted_types'] = array('web_image');
+ //$filepickeroptions['accepted_types'] = array('web_image');
+ $filepickeroptions['accepted_types'] = array('*');
$filepickeroptions['maxbytes'] = 0;
$filepickeroptions['maxfiles'] = 1;
$filepickeroptions['subdirs'] = 0;
@@ -78,8 +79,15 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
* @param object $mform (the form being built).
*/
protected function definition_inner($mform) {
- $mform->addElement('filepicker', 'bgimage', get_string('bgimage', 'qtype_ddimagetoimage'),
- null, self::file_picker_options());
+
+ $previewareaheaderelement = $mform->createElement('header', 'previewareaheader',
+ get_string('previewareaheader', 'qtype_ddimagetoimage'));
+ $mform->insertElementBefore($previewareaheaderelement, 'generalheader');
+ $previewareaelement = $mform->createElement('static', 'previewarea',
+ get_string('previewarea', 'qtype_ddimagetoimage'),
+ get_string('previewareamessage', 'qtype_ddimagetoimage'));
+ $mform->insertElementBefore($previewareaelement, 'generalheader');
+
list($imagerepeatsatstart, $imagerepeats) = $this->get_drag_image_repeats();
$this->definition_drop_zones($mform, $imagerepeats);
@@ -98,6 +106,10 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
$mform->addElement('header', 'dropzoneheader',
get_string('dropzoneheader', 'qtype_ddimagetoimage'));
+ $mform->addElement('filepicker', 'bgimage', get_string('bgimage', 'qtype_ddimagetoimage'),
+ null, self::file_picker_options());
+
+
$countdropzones = 0;
if (isset($this->question->id)) {
foreach ($this->question->options->drops as $drop) {
@@ -136,6 +148,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
$mform->setType('ytop', PARAM_NOTAGS);
$options = array();
+ $options[0] = '';
for ($i = 1; $i <= $imagerepeats; $i += 1) {
$options[$i] = $i;
}
@@ -156,7 +169,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
protected function drop_zones_repeated_options() {
$repeatedoptions = array();
- $repeatedoptions['choicegroup']['default'] = '1';
+ $repeatedoptions['choice']['default'] = '0';
return $repeatedoptions;
}
@@ -204,6 +217,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
}
public function data_preprocessing($question) {
+ global $PAGE;
$question = parent::data_preprocessing($question);
$question = $this->data_preprocessing_combined_feedback($question, true);
@@ -225,8 +239,8 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
//numbers not allowed in filearea name
$filearea = str_replace(range('0', '9'), range('a', 'j'), "drag_$imageindex");
file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimagetoimage',
- $filearea, !empty($question->id) ? (int) $question->id : null,
- self::file_picker_options());
+ $filearea, !empty($question->id) ? (int) $question->id : null,
+ self::file_picker_options());
$question->dragitem[$imageindex] = $draftitemid;
}
$question->drops = array();
@@ -237,18 +251,34 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
$question->drops[$drop->no -1]['xleft'] = $drop->xleft;
$question->drops[$drop->no -1]['ytop'] = $drop->ytop;
}
+ $draftitemid = file_get_submitted_draft_itemid('bgimage');
+ file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimagetoimage',
+ 'bgimage', !empty($question->id) ? (int) $question->id : null,
+ self::file_picker_options());
+ $question->bgimage = $draftitemid;
}
- $draftitemid = file_get_submitted_draft_itemid('bgimage');
- file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimagetoimage',
- 'bgimage', !empty($question->id) ? (int) $question->id : null,
- self::file_picker_options());
- $question->bgimage = $draftitemid;
- error_log(print_r(array('mform' => $this), true));
- error_log(print_r(compact('question'), true));
+ $jsmodule = array(
+ 'name' => 'qtype_ddimagetoimage',
+ 'fullpath' => '/question/type/ddimagetoimage/module.js',
+ 'requires' => array('node', 'dd-drop', 'dd-constrain', 'form_filepicker')
+ );
+ $PAGE->requires->js_init_call('M.qtype_ddimagetoimage.init_form',
+ null, true, $jsmodule);
+
return $question;
}
+ public static function file_get_draft_area_files($draftitemid) {
+ $toreturn = new stdClass();
+ $toreturn->draftitemid = $draftitemid;
+ $draftareafiles = file_get_drafarea_files($draftitemid);
+ $draftareafile = reset($draftareafiles->list);
+ $toreturn->url = $draftareafile->url;
+ return $toreturn;
+ }
+
+
public function validation($data, $files) {
$errors = parent::validation($data, $files);
diff --git a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
index d836df9f9c2..6796aa9898a 100644
--- a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
@@ -38,6 +38,9 @@ $string['dropzoneheader'] = 'Drop zones';
$string['editingddimagetoimage'] = 'Editing drag and drop: images onto images';
$string['infinite'] = 'Infinite';
$string['label'] = 'Label';
+$string['previewarea'] = 'Preview area -';
+$string['previewareaheader'] = 'Preview';
+$string['previewareamessage'] = 'Choose a background image and draggable images and designate drop zones and they will be previewed here.';
$string['shuffleimages'] = 'Shuffle Draggable Images';
$string['xleft'] = 'Left';
$string['ytop'] = 'Top';
\ No newline at end of file
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index 74750609547..ba760b4d5ed 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -44,20 +44,7 @@ class qtype_ddimagetoimage_renderer extends qtype_elements_embedded_in_question_
protected function post_qtext_elements(question_attempt $qa,
question_display_options $options) {
$result = '';
- $question = $qa->get_question();
- $dragboxs = '';
- foreach ($question->choices as $group => $choices) {
- $dragboxs .= $this->drag_boxes($qa, $group,
- $question->get_ordered_choices($group), $options);
- }
- $result .= html_writer::tag('div', $dragboxs,
- array('class' => 'answercontainer'));
- // We abuse the clear_wrong method to output the hidden form fields we
- // want irrespective of whether we are actually clearing the wrong
- // bits of the response.
- if (!$options->clearwrong) {
- $result .= $this->clear_wrong($qa, false);
- }
+
return $result;
}
diff --git a/question/type/ddimageortext/styles.css b/question/type/ddimageortext/styles.css
index 4b26ec74d81..ccc0cf63947 100755
--- a/question/type/ddimageortext/styles.css
+++ b/question/type/ddimageortext/styles.css
@@ -68,3 +68,34 @@
.que.ddimagetoimage .group8 {
background-color: #F0E68C;
}
+
+form.mform fieldset#previewareaheader .drag {
+ border: 1px solid black;
+ background-color: #004C6D;
+ cursor: move;
+ margin: 5px;
+ z-index: 3;
+}
+form.mform fieldset#previewareaheader .dragitems {
+ clear:left;
+}
+
+
+form.mform fieldset#previewareaheader {
+ text-align : center;
+}
+form.mform fieldset#previewareaheader .dropbackground {
+ margin:0 auto;
+ background-color: #8DD5E7;
+ z-index: 1;
+}
+form.mform fieldset#previewareaheader .droptarget {
+ border: 1px solid black;
+ position: absolute;
+ background-color: #FFA928;
+ z-index: 2;
+}
+
+form.mform fieldset#previewareaheader .droptarget.yui3-dd-drop-over {
+ background-color: #FFA928;
+}
From 649e58e904970bacad86cc0f1c89047993d0a771 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Mon, 1 Aug 2011 20:42:18 +0700
Subject: [PATCH 032/208] MDL-47494 ddimageortext: NOBUG implemented resizing
of images,validity checks on form data, different sizes for margins so all
items in a group take up the same screen real estate.
---
question/type/ddimageortext/TODO.txt | 16 ++--
.../edit_ddimagetoimage_form.php | 86 +++++++++++++++----
.../lang/en/qtype_ddimagetoimage.php | 13 ++-
question/type/ddimageortext/questiontype.php | 2 +-
question/type/ddimageortext/styles.css | 40 +++++++--
5 files changed, 120 insertions(+), 37 deletions(-)
diff --git a/question/type/ddimageortext/TODO.txt b/question/type/ddimageortext/TODO.txt
index 7c6564c25a1..aceaf24f456 100644
--- a/question/type/ddimageortext/TODO.txt
+++ b/question/type/ddimageortext/TODO.txt
@@ -1,16 +1,12 @@
-Question authoring form fields 2 hours
-Display Image in authoring form
-Calculation of size of drop zones
-Calculate size of images, server side and save the sizes upon image upload
-Display of drop zones on authoring form 4 hours
+Question authoring form fields
+* correct sizing of borders and margins
+
Question instance saving 2 hours
Question instance loading 2 hours
Question rendering code 6 hours
-- correctly position images
-- make images draggable
-- react to drop of images
-- write position that images where dropped to in hidden fields
+- repurpose and extend authoring form code for question rendering
+- make sure code works with multiple questions on the page
+- get position that images where dropped to from hidden fields
- grade question parts based on where images dragged to
-- have position of images at start respond to saved state
Testing and debugging for cross browser compatibility 4 hours
diff --git a/question/type/ddimageortext/edit_ddimagetoimage_form.php b/question/type/ddimageortext/edit_ddimagetoimage_form.php
index bf34edb813d..909fc2e479c 100644
--- a/question/type/ddimageortext/edit_ddimagetoimage_form.php
+++ b/question/type/ddimageortext/edit_ddimagetoimage_form.php
@@ -80,18 +80,16 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
*/
protected function definition_inner($mform) {
- $previewareaheaderelement = $mform->createElement('header', 'previewareaheader',
+ $mform->addElement('header', 'previewareaheader',
get_string('previewareaheader', 'qtype_ddimagetoimage'));
- $mform->insertElementBefore($previewareaheaderelement, 'generalheader');
- $previewareaelement = $mform->createElement('static', 'previewarea',
+ $mform->addElement('static', 'previewarea',
get_string('previewarea', 'qtype_ddimagetoimage'),
get_string('previewareamessage', 'qtype_ddimagetoimage'));
- $mform->insertElementBefore($previewareaelement, 'generalheader');
list($imagerepeatsatstart, $imagerepeats) = $this->get_drag_image_repeats();
$this->definition_drop_zones($mform, $imagerepeats);
- $mform->addElement('checkbox', 'shuffleanswers', ' ',
+ $mform->addElement('advcheckbox', 'shuffleanswers', ' ',
get_string('shuffleimages', 'qtype_ddimagetoimage'));
$mform->setDefault('shuffleanswers', 0);
$mform->closeHeaderBefore('shuffleanswers');
@@ -202,9 +200,8 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
get_string('group', 'qtype_gapselect').' ');
$grouparray[] = $mform->createElement('select', 'draggroup',
get_string('group', 'qtype_gapselect'), $options);
- $grouparray[] = $mform->createElement('checkbox', 'infinite', ' ',
- get_string('infinite', 'qtype_ddimagetoimage'), null,
- array('size' => 1, 'class' => 'tweakcss'));
+ $grouparray[] = $mform->createElement('advcheckbox', 'infinite', ' ',
+ get_string('infinite', 'qtype_ddimagetoimage'));
$draggableimageitem[] = $mform->createElement('group', 'drags',
get_string('label', 'qtype_ddimagetoimage'), $grouparray);
return $draggableimageitem;
@@ -261,7 +258,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
$jsmodule = array(
'name' => 'qtype_ddimagetoimage',
'fullpath' => '/question/type/ddimagetoimage/module.js',
- 'requires' => array('node', 'dd-drop', 'dd-constrain', 'form_filepicker')
+ 'requires' => array('node', 'dd', 'dd-drop', 'dd-constrain', 'form_filepicker')
);
$PAGE->requires->js_init_call('M.qtype_ddimagetoimage.init_form',
null, true, $jsmodule);
@@ -269,19 +266,78 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
return $question;
}
- public static function file_get_draft_area_files($draftitemid) {
- $toreturn = new stdClass();
- $toreturn->draftitemid = $draftitemid;
+
+ public static function file_uploaded($draftitemid) {
$draftareafiles = file_get_drafarea_files($draftitemid);
- $draftareafile = reset($draftareafiles->list);
- $toreturn->url = $draftareafile->url;
- return $toreturn;
+ do {
+ $draftareafile = array_shift($draftareafiles->list);
+ } while ($draftareafile !== null && $draftareafile->filename == '.');
+ if ($draftareafile === null) {
+ return false;
+ }
+ return true;
}
public function validation($data, $files) {
$errors = parent::validation($data, $files);
+ if (!self::file_uploaded($data['bgimage'])){
+ $errors["bgimage"] = get_string('formerror_nobgimage', 'qtype_ddimagetoimage');
+ }
+ $allchoices = array();
+ for ($i=0; $i < $data['nodropzone']; $i++) {
+ $ytoppresent = (trim($data['drops'][$i]['ytop']) !== '');
+ $xleftpresent = (trim($data['drops'][$i]['ytop']) !== '');
+ $labelpresent = (trim($data['drops'][$i]['droplabel']) !== '');
+ $choice = $data['drops'][$i]['choice'];
+ $imagechoicepresent = ($choice !== '0');
+
+ if ($imagechoicepresent) {
+ if (!$ytoppresent) {
+ $errors["drops[$i]"] =
+ get_string('formerror_noytop', 'qtype_ddimagetoimage');
+ }
+ if (!$xleftpresent) {
+ $errors["drops[$i]"] =
+ get_string('formerror_noxleft', 'qtype_ddimagetoimage');
+ }
+ if (!self::file_uploaded($data['dragitem'][$choice - 1])) {
+ $errors["drops[$i]"] =
+ get_string('formerror_nofile', 'qtype_ddimagetoimage', $choice);
+ $errors['dragitem['.($choice - 1).']'] =
+ get_string('formerror_nofile2', 'qtype_ddimagetoimage', $i);
+ }
+ if (isset($allchoices[$choice]) && !$data['drags'][$choice-1]['infinite']) {
+ $errors["drops[$i]"] =
+ get_string('formerror_multipledraginstance', 'qtype_ddimagetoimage', $choice);
+ $errors['drops['.($allchoices[$choice]).']'] =
+ get_string('formerror_multipledraginstance', 'qtype_ddimagetoimage', $choice);
+ $errors['drags['.($choice-1).']'] =
+ get_string('formerror_multipledraginstance2', 'qtype_ddimagetoimage', $choice);
+ }
+ $allchoices[$choice] = $i;
+ } else {
+ if ($ytoppresent || $xleftpresent || $labelpresent) {
+ echo '
';
+ $errors["drops[$i]"] =
+ get_string('formerror_noimageselected', 'qtype_ddimagetoimage');
+ }
+ }
+
+ }
+ for ($i=0; $i < $data['noimages']; $i++) {
+ $labelpresent = (trim($data['drags'][$i]['draglabel']) !== '');
+ $infinitechecked = (trim($data['drags'][$i]['infinite']) === '1');
+ if (!self::file_uploaded($data['dragitem'][$i])) {
+ if ($infinitechecked || $labelpresent) {
+ $errors['dragitem['.($i).']'] =
+ get_string('formerror_nofile3', 'qtype_ddimagetoimage');
+ }
+ }
+ }
return $errors;
}
diff --git a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
index 6796aa9898a..6e0424cffe9 100644
--- a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
@@ -29,18 +29,27 @@ $string['answer'] = 'Answer';
$string['bgimage'] = 'Background Image';
$string['correctansweris'] = 'The correct answer is: {$a}';
$string['ddimagetoimage'] = 'Drag and drop: images onto images';
-$string['ddimagetoimage_help'] = 'Select a background image file, select a number of draggable images and define the drop zones on the background image to which they must be dragged.';
+$string['ddimagetoimage_help'] = 'Select a background image file, select draggable images and define the drop zones on the background image to which they must be dragged.';
$string['ddimagetoimagesummary'] = 'Images are dragged and dropped into drop zones on a background image.';
$string['draggableimage'] = 'Draggable image';
$string['draggableimageheader'] = 'Draggable image {$a}';
$string['dropzone'] = 'Drop zone {$a}';
$string['dropzoneheader'] = 'Drop zones';
$string['editingddimagetoimage'] = 'Editing drag and drop: images onto images';
+$string['formerror_noytop'] = 'You must provide a value for the y coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
+$string['formerror_noxleft'] = 'You must provide a value for the y coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
+$string['formerror_nofile'] = 'Although you selected drag image {$a} as the correct choice for this drop zone you have not selected an image for drag image {$a}.';
+$string['formerror_nofile2'] = 'You need to select an image file here, this drag item is referred to as the correct answer for drop zone {$a}.';
+$string['formerror_nofile3'] = 'You need to select an image file here, or delete the associated label and uncheck the infinite checkbox.';
+$string['formerror_multipledraginstance'] = 'You have selected this image {$a} more than once as the correct choice for a drop zone but it is not marked as being an infinite drag item.';
+$string['formerror_multipledraginstance2'] = 'You have selected this image more than once as the correct choice for a drop zone but it is not marked as being an infinite drag item.';
+$string['formerror_noimageselected'] = 'You need to select a drag item to be the correct choice for this drop zone.';
+$string['formerror_nobgimage'] = 'You need to select an image to use as the background for the drag and drop area.';
$string['infinite'] = 'Infinite';
$string['label'] = 'Label';
$string['previewarea'] = 'Preview area -';
$string['previewareaheader'] = 'Preview';
-$string['previewareamessage'] = 'Choose a background image and draggable images and designate drop zones and they will be previewed here.';
+$string['previewareamessage'] = '
Select a background image file.
Select draggable images.
And define drop zones by selecting an image that the student must drag to the drop zone and drag it to where the student should drag it too.
';
- $qdata->options->incorrectfeedbackformat = FORMAT_MOODLE;
-
- $qdata->options->answers = array(
- 13 => new question_answer(13, 'Alpha', 0,
- 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}',
- FORMAT_MOODLE),
- 14 => new question_answer(14, 'Beta', 0,
- 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}',
- FORMAT_MOODLE),
- 15 => new question_answer(15, 'Gamma', 0,
- 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}',
- FORMAT_MOODLE),
- );
-
- $qdata->hints = array(
- 1 => new question_hint_with_parts(1, 'Try again.', FORMAT_MOODLE, true, false),
- 2 => new question_hint_with_parts(2,
- 'These are the first three letters of the Greek alphabet.',
- FORMAT_MOODLE, true, true),
- );
-
- $exporter = new qformat_xml();
- $xml = $exporter->writequestion($qdata);
-
- $expectedxml = '
-
-
- A drag-and-drop question
-
-
- Put these in order: [[1]], [[2]], [[3]].
-
-
- The answer is Alpha, Beta, Gamma.
-
- 3
- 0.3333333
- 0
- 1
-
- Your answer is correct.]]>
-
-
- Your answer is partially correct.]]>
-
-
- Your answer is incorrect.]]>
-
-
-
- Alpha
- 1
-
-
- Beta
- 1
-
-
- Gamma
- 1
-
-
-
- Try again.
-
-
-
- These are the first three letters of the Greek alphabet.
-
-
-
-
-';
-
- $this->assert_same_xml($expectedxml, $xml);
- }
}
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index bbbdf4118eb..e2e15c2516b 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -73,6 +73,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -83,6 +84,8 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->quba->get_field_prefix($this->slot) . 'p2', '0'),
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', '0'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -94,6 +97,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -116,6 +120,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true),
$this->get_contains_drop_box_expectation('p2', 2, true),
@@ -133,6 +138,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -155,6 +161,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(2);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
$this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
@@ -181,6 +188,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -199,6 +207,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -218,6 +227,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$complete);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -264,6 +274,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -284,6 +295,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -304,6 +316,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gaveup);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true),
$this->get_contains_drop_box_expectation('p2', 2, true),
@@ -320,6 +333,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -339,6 +353,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -358,6 +373,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(1);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
$this->get_contains_drop_box_expectation('p2', 2, true, 'incorrect'),
@@ -383,6 +399,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->check_current_mark(null);
$this->assertEqual('interactivecountback',
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -405,6 +422,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true),
$this->get_contains_drop_box_expectation('p2', 2, true),
@@ -436,6 +454,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -459,6 +478,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true),
$this->get_contains_drop_box_expectation('p2', 2, true),
@@ -484,6 +504,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -507,6 +528,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(6);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
$this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
@@ -541,6 +563,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -565,6 +588,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(3);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
$this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
@@ -597,6 +621,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
@@ -621,6 +646,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(1);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
$this->get_contains_drop_box_expectation('p2', 2, true, 'incorrect'),
@@ -651,6 +677,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
$this->get_contains_drop_box_expectation('p1', 1, false),
@@ -713,6 +740,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
+ $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
$this->get_contains_drop_box_expectation('p1', 1, false),
$this->get_contains_drop_box_expectation('p2', 2, false),
From e074cd91ea2171a2b4e795d28d2170d9500ee31e Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Wed, 24 Aug 2011 17:52:53 +0700
Subject: [PATCH 072/208] MDL-47494 ddimageortext: NOBUG "Typo in DDWtoS
foreign key definition #874" applying a small fix for a typo from a fix to
the ddwtos code that this code is based on.
---
question/type/ddimageortext/db/install.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/question/type/ddimageortext/db/install.xml b/question/type/ddimageortext/db/install.xml
index 6ab689a2b2e..07a40be9766 100755
--- a/question/type/ddimageortext/db/install.xml
+++ b/question/type/ddimageortext/db/install.xml
@@ -19,7 +19,7 @@
-
+
From 87c64021c2dc001a38648bbb5293168abc4e2fa6 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Wed, 24 Aug 2011 18:25:53 +0700
Subject: [PATCH 073/208] MDL-47494 ddimageortext: NOBUG mainly white space
changes to fix code formatting issues highlighted by code checker.
---
question/type/ddimageortext/README.txt | 6 ++-
question/type/ddimageortext/TODO.txt | 12 -----
...ckup_qtype_ddimagetoimage_plugin.class.php | 2 -
...tore_qtype_ddimagetoimage_plugin.class.php | 8 +--
question/type/ddimageortext/db/install.xml | 2 +-
.../edit_ddimagetoimage_form.php | 7 +--
question/type/ddimageortext/questiontype.php | 13 +++--
question/type/ddimageortext/renderer.php | 3 +-
question/type/ddimageortext/styles.css | 1 -
question/type/ddimageortext/yui/dd/dd.js | 33 ++++++------
question/type/ddimageortext/yui/form/form.js | 51 +++++++++----------
11 files changed, 58 insertions(+), 80 deletions(-)
delete mode 100644 question/type/ddimageortext/TODO.txt
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
index 5fbeb377a09..6c4605afe54 100644
--- a/question/type/ddimageortext/README.txt
+++ b/question/type/ddimageortext/README.txt
@@ -11,8 +11,10 @@ This question type is compatible with Moodle 2.1+.
Requires this fix : MDL-28099
filepicker form element does not work with element names with an index such as image[0]
-To install using git, type this command in the root of your Moodle install
- git clone git://github.com/jamiepratt/moodle-qtype_ddimagetoimage.git question/type/ddimagetoimage
+To install using git, type this command in the root of your Moodle install :
+
+git clone git://github.com/jamiepratt/moodle-qtype_ddimagetoimage.git question/type/ddimagetoimage
+
Then add question/type/ddimagetoimage to your git ignore.
Alternatively, download the zip from
diff --git a/question/type/ddimageortext/TODO.txt b/question/type/ddimageortext/TODO.txt
deleted file mode 100644
index aceaf24f456..00000000000
--- a/question/type/ddimageortext/TODO.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-Question authoring form fields
-* correct sizing of borders and margins
-
-Question instance saving 2 hours
-Question instance loading 2 hours
-Question rendering code 6 hours
-- repurpose and extend authoring form code for question rendering
-- make sure code works with multiple questions on the page
-- get position that images where dropped to from hidden fields
-- grade question parts based on where images dragged to
-
-Testing and debugging for cross browser compatibility 4 hours
diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
index 4aeef438677..de8d93da728 100644
--- a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
@@ -57,7 +57,6 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
$drop = new backup_nested_element('drop', array('id'),
array('no', 'xleft', 'ytop', 'choice', 'label'));
-
$ddimagetoimages->set_source_table('qtype_ddimagetoimage',
array('questionid' => backup::VAR_PARENTID));
@@ -69,7 +68,6 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
$drag->set_source_table('qtype_ddimagetoimage_drags',
array('questionid' => backup::VAR_PARENTID));
-
$drop->set_source_table('qtype_ddimagetoimage_drops',
array('questionid' => backup::VAR_PARENTID));
diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
index eeb4ac1f289..7d54ed41861 100644
--- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
@@ -21,10 +21,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
defined('MOODLE_INTERNAL') || die();
-
/**
* restore plugin class that provides the necessary information
* needed to restore one ddimagetoimage qtype plugin
@@ -71,7 +69,8 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
$newquestionid = $this->get_new_parentid('question');
$questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;
- // If the question has been created by restore, we need to create its qtype_ddimagetoimage too
+ // If the question has been created by restore,
+ // we need to create its qtype_ddimagetoimage too
if ($questioncreated) {
// Adjust some columns
$data->questionid = $newquestionid;
@@ -137,7 +136,8 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
$contents = array();
$fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
- $contents[] = new restore_decode_content('qtype_ddimagetoimage', $fields, 'question_ddimagetoimage');
+ $contents[] =
+ new restore_decode_content('qtype_ddimagetoimage', $fields, 'question_ddimagetoimage');
return $contents;
}
diff --git a/question/type/ddimageortext/db/install.xml b/question/type/ddimageortext/db/install.xml
index 07a40be9766..209aa0a2a08 100755
--- a/question/type/ddimageortext/db/install.xml
+++ b/question/type/ddimageortext/db/install.xml
@@ -52,4 +52,4 @@
-
\ No newline at end of file
+
diff --git a/question/type/ddimageortext/edit_ddimagetoimage_form.php b/question/type/ddimageortext/edit_ddimagetoimage_form.php
index d47bff8ed0f..f21e4d9b114 100644
--- a/question/type/ddimageortext/edit_ddimagetoimage_form.php
+++ b/question/type/ddimageortext/edit_ddimagetoimage_form.php
@@ -67,7 +67,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
}
$imagerepeats = optional_param('noimages', $imagerepeatsatstart, PARAM_INT);
$addfields = optional_param('addimages', '', PARAM_TEXT);
- if (!empty($addfields)){
+ if (!empty($addfields)) {
$imagerepeats += self::ADD_NUM_IMAGES;
}
return array($imagerepeatsatstart, $imagerepeats);
@@ -85,7 +85,6 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
get_string('previewarea', 'qtype_ddimagetoimage'),
get_string('previewareamessage', 'qtype_ddimagetoimage'));
-
list($imagerepeatsatstart, $imagerepeats) = $this->get_drag_image_repeats();
$this->definition_drop_zones($mform, $imagerepeats);
$mform->addElement('advcheckbox', 'shuffleanswers', ' ',
@@ -106,7 +105,6 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
$mform->addElement('filepicker', 'bgimage', get_string('bgimage', 'qtype_ddimagetoimage'),
null, self::file_picker_options());
-
$countdropzones = 0;
if (isset($this->question->id)) {
foreach ($this->question->options->drops as $drop) {
@@ -129,7 +127,6 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
protected function drop_zone($mform, $imagerepeats) {
$dropzoneitem = array();
-
$grouparray = array();
$grouparray[] = $mform->createElement('static', 'xleftlabel', '',
' '.get_string('xleft', 'qtype_ddimagetoimage').' ');
@@ -293,7 +290,7 @@ class qtype_ddimagetoimage_edit_form extends question_edit_form {
public function validation($data, $files) {
$errors = parent::validation($data, $files);
- if (!self::file_uploaded($data['bgimage'])){
+ if (!self::file_uploaded($data['bgimage'])) {
$errors["bgimage"] = get_string('formerror_nobgimage', 'qtype_ddimagetoimage');
}
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index ead9773eb8b..e3d7cea2180 100755
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -134,8 +134,8 @@ class qtype_ddimagetoimage extends question_type {
$this->save_hints($formdata, true);
$DB->update_record('qtype_ddimagetoimage', $options);
$DB->delete_records('qtype_ddimagetoimage_drops', array('questionid' => $formdata->id));
- foreach (array_keys($formdata->drops) as $dropno){
- if ($formdata->drops[$dropno]['choice'] == 0){
+ foreach (array_keys($formdata->drops) as $dropno) {
+ if ($formdata->drops[$dropno]['choice'] == 0) {
continue;
}
$drop = new stdClass();
@@ -153,7 +153,7 @@ class qtype_ddimagetoimage extends question_type {
$olddragids = $DB->get_records_menu('qtype_ddimagetoimage_drags',
array('questionid' => $formdata->id),
'', 'no, id');
- foreach (array_keys($formdata->drags) as $dragno){
+ foreach (array_keys($formdata->drags) as $dragno) {
$info = file_get_draft_area_info($formdata->dragitem[$dragno]);
if ($info['filecount'] > 0) {
$draftitemid = $formdata->dragitem[$dragno];
@@ -173,8 +173,6 @@ class qtype_ddimagetoimage extends question_type {
$drag->id = $DB->insert_record('qtype_ddimagetoimage_drags', $drag);
}
-
-
self::constrain_image_size_in_draft_area($draftitemid,
QTYPE_DDIMAGETOIMAGE_DRAGIMAGE_MAXWIDTH,
QTYPE_DDIMAGETOIMAGE_DRAGIMAGE_MAXHEIGHT);
@@ -218,7 +216,7 @@ class qtype_ddimagetoimage extends question_type {
$quality = 8;
break;
default :
- $quality = NULL;
+ $quality = null;
}
$newwidth = min($maxwidth, $width);
$newheight = min($maxheight, $height);
@@ -291,7 +289,8 @@ class qtype_ddimagetoimage extends question_type {
$output .= " ".$this->write_files($files, 2)."\n";;
foreach ($question->options->drags as $drag) {
- $files = $fs->get_area_files($contextid, 'qtype_ddimagetoimage', 'dragimage', $drag->id);
+ $files =
+ $fs->get_area_files($contextid, 'qtype_ddimagetoimage', 'dragimage', $drag->id);
$output .= " \n";
$output .= " {$drag->no}\n";
$output .= $format->writetext($drag->label, 3)."\n";
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index 18a3c238a04..fb5fe30679c 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -100,7 +100,7 @@ class qtype_ddimagetoimage_renderer extends qtype_with_combined_feedback_rendere
$dropzones = html_writer::empty_tag('div', array('class'=>'dropzones'));
$output .= html_writer::tag('div', $droparea.$dragitems.$dropzones,
array('class'=>'ddarea'));
- foreach ($question->places as $placeno => $place){
+ foreach ($question->places as $placeno => $place) {
$varname = $question->field($placeno);
list($fieldname, $html) = $this->hidden_field_for_qt_var($qa, $varname);
$output .= $html;
@@ -115,7 +115,6 @@ class qtype_ddimagetoimage_renderer extends qtype_with_combined_feedback_rendere
'M.qtype_ddimagetoimage.init_question',
array($params));
-
if ($qa->get_state() == question_state::$invalid) {
$output .= html_writer::nonempty_tag('div',
$question->get_validation_error($qa->get_last_qt_data()),
diff --git a/question/type/ddimageortext/styles.css b/question/type/ddimageortext/styles.css
index 9453d9273e5..77038e98293 100755
--- a/question/type/ddimageortext/styles.css
+++ b/question/type/ddimageortext/styles.css
@@ -123,4 +123,3 @@ form.mform fieldset#previewareaheader .droptarget {
form.mform fieldset#previewareaheader div.droparea img {
border: 1px solid #000000;
}
-
diff --git a/question/type/ddimageortext/yui/dd/dd.js b/question/type/ddimageortext/yui/dd/dd.js
index 2f024e7c0bc..32c199795ef 100644
--- a/question/type/ddimageortext/yui/dd/dd.js
+++ b/question/type/ddimageortext/yui/dd/dd.js
@@ -1,4 +1,3 @@
-
YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
var DDIMAGETOIMAGEDDNAME = 'ddimagetoimage_dd';
var DDIMAGETOIMAGE_DD = function() {
@@ -16,7 +15,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
bgdone = bgdone && this.doc.bg_img().hasClass('constrained');
}
var alldragsloaded = !this.doc.drag_image_homes().some(function(dragimagehome){
- //in 'some' loop returning true breaks the loop and is passed as return value from
+ //in 'some' loop returning true breaks the loop and is passed as return value from
//'some' else returns false. Can be though of as equivalent to ||.
var done = (dragimagehome.get('complete'));
if (waitforimageconstrain) {
@@ -141,13 +140,13 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
node: drag,
dragMode: 'intersect'
}).plug(Y.Plugin.DDConstrained, {constrain2node: topnode});
-
+
dd.on('drag:end', function(e) {
mainobj.reposition_drags_for_question();
}, this);
drag.setData('group', group);
drag.setData('choice', choice);
-
+
},
draggable_for_form : function (drag) {
var dd = new Y.DD.Drag({
@@ -159,7 +158,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
var draginstanceno = dragnode.getData('draginstanceno');
var gooddrop = dragnode.getData('gooddrop');
var endxy;
-
+
if (!gooddrop) {
mainobj.reset_drag_xy(draginstanceno);
} else {
@@ -171,12 +170,12 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
var drag = e.target;
drag.get('node').setData('gooddrop', false);
}, this);
-
+
}
-
+
}
},
-
+
update_padding_sizes_all : function () {
for (var groupno = 1; groupno <= 8; groupno++) {
this.update_padding_size_for_group(groupno);
@@ -238,7 +237,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
this.update_padding_sizes_all();
var i = 0;
this.doc.drag_image_homes().each(function(dragimagehome){
- var dragimageno =
+ var dragimageno =
+this.doc.get_classname_numeric_suffix(dragimagehome, 'dragimagehomes');
var choice = +this.doc.get_classname_numeric_suffix(dragimagehome, 'choice');
var group = +this.doc.get_classname_numeric_suffix(dragimagehome, 'group')
@@ -272,7 +271,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
},
drop_zone_key_press : function (e) {
switch (e.direction) {
- case 'next' :
+ case 'next' :
this.place_next_drag_in(e.target);
break;
case 'previous' :
@@ -370,7 +369,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
}
}, this);
},
- get_choices_for_drop : function(choice, drop) {
+ get_choices_for_drop : function(choice, drop) {
var group = drop.getData('group');
var dragimage = null;
var dragimages = this.doc.top_node()
@@ -379,6 +378,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
},
get_unplaced_choice_for_drop : function(choice, drop) {
var dragimages = this.get_choices_for_drop(choice, drop);
+ var dragimage = null;
if (dragimages.some(function (d) {
if (!d.hasClass('placed')) {
dragimage = d;
@@ -386,11 +386,8 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
} else {
return false;
}
- })) {
- return dragimage;
- } else {
- return null;
- }
+ }));
+ return dragimage;
},
init_drops : function () {
var dropareas = this.doc.top_node().one('div.dropzones');
@@ -424,7 +421,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
};
}
}, {NAME : DDIMAGETOIMAGEQUESTIONNAME, ATTRS : {}});
-
+
Y.Event.define('dragchange', {
// Webkit and IE repeat keydown when you hold down arrow keys.
// Opera links keypress to page scroll; others keydown.
@@ -453,7 +450,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
this, notifier);
}
});
- M.qtype_ddimagetoimage.init_question = function(config) {
+ M.qtype_ddimagetoimage.init_question = function(config) {
return new DDIMAGETOIMAGE_QUESTION(config);
}
}, '@VERSION@', {
diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js
index 2189d75bfe9..e8b0436bf76 100644
--- a/question/type/ddimageortext/yui/form/form.js
+++ b/question/type/ddimageortext/yui/form/form.js
@@ -17,7 +17,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
this.doc = this.doc_structure(this);
this.draw_dd_area();
},
-
+
draw_dd_area : function() {
var bgimageurl = this.fp.file('bgimage').href;
this.stop_selector_events();
@@ -25,7 +25,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
if (bgimageurl !== null) {
this.doc.load_bg_img(bgimageurl);
this.load_drag_homes();
-
+
var drop = new Y.DD.Drop({
node: this.doc.bg_img()
});
@@ -33,9 +33,9 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
drop.on('drop:hit', function(e) {
e.drag.get('node').setData('gooddrop', true);
});
-
+
Y.on('windowresize', this.reposition_drags_for_form, this);
-
+
this.doc.bg_img().on('load', this.constrain_image_size, this, 'bgimage');
this.doc.drag_image_homes()
.on('load', this.constrain_image_size, this, 'dragimage');
@@ -47,7 +47,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
this.setup_form_events();
}
},
-
+
after_all_images_loaded : function () {
this.update_padding_sizes_all();
this.update_drag_instances();
@@ -55,7 +55,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
this.set_options_for_drag_image_selectors();
this.setup_form_events();
},
-
+
constrain_image_size : function (e, imagetype) {
var maxsize = this.get('maxsizes')[imagetype];
var reduceby = Math.max(e.target.get('width') / maxsize.width,
@@ -66,22 +66,22 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
e.target.addClass('constrained');
e.target.detach('load', this.constrain_image_size);
},
-
+
load_drag_homes : function () {
//set up drag items homes
- var dragimagesoptions = {0: ''};
+ var dragimagesoptions = {0: ''};
for (var i=0; i < this.form.get_form_value('noimages', []); i++) {
this.load_drag_home(i);
}
},
-
+
load_drag_home : function (dragimageno) {
var url = this.fp.file(this.form.to_name_with_index('dragitem', [dragimageno])).href;
- this.doc.add_or_update_drag_image_home(dragimageno, url,
+ this.doc.add_or_update_drag_image_home(dragimageno, url,
this.form.get_form_value('drags', [dragimageno, 'draglabel']),
this.form.get_form_value('drags', [dragimageno, 'draggroup']));
},
-
+
update_drag_instances : function () {
//set up drop zones
for (var i=0; i < this.form.get_form_value('nodropzone', []); i++) {
@@ -95,7 +95,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}
},
set_options_for_drag_image_selectors : function () {
- var dragimagesoptions = {0: ''};
+ var dragimagesoptions = {0: ''};
for (var i=0; i < this.form.get_form_value('noimages', []); i++) {
var file = this.fp.file(this.form.to_name_with_index('dragitem', [i]));
if (file.name !== null) {
@@ -130,21 +130,21 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}
}
},
-
+
stop_selector_events : function () {
Y.all('fieldset#dropzoneheader select').detachAll();
},
-
+
setup_form_events : function () {
//events triggered by changes to form data
-
+
//x and y coordinates
Y.all('fieldset#dropzoneheader input').on('blur', function (e){
var name = e.target.getAttribute('name');
var draginstanceno = this.form.from_name_with_index(name).indexes[0];
this.reposition_drag_for_form(draginstanceno);
}, this);
-
+
//change in selected image
Y.all('fieldset#dropzoneheader select').on('change', function (e){
var name = e.target.getAttribute('name');
@@ -155,7 +155,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}
this.draw_dd_area();
}, this);
-
+
for (var i=0; i < this.form.get_form_value('noimages', []); i++) {
//change to group selector
Y.all('fieldset#draggableimageheader_'+i+' select').on('change', function (e){
@@ -171,26 +171,25 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
var name = this.fp.name(e.id);
if (name !== 'bgimage') {
this.doc.drag_images().remove(true);
- }
+ }
this.draw_dd_area();
}, M.form_filepicker, 'callback', this);
},
-
-
+
reposition_drags_for_form : function() {
this.doc.drag_images().each(function (drag) {
var draginstanceno = drag.getData('draginstanceno');
this.reposition_drag_for_form(draginstanceno);
}, this);
},
-
+
reposition_drag_for_form : function (draginstanceno) {
var drag = this.doc.drag_image(draginstanceno);
if (null !== drag) {
var fromform = [this.form.get_form_value('drops', [draginstanceno, 'xleft']),
this.form.get_form_value('drops', [draginstanceno, 'ytop'])];
if (fromform[0] == '' && fromform[1] == '') {
- var dragimageno = drag.getData('dragimageno');
+ var dragimageno = drag.getData('dragimageno');
drag.setXY(this.doc.drag_image_home(dragimageno).getXY());
} else {
var constrainedxy = this.constrain_xy(draginstanceno, fromform);
@@ -213,7 +212,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
this.form.set_form_value('drops', [draginstanceno, 'ytop'], '');
this.reposition_drag_for_form(draginstanceno);
},
-
+
//make sure xy value is not out of bounds of bg image
constrain_xy : function (draginstanceno, bgimgxy) {
var drag = this.doc.drag_image(draginstanceno);
@@ -229,7 +228,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
return [windowxy[0] - this.doc.bg_img().getX(),
windowxy[1] - this.doc.bg_img().getY()];
},
-
+
/**
* Low level operations on form.
*/
@@ -270,7 +269,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
return toreturn;
}
},
-
+
file_pickers : function () {
var draftitemidstoname;
var nametoparentnode;
@@ -301,7 +300,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}
}, {NAME : DDIMAGETOIMAGEFORMNAME, ATTRS : {maxsizes:{value:null}}});
M.qtype_ddimagetoimage = M.qtype_ddimagetoimage || {};
- M.qtype_ddimagetoimage.init_form = function(config) {
+ M.qtype_ddimagetoimage.init_form = function(config) {
return new DDIMAGETOIMAGE_FORM(config);
}
}, '@VERSION@', {
From c1844f5be82e23bf98467a97386465a8bd0e0f98 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Wed, 24 Aug 2011 18:30:12 +0700
Subject: [PATCH 074/208] MDL-47494 ddimageortext: NOBUG updating README file
with up to date installation instructions.
---
question/type/ddimageortext/README.txt | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
index 6c4605afe54..8812e8a8152 100644
--- a/question/type/ddimageortext/README.txt
+++ b/question/type/ddimageortext/README.txt
@@ -6,10 +6,7 @@ to be installed in order to work.
This question type was written by Jamie Pratt (http://jamiep.org/).
-This question type is compatible with Moodle 2.1+.
-
-Requires this fix : MDL-28099
-filepicker form element does not work with element names with an index such as image[0]
+This question type is compatible with Moodle 2.1.
To install using git, type this command in the root of your Moodle install :
@@ -19,5 +16,4 @@ Then add question/type/ddimagetoimage to your git ignore.
Alternatively, download the zip from
https://github.com/jamiepratt/moodle-qtype_ddimagetoimage/zipball/master
-unzip it into the question/type folder, and then rename the new folder to
-ddimagetoimage.
+unzip it into the question/type folder, and then rename the new folder to ddimagetoimage.
From dfd89ae5a21cda9a253a33f33e1f0df5890f3527 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Wed, 24 Aug 2011 19:48:46 +0700
Subject: [PATCH 075/208] MDL-47494 ddimageortext: NOBUG removed exception as
it messes up unit tests where files do not exist and are not needed.
---
question/type/ddimageortext/renderer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php
index fb5fe30679c..6f8d585c3c6 100755
--- a/question/type/ddimageortext/renderer.php
+++ b/question/type/ddimageortext/renderer.php
@@ -144,7 +144,7 @@ class qtype_ddimagetoimage_renderer extends qtype_with_combined_feedback_rendere
return $url->out();
}
}
- throw new coding_exception('File not found in filearea '.$filearea);
+ return null;
}
protected function hidden_field_for_qt_var(question_attempt $qa, $varname, $value = null) {
From 3637ee16866fc6002a968ac543fc20dcbd3ad9f3 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 25 Aug 2011 13:37:38 +0700
Subject: [PATCH 076/208] MDL-47494 ddimageortext: NOBUG implemented question
walkthrough unit tests.
---
.../simpletest/testwalkthrough.php | 549 ++++++++++--------
1 file changed, 306 insertions(+), 243 deletions(-)
diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php
index e2e15c2516b..bb6dae2140d 100755
--- a/question/type/ddimageortext/simpletest/testwalkthrough.php
+++ b/question/type/ddimageortext/simpletest/testwalkthrough.php
@@ -38,25 +38,14 @@ require_once($CFG->dirroot . '/question/type/ddimagetoimage/simpletest/helper.ph
*/
class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_base {
- protected function get_contains_drop_box_expectation($place, $group, $readonly,
- $stateclass = '0') {
- $qa = $this->quba->get_question_attempt($this->slot);
+ protected function get_contains_drag_image_home_expectation($dragimageno, $choice, $group) {
+ $class = 'group' . $group;
+ $class .= ' draghome dragimagehomes' . $dragimageno. ' choice'.$choice;
- $expectedattrs = array(
- 'id' => $qa->get_qt_field_name($place . '_' . $group),
- );
- $class = 'slot group' . $group;
- if ($readonly) {
- $class .= ' readonly';
- } else {
- $expectedattrs['tabindex'] = 0;
- }
- if ($stateclass) {
- $class .= ' ' . $stateclass;
- }
+ $expectedattrs = array();
$expectedattrs['class'] = $class;
- return new ContainsTagWithAttributes('span', $expectedattrs);
+ return new ContainsTagWithAttributes('img', $expectedattrs);
}
public function test_interactive_behaviour() {
@@ -68,66 +57,74 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
new question_hint_with_parts(14, 'This is the second hint.', FORMAT_HTML, true, true),
);
$dd->shufflechoices = false;
- $this->start_attempt_at_question($dd, 'interactive', 3);
+ $this->start_attempt_at_question($dd, 'interactive', 12);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p4', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
$this->get_no_hint_visible_expectation());
// Save the wrong answer.
- $this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2'));
-
+ $this->process_submission(array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1'));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '2'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '2'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 1),
$this->get_contains_submit_button_expectation(true),
- $this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
$this->get_no_hint_visible_expectation());
-
// Submit the wrong answer.
- $this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2', '-submit' => 1));
+ $this->process_submission(
+ array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1', '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true),
- $this->get_contains_drop_box_expectation('p2', 2, true),
- $this->get_contains_drop_box_expectation('p3', 3, true),
- $this->get_contains_submit_button_expectation(false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', 1),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 1),
$this->get_contains_try_again_button_expectation(true),
- $this->get_does_not_contain_correctness_expectation(),
new PatternExpectation('/' .
preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'),
$this->get_contains_hint_expectation('This is the first hint'));
@@ -138,17 +135,20 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p1', '2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p3', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', '1'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation(),
@@ -156,16 +156,25 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_no_hint_visible_expectation());
// Submit the right answer.
- $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '1', '-submit' => 1));
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2', '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$gradedright);
- $this->check_current_mark(2);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+ $this->check_current_mark(8);
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', '1'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', '2'),
$this->get_contains_submit_button_expectation(false),
$this->get_contains_correct_expectation(),
$this->get_no_hint_visible_expectation());
@@ -175,7 +184,7 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedright);
- $this->check_current_mark(2);
+ $this->check_current_mark(8);
}
public function test_deferred_feedback() {
@@ -183,61 +192,68 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Create a drag-and-drop question.
$dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
- $this->start_attempt_at_question($dd, 'deferredfeedback', 3);
+ $this->start_attempt_at_question($dd, 'deferredfeedback', 12);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_does_not_contain_feedback_expectation());
// Save a partial answer.
- $this->process_submission(array('p1' => '1', 'p2' => '2'));
-
+ $this->process_submission(array('p1' => '2', 'p2' => '1'));
// Verify.
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '2'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', ''),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
-
// Save the right answer.
- $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '1'));
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'));
// Verify.
$this->check_current_state(question_state::$complete);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', 1),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 2),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -246,22 +262,32 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedright);
- $this->check_current_mark(3);
+ $this->check_current_mark(12);
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', 1),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 2),
$this->get_contains_correct_expectation());
// Change the right answer a bit.
- $dd->rightchoices[2] = 2;
+ $dd->rightchoices[2] = 1;
// Check regrading does not mess anything up.
$this->quba->regrade_all_questions();
// Verify.
$this->check_current_state(question_state::$gradedpartial);
- $this->check_current_mark(2);
+ $this->check_current_mark(9);
}
public function test_deferred_feedback_unanswered() {
@@ -269,43 +295,47 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Create a drag-and-drop question.
$dd = test_question_maker::make_question('ddimagetoimage');
$dd->shufflechoices = false;
- $this->start_attempt_at_question($dd, 'deferredfeedback', 3);
+ $this->start_attempt_at_question($dd, 'deferredfeedback', 12);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
$this->check_step_count(1);
// Save a blank response.
- $this->process_submission(array('p1' => '0', 'p2' => '0', 'p3' => '0'));
+ $this->process_submission(array('p1' => '', 'p2' => '', 'p3' => '', 'p4' => ''));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', ''),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', ''),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', ''),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
$this->check_step_count(1);
@@ -316,11 +346,11 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gaveup);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true),
- $this->get_contains_drop_box_expectation('p2', 2, true),
- $this->get_contains_drop_box_expectation('p3', 3, true));
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2));
}
public function test_deferred_feedback_partial_answer() {
@@ -333,37 +363,41 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
// Save a partial response.
- $this->process_submission(array('p1' => '1', 'p2' => '0', 'p3' => '0'));
+ $this->process_submission(array('p1' => '1', 'p2' => '2', 'p3' => '', 'p4' => ''));
// Verify.
$this->check_current_state(question_state::$invalid);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', ''),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -372,12 +406,12 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedpartial);
- $this->check_current_mark(1);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+ $this->check_current_mark(1.5);
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'incorrect'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'incorrect'),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_partcorrect_expectation());
}
@@ -392,24 +426,26 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
- $this->start_attempt_at_question($dd, 'interactive', 9);
+ $this->start_attempt_at_question($dd, 'interactive', 12);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->assertEqual('interactivecountback',
$this->quba->get_question_attempt($this->slot)->get_behaviour_name());
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
@@ -417,16 +453,17 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_no_hint_visible_expectation());
// Submit an response with the first two parts right.
- $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '2', '-submit' => 1));
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '2', 'p3' => '2', 'p4' => '1', '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true),
- $this->get_contains_drop_box_expectation('p2', 2, true),
- $this->get_contains_drop_box_expectation('p3', 3, true),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_contains_try_again_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
@@ -436,35 +473,41 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_contains_num_parts_correct(2),
$this->get_contains_standard_partiallycorrect_combined_feedback_expectation(),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'));
+ $this->quba->get_field_prefix($this->slot) . 'p3', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 1));
// Check that extract responses will return the reset data.
$prefix = $this->quba->get_field_prefix($this->slot);
- $this->assertEqual(array('p1' => '1', 'p2' => '1'),
+ $this->assertEqual(array('p1' => '1', 'p2' => '2'),
$this->quba->extract_responses($this->slot,
- array($prefix . 'p1' => '1', $prefix . 'p2' => '1', '-tryagain' => 1)));
+ array($prefix . 'p1' => '1', $prefix . 'p2' => '2', '-tryagain' => 1)));
// Do try again.
- $this->process_submission(array('p1' => '1', 'p2' => '1', '-tryagain' => 1));
+ // keys p3 and p4 are extra hidden fields to clear data.
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '2', 'p3' => '', 'p4' => '', '-tryagain' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', ''),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_correctness_expectation(),
@@ -473,16 +516,17 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_no_hint_visible_expectation());
// Submit an response with the first and last parts right.
- $this->process_submission(array('p1' => '1', 'p2' => '2', 'p3' => '1', '-submit' => 1));
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '1', 'p3' => '2', 'p4' => '2', '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true),
- $this->get_contains_drop_box_expectation('p2', 2, true),
- $this->get_contains_drop_box_expectation('p3', 3, true),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_contains_try_again_button_expectation(true),
$this->get_does_not_contain_correctness_expectation(),
@@ -492,29 +536,34 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_contains_num_parts_correct(2),
$this->get_contains_standard_partiallycorrect_combined_feedback_expectation(),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '1'));
+ $this->quba->get_field_prefix($this->slot) . 'p3', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 2));
// Do try again.
- $this->process_submission(array('p1' => '1', 'p3' => '1', '-tryagain' => 1));
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '', 'p3' => '', 'p4' => '2', '-tryagain' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', ''),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '1'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 2),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_correctness_expectation(),
@@ -523,28 +572,31 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_no_hint_visible_expectation());
// Submit the right answer.
- $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '1', '-submit' => 1));
+ $this->process_submission(
+ array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2', '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$gradedright);
- $this->check_current_mark(6);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+ $this->check_current_mark(7);
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p1', 1),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p2', 2),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p3', 1),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', 2),
$this->get_contains_submit_button_expectation(false),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_contains_correct_expectation(),
$this->get_no_hint_visible_expectation(),
$this->get_does_not_contain_num_parts_correct(),
- $this->get_contains_standard_correct_combined_feedback_expectation(),
- $this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '1'),
- $this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '1'),
- $this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '1'));
+ $this->get_contains_standard_correct_combined_feedback_expectation());
}
public function test_interactive_correct_no_submit() {
@@ -563,24 +615,26 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
$this->get_no_hint_visible_expectation());
// Save the right answer.
- $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '1'));
+ $this->process_submission(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2'));
// Finish the attempt without clicking check.
$this->quba->finish_all_questions();
@@ -588,11 +642,11 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(3);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_contains_correct_expectation(),
$this->get_no_hint_visible_expectation());
@@ -616,29 +670,32 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
FORMAT_MOODLE, true, true),
);
$dd->shufflechoices = false;
- $this->start_attempt_at_question($dd, 'interactive', 3);
+ $this->start_attempt_at_question($dd, 'interactive', 4);
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
$this->get_no_hint_visible_expectation());
// Save the a partially right answer.
- $this->process_submission(array('p1' => '1', 'p2' => '2', 'p3' => '2'));
+ $this->process_submission(array('p1' => '1', 'p2' => '1', 'p3' => '2', 'p4' => '1'));
// Finish the attempt without clicking check.
$this->quba->finish_all_questions();
@@ -646,11 +703,12 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->check_current_state(question_state::$gradedpartial);
$this->check_current_mark(1);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'incorrect'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'incorrect'),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_contains_partcorrect_expectation(),
$this->get_no_hint_visible_expectation());
@@ -677,54 +735,63 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(3),
$this->get_no_hint_visible_expectation());
// Save the a completely wrong answer.
- $this->process_submission(array('p1' => '2', 'p2' => '2', 'p3' => '2', '-submit' => 1));
+ $this->process_submission(
+ array('p1' => '2', 'p2' => '1', 'p3' => '2', 'p4' => '1', '-submit' => 1));
// Verify.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
- $this->get_contains_drop_box_expectation('p1', 1, true),
- $this->get_contains_drop_box_expectation('p2', 2, true),
- $this->get_contains_drop_box_expectation('p3', 3, true),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_submit_button_expectation(false),
$this->get_contains_hint_expectation('This is the first hint'));
// Do try again.
- $this->process_submission(array('p1' => '0', 'p2' => '0', 'p3' => '0', '-tryagain' => 1));
+ $this->process_submission(
+ array('p1' => '', 'p2' => '', 'p3' => '', 'p4' => '', '-tryagain' => 1));
// Check that all the wrong answers have been cleared.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
$this->check_current_output(
$this->get_contains_marked_out_of_summary(),
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
+ $this->get_contains_drag_image_home_expectation(1, 1, 1),
+ $this->get_contains_drag_image_home_expectation(2, 2, 1),
+ $this->get_contains_drag_image_home_expectation(1, 1, 2),
+ $this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1', ''),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2', ''),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4', ''),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(2),
@@ -740,17 +807,16 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Check the initial state.
$this->check_current_state(question_state::$todo);
$this->check_current_mark(null);
- $this->expectException(new coding_exception('File not found in filearea bgimage'));
+
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p1'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p2'),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', '0'),
+ $this->quba->get_field_prefix($this->slot) . 'p3'),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4'),
$this->get_does_not_contain_feedback_expectation());
// Save a partial answer.
@@ -760,9 +826,6 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->check_current_state(question_state::$complete);
$this->check_current_mark(null);
$this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, false),
- $this->get_contains_drop_box_expectation('p2', 2, false),
- $this->get_contains_drop_box_expectation('p3', 3, false),
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p1',
$dd->get_right_choice_for(1)),
@@ -772,6 +835,9 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p3',
$dd->get_right_choice_for(3)),
+ $this->get_contains_hidden_expectation(
+ $this->quba->get_field_prefix($this->slot) . 'p4',
+ $dd->get_right_choice_for(4)),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -780,15 +846,12 @@ class qtype_ddimagetoimage_walkthrough_test extends qbehaviour_walkthrough_test_
// Verify.
$this->displayoptions->rightanswer = question_display_options::VISIBLE;
- $this->assertEqual('{quick} {fox} {lazy}', $dd->get_right_answer_summary());
+ $this->assertEqual('Drop zone 1 -> {1. quick} '.
+ 'Drop zone 2 -> {2. fox} '.
+ 'Drop zone 3 -> {1. lazy} '.
+ 'Drop zone 4 -> {2. dog}',
+ $dd->get_right_answer_summary());
$this->check_current_state(question_state::$gradedright);
$this->check_current_mark(3);
- $this->check_current_output(
- $this->get_contains_drop_box_expectation('p1', 1, true, 'correct'),
- $this->get_contains_drop_box_expectation('p2', 2, true, 'correct'),
- $this->get_contains_drop_box_expectation('p3', 3, true, 'correct'),
- $this->get_contains_correct_expectation(),
- new PatternExpectation('/' .
- preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/'));
}
}
From 5a641fe31e533f69ccf184fa7e8aa68231c55d96 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 25 Aug 2011 18:17:13 +0700
Subject: [PATCH 077/208] MDL-47494 ddimageortext: NOBUG change to use id to
find form in a way that works with IE7.
---
question/type/ddimageortext/yui/form/form.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js
index e8b0436bf76..28b1ac814f1 100644
--- a/question/type/ddimageortext/yui/form/form.js
+++ b/question/type/ddimageortext/yui/form/form.js
@@ -240,8 +240,12 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}
return indexstring;
},
+ get_el : function (name, indexes) {
+ var form = document.getElementById('mform1');
+ return form.elements[this.to_name_with_index(name, indexes)]
+ },
get_form_value : function(name, indexes) {
- var el = document.forms[0].elements[this.to_name_with_index(name, indexes)];
+ var el = this.get_el(name, indexes);
if (el.type === 'checkbox') {
return el.checked;
} else {
@@ -249,7 +253,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}
},
set_form_value : function(name, indexes, value) {
- var el = document.forms[0].elements[this.to_name_with_index(name, indexes)];
+ var el = this.get_el(name, indexes);
if (el.type === 'checkbox') {
el.checked = value;
} else {
From 8c2bf1f0d74109e7e7ded1706821f4e6903084bd Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 1 Sep 2011 17:19:24 +0700
Subject: [PATCH 078/208] MDL-47494 ddimageortext: NOBUG wait a little longer
for page to settle down after images loaded. This seems to be necessary
because after the tinymce editor loads xy coords all change.
---
question/type/ddimageortext/yui/dd/dd.js | 2 +-
question/type/ddimageortext/yui/form/form.js | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/question/type/ddimageortext/yui/dd/dd.js b/question/type/ddimageortext/yui/dd/dd.js
index 32c199795ef..0d21ec45d81 100644
--- a/question/type/ddimageortext/yui/dd/dd.js
+++ b/question/type/ddimageortext/yui/dd/dd.js
@@ -38,7 +38,7 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
} else if (this.polltimer === null) {
var pollarguments = [null, waitforimageconstrain, pause, doafterwords];
this.polltimer =
- Y.later(500, this, this.poll_for_image_load, pollarguments, true);
+ Y.later(1000, this, this.poll_for_image_load, pollarguments, true);
}
},
/**
diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js
index 28b1ac814f1..039bd633622 100644
--- a/question/type/ddimageortext/yui/form/form.js
+++ b/question/type/ddimageortext/yui/form/form.js
@@ -40,9 +40,9 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
this.doc.drag_image_homes()
.on('load', this.constrain_image_size, this, 'dragimage');
this.doc.bg_img().after('load', this.poll_for_image_load, this,
- true, 1000, this.after_all_images_loaded);
+ true, 3000, this.after_all_images_loaded);
this.doc.drag_image_homes() .after('load', this.poll_for_image_load, this,
- true, 1000, this.after_all_images_loaded);
+ true, 3000, this.after_all_images_loaded);
} else {
this.setup_form_events();
}
From dd6550e23b3802621e823e0e684b0d3538403751 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 1 Sep 2011 18:07:32 +0700
Subject: [PATCH 079/208] MDL-47494 ddimageortext: NOBUG should say drag images
to image not images to images.
---
.../type/ddimageortext/lang/en/qtype_ddimagetoimage.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
index 75ef985e90e..6e85e3aafbb 100644
--- a/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddimagetoimage.php
@@ -22,20 +22,20 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['addingddimagetoimage'] = 'Adding drag and drop: images onto images';
+$string['addingddimagetoimage'] = 'Adding drag and drop: images onto image';
$string['addmoredropzones'] = 'Blanks for {no} More Drop Zones';
$string['addmoreimages'] = 'Blanks for {no} More Draggable Images';
$string['answer'] = 'Answer';
$string['bgimage'] = 'Background Image';
$string['correctansweris'] = 'The correct answer is: {$a}';
-$string['ddimagetoimage'] = 'Drag and drop: images onto images';
+$string['ddimagetoimage'] = 'Drag and drop: images onto image';
$string['ddimagetoimage_help'] = 'Select a background image file, select draggable images and define the drop zones on the background image to which they must be dragged.';
$string['ddimagetoimagesummary'] = 'Images are dragged and dropped into drop zones on a background image.';
$string['draggableimage'] = 'Draggable image';
$string['draggableimageheader'] = 'Draggable image {$a}';
$string['dropzone'] = 'Drop zone {$a}';
$string['dropzoneheader'] = 'Drop zones';
-$string['editingddimagetoimage'] = 'Editing drag and drop: images onto images';
+$string['editingddimagetoimage'] = 'Editing drag and drop: images onto image';
$string['formerror_noytop'] = 'You must provide a value for the y coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
$string['formerror_noxleft'] = 'You must provide a value for the y coords for the top left corner of this drop area. You can drag and drop the drop area above to set the coordinates or enter them manually here.';
$string['formerror_nofile'] = 'Although you selected drag image {$a} as the correct choice for this drop zone you have not selected an image for drag image {$a}.';
From a116cdfa3de63617b44a61e2fea7b311fc65d5ec Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Thu, 1 Sep 2011 18:08:21 +0700
Subject: [PATCH 080/208] MDL-47494 ddimageortext: NOBUG refactored backup and
restore code so it can be reused by ddwordtoimage
---
...ckup_qtype_ddimagetoimage_plugin.class.php | 16 ++++++------
...tore_qtype_ddimagetoimage_plugin.class.php | 25 ++++++++++---------
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
index de8d93da728..1c6a0944db9 100644
--- a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
@@ -31,23 +31,25 @@ defined('MOODLE_INTERNAL') || die();
*/
class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
+ protected $qtype = "ddimagetoimage";
+
/**
* Returns the qtype information to attach to question element
*/
protected function define_question_plugin_structure() {
- $plugin = $this->get_plugin_element(null, '../../qtype', 'ddimagetoimage');
+ $plugin = $this->get_plugin_element(null, '../../qtype', $this->qtype);
$pluginwrapper = new backup_nested_element($this->get_recommended_name());
$plugin->add_child($pluginwrapper);
- $ddimagetoimages = new backup_nested_element('ddimagetoimage', array('id'), array(
+ $dds = new backup_nested_element($this->qtype, array('id'), array(
'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));
- $pluginwrapper->add_child($ddimagetoimages);
+ $pluginwrapper->add_child($dds);
$drags = new backup_nested_element('drags');
$drag = new backup_nested_element('drag', array('id'),
@@ -57,7 +59,7 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
$drop = new backup_nested_element('drop', array('id'),
array('no', 'xleft', 'ytop', 'choice', 'label'));
- $ddimagetoimages->set_source_table('qtype_ddimagetoimage',
+ $dds->set_source_table("qtype_{$this->qtype}",
array('questionid' => backup::VAR_PARENTID));
$pluginwrapper->add_child($drags);
@@ -65,10 +67,10 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
$pluginwrapper->add_child($drops);
$drops->add_child($drop);
- $drag->set_source_table('qtype_ddimagetoimage_drags',
+ $drag->set_source_table("qtype_{$this->qtype}_drags",
array('questionid' => backup::VAR_PARENTID));
- $drop->set_source_table('qtype_ddimagetoimage_drops',
+ $drop->set_source_table("qtype_{$this->qtype}_drops",
array('questionid' => backup::VAR_PARENTID));
return $plugin;
@@ -87,6 +89,6 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
'incorrectfeedback' => 'question_created',
'bgimage' => 'question_created',
- 'dragimage' => 'qtype_ddimagetoimage_drags');
+ 'dragimage' => "qtype_{$this->qtype}_drags");
}
}
diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
index 7d54ed41861..27433c399ba 100644
--- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
@@ -32,6 +32,8 @@ defined('MOODLE_INTERNAL') || die();
*/
class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
+ protected $qtype = "ddimagetoimage";
+
/**
* Returns the paths to be handled by the plugin at question level
*/
@@ -40,8 +42,8 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
$paths = array();
// Add own qtype stuff
- $elename = 'ddimagetoimage';
- $elepath = $this->get_pathfor('/ddimagetoimage');
+ $elename = dds;
+ $elepath = $this->get_pathfor('/'.$this->qtype);
$paths[] = new restore_path_element($elename, $elepath);
$elename = 'drag';
@@ -56,9 +58,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
}
/**
- * Process the qtype/ddimagetoimage element
+ * Process the qtype/{qtypename} element
*/
- public function process_ddimagetoimage($data) {
+ public function process_dds($data) {
global $DB;
$data = (object)$data;
@@ -75,9 +77,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
// Adjust some columns
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record('qtype_ddimagetoimage', $data);
+ $newitemid = $DB->insert_record('qtype_'.$this->qtype, $data);
// Create mapping (needed for decoding links)
- $this->set_mapping('qtype_ddimagetoimage', $oldid, $newitemid);
+ $this->set_mapping('qtype_'.$this->qtype, $oldid, $newitemid);
}
}
@@ -98,9 +100,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
if ($questioncreated) {
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record('qtype_ddimagetoimage_drags', $data);
+ $newitemid = $DB->insert_record("qtype_{$this->qtype}_drags", $data);
// Create mapping (there are files and states based on this)
- $this->set_mapping('qtype_ddimagetoimage_drags', $oldid, $newitemid);
+ $this->set_mapping("qtype_{$this->qtype}_drags", $oldid, $newitemid);
}
}
@@ -122,10 +124,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
if ($questioncreated) {
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record('qtype_ddimagetoimage_drops', $data);
+ $newitemid = $DB->insert_record("qtype_{$this->qtype}_drops", $data);
// Create mapping (there are files and states based on this)
- $this->set_mapping('qtype_ddimagetoimage_drops', $oldid, $newitemid);
-
+ $this->set_mapping("qtype_{$this->qtype}_drops", $oldid, $newitemid);
}
}
/**
@@ -137,7 +138,7 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
$fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
$contents[] =
- new restore_decode_content('qtype_ddimagetoimage', $fields, 'question_ddimagetoimage');
+ new restore_decode_content('qtype_'.$this->qtype, $fields, 'qtype_'.$this->qtype);
return $contents;
}
From 5445febbc8b4714c9fae832631a9b8ce38732319 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Fri, 2 Sep 2011 18:38:08 +0700
Subject: [PATCH 081/208] MDL-47494 ddimageortext: NOBUG fixing an issue with
refactoring.
---
...ckup_qtype_ddimagetoimage_plugin.class.php | 19 +++++++------
...tore_qtype_ddimagetoimage_plugin.class.php | 28 +++++++++++++------
2 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
index 1c6a0944db9..dedd031afa0 100644
--- a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimagetoimage_plugin.class.php
@@ -31,20 +31,22 @@ defined('MOODLE_INTERNAL') || die();
*/
class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
- protected $qtype = "ddimagetoimage";
+ protected static function qtype_name() {
+ return 'ddimagetoimage';
+ }
/**
* Returns the qtype information to attach to question element
*/
protected function define_question_plugin_structure() {
-
- $plugin = $this->get_plugin_element(null, '../../qtype', $this->qtype);
+ $qtype = self::qtype_name();
+ $plugin = $this->get_plugin_element(null, '../../qtype', $qtype);
$pluginwrapper = new backup_nested_element($this->get_recommended_name());
$plugin->add_child($pluginwrapper);
- $dds = new backup_nested_element($this->qtype, array('id'), array(
+ $dds = new backup_nested_element($qtype, array('id'), array(
'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));
@@ -59,7 +61,7 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
$drop = new backup_nested_element('drop', array('id'),
array('no', 'xleft', 'ytop', 'choice', 'label'));
- $dds->set_source_table("qtype_{$this->qtype}",
+ $dds->set_source_table("qtype_{$qtype}",
array('questionid' => backup::VAR_PARENTID));
$pluginwrapper->add_child($drags);
@@ -67,10 +69,10 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
$pluginwrapper->add_child($drops);
$drops->add_child($drop);
- $drag->set_source_table("qtype_{$this->qtype}_drags",
+ $drag->set_source_table("qtype_{$qtype}_drags",
array('questionid' => backup::VAR_PARENTID));
- $drop->set_source_table("qtype_{$this->qtype}_drops",
+ $drop->set_source_table("qtype_{$qtype}_drops",
array('questionid' => backup::VAR_PARENTID));
return $plugin;
@@ -83,12 +85,13 @@ class backup_qtype_ddimagetoimage_plugin extends backup_qtype_plugin {
* files to be processed both in backup and restore.
*/
public static function get_qtype_fileareas() {
+ $qtype = self::qtype_name();
return array(
'correctfeedback' => 'question_created',
'partiallycorrectfeedback' => 'question_created',
'incorrectfeedback' => 'question_created',
'bgimage' => 'question_created',
- 'dragimage' => "qtype_{$this->qtype}_drags");
+ 'dragimage' => "qtype_{$qtype}_drags");
}
}
diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
index 27433c399ba..977f4754019 100644
--- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
+++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimagetoimage_plugin.class.php
@@ -32,7 +32,9 @@ defined('MOODLE_INTERNAL') || die();
*/
class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
- protected $qtype = "ddimagetoimage";
+ protected static function qtype_name() {
+ return 'ddimagetoimage';
+ }
/**
* Returns the paths to be handled by the plugin at question level
@@ -43,7 +45,7 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
// Add own qtype stuff
$elename = dds;
- $elepath = $this->get_pathfor('/'.$this->qtype);
+ $elepath = $this->get_pathfor('/'.self::qtype_name());
$paths[] = new restore_path_element($elename, $elepath);
$elename = 'drag';
@@ -63,6 +65,8 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
public function process_dds($data) {
global $DB;
+ $prefix = 'qtype_'.self::qtype_name();
+
$data = (object)$data;
$oldid = $data->id;
@@ -77,9 +81,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
// Adjust some columns
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record('qtype_'.$this->qtype, $data);
+ $newitemid = $DB->insert_record($prefix, $data);
// Create mapping (needed for decoding links)
- $this->set_mapping('qtype_'.$this->qtype, $oldid, $newitemid);
+ $this->set_mapping($prefix, $oldid, $newitemid);
}
}
@@ -89,6 +93,8 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
public function process_drag($data) {
global $DB;
+ $prefix = 'qtype_'.self::qtype_name();
+
$data = (object)$data;
$oldid = $data->id;
@@ -100,9 +106,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
if ($questioncreated) {
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record("qtype_{$this->qtype}_drags", $data);
+ $newitemid = $DB->insert_record("{$prefix}_drags", $data);
// Create mapping (there are files and states based on this)
- $this->set_mapping("qtype_{$this->qtype}_drags", $oldid, $newitemid);
+ $this->set_mapping("{$prefix}_drags", $oldid, $newitemid);
}
}
@@ -113,6 +119,8 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
public function process_drop($data) {
global $DB;
+ $prefix = 'qtype_'.self::qtype_name();
+
$data = (object)$data;
$oldid = $data->id;
@@ -124,9 +132,9 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
if ($questioncreated) {
$data->questionid = $newquestionid;
// Insert record
- $newitemid = $DB->insert_record("qtype_{$this->qtype}_drops", $data);
+ $newitemid = $DB->insert_record("{$prefix}_drops", $data);
// Create mapping (there are files and states based on this)
- $this->set_mapping("qtype_{$this->qtype}_drops", $oldid, $newitemid);
+ $this->set_mapping("{$prefix}_drops", $oldid, $newitemid);
}
}
/**
@@ -134,11 +142,13 @@ class restore_qtype_ddimagetoimage_plugin extends restore_qtype_plugin {
*/
public static function define_decode_contents() {
+ $prefix = 'qtype_'.self::qtype_name();
+
$contents = array();
$fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
$contents[] =
- new restore_decode_content('qtype_'.$this->qtype, $fields, 'qtype_'.$this->qtype);
+ new restore_decode_content($prefix, $fields, $prefix);
return $contents;
}
From 79594d6018f03c22538735c39d061a4eb713870f Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Fri, 2 Sep 2011 18:51:32 +0700
Subject: [PATCH 082/208] MDL-47494 ddimageortext: OU-1430 changing from
repositioning drags when needed to repositioning every 1/2 second. This
solves the problem of being able to detect when html editor has upset the x y
coords on a page.
---
question/type/ddimageortext/yui/form/form.js | 21 +++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js
index 039bd633622..86ad78e700e 100644
--- a/question/type/ddimageortext/yui/form/form.js
+++ b/question/type/ddimageortext/yui/form/form.js
@@ -10,6 +10,11 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
fp : null,
initializer : function(params) {
+ /*Y.before(function(Y, editorid, options) {
+ console.log('editor id' + editorid);
+ options['oninit'] =
+ return Y.Do.AlterArgs(message, [Y, editorid, options])
+ }, M.editor_tinymce, 'init_editor', this);*/
this.fp = this.file_pickers();
Y.one(this.get('topnode')).append('
'+
''+
@@ -34,15 +39,16 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
e.drag.get('node').setData('gooddrop', true);
});
- Y.on('windowresize', this.reposition_drags_for_form, this);
+ //Y.on('windowresize', this.reposition_drags_for_form, this);
+ Y.later(500, this, this.reposition_drags_for_form, [], true);
this.doc.bg_img().on('load', this.constrain_image_size, this, 'bgimage');
this.doc.drag_image_homes()
.on('load', this.constrain_image_size, this, 'dragimage');
this.doc.bg_img().after('load', this.poll_for_image_load, this,
- true, 3000, this.after_all_images_loaded);
+ true, 0, this.after_all_images_loaded);
this.doc.drag_image_homes() .after('load', this.poll_for_image_load, this,
- true, 3000, this.after_all_images_loaded);
+ true, 0, this.after_all_images_loaded);
} else {
this.setup_form_events();
}
@@ -142,7 +148,6 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
Y.all('fieldset#dropzoneheader input').on('blur', function (e){
var name = e.target.getAttribute('name');
var draginstanceno = this.form.from_name_with_index(name).indexes[0];
- this.reposition_drag_for_form(draginstanceno);
}, this);
//change in selected image
@@ -164,7 +169,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
}, this);
//change to infinite checkbox
Y.all('fieldset#draggableimageheader_'+i+' input[type="checkbox"]')
- .on('change', this.set_options_for_drag_image_selectors, this);
+ .on('change', this.set_options_for_drag_image_selectors, this);
}
//event on file picker new file selection
Y.after(function (e){
@@ -185,7 +190,7 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
reposition_drag_for_form : function (draginstanceno) {
var drag = this.doc.drag_image(draginstanceno);
- if (null !== drag) {
+ if (null !== drag && !drag.hasClass('yui3-dd-dragging')) {
var fromform = [this.form.get_form_value('drops', [draginstanceno, 'xleft']),
this.form.get_form_value('drops', [draginstanceno, 'ytop'])];
if (fromform[0] == '' && fromform[1] == '') {
@@ -205,12 +210,10 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
xy = this.constrain_xy(draginstanceno, this.convert_to_bg_img_xy(xy));
this.form.set_form_value('drops', [draginstanceno, 'xleft'], Math.floor(xy[0]));
this.form.set_form_value('drops', [draginstanceno, 'ytop'], Math.floor(xy[1]));
- this.reposition_drag_for_form(draginstanceno);
},
reset_drag_xy : function (draginstanceno) {
this.form.set_form_value('drops', [draginstanceno, 'xleft'], '');
this.form.set_form_value('drops', [draginstanceno, 'ytop'], '');
- this.reposition_drag_for_form(draginstanceno);
},
//make sure xy value is not out of bounds of bg image
@@ -308,5 +311,5 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
return new DDIMAGETOIMAGE_FORM(config);
}
}, '@VERSION@', {
- requires:['moodle-qtype_ddimagetoimage-dd', 'form_filepicker']
+ requires:['moodle-qtype_ddimagetoimage-dd', 'form_filepicker', 'editor_tinymce']
});
\ No newline at end of file
From 1025d075c836d3b8329d32851d8554f34592ba93 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Fri, 2 Sep 2011 20:13:05 +0700
Subject: [PATCH 083/208] MDL-47494 ddimageortext: NOBUG noticed that when
dragging and dropping drag item was off by 1 pixel in both x and y axis.
---
question/type/ddimageortext/yui/dd/dd.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/question/type/ddimageortext/yui/dd/dd.js b/question/type/ddimageortext/yui/dd/dd.js
index 0d21ec45d81..91d2f2d724c 100644
--- a/question/type/ddimageortext/yui/dd/dd.js
+++ b/question/type/ddimageortext/yui/dd/dd.js
@@ -201,8 +201,8 @@ YUI.add('moodle-qtype_ddimagetoimage-dd', function(Y) {
}
},
convert_to_window_xy : function (bgimgxy) {
- return [+bgimgxy[0] + this.doc.bg_img().getX() + 1,
- +bgimgxy[1] + this.doc.bg_img().getY() + 1];
+ return [+bgimgxy[0] + this.doc.bg_img().getX(),
+ +bgimgxy[1] + this.doc.bg_img().getY()];
}
}, {
NAME : DDIMAGETOIMAGEDDNAME,
From 8d24c8c6f8108ad917c9d29f59171344dc0e7499 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Fri, 2 Sep 2011 20:33:52 +0700
Subject: [PATCH 084/208] MDL-47494 ddimageortext: NOBUG removing some
commented out code.
---
question/type/ddimageortext/yui/form/form.js | 6 ------
1 file changed, 6 deletions(-)
diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js
index 86ad78e700e..e0d261bd25b 100644
--- a/question/type/ddimageortext/yui/form/form.js
+++ b/question/type/ddimageortext/yui/form/form.js
@@ -10,11 +10,6 @@ YUI.add('moodle-qtype_ddimagetoimage-form', function(Y) {
fp : null,
initializer : function(params) {
- /*Y.before(function(Y, editorid, options) {
- console.log('editor id' + editorid);
- options['oninit'] =
- return Y.Do.AlterArgs(message, [Y, editorid, options])
- }, M.editor_tinymce, 'init_editor', this);*/
this.fp = this.file_pickers();
Y.one(this.get('topnode')).append('
'+
- ''+
+ var tn = Y.one(this.get('topnode'));
+ tn.one('div.fcontainer').append('
'+
'
');
this.doc = this.doc_structure(this);
this.draw_dd_area();
@@ -77,11 +77,11 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
load_drag_home : function (dragitemno) {
var url = null;
- if ('image' === this.form.get_form_value('dragitemtype', [dragitemno])) {
+ if ('image' === this.form.get_form_value('drags', [dragitemno, 'dragitemtype'])) {
url = this.fp.file(this.form.to_name_with_index('dragitem', [dragitemno])).href;
}
this.doc.add_or_update_drag_item_home(dragitemno, url,
- this.form.get_form_value('drags', [dragitemno, 'draglabel']),
+ this.form.get_form_value('draglabel', [dragitemno]),
this.form.get_form_value('drags', [dragitemno, 'draggroup']));
},
@@ -100,9 +100,9 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
set_options_for_drag_item_selectors : function () {
var dragitemsoptions = {0: ''};
for (var i=0; i < this.form.get_form_value('noitems', []); i++) {
- var label = this.form.get_form_value('drags', [i, 'draglabel']);
+ var label = this.form.get_form_value('draglabel', [i]);
var file = this.fp.file(this.form.to_name_with_index('dragitem', [i]));
- if ('image' === this.form.get_form_value('dragitemtype', [i])
+ if ('image' === this.form.get_form_value('drags', [i, 'dragitemtype'])
&& file.name !== null) {
dragitemsoptions[i + 1] = (i + 1) + '. ' + label + ' (' + file.name + ')';
} else if (label !== '') {
@@ -124,12 +124,9 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
optionnode.set('selected', true);
} else {
if (value !== 0) { // no item option is always selectable
- var cbselector = 'fieldset#draggableitemheader_'+(value-1)
- +' input[type="checkbox"]';
- var cbel = Y.one(cbselector);
- var infinite = cbel.get('checked');
- if (!infinite) {
- Y.all('fieldset#dropzoneheader select').some(function (selector) {
+ var cbel = Y.one('#id_drags_'+(value-1)+'_infinite');
+ if (cbel && !cbel.get('checked')) {
+ Y.all('fieldset#id_dropzoneheader select').some(function (selector) {
if (+selector.get('value') === value) {
optionnode.set('disabled', true);
return true; // stop looping
@@ -144,14 +141,14 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
},
stop_selector_events : function () {
- Y.all('fieldset#dropzoneheader select').detachAll();
+ Y.all('fieldset#id_dropzoneheader select').detachAll();
},
setup_form_events : function () {
//events triggered by changes to form data
//x and y coordinates
- Y.all('fieldset#dropzoneheader input').on('blur', function (e) {
+ Y.all('fieldset#id_dropzoneheader input').on('blur', function (e) {
var name = e.target.getAttribute('name');
var draginstanceno = this.form.from_name_with_index(name).indexes[0];
var fromform = [this.form.get_form_value('drops', [draginstanceno, 'xleft']),
@@ -162,7 +159,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
}, this);
//change in selected item
- Y.all('fieldset#dropzoneheader select').on('change', function (e) {
+ Y.all('fieldset#id_dropzoneheader select').on('change', function (e) {
var name = e.target.getAttribute('name');
var draginstanceno = this.form.from_name_with_index(name).indexes[0];
var old = this.doc.drag_item(draginstanceno);
@@ -174,12 +171,12 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
for (var i=0; i < this.form.get_form_value('noitems', []); i++) {
//change to group selector
- Y.all('fieldset#draggableitemheader_'+i+' select.draggroup').on(
+ Y.all('#fgroup_id_drags_'+i+' select.draggroup').on(
'change', function () {
this.doc.drag_items().remove(true);
this.draw_dd_area();
}, this);
- Y.all('fieldset#draggableitemheader_' + i + ' select.dragitemtype').on(
+ Y.all('#fgroup_id_drags_'+i+' select.dragitemtype').on(
'change', function () {
this.doc.drag_items().remove(true);
this.draw_dd_area();
@@ -202,7 +199,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) {
update_visibility_of_file_pickers : function() {
for (var i=0; i < this.form.get_form_value('noitems', []); i++) {
- if ('image' === this.form.get_form_value('dragitemtype', [i])) {
+ if ('image' === this.form.get_form_value('drags', [i, 'dragitemtype'])) {
Y.one('input#id_dragitem_'+i).get('parentNode').get('parentNode')
.setStyle('display', 'block');
} else {
From e9a2711b855ddc02001fb5effb418fe36816992c Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 22 May 2013 14:02:38 +0100
Subject: [PATCH 181/208] MDL-47494 ddimageortext: Final form improvement
tweaks. #6614
---
.../ddimageortext/edit_ddimageortext_form.php | 2 +-
.../ddimageortext/edit_ddtoimage_form_base.php | 17 +++++++++--------
.../lang/en/qtype_ddimageortext.php | 3 +--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/question/type/ddimageortext/edit_ddimageortext_form.php b/question/type/ddimageortext/edit_ddimageortext_form.php
index 83c1c437418..adfe694fe73 100644
--- a/question/type/ddimageortext/edit_ddimageortext_form.php
+++ b/question/type/ddimageortext/edit_ddimageortext_form.php
@@ -131,7 +131,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base {
$mform->addElement('header', 'draggableitemheader',
get_string('draggableitems', 'qtype_ddimageortext'));
$mform->addElement('advcheckbox', 'shuffleanswers', ' ',
- get_string('shuffleimages', 'qtype_'.$this->qtype()));
+ get_string('shuffleimages', 'qtype_'.$this->qtype()));
$mform->setDefault('shuffleanswers', 0);
$this->repeat_elements($this->draggable_item($mform), $itemrepeatsatstart,
$this->draggable_items_repeated_options(),
diff --git a/question/type/ddimageortext/edit_ddtoimage_form_base.php b/question/type/ddimageortext/edit_ddtoimage_form_base.php
index 099ec22a5aa..c7ece0f71ee 100644
--- a/question/type/ddimageortext/edit_ddtoimage_form_base.php
+++ b/question/type/ddimageortext/edit_ddtoimage_form_base.php
@@ -51,14 +51,14 @@ abstract class qtype_ddtoimage_edit_form_base extends question_edit_form {
/**
* definition_inner adds all specific fields to the form.
- * @param object $mform (the form being built).
+ * @param MoodleQuickForm $mform (the form being built).
*/
protected function definition_inner($mform) {
$mform->addElement('header', 'previewareaheader',
get_string('previewareaheader', 'qtype_'.$this->qtype()));
- $mform->addElement('static', 'previewarea',
- get_string('previewarea', 'qtype_'.$this->qtype()),
+ $mform->setExpanded('previewareaheader');
+ $mform->addElement('static', 'previewarea', '',
get_string('previewareamessage', 'qtype_'.$this->qtype()));
$mform->registerNoSubmitButton('refresh');
@@ -102,7 +102,7 @@ abstract class qtype_ddtoimage_edit_form_base extends question_edit_form {
abstract protected function drop_zones_repeated_options();
- abstract protected function definition_draggable_items($mform, $itemrepeatsatstart) ;
+ abstract protected function definition_draggable_items($mform, $itemrepeatsatstart);
abstract protected function draggable_item($mform);
@@ -115,11 +115,12 @@ abstract class qtype_ddtoimage_edit_form_base extends question_edit_form {
$countimages = max($countimages, $drag->no);
}
}
- if ($this->question->formoptions->repeatelements) {
- $itemrepeatsatstart = max(self::START_NUM_ITEMS, $countimages + self::ADD_NUM_ITEMS);
- } else {
- $itemrepeatsatstart = $countimages;
+
+ if (!$countimages) {
+ $countimages = self::START_NUM_ITEMS;
}
+ $itemrepeatsatstart = $countimages;
+
$imagerepeats = optional_param('noitems', $itemrepeatsatstart, PARAM_INT);
$addfields = optional_param('additems', '', PARAM_TEXT);
if (!empty($addfields)) {
diff --git a/question/type/ddimageortext/lang/en/qtype_ddimageortext.php b/question/type/ddimageortext/lang/en/qtype_ddimageortext.php
index 1ee1492e5aa..a79053031db 100644
--- a/question/type/ddimageortext/lang/en/qtype_ddimageortext.php
+++ b/question/type/ddimageortext/lang/en/qtype_ddimageortext.php
@@ -58,8 +58,7 @@ $string['pluginname_link'] = 'question/type/ddimageortext';
$string['pluginnameadding'] = 'Adding drag and drop onto image';
$string['pluginnameediting'] = 'Editing drag and drop onto image';
$string['pluginnamesummary'] = 'Images or text labels are dragged and dropped into drop zones on a background image.';
-$string['previewarea'] = '';
-$string['previewareaheader'] = 'Background image';
+$string['previewareaheader'] = 'Preview';
$string['previewareamessage'] = 'Select a background image file and select draggable images or just enter text that will be made draggable. Then choose a drag item for each \'drop zone\', and drag the drag item to where the student should drag it to.';
$string['refresh'] = 'Refresh preview';
$string['shuffleimages'] = 'Shuffle drag items each time question is attempted';
From 09e43f0a688d64516705229db088b49698d94ca8 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 22 May 2013 14:05:26 +0100
Subject: [PATCH 182/208] MDL-47494 ddimageortext: Fix failing unit tests.
---
.../ddimageortext/tests/walkthrough_test.php | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/question/type/ddimageortext/tests/walkthrough_test.php b/question/type/ddimageortext/tests/walkthrough_test.php
index ce7f431960f..95adfaaf57e 100644
--- a/question/type/ddimageortext/tests/walkthrough_test.php
+++ b/question/type/ddimageortext/tests/walkthrough_test.php
@@ -396,9 +396,9 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p2', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p3', 0),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p4', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p4', 0),
$this->get_does_not_contain_correctness_expectation(),
$this->get_does_not_contain_feedback_expectation());
@@ -506,9 +506,9 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p2', 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p3', 0),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p4', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p4', 0),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_try_again_button_expectation(),
$this->get_does_not_contain_correctness_expectation(),
@@ -560,9 +560,9 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p1', 1),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 0),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p3', 0),
$this->get_contains_hidden_expectation(
$this->quba->get_field_prefix($this->slot) . 'p4', 2),
$this->get_contains_submit_button_expectation(true),
@@ -786,13 +786,13 @@ class qtype_ddimageortext_walkthrough_test extends qbehaviour_walkthrough_test_b
$this->get_contains_drag_image_home_expectation(1, 1, 2),
$this->get_contains_drag_image_home_expectation(2, 2, 2),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p1', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p1', 0),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p2', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p2', 0),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p3', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p3', 0),
$this->get_contains_hidden_expectation(
- $this->quba->get_field_prefix($this->slot) . 'p4', ''),
+ $this->quba->get_field_prefix($this->slot) . 'p4', 0),
$this->get_contains_submit_button_expectation(true),
$this->get_does_not_contain_feedback_expectation(),
$this->get_tries_remaining_expectation(2),
From cdf20995e9b242ce5211810b8155a4ea5af736a7 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Mon, 1 Jul 2013 15:38:58 +0100
Subject: [PATCH 183/208] MDL-47494 ddimageortext: Update version and readme
for the 1.3 release.
---
question/type/ddimageortext/README.txt | 21 +++++++--------------
question/type/ddimageortext/version.php | 4 ++--
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/question/type/ddimageortext/README.txt b/question/type/ddimageortext/README.txt
index 0f4109b189c..1532a2a799c 100644
--- a/question/type/ddimageortext/README.txt
+++ b/question/type/ddimageortext/README.txt
@@ -1,4 +1,4 @@
-A drag-and-drop question type.
+A drag-and-drop question type
You can use text and / or images as drag items onto defined drop zones on a
background image.
@@ -9,21 +9,14 @@ to be installed in order to work.
This question type was written by Jamie Pratt (http://jamiep.org/).
-This question type is compatible with Moodle 2.3+.
-
-To install using git for a 2.3+ Moodle installation, type this command in the
-root of your Moodle install:
-
-git clone git://github.com/moodleou/moodle-qtype_ddimageortext.git question/type/ddimageortext
-
-To install using git for a 2.1+ Moodle installation, type this command in the
-root of your Moodle install:
-
-git clone -b MOODLE_21_STABLE git://github.com/moodleou/moodle-qtype_ddimageortext.git question/type/ddimageortext
+This version of this question type is compatible with Moodle 2.5+. There are
+other versions available for Moodle 2.3+.
+To install using git, type this command in the root of your Moodle install
+ git clone git@github.com:moodleou/moodle-qtype_ddimageortext.git question/type/ddimageortext
Then add question/type/ddimageortext to your git ignore.
+
Alternatively, download the zip from
- Moodle 2.2+ - https://github.com/moodleou/moodle-qtype_ddimageortext/zipball/master
- Moodle 2.1+ - https://github.com/moodleou/moodle-qtype_ddimageortext/zipball/MOODLE_21_STABLE
+ https://github.com/moodleou/moodle-qtype_ddimageortext/zipball/master
unzip it into the question/type folder, and then rename the new folder to ddimageortext.
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index 939243ab4b2..fe60e1b63c4 100644
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013052000;
+$plugin->version = 2013070100;
$plugin->requires = 2013051400;
$plugin->cron = 0;
$plugin->component = 'qtype_ddimageortext';
@@ -33,5 +33,5 @@ $plugin->maturity = MATURITY_STABLE;
$plugin->release = '1.3 for Moodle 2.5+';
$plugin->dependencies = array(
- 'qtype_gapselect' => 2013042900,
+ 'qtype_gapselect' => 2013070100,
);
From 86687aadb61d4fda6fcd1b5542082128597828ce Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Fri, 2 Aug 2013 14:28:56 +0100
Subject: [PATCH 184/208] MDL-47494 ddimageortext: Fix use of deprecated
context functions.
Also, improve import to use new qformat_xml method.
---
question/type/ddimageortext/questiontype.php | 5 ++--
.../type/ddimageortext/questiontypebase.php | 29 +------------------
2 files changed, 3 insertions(+), 31 deletions(-)
diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php
index 83c75a1f9ab..b3546c9ef06 100644
--- a/question/type/ddimageortext/questiontype.php
+++ b/question/type/ddimageortext/questiontype.php
@@ -236,7 +236,7 @@ class qtype_ddimageortext extends qtype_ddtoimage_base {
$format->getpath($data, array('#'), array()));
$filexml = $format->getpath($data, array('#', 'file'), array());
- $question->bgimage = $this->import_files_to_draft_file_area($format, $filexml);
+ $question->bgimage = $format->import_files_as_draft($filexml);
$drags = $data['#']['drag'];
$question->drags = array();
@@ -250,8 +250,7 @@ class qtype_ddimageortext extends qtype_ddtoimage_base {
$question->drags[$dragindex]['draggroup'] =
$format->getpath($dragxml, array('#', 'draggroup', 0, '#'), 1);
$filexml = $format->getpath($dragxml, array('#', 'file'), array());
- $question->dragitem[$dragindex] =
- $this->import_files_to_draft_file_area($format, $filexml);
+ $question->dragitem[$dragindex] = $format->import_files_as_draft($filexml);
if (count($filexml)) {
$question->drags[$dragindex]['dragitemtype'] = 'image';
} else {
diff --git a/question/type/ddimageortext/questiontypebase.php b/question/type/ddimageortext/questiontypebase.php
index 4a370244681..7acfca73cd0 100644
--- a/question/type/ddimageortext/questiontypebase.php
+++ b/question/type/ddimageortext/questiontypebase.php
@@ -93,7 +93,7 @@ class qtype_ddtoimage_base extends question_type {
public static function constrain_image_size_in_draft_area($draftitemid, $maxwidth, $maxheight) {
global $USER;
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
if ($draftfiles) {
@@ -135,33 +135,6 @@ class qtype_ddtoimage_base extends question_type {
}
}
-
-
- /**
- * Create a draft files area, import files into it and return the draft item id.
- * @param qformat_xml $format
- * @param array $xml an array of nodes from the the parsed XML.
- * @return integer draftitemid
- */
- public function import_files_to_draft_file_area($format, $xml) {
- global $USER;
- $fs = get_file_storage();
- $files = $format->import_files($xml);
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
- $draftitemid = file_get_unused_draft_itemid();
- foreach ($files as $file) {
- $record = new stdClass();
- $record->contextid = $usercontext->id;
- $record->component = 'user';
- $record->filearea = 'draft';
- $record->itemid = $draftitemid;
- $record->filename = $file->name;
- $record->filepath = '/';
- $fs->create_file_from_string($record, $this->decode_file($file));
- }
- return $draftitemid;
- }
-
/**
* Convert files into text output in the given format.
* This method is copied from qformat_default as a quick fix, as the method there is
From 874104d5afd9b801a6c9afb17785d92553e711a6 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 7 Aug 2013 19:37:32 +0100
Subject: [PATCH 185/208] MDL-47494 ddimageortext: Fix incorrect PARAM_TEXT.
---
question/type/ddimageortext/edit_ddimageortext_form.php | 2 +-
question/type/ddimageortext/edit_ddtoimage_form_base.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/question/type/ddimageortext/edit_ddimageortext_form.php b/question/type/ddimageortext/edit_ddimageortext_form.php
index adfe694fe73..4202b410970 100644
--- a/question/type/ddimageortext/edit_ddimageortext_form.php
+++ b/question/type/ddimageortext/edit_ddimageortext_form.php
@@ -213,7 +213,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base {
// We do the necessary validation in the validation method.
$repeatedoptions['drops[xleft]']['type'] = PARAM_RAW;
$repeatedoptions['drops[ytop]']['type'] = PARAM_RAW;
- $repeatedoptions['drops[droplabel]']['type'] = PARAM_TEXT;
+ $repeatedoptions['drops[droplabel]']['type'] = PARAM_RAW;
$repeatedoptions['choice']['default'] = '0';
return $repeatedoptions;
}
diff --git a/question/type/ddimageortext/edit_ddtoimage_form_base.php b/question/type/ddimageortext/edit_ddtoimage_form_base.php
index c7ece0f71ee..5cc6b4b699b 100644
--- a/question/type/ddimageortext/edit_ddtoimage_form_base.php
+++ b/question/type/ddimageortext/edit_ddtoimage_form_base.php
@@ -122,8 +122,8 @@ abstract class qtype_ddtoimage_edit_form_base extends question_edit_form {
$itemrepeatsatstart = $countimages;
$imagerepeats = optional_param('noitems', $itemrepeatsatstart, PARAM_INT);
- $addfields = optional_param('additems', '', PARAM_TEXT);
- if (!empty($addfields)) {
+ $addfields = optional_param('additems', false, PARAM_BOOL);
+ if ($addfields) {
$imagerepeats += self::ADD_NUM_ITEMS;
}
return array($itemrepeatsatstart, $imagerepeats);
From ff8fee7f82b35d3919eb082c8a4d3099a05bdaf3 Mon Sep 17 00:00:00 2001
From: Jamie Pratt
Date: Tue, 20 Aug 2013 11:38:42 +0700
Subject: [PATCH 186/208] MDL-47494 ddimageortext: CONTRIB-4557 make sure bg
image is not re-sized
by bootstrap based themes.
---
question/type/ddimageortext/styles.css | 1 +
1 file changed, 1 insertion(+)
diff --git a/question/type/ddimageortext/styles.css b/question/type/ddimageortext/styles.css
index 0ee6b36d224..5754309fa3e 100644
--- a/question/type/ddimageortext/styles.css
+++ b/question/type/ddimageortext/styles.css
@@ -5,6 +5,7 @@
.que.ddimageortext div.droparea img, form.mform fieldset#id_previewareaheader div.droparea img {
border: 1px solid #000000;
+ max-width: none;
}
.que.ddimageortext .draghome, form.mform fieldset#id_previewareaheader .draghome {
From e7a04b042334daf8266618ca45e87b3b9e4b9a33 Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 8 Jan 2014 11:45:33 +0000
Subject: [PATCH 187/208] MDL-47494 ddimageortext: Incorrect types causing tags
to be stripped. #9127
---
question/type/ddimageortext/edit_ddimageortext_form.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/question/type/ddimageortext/edit_ddimageortext_form.php b/question/type/ddimageortext/edit_ddimageortext_form.php
index 4202b410970..ee15f390d8c 100644
--- a/question/type/ddimageortext/edit_ddimageortext_form.php
+++ b/question/type/ddimageortext/edit_ddimageortext_form.php
@@ -168,7 +168,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base {
$draggableimageitem[] = $mform->createElement('text', 'draglabel',
get_string('label', 'qtype_ddimageortext'),
array('size'=>30, 'class'=>'tweakcss'));
- $mform->setType('draglabel', PARAM_NOTAGS);
+ $mform->setType('draglabel', PARAM_RAW); // These are validated manually.
return $draggableimageitem;
}
From 864d36c9392c14b1f6b0e9ebfe1748dedd0074cc Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Wed, 8 Jan 2014 13:08:26 +0000
Subject: [PATCH 188/208] MDL-47494 ddimageortext: Update version number for
the 1.4 release.
---
question/type/ddimageortext/version.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index fe60e1b63c4..6a4601b24e0 100644
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -25,13 +25,13 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2013070100;
+$plugin->version = 2014010800;
$plugin->requires = 2013051400;
$plugin->cron = 0;
$plugin->component = 'qtype_ddimageortext';
$plugin->maturity = MATURITY_STABLE;
-$plugin->release = '1.3 for Moodle 2.5+';
+$plugin->release = '1.4 for Moodle 2.5+';
$plugin->dependencies = array(
- 'qtype_gapselect' => 2013070100,
+ 'qtype_gapselect' => 2014010800,
);
From 13ee9a2639e651685c36a2bb048db1ec6052e7ee Mon Sep 17 00:00:00 2001
From: James Pratt
Date: Fri, 18 Apr 2014 19:40:50 +0700
Subject: [PATCH 189/208] MDL-47494 ddimageortext: MDL-45111 quiz responses
report : fatal error when counting responses
not all possible responses where returned by question type method.
---
question/type/ddimageortext/questionbase.php | 8 ++++++--
question/type/ddimageortext/questiontypebase.php | 13 +++----------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/question/type/ddimageortext/questionbase.php b/question/type/ddimageortext/questionbase.php
index 6c75098985c..38b1a96eadd 100644
--- a/question/type/ddimageortext/questionbase.php
+++ b/question/type/ddimageortext/questionbase.php
@@ -122,8 +122,12 @@ class qtype_ddtoimage_question_base extends qtype_gapselect_question_base {
$choice = $this->choices[$group][$choiceno];
$correct = $this->get_right_choice_for($placeno) == $response[$fieldname];
- $parts[$placeno] = new question_classified_response(
- $choiceno, $choice->summarise(), $correct?1:0);
+ if ($correct) {
+ $grade = 1;
+ } else {
+ $grade = 0;
+ }
+ $parts[$placeno] = new question_classified_response($choiceno, $choice->summarise(), $grade);
}
return $parts;
}
diff --git a/question/type/ddimageortext/questiontypebase.php b/question/type/ddimageortext/questiontypebase.php
index 7acfca73cd0..2512852da0d 100644
--- a/question/type/ddimageortext/questiontypebase.php
+++ b/question/type/ddimageortext/questiontypebase.php
@@ -60,7 +60,7 @@ class qtype_ddtoimage_base extends question_type {
$this->initialise_combined_feedback($question, $questiondata, true);
$question->choices = array();
- $choiceindexmap= array();
+ $choiceindexmap = array();
// Store the choices in arrays by group.
foreach ($questiondata->options->drags as $dragdata) {
@@ -165,18 +165,11 @@ class qtype_ddtoimage_base extends question_type {
$parts = array();
foreach ($question->places as $placeno => $place) {
- $group = $place->group;
$choices = array();
- foreach ($question->choices[$group] as $i => $choice) {
- $summarisechoice = $choice->summarise();
-
+ foreach ($question->choices[$place->group] as $i => $choice) {
$correct = $question->rightchoices[$placeno] == $i;
- if ($correct) {
- $choices[$choice->no] = new question_possible_response(
- $summarisechoice,
- $correct?1:0);
- }
+ $choices[$choice->no] = new question_possible_response($choice->summarise(), $correct ? 1 : 0);
}
$choices[null] = question_possible_response::no_response();
From dacc4272714bb582edd5c58c3806408fbc512b2c Mon Sep 17 00:00:00 2001
From: Tim Hunt
Date: Mon, 28 Apr 2014 20:23:01 +0100
Subject: [PATCH 190/208] MDL-47494 ddimageortext: Update version.php for the
1.5 release.
---
question/type/ddimageortext/version.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/question/type/ddimageortext/version.php b/question/type/ddimageortext/version.php
index 6a4601b24e0..57ccc69f6b9 100644
--- a/question/type/ddimageortext/version.php
+++ b/question/type/ddimageortext/version.php
@@ -25,12 +25,12 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2014010800;
+$plugin->version = 2014042800;
$plugin->requires = 2013051400;
$plugin->cron = 0;
$plugin->component = 'qtype_ddimageortext';
$plugin->maturity = MATURITY_STABLE;
-$plugin->release = '1.4 for Moodle 2.5+';
+$plugin->release = '1.5 for Moodle 2.5+';
$plugin->dependencies = array(
'qtype_gapselect' => 2014010800,
From 3b5048294f933d429b65e66b9f1464230448b310 Mon Sep 17 00:00:00 2001
From: M Kassaei
Date: Mon, 3 Nov 2014 14:37:38 +0000
Subject: [PATCH 191/208] MDL-47494 ddimageortext: Adding a behat feature to
ddimageotext qtype, #12175
---
.../tests/behat/basic_test.feature | 198 ++++++++++++++++++
.../tests/behat/import_test.feature | 30 +++
.../tests/fixtures/oceanflooranswer.jpg | Bin 0 -> 24934 bytes
.../tests/fixtures/oceanfloorbase.jpg | Bin 0 -> 9881 bytes
.../tests/fixtures/testquestion.moodle.xml | 181 ++++++++++++++++
5 files changed, 409 insertions(+)
create mode 100644 question/type/ddimageortext/tests/behat/basic_test.feature
create mode 100644 question/type/ddimageortext/tests/behat/import_test.feature
create mode 100644 question/type/ddimageortext/tests/fixtures/oceanflooranswer.jpg
create mode 100644 question/type/ddimageortext/tests/fixtures/oceanfloorbase.jpg
create mode 100644 question/type/ddimageortext/tests/fixtures/testquestion.moodle.xml
diff --git a/question/type/ddimageortext/tests/behat/basic_test.feature b/question/type/ddimageortext/tests/behat/basic_test.feature
new file mode 100644
index 00000000000..65e20190a2c
--- /dev/null
+++ b/question/type/ddimageortext/tests/behat/basic_test.feature
@@ -0,0 +1,198 @@
+@ou @ou_vle @qtype @qtype_ddimageortext
+Feature: Test all the basic functionality of this question type
+ In order to evaluate students responses, As a teacher I need to
+ create and preview ddimageortext (Drag and drop onto image) questions.
+
+ # Due to complexity and since the javascript code needs to be converted at some stage,
+ # we are not going to test attempting this qtype. However, we will do all other
+ # possible testings, such as creating the question preview it and seeing the
+ # correct information on the preview string as well as backing-up and restoring
+ # the course containing this qtype.
+
+ # Another way to test attempting this qtype while previewing it, it write a
+ # customised step for tabbing through place-holders and another customised
+ # step for making use of arrow keys in order to go through the list of choices.
+
+ Background:
+ Given the following "users" exist:
+ | username | firstname | lastname | email |
+ | teacher1 | T1 | Teacher1 | teacher1@moodle.com |
+ And the following "courses" exist:
+ | fullname | shortname | category |
+ | Course 1 | C1 | 0 |
+ And the following "course enrolments" exist:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+
+ @javascript
+ Scenario: Create, edit then preview a ddimageortext question.
+ Given I log in as "teacher1"
+ And I follow "Course 1"
+ And I navigate to "Question bank" node in "Course administration"
+ Then I should see "Question bank"
+
+ # Create a new question
+ # We have to set the fields individually, because of the step for uploading the background image.
+ Given I press "Create a new question ..."
+ And I set the field "Drag and drop onto image" to "1"
+ Then I press "Add"
+ And I should see "Adding drag and drop onto image"
+ Then I set the field "Question name" to "Drag and drop onto image 001"
+ And I set the field "Question text" to "Identify the features in this cross-section."
+ And I set the field "General feedback" to "The locations are now labelled on the diagram below."
+ Given I upload "question/type/ddimageortext/tests/fixtures/oceanfloorbase.jpg" file to "Background image" filemanager
+
+ # Draggable items
+ Given I follow "Draggable items"
+ Then I press "Blanks for 3 more draggable items"
+
+ And I set the field "id_drags_0_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_0" to "island arc"
+
+ And I set the field "id_drags_1_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_1" to "mid-ocean ridge"
+
+ And I set the field "id_drags_2_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_2" to "abyssal plain"
+
+ And I set the field "id_drags_3_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_3" to "continental rise"
+
+ And I set the field "id_drags_4_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_4" to "ocean trench"
+
+ And I set the field "id_drags_5_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_5" to "continental slope"
+
+ And I set the field "id_drags_6_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_6" to "mountain belt"
+
+ And I set the field "id_drags_7_dragitemtype" to "Draggable text"
+ And I set the field "id_draglabel_7" to "continental shelf"
+
+ # Drop zones
+ Given I follow "Drop zones"
+ Then I press "Blanks for 3 more drop zones"
+
+ And I set the field "id_drops_0_xleft" to "53"
+ And I set the field "id_drops_0_ytop" to "17"
+ And I set the field "id_drops_0_choice" to "7"
+
+ And I set the field "id_drops_1_xleft" to "172"
+ And I set the field "id_drops_1_ytop" to "2"
+ And I set the field "id_drops_1_choice" to "8"
+
+ And I set the field "id_drops_2_xleft" to "363"
+ And I set the field "id_drops_2_ytop" to "31"
+ And I set the field "id_drops_2_choice" to "5"
+
+ And I set the field "id_drops_3_xleft" to "440"
+ And I set the field "id_drops_3_ytop" to "13"
+ And I set the field "id_drops_3_choice" to "3"
+
+ And I set the field "id_drops_4_xleft" to "115"
+ And I set the field "id_drops_4_ytop" to "74"
+ And I set the field "id_drops_4_choice" to "6"
+
+ And I set the field "id_drops_5_xleft" to "210"
+ And I set the field "id_drops_5_ytop" to "94"
+ And I set the field "id_drops_5_choice" to "4"
+
+ And I set the field "id_drops_6_xleft" to "310"
+ And I set the field "id_drops_6_ytop" to "87"
+ And I set the field "id_drops_6_choice" to "1"
+
+ And I set the field "id_drops_7_xleft" to "479"
+ And I set the field "id_drops_7_ytop" to "84"
+ And I set the field "id_drops_7_choice" to "2"
+
+
+ And I press "id_submitbutton"
+ Then I should see "Drag and drop onto image 001"
+
+ # Preview it.
+ When I click on "Preview" "link" in the "Drag and drop onto image 001" "table_row"
+ And I switch to "questionpreview" window
+ Then I should see "Preview question: Drag and drop onto image 001"
+ And I switch to the main window
+
+ # Backup the course and restore it.
+ When I log out
+ And I log in as "admin"
+ When I backup "Course 1" course using this options:
+ | Confirmation | Filename | test_backup.mbz |
+ When I restore "test_backup.mbz" backup into a new course using this options:
+ | Schema | Course name | Course 2 |
+ Then I should see "Course 2"
+ When I navigate to "Question bank" node in "Course administration"
+ Then I should see "Drag and drop onto image 001"
+
+ # Edit the copy and verify the form field contents.
+ When I click on "Edit" "link" in the "Drag and drop onto image 001" "table_row"
+ Then the following fields match these values:
+ | Question name | Drag and drop onto image 001 |
+ | Question text | Identify the features in this cross-section. |
+ | General feedback | The locations are now labelled on the diagram below. |
+
+ # Draggable items
+ | id_drags_0_dragitemtype | Draggable text |
+ | id_draglabel_0 | island arc |
+
+ | id_drags_1_dragitemtype | Draggable text |
+ | id_draglabel_1 | mid-ocean ridge |
+
+ | id_drags_2_dragitemtype | Draggable text |
+ | id_draglabel_2 | abyssal plain |
+
+ | id_drags_3_dragitemtype | Draggable text |
+ | id_draglabel_3 | continental rise |
+
+ | id_drags_4_dragitemtype | Draggable text |
+ | id_draglabel_4 | ocean trench |
+
+ | id_drags_5_dragitemtype | Draggable text |
+ | id_draglabel_5 | continental slope |
+
+ | id_drags_6_dragitemtype | Draggable text |
+ | id_draglabel_6 | mountain belt |
+
+ | id_drags_7_dragitemtype | Draggable text |
+ | id_draglabel_7 | continental shelf |
+
+ # Drop zones
+ | id_drops_0_xleft | 53 |
+ | id_drops_0_ytop | 17 |
+ | id_drops_0_choice | 7 |
+
+ | id_drops_1_xleft | 172 |
+ | id_drops_1_ytop | 2 |
+ | id_drops_1_choice | 8 |
+
+ | id_drops_2_xleft | 363 |
+ | id_drops_2_ytop | 31 |
+ | id_drops_2_choice | 5 |
+
+ | id_drops_3_xleft | 440 |
+ | id_drops_3_ytop | 13 |
+ | id_drops_3_choice | 3 |
+
+ | id_drops_4_xleft | 115 |
+ | id_drops_4_ytop | 74 |
+ | id_drops_4_choice | 6 |
+
+ | id_drops_5_xleft | 210 |
+ | id_drops_5_ytop | 94 |
+ | id_drops_5_choice | 4 |
+
+ | id_drops_6_xleft | 310 |
+ | id_drops_6_ytop | 87 |
+ | id_drops_6_choice | 1 |
+
+ | id_drops_7_xleft | 479 |
+ | id_drops_7_ytop | 84 |
+ | id_drops_7_choice | 2 |
+
+ And I set the following fields to these values:
+ | Question name | Edited question name |
+ And I press "id_submitbutton"
+ Then I should see "Edited question name"
diff --git a/question/type/ddimageortext/tests/behat/import_test.feature b/question/type/ddimageortext/tests/behat/import_test.feature
new file mode 100644
index 00000000000..ab4ddf770c2
--- /dev/null
+++ b/question/type/ddimageortext/tests/behat/import_test.feature
@@ -0,0 +1,30 @@
+@ou @ou_vle @qtype @qtype_ddimageortext
+Feature: Test all the basic functionality of this question type
+ As a manager/teacher i should be able to import questions from other courses to this course
+
+ Background:
+ Given the following "users" exist:
+ | username | firstname | lastname | email |
+ | teacher1 | T1 | Teacher1 | teacher1@moodle.com |
+ | manager1 | M1 | Manager1 | manager11@moodle.com |
+ And the following "courses" exist:
+ | fullname | shortname | category |
+ | Course 1 | C1 | 0 |
+ And the following "course enrolments" exist:
+ | user | course | role |
+ | teacher1 | C1 | editingteacher |
+ | manager1 | C1 | manager |
+ And I log in as "teacher1"
+ And I follow "Course 1"
+
+ @javascript
+ Scenario: import a variable numeric sets question.
+ When I navigate to "Import" node in "Course administration > Question bank"
+ And I set the field "id_format_xml" to "1"
+ And I upload "question/type/ddimageortext/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager
+ And I press "id_submitbutton"
+ Then I should see "Parsing questions from import file."
+ And I should see "Importing 1 questions from file"
+ And I should see "Identify the features in this cross-section by dragging the labels into the boxes."
+ And I press "Continue"
+ And I should see "Imported Drag and drop onto image 001"
diff --git a/question/type/ddimageortext/tests/fixtures/oceanflooranswer.jpg b/question/type/ddimageortext/tests/fixtures/oceanflooranswer.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..fe20f07267d049f5a48e3c02986d42ef16e002d1
GIT binary patch
literal 24934
zcmeFZXH*njw=P;pQbdrPX_Y8Zat0B}0)j%5QGz7NIkrerQWGR61<8^_gM?P1fRb~R
zBpI6AK+}Ed{m#B;@9+K2xO?9{&i!%6xa}xdaNv{)wAM%?wZ;(=uQ&LipQ&3RRGSg8}Gty8{
z(BGwJWMP3oAXIes*zd8jGqXZi|0)Cze3Y1onC$v>GFEB|YS#b9AKW*9;yRFfO&1^U
z9&n8U51#@L*9kxX0FMx??OzrCw-4Smd;+kR*Kd&A1aGLn4P3*+$G-;FA2a~GI|%$8
zAfOuiszztiXqqu50(-QV6Ip{1i|VC3NB;=a!#Dkd%=
zDJ8A+SXo6?OqbwaqJAJ9`HYPcLsDUqAoQu<(e;ckiPTlRhM;q^6~3
zwj7HH@hf6yRL!VLO}eNU3k}gzyqIxfbgym5v8Io@k=+Vd%_{t
zsUIbLs{Ve1O+*hxW9dFjLd!0?#BuPKY5%b7zh>Cm|CVL{%dmg9YX%_2#{)YLp8`+-
zE}+Zu2*0I40G-rH%S)YVY@X`nckRiI*c|Tku?GZ{O}bgP-R2Bzr-Hd*Ln})V45t9>
zTpk{$aH!Jafded0KjDDShfp&!11V>Bg_mgXR0$piL!~w0fYl56jsqoZB;+~{SP}y7
z?md~*RgO2yg8!|wD$G+H@TsR=0sX`j2OI`@jp;mkUg;_BM|&Y2y>z93sH=cW8Z>-YE(77t>C=88!CAd)Xd+@hKV
zvTUS`nC|r~hY)}Tzg%J!%0(9n=mdHr3;rq}2mDxCqUeEcp#$w23de3F9}7FdCC=C=8>gzg^?_IE{&JUJiwA~i
zCHO^(v%v4@Qp4)5JOYPVggljnJrT(X*z@R~ezwZC=sLJq7GCSyr-2bxUg0aZc
z@(G}>RV0jjbHcmHa8Kwx^A|d2eZ>@^q>vPvTyWf_#==&wWK!LQ4KcUTiqp1m@uT4t|sC3^+Y^Xap)QcvO=o84_&I9UcWOpha`|4mg&BbuQ
z$2lb0{$w93r~0>Z^W{nLejk=h)5i#5HnsRvylLvMV{W#;J~luM|F2Odn!qE)BJPVJJwNW
zO#PVwGV0EId-o8CaMHwn-mu3{g^k|-24pf;g2mzksT@?OlJ{^S?TfowP+tZNVla7~&i(<*xZA09;ieb@B=*X_UO(*Hl-ZnAev(M4D)
zEys==wlUFY98kSEAyK9CvZ&u4+ot*1+Qx5fKz`u!ZPf)?sF`VS5)R@|h=K+f6BrNA-+z(6|U$6HZOkvYYk7iCGpo%e>+01_Rj
zd=+w)$}BBj@MV4r(cL#P(b>*2r^NSDJwt5>h;Le}%>ty#+uXJN{d1&k&tYul7Uk&A
z4oK#fTX}|jE;d$QOrxXU3R^dtiJyDl9{>~^S;>s54?o=L{F4_QCKdb3u`@>&+uz8j
z&<>-_{PXax1a!u@yF9170hLI+Fx$P-4K4QzGp9wzME%i;z~0TVH|!T3EVgf6OKwV-
zimqIiT`34sQ1*CkKB~^*S-2_Fc@D=?+_Cej9jU|YE`
zYzh=UkvJgSwqlQ1>e4$s=|sVyvWSOQGt;p#rU5}=s=~6uPZfce996UGLwcR9n&8<*
z3;wp3P6lyA@IAs=96&N?KD&8(B?0(b?fPPlprW_9mS4p#^Rk#PF6A_*txdb<&M>;{
z-+`Uvb8ho#)4W;vqs;#Mc5t-gyNNv+y_)kxHnr>Tqksa%{uMig2jAGK2JpUj)~%=r
z`8*!$)OK4-SerSE6U!!lJSNuqY$-B^zwSzYMzbuvZMXoLO6_1Y>##uSiYEyq#Swas
z!w+V$YLRe-9g{KGafZg!)<-zDK~A;Y`&p*H$Xi#<7kN>$1lIe!D^jtEekCkTzzVw_R_5vCjXV;?Ozn-?CiOn-lF4qXI!it
zsxIE^=uAnUclk2vF{j*u!})dLuK18XswDGRw~rf8>9w|Ix4g|!hl$>`??D`;Vx5|U
zeKizKsz2xO=Pt&EH#1%b>!cRVa3zS$DL2rtnpQRkM)#1;F0#A(i2G-lZ%6VP3!Sy^XaaS2fHwz5k=>tFhbe6CHT*uk`;$?RP8BU
zo@vLiv{a&WOir{j9E(&n>8P|dqbRx+g5*KTvNLJ(Oiuyjfo%H+&2LQR&g0AchHp*9
z9?ILCuV^_KZy=6&LM`mEiyxu+EJdx{fZ}I>^cezwn6K74_B8I+<*pXQLdM=8l|=
z&1UkNIN;8dx;(ofX*_QvP%_hGmaZpkltZ1XKPG?2*Bb{sKe)A8V{EvcQbW#3V3Lez
zi@GyF;78g=k@-^h13k%2{JD=P!HBva%Zf{_j2%y!r=nyteai*d&EL3Esu=mZs=-d1
z#-ur;Ue#x9GWsQs*mE_&YB@KolQ>nC;K`XD)^Xa}{$oc4rT=K+ZJ3Y;d%4TjK9+dS
z*Bh}M>wl>>v9sspWbt(5#NzsvahS0AtYHUfX`X_B$@B1-O$sBX=$HoaqxkVn2m^BU
zaSb?dLmz>uc6ouzG+MPiMb}i>b}5!}My66^_a;r48s`EK^iA+rBS7ZAlF^Qy08m=R
z%;adbI)y74W4%A7rQ)*}I3NUTLM5JYi36Bm2~En>P{nR)U1i|Edib5S!|*m{*4qbf
zIQkcstlW&gQhHqT^=m4Ya#uI7*E)n@_NFV)Pw5JfWCMGl164xgaV8Jaq
zTE}S_HKG