MDL-47180 qformat_webct: Import of calculated questions broken

This commit is contained in:
Jean-Michel Vedrine
2014-09-23 14:47:36 +02:00
parent 8152e9fa60
commit ba50cd880c
3 changed files with 63 additions and 2 deletions
+1 -2
View File
@@ -525,7 +525,7 @@ class qformat_webct extends qformat_default {
break;
case 'calculated':
foreach ($question->answers as $answer) {
foreach ($question->answer as $answer) {
if ($formulaerror = qtype_calculated_find_formula_errors($answer)) {
$warnings[] = "'$question->name': ". $formulaerror;
$questionok = false;
@@ -535,7 +535,6 @@ class qformat_webct extends qformat_default {
$dataset->itemcount = count($dataset->datasetitem);
}
$question->import_process = true;
unset($question->answer); // Not used in calculated question.
break;
case 'match':
// MDL-10680:
@@ -0,0 +1,30 @@
@qformat @qformat_webct
Feature: Test importing calculated question from WebCT format.
In order to reuse calculated questions from a commercial LMS
As a teacher
I need to be able to import them in WebCT format.
Background:
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "users" exist:
| username | firstname |
| teacher | Teacher |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And I log in as "teacher"
And I follow "Course 1"
@javascript @_file_upload
Scenario: import a WebCT calculated question
When I navigate to "Import" node in "Course administration > Question bank"
And I set the field "id_format_webct" to "1"
And I upload "question/format/webct/tests/fixtures/sample_calculated_webct.txt" 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 "Find the area in m2 of a square with sides of length {l} m."
When I press "Continue"
Then I should see "calculated: Square area"
@@ -0,0 +1,32 @@
# Start of calculated question: Square area
:TYPE:C
:TITLE:calculated: Square area
:QUESTION:H
Find the area in m<sup>2</sup> of a square with sides of length {l} m.
:IMAGE:
:FORMULA:{l}*{l}
:l-MIN:10
:l-MAX:100
:l-DEC:0
:VALUES:10
:l-VAL1:51
:l-VAL2:32
:l-VAL3:57
:l-VAL4:94
:l-VAL5:38
:l-VAL6:54
:l-VAL7:87
:l-VAL8:90
:l-VAL9:78
:l-VAL10:39
:ANS-DEC:1
:TOL:
:TOLTYPE:percent
:UNITREQ:0
:UNITSPACE:0
:UNITCASE:0
:UNITVAL:0
:ANSTYPE:dec
:FEEDBACK:H
:CAT:Import from WebCT
# End of calculated question: Square area