This commit is contained in:
Eloy Lafuente (stronk7)
2019-01-09 23:33:36 +01:00
6 changed files with 55 additions and 8 deletions
File diff suppressed because one or more lines are too long
@@ -123,8 +123,9 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
*/
DragDropOntoImageQuestion.prototype.resizeAllDragsAndDrops = function() {
var thisQ = this;
this.getRoot().find('.draghomes > div').each(function(i) {
thisQ.resizeAllDragsAndDropsInGroup(i + 1);
this.getRoot().find('.draghomes > div').each(function(i, node) {
thisQ.resizeAllDragsAndDropsInGroup(
thisQ.getClassnameNumericSuffix($(node), 'dragitemgroup'));
});
};
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -64,8 +64,9 @@ define(['jquery', 'core/dragdrop', 'core/key_codes'], function($, dragDrop, keys
*/
DragDropToTextQuestion.prototype.resizeAllDragsAndDrops = function() {
var thisQ = this;
this.getRoot().find('.answercontainer > div').each(function(i) {
thisQ.resizeAllDragsAndDropsInGroup(i + 1);
this.getRoot().find('.answercontainer > div').each(function(i, node) {
thisQ.resizeAllDragsAndDropsInGroup(
thisQ.getClassnameNumericSuffix($(node), 'draggrouphomes'));
});
};
@@ -63,3 +63,19 @@ Feature: Preview a drag-drop into text question
Then the state of "The" question is shown as "Incorrect"
And I should see "Mark 0.00 out of 1.00"
And I switch to the main window
@javascript
Scenario: Preview a question that uses strange group numbers using the keyboard.
Given the following "questions" exist:
| questioncategory | qtype | name | template |
| Test questions | ddwtos | Funny groups | oddgroups |
And I reload the page
When I click on "Preview" "link" in the "Funny groups" "table_row"
And I switch to "questionpreview" window
And I type " " into space "1" in the drag and drop onto image question
And I type " " into space "2" in the drag and drop onto image question
And I type " " into space "3" in the drag and drop onto image question
And I press "Submit and finish"
Then the state of "The" question is shown as "Correct"
And I should see "Mark 1.00 out of 1.00"
And I switch to the main window
+31 -2
View File
@@ -34,7 +34,7 @@ defined('MOODLE_INTERNAL') || die();
*/
class qtype_ddwtos_test_helper extends question_test_helper {
public function get_test_questions() {
return array('fox', 'maths');
return array('fox', 'maths', 'oddgroups');
}
/**
@@ -75,7 +75,9 @@ class qtype_ddwtos_test_helper extends question_test_helper {
}
/**
* @return stdClass date to create a ddwtos question.
* This is a simple question with choices in three groups.
*
* @return stdClass data to create a ddwtos question.
*/
public function get_ddwtos_question_form_data_fox() {
$fromform = new stdClass();
@@ -99,6 +101,33 @@ class qtype_ddwtos_test_helper extends question_test_helper {
return $fromform;
}
/**
* Similar to the 'fox' example above, but using different, non-continuous group numbers.
*
* @return stdClass data to create a ddwtos question.
*/
public function get_ddwtos_question_form_data_oddgroups() {
$fromform = new stdClass();
$fromform->name = 'Drag-and-drop words with strange groups';
$fromform->questiontext = array('text' => 'The [[1]] brown [[2]] jumped over the [[3]] dog.', 'format' => FORMAT_HTML);
$fromform->defaultmark = 1.0;
$fromform->generalfeedback = array('text' => 'This sentence uses each letter of the alphabet.', 'format' => FORMAT_HTML);
$fromform->choices = array(
array('answer' => 'quick', 'choicegroup' => '5'),
array('answer' => 'fox', 'choicegroup' => '7'),
array('answer' => 'lazy', 'choicegroup' => '3'),
array('answer' => 'slow', 'choicegroup' => '5'),
array('answer' => 'dog', 'choicegroup' => '7'),
array('answer' => 'assiduous', 'choicegroup' => '3'),
);
test_question_maker::set_standard_combined_feedback_form_data($fromform);
$fromform->shownumcorrect = 0;
$fromform->penalty = 0.3333333;
return $fromform;
}
/**
* @return qtype_ddwtos_question
*/