Skip to content

Commit e0a0f90

Browse files
michaelsharmanTrungtin Ton
authored and
Trungtin Ton
committed
QtiV2/In: Fix incorrect imageclozeassociationV2 image path
Where image paths in the QTI source were in sub-directories, we had a problem with compatibility with Learnosity's Data API asset upload endpoint. The correct path needs to be: `https://assets.learnosity.com/organisations/[organisation_id]/[filename]` The problem was if images were stored in sub-directories in the QTI source, that sub-directory would form an extra part of the file path, thus breaking once uploaded via Data API.
1 parent 6b90235 commit e0a0f90

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Processors/QtiV2/In/Interactions/GraphicGapMatchInteractionMapper.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use LearnosityQti\Entities\QuestionTypes\imageclozeassociationV2_image;
77
use LearnosityQti\Entities\QuestionTypes\imageclozeassociationV2_response_containers_item;
88
use LearnosityQti\Exceptions\MappingException;
9+
use LearnosityQti\Processors\QtiV2\In\Constants;
910
use LearnosityQti\Processors\QtiV2\In\Validation\GapMatchInteractionValidationBuilder;
1011
use LearnosityQti\Utils\QtiCoordinateUtil;
1112
use LearnosityQti\Utils\QtiMarshallerUtil;
@@ -32,7 +33,11 @@ public function getQuestionType()
3233
$associableHotspots = $this->buildTemplate($interaction, $imageObject);
3334

3435
$image = new imageclozeassociationV2_image();
35-
$image->set_src($imageObject->getData());
36+
// Make sure to have the Learnosity base asset URL, with the organisation_id, then the filename.
37+
// Nothing else should be in the path
38+
$imageArray = explode('/',$imageObject->getData());
39+
$imageBaseUrl = Constants::$baseLearnosityAssetsUrl . $this->organisationId . '/' . end($imageArray);
40+
$image->set_src($imageBaseUrl);
3641
$image->set_width($imageObject->getWidth());
3742
$image->set_height($imageObject->getHeight());
3843

0 commit comments

Comments
 (0)