MDL-70916 Essay/Moodle XML: min and max word limits not imported

This commit is contained in:
Tim Hunt 2021-02-16 14:35:00 +00:00
parent a2fda1289f
commit 9bc2094202
5 changed files with 36 additions and 2 deletions

View file

@ -772,8 +772,10 @@ class qformat_xml extends qformat_default {
array('#', 'responserequired', 0, '#'), 1); array('#', 'responserequired', 0, '#'), 1);
$qo->minwordlimit = $this->getpath($question, $qo->minwordlimit = $this->getpath($question,
array('#', 'minwordlimit', 0, '#'), null); array('#', 'minwordlimit', 0, '#'), null);
$qo->minwordenabled = !empty($qo->minwordlimit);
$qo->maxwordlimit = $this->getpath($question, $qo->maxwordlimit = $this->getpath($question,
array('#', 'maxwordlimit', 0, '#'), null); array('#', 'maxwordlimit', 0, '#'), null);
$qo->maxwordenabled = !empty($qo->maxwordlimit);
$qo->attachments = $this->getpath($question, $qo->attachments = $this->getpath($question,
array('#', 'attachments', 0, '#'), 0); array('#', 'attachments', 0, '#'), 0);
$qo->attachmentsrequired = $this->getpath($question, $qo->attachmentsrequired = $this->getpath($question,

View file

@ -407,7 +407,9 @@ END;
$expectedq->responserequired = 1; $expectedq->responserequired = 1;
$expectedq->responsefieldlines = 15; $expectedq->responsefieldlines = 15;
$expectedq->minwordlimit = null; $expectedq->minwordlimit = null;
$expectedq->minwordenabled = false;
$expectedq->maxwordlimit = null; $expectedq->maxwordlimit = null;
$expectedq->maxwordenabled = false;
$expectedq->attachments = 0; $expectedq->attachments = 0;
$expectedq->attachmentsrequired = 0; $expectedq->attachmentsrequired = 0;
$expectedq->maxbytes = 0; $expectedq->maxbytes = 0;
@ -470,7 +472,9 @@ END;
$expectedq->responserequired = 0; $expectedq->responserequired = 0;
$expectedq->responsefieldlines = 42; $expectedq->responsefieldlines = 42;
$expectedq->minwordlimit = null; $expectedq->minwordlimit = null;
$expectedq->minwordenabled = false;
$expectedq->maxwordlimit = null; $expectedq->maxwordlimit = null;
$expectedq->maxwordenabled = false;
$expectedq->attachments = -1; $expectedq->attachments = -1;
$expectedq->attachmentsrequired = 1; $expectedq->attachmentsrequired = 1;
$expectedq->maxbytes = 0; $expectedq->maxbytes = 0;
@ -537,7 +541,9 @@ END;
$expectedq->responserequired = 0; $expectedq->responserequired = 0;
$expectedq->responsefieldlines = 42; $expectedq->responsefieldlines = 42;
$expectedq->minwordlimit = 10; $expectedq->minwordlimit = 10;
$expectedq->minwordenabled = true;
$expectedq->maxwordlimit = 20; $expectedq->maxwordlimit = 20;
$expectedq->maxwordenabled = true;
$expectedq->attachments = -1; $expectedq->attachments = -1;
$expectedq->attachmentsrequired = 1; $expectedq->attachmentsrequired = 1;
$expectedq->maxbytes = 52428800; // 50MB. $expectedq->maxbytes = 52428800; // 50MB.

View file

@ -18,7 +18,7 @@ I need to choose the appropriate minimum and/or maximum number of words for inpu
| Course | C1 | Test questions | | Course | C1 | Test questions |
And the following "questions" exist: And the following "questions" exist:
| questioncategory | qtype | name | template | minwordlimit | maxwordlimit | | questioncategory | qtype | name | template | minwordlimit | maxwordlimit |
| Test questions | essay | essay-min-max | editor | null | null | | Test questions | essay | essay-min-max | editor | 0 | 0 |
Given I log in as "teacher1" Given I log in as "teacher1"
And I am on "Course 1" course homepage And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration And I navigate to "Question bank" in current page administration
@ -56,3 +56,27 @@ I need to choose the appropriate minimum and/or maximum number of words for inpu
When I set the field "Require text" to "Text input is optional" When I set the field "Require text" to "Text input is optional"
Then I should not see "Minimum word limit" Then I should not see "Minimum word limit"
And I should not see "Minimum word limit" And I should not see "Minimum word limit"
@javascript
Scenario: Minimum/Maximum word limit can be unset after being set.
Given I choose "Edit question" action for "essay-min-max" in the question bank
When I set the following fields to these values:
| minwordenabled | 1 |
| id_minwordlimit | 100 |
| maxwordenabled | 1 |
| id_maxwordlimit | 200 |
And I click on "Save changes and continue editing" "button"
Then the following fields match these values:
| minwordenabled | 1 |
| id_minwordlimit | 100 |
| maxwordenabled | 1 |
| id_maxwordlimit | 200 |
And I set the following fields to these values:
| minwordenabled | 0 |
| maxwordenabled | 0 |
And I click on "Save changes and continue editing" "button"
And the following fields match these values:
| minwordenabled | 0 |
| id_minwordlimit | |
| maxwordenabled | 0 |
| id_maxwordlimit | |

View file

@ -28,3 +28,5 @@ Feature: Test importing Essay questions
And I should see "Write an essay with 500 words." And I should see "Write an essay with 500 words."
And I press "Continue" And I press "Continue"
And I should see "essay-001" And I should see "essay-001"
And I choose "Edit question" action for "essay-001" in the question bank
And the field "id_maxwordlimit" matches value "20"

View file

@ -26,7 +26,7 @@
<responserequired>1</responserequired> <responserequired>1</responserequired>
<responsefieldlines>15</responsefieldlines> <responsefieldlines>15</responsefieldlines>
<minwordlimit></minwordlimit> <minwordlimit></minwordlimit>
<maxwordlimit></maxwordlimit> <maxwordlimit>20</maxwordlimit>
<attachments>0</attachments> <attachments>0</attachments>
<attachmentsrequired>0</attachmentsrequired> <attachmentsrequired>0</attachmentsrequired>
<maxbytes>0</maxbytes> <maxbytes>0</maxbytes>