MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005811ATutorImport Contentpublic2017-09-25 12:022017-10-05 18:32
Reportergreg 
Assigned Tocindy 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version2.2.3Fixed in Version2.2.3 
Summary0005811: Test question truncated on import CC w/ PHP7
DescriptionWhen importing a common cartridge with test questions, the question in is truncated to one letter using php 7.1.1. (could also be earlier versions of php7)
Steps To ReproduceImport a common cartridge with test questions in it, or a QTI test or testbank, first using php5.6. then the same with php7.1.1.

Examine the questions imported into the question bank.
TagsNo tags attached.
Affects versionSVN
SVN Revision#78acadf..f6749fa
Attached Fileszip file icon Import_CC_-_Principle_1__Perceivable_imscc.zip [^] (505,514 bytes) 2017-10-04 17:45

- Relationships

-  Notes
(0007658)
greg (administrator)
2017-09-29 19:56

Also happens with QTI EXPORT/IMPORT
AT ~LINE 70 /mods/core/imsqti/classes/QTIParser.class.php
xml_parse($this->parser, $xml_data, TRUE);

The XML contains the question names when going in, coming out with only the first letter of the question.
(0007666)
greg (administrator)
2017-10-04 17:56

From stack overflow
The problem I'm having occurs with the xml_parse() function in the ATutor QTI Parser

I'm hoping someone can point out what I'm missing, or perhaps come up with a work around for PHP 7.1.1.

I've found no documentation, or posts here, that suggest changes to the PHP xml_parse() function from 5.6 to 7.1, though the two versions seem to parse xml differently. The XML being parse appears below.

Specifically, for the question array in the examples, 5.6.30 returns an array of questions, like:

[question] => Array
    (
        [0] => graphic matching
        [1] => LIKERT
        [2] => multi choice question
        [3] => Mutliple question
        [4] => open ended
        [5] => ordering
        [6] => Simple match
        [7] => true
    )

While with php 7.1.1, all else being the same, it returns only the first letters from each of the array elements above, as a string.

[question] => gLmMooSt

The XML file is an IMS QTI 1.2.1 manifest, from a QTI test (i.e. quiz) package.

The element where the truncating occurs is the question title (the question itself), found in the following element, which returns as the first element in the array when using PHP5.6 ([0] => graphic matching), and return as the first letter, "g", in the question string when using PHP7.1.1 ([question] => gLmMooSt)

<material>
        <mattext texttype="text/html">graphic matching</mattext>
</material>
(0007667)
greg (administrator)
2017-10-04 17:58

The line where the problem occurs is:
https://github.com/atutor/ATutor/blob/master/mods/_core/imsqti/classes/QTIParser.class.php#L70 [^]
(0007668)
cindy (administrator)
2017-10-05 16:14

I've issued a pull request - https://github.com/atutor/ATutor/pull/137 [^] to fix this problem. Please test and verify.

The change is at https://github.com/cindyli/ATutor/blob/411b0be88d657bf8d4f5a627c15b58d5411b391c/mods/_core/imsqti/classes/QTIParser.class.php#L34 [^]

It's because PHP7 has a much strict variable type validation. This $question variable was initiated as a string value ''. Before PHP7, when it's treated as an array in the code, PHP silently convert it to array. With PHP7, this variable is treated as a string throughout the class, which results in array values assigned to this variable are truncated to compose a string by only taking the first character from each array value.

Quite a hidden issue. Glad it's fixed and now we know more about PHP7. Cheers!
(0007670)
greg (administrator)
2017-10-05 18:32

Cindy Li: explicitely define $question as an array, rather than the string it was previously set to.

- Issue History
Date Modified Username Field Change
2017-09-25 12:02 greg New Issue
2017-09-25 12:08 greg Summary Test quetion truncated on import CC => Test question truncated on import CC
2017-09-29 19:56 greg Note Added: 0007658
2017-10-02 17:59 greg Description Updated View Revisions
2017-10-02 17:59 greg Steps to Reproduce Updated View Revisions
2017-10-03 18:06 greg Summary Test question truncated on import CC => Test question truncated on import CC w/ PHP7
2017-10-04 17:45 greg File Added: Import_CC_-_Principle_1__Perceivable_imscc.zip
2017-10-04 17:48 greg Description Updated View Revisions
2017-10-04 17:56 greg Note Added: 0007666
2017-10-04 17:58 greg Note Added: 0007667
2017-10-05 16:14 cindy Note Added: 0007668
2017-10-05 18:32 greg SVN Revision# => 78acadf..f6749fa
2017-10-05 18:32 greg Note Added: 0007670
2017-10-05 18:32 greg Status new => resolved
2017-10-05 18:32 greg Fixed in Version => 2.2.3
2017-10-05 18:32 greg Resolution open => fixed
2017-10-05 18:32 greg Assigned To => cindy


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker