Skip to content

Commit

Permalink
feat: Update delivery type service
Browse files Browse the repository at this point in the history
  • Loading branch information
yaraslau-kavaliou committed Aug 31, 2023
1 parent b4a5818 commit 0636368
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"oat-sa/extension-tao-delivery": ">=15.0.0",
"oat-sa/extension-tao-lti": ">=12.0.0",
"oat-sa/extension-tao-outcomeui": ">=11.0.0",
"oat-sa/extension-tao-testqti-previewer": ">=3.0.0"
"oat-sa/extension-tao-testqti-previewer": ">=3.0.0",
"oat-sa/extension-tao-testqti" : ">=41.22.2"
}
}
27 changes: 17 additions & 10 deletions controller/ItemResultPreviewer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -19,21 +20,21 @@

namespace oat\ltiOutcomeUi\controller;

use core_kernel_classes_Resource;
use oat\generis\model\OntologyAwareTrait;
use oat\ltiOutcomeUi\model\service\ResultVariableStructureHandler;
use oat\oatbox\log\LoggerAwareTrait;
use oat\taoDelivery\model\execution\ServiceProxy;
use oat\taoLti\controller\ToolModule;
use oat\taoLti\models\classes\LtiException;
use oat\taoLti\models\classes\LtiMessages\LtiErrorMessage;
use oat\taoOutcomeUi\model\ResultsService;
use oat\taoOutcomeUi\model\ResultsViewerService;
use oat\taoOutcomeUi\model\Wrapper\ResultServiceWrapper;
use oat\taoQtiTest\models\DeliveryItemTypeRepository;
use oat\taoQtiTestPreviewer\models\ItemPreviewer;
use oat\taoQtiTestPreviewer\models\PreviewLanguageService;
use oat\taoOutcomeUi\model\Wrapper\ResultServiceWrapper;
use oat\taoResultServer\models\classes\ResultServerService;
use core_kernel_classes_Resource;
use tao_helpers_Uri;
use oat\taoLti\models\classes\LtiMessages\LtiErrorMessage;

/**
* Class ItemResultPreviewer
Expand All @@ -46,8 +47,8 @@ class ItemResultPreviewer extends ToolModule
use OntologyAwareTrait;
use LoggerAwareTrait;

const PARAM_RESULT_ID = 'resultId';
const PARAM_ITEM_REF = 'itemRef';
public const PARAM_RESULT_ID = 'resultId';
public const PARAM_ITEM_REF = 'itemRef';

/**
* The result variables of an item
Expand Down Expand Up @@ -103,7 +104,9 @@ public function preview()
$this->defaultData();
$data['type'] = $this->getItemResultPreviewerType($resultIdentifier);
$data['content'] = $this->getItemContent($itemDefinition, $resultIdentifier, $delivery->getUri());
$data['state'] = current($this->getItemResultVariables($delivery, $resultIdentifier, $itemDefinition) ?? []);
$data['state'] = current(
$this->getItemResultVariables($delivery, $resultIdentifier, $itemDefinition) ?? []
);
$data['itemDefinition'] = $itemDefinition;
$data['resultIdentifier'] = $resultIdentifier;
$data['deliveryIdentifier'] = $delivery->getUri();
Expand All @@ -124,8 +127,10 @@ public function preview()
*/
protected function getItemResultPreviewerType($resultIdentifier)
{
return $this->getServiceLocator()->get(ResultsViewerService::SERVICE_ID)
->getDeliveryItemType($resultIdentifier);
/** @var DeliveryItemTypeRepository $deliveryItemTypeRepository */
$deliveryItemTypeRepository = $this->getServiceLocator()->get(DeliveryItemTypeRepository::SERVICE_ID);

return $deliveryItemTypeRepository->getDeliveryItemType($resultIdentifier);
}

/**
Expand Down Expand Up @@ -230,7 +235,9 @@ protected function getItemVariable($delivery, $resultIdentifier, $itemDefinition
{
if (!isset($this->itemVariables[$itemDefinition])) {
$variables = $this->getDeliveryResultsService($delivery)->getStructuredVariables(
$resultIdentifier, ResultsService::VARIABLES_FILTER_ALL, [\taoResultServer_models_classes_ResponseVariable::class]
$resultIdentifier,
ResultsService::VARIABLES_FILTER_ALL,
[\taoResultServer_models_classes_ResponseVariable::class]
);

$itemVariables = [];
Expand Down

0 comments on commit 0636368

Please sign in to comment.