This commit is contained in:
Sara Arjona
2021-04-19 17:18:33 +02:00
9 changed files with 45 additions and 3 deletions
@@ -117,7 +117,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()));
$mform->setDefault('shuffleanswers', 0);
$mform->setDefault('shuffleanswers', $this->get_default_value('shuffleanswers', 0));
$this->repeat_elements($this->draggable_item($mform), $itemrepeatsatstart,
$this->draggable_items_repeated_options(),
'noitems', 'additems', self::ADD_NUM_ITEMS,
@@ -50,6 +50,11 @@ class qtype_ddimageortext extends qtype_ddtoimage_base {
return question_hint_with_parts::load_from_record($hint);
}
public function save_defaults_for_new_questions(stdClass $fromform): void {
parent::save_defaults_for_new_questions($fromform);
$this->set_default_value('shuffleanswers', $fromform->shuffleanswers);
}
public function save_question_options($formdata) {
global $DB, $USER;
$context = $formdata->context;
@@ -32,6 +32,7 @@ Feature: Test creating a drag and drop onto image question
And I follow "Draggable items"
And I press "Blanks for 3 more draggable items"
And I set the field "id_shuffleanswers" to "1"
And I set the field "id_drags_0_dragitemtype" to "Draggable text"
And I set the field "id_draglabel_0" to "island<br/>arc"
@@ -94,3 +95,10 @@ Feature: Test creating a drag and drop onto image question
And I press "id_submitbutton"
Then I should see "Drag and drop onto image 001"
# Checking that the next new question form displays user preferences settings.
When I press "Create a new question ..."
And I set the field "item_qtype_ddimageortext" to "1"
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
Then the following fields match these values:
| id_shuffleanswers | 1 |
@@ -45,6 +45,7 @@ class qtype_ddmarker_edit_form extends qtype_ddtoimage_edit_form_base {
protected function definition_inner($mform) {
$mform->addElement('advcheckbox', 'showmisplaced', get_string('showmisplaced', 'qtype_ddmarker'));
$mform->setDefault('showmisplaced', $this->get_default_value('showmisplaced', 0));
parent::definition_inner($mform);
$mform->addHelpButton('drops[0]', 'dropzones', 'qtype_ddmarker');
@@ -60,7 +61,7 @@ class qtype_ddmarker_edit_form extends qtype_ddtoimage_edit_form_base {
$mform->addElement('header', 'draggableitemheader',
get_string('markers', 'qtype_ddmarker'));
$mform->addElement('advcheckbox', 'shuffleanswers', get_string('shuffleimages', 'qtype_'.$this->qtype()));
$mform->setDefault('shuffleanswers', 0);
$mform->setDefault('shuffleanswers', $this->get_default_value('shuffleanswers', 0));
$this->repeat_elements($this->draggable_item($mform), $itemrepeatsatstart,
$this->draggable_items_repeated_options(),
'noitems', 'additems', self::ADD_NUM_ITEMS,
+6
View File
@@ -82,6 +82,12 @@ class question_hint_ddmarker extends question_hint_with_parts {
*/
class qtype_ddmarker extends qtype_ddtoimage_base {
public function save_defaults_for_new_questions(stdClass $fromform): void {
parent::save_defaults_for_new_questions($fromform);
$this->set_default_value('showmisplaced', $fromform->showmisplaced);
$this->set_default_value('shuffleanswers', $fromform->shuffleanswers);
}
public function save_question_options($formdata) {
global $DB, $USER;
$context = $formdata->context;
@@ -26,10 +26,12 @@ Feature: Test creating a drag and drop markers question
And I set the field "Question name" to "Drag and drop markers"
And I set the field "Question text" to "Please place the markers on the map of Milton Keynes and be aware that there is more than one railway station."
And I set the field "General feedback" to "The Open University is at the junction of Brickhill Street and Groveway. There are three railway stations, Wolverton, Milton Keynes Central and Bletchley."
And I set the field "id_showmisplaced" to "1"
And I upload "question/type/ddmarker/tests/fixtures/mkmap.png" file to "Background image" filemanager
And I expand all fieldsets
# Markers.
And I set the field "id_shuffleanswers" to "1"
And I set the field "id_drags_0_label" to "OU"
And I set the field "id_drags_0_noofdrags" to "1"
And I set the field "id_drags_1_label" to "Railway station"
@@ -56,3 +58,10 @@ Feature: Test creating a drag and drop markers question
And I set the field "id_drops_3_choice" to "2"
And I press "id_submitbutton"
And I should see "Drag and drop markers"
# Checking that the next new question form displays user preferences settings.
When I press "Create a new question ..."
And I set the field "item_qtype_ddmarker" to "1"
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
Then the following fields match these values:
| id_showmisplaced | 1 |
| id_shuffleanswers | 1 |
+1 -1
View File
@@ -60,7 +60,7 @@ class qtype_match_edit_form extends question_edit_form {
$mform->addElement('advcheckbox', 'shuffleanswers',
get_string('shuffle', 'qtype_match'), null, null, array(0, 1));
$mform->addHelpButton('shuffleanswers', 'shuffle', 'qtype_match');
$mform->setDefault('shuffleanswers', 1);
$mform->setDefault('shuffleanswers', $this->get_default_value('shuffleanswers', 1));
$this->add_per_answer_fields($mform, get_string('questionno', 'question', '{no}'), 0);
+5
View File
@@ -47,6 +47,11 @@ class qtype_match extends question_type {
return true;
}
public function save_defaults_for_new_questions(stdClass $fromform): void {
parent::save_defaults_for_new_questions($fromform);
$this->set_default_value('shuffleanswers', $fromform->shuffleanswers);
}
public function save_question_options($question) {
global $DB;
$context = $question->context;
@@ -18,11 +18,13 @@ Feature: Test creating a Matching question
And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
@javascript
Scenario: Create a Matching question with 3 subquestions
When I add a "Matching" question filling the form with:
| Question name | match-001 |
| Question text | Match the country with the capital city. |
| General feedback | England=London, France=Paris and Spain=Madrid. |
| id_shuffleanswers | 0 |
| id_subquestions_0 | England |
| id_subanswers_0 | London |
| id_subquestions_1 | France |
@@ -35,3 +37,9 @@ Feature: Test creating a Matching question
| Hint 1 | This is your first hint |
| Hint 2 | This is your second hint |
Then I should see "match-001"
# Checking that the next new question form displays user preferences settings.
When I press "Create a new question ..."
And I set the field "item_qtype_match" to "1"
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
Then the following fields match these values:
| id_shuffleanswers | 0 |