Skip to content

Commit

Permalink
Merge branch 'release-2.22.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wazelin committed Sep 25, 2020
2 parents c7d9633 + 0cce902 commit 50660dc
Show file tree
Hide file tree
Showing 16 changed files with 885 additions and 193 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
},
"minimum-stability": "dev",
"require": {
"oat-sa/oatbox-extension-installer": "~1.1||dev-master"
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"qtism/qtism": "~0"
},
"autoload": {
"psr-4": {
"oat\\taoQtiTestPreviewer\\": ""
}
}
}

6 changes: 3 additions & 3 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
'label' => 'extension-tao-testqti-previewer',
'description' => 'extension that provides QTI test previewer',
'license' => 'GPL-2.0',
'version' => '2.19.1',
'version' => '2.22.0',
'author' => 'Open Assessment Technologies SA',
'requires' => [
'generis' => '>=12.15.0',
'tao' => '>=45.2.0',
'taoTests' => '>=12.0.0',
'taoItems' => '>=10.2.0',
'taoTests' => '>=14.5.0',
'taoItems' => '>=10.12.0',
'taoQtiTest' => '>=29.0.0',
'taoQtiItem' => '>=23.1.0',
'taoOutcomeUi' => '>=6.0.0'
Expand Down
22 changes: 11 additions & 11 deletions models/test/mapper/TestPreviewMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
use oat\oatbox\service\ConfigurableService;
use oat\taoQtiTestPreviewer\models\test\TestPreviewConfig;
use oat\taoQtiTestPreviewer\models\test\TestPreviewMap;
use qtism\data\AssessmentItemRef;
use qtism\data\AssessmentTest;
use qtism\data\IAssessmentItem;
use qtism\data\NavigationMode;
use qtism\runtime\tests\Route;
use qtism\runtime\tests\RouteItem;
Expand All @@ -46,9 +46,7 @@ public function map(AssessmentTest $test, Route $route, TestPreviewConfig $confi
$routeItems = $route->getAllRouteItems();
$checkInformational = $config->get(TestPreviewConfig::CHECK_INFORMATIONAL);
$forceInformationalTitles = $config->get(TestPreviewConfig::REVIEW_FORCE_INFORMATION_TITLE);
$displaySubsectionTitle = $config->get(TestPreviewConfig::REVIEW_DISPLAY_SUBSECTION_TITLE) === null
? true
: $config->get(TestPreviewConfig::REVIEW_DISPLAY_SUBSECTION_TITLE);
$displaySubsectionTitle = $config->get(TestPreviewConfig::REVIEW_DISPLAY_SUBSECTION_TITLE) ?? true;

$map['title'] = $test->getTitle();
$map['identifier'] = $test->getIdentifier();
Expand All @@ -63,10 +61,7 @@ public function map(AssessmentTest $test, Route $route, TestPreviewConfig $confi

/** @var RouteItem $routeItem */
foreach ($routeItems as $routeItem) {
$itemRefs = $this->getRouteItemAssessmentItemRefs($routeItem);

/** @var IAssessmentItem $itemRef */
foreach ($itemRefs as $itemRef) {
foreach ($this->getRouteItemAssessmentItemRefs($routeItem) as $itemRef) {
$occurrence = $routeItem->getOccurence();

$isItemInformational = true; //@TODO Implement this as a feature
Expand All @@ -85,7 +80,7 @@ public function map(AssessmentTest $test, Route $route, TestPreviewConfig $confi
$sectionId = $section->getIdentifier();
$itemId = $itemRef->getIdentifier();

if ($lastSection != $sectionId) {
if ($lastSection !== $sectionId) {
$offsetSection = 0;
$lastSection = $sectionId;
}
Expand All @@ -98,11 +93,11 @@ public function map(AssessmentTest $test, Route $route, TestPreviewConfig $confi
'label' => $this->getItemLabel($itemUri),
'position' => $offset,
'occurrence' => $occurrence,
'remainingAttempts' => 0,
'remainingAttempts' => -1,
'answered' => 0,
'flagged' => false,
'viewed' => false,
'categories' => [],
'categories' => $itemRef->getCategories()->getArrayCopy(),
];

if ($checkInformational) {
Expand Down Expand Up @@ -188,6 +183,11 @@ private function updateStats(array &$target, array $itemInfos): void
$target['stats']['total']++;
}

/**
* @param RouteItem $routeItem
*
* @return AssessmentItemRef[]
*/
private function getRouteItemAssessmentItemRefs(RouteItem $routeItem): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class TestPreviewerConfigurationMapper extends ConfigurableService
{
/**
* @param ProviderModule[] $providerModules
* @param PluginModule[] $plugins
* @param mixed[] $options
* @param PluginModule[] $plugins
* @param mixed[] $options
*
* @return TestPreviewerConfig
*/
public function map(array $providerModules, array $plugins, array $options): TestPreviewerConfig
{
Expand All @@ -55,10 +56,6 @@ private function getActiveProviders(array $providerModules, array $plugins): arr
if ($provider->isActive()) {
$category = $provider->getCategory();

if (!isset($providers[$category])) {
$providers[$category] = [];
}

$providers[$category][] = $provider;
}
}
Expand Down
45 changes: 31 additions & 14 deletions scripts/install/RegisterPreviewers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2018 (original work) Open Assessment Technologies SA;
* Copyright (c) 2018-2020 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\taoQtiTestPreviewer\scripts\install;

use common_Exception as Exception;
use common_report_Report as Report;
use oat\oatbox\extension\InstallAction;
use oat\tao\model\modules\DynamicModule;
use oat\taoItems\model\preview\ItemPreviewerService;
use oat\taoOutcomeUi\model\ResultsViewerService;
use oat\oatbox\service\exception\InvalidServiceManagerException;
use common_exception_InconsistentData as InconsistentDataException;
use oat\taoItems\model\preview\ItemPreviewerRegistryServiceInterface;

/**
* Installation action that registers the test runner providers
Expand All @@ -33,8 +38,7 @@
*/
class RegisterPreviewers extends InstallAction
{

public static $providers = [
private const PROVIDERS = [
'previewer' => [
[
'id' => 'qtiItem',
Expand All @@ -44,29 +48,42 @@ class RegisterPreviewers extends InstallAction
'description' => 'QTI implementation of the item previewer',
'category' => 'previewer',
'active' => true,
'tags' => [ 'core', 'qti', 'previewer' ]
]
]
'tags' => ['core', 'qti', 'previewer'],
],
],
];

/**
* @param array $params
*
* @throws Exception
* @throws InconsistentDataException
* @throws InvalidServiceManagerException
*
* @return Report
*/
public function __invoke($params)
{
$registry = $this->getServiceLocator()->get(ItemPreviewerService::SERVICE_ID);

$serviceManager = $this->getServiceManager();

/** @var ItemPreviewerRegistryServiceInterface $registry */
$registry = $serviceManager->get(ItemPreviewerRegistryServiceInterface::SERVICE_ID);

$count = 0;

foreach (self::$providers as $categoryProviders) {
foreach (self::PROVIDERS as $categoryProviders) {
foreach ($categoryProviders as $providerData) {
if ($registry->registerAdapter(DynamicModule::fromArray($providerData))) {
$count++;
++$count;
}
}
}

$service = $this->getServiceManager()->get(ResultsViewerService::SERVICE_ID);
/** @var ResultsViewerService $service */
$service = $serviceManager->get(ResultsViewerService::SERVICE_ID);
$service->setDefaultItemType('qtiItem');
$this->getServiceManager()->register(ResultsViewerService::SERVICE_ID, $service);
$serviceManager->register(ResultsViewerService::SERVICE_ID, $service);

return new Report(Report::TYPE_SUCCESS, $count . ' providers registered.');
return Report::createSuccess($count . ' providers registered.');
}
}
73 changes: 39 additions & 34 deletions scripts/install/RegisterTestPreviewer.php
Original file line number Diff line number Diff line change
@@ -1,68 +1,73 @@
<?php
/**

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* Copyright (c) 2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
*
*/

// !!!TODO - should be to rely on the taoTest extension
// to supply the API to manage the provider registration and management instead of directly write into the registry
declare(strict_types=1);

namespace oat\taoQtiTestPreviewer\scripts\install;

use common_Exception as Exception;
use common_report_Report as Report;
use oat\oatbox\extension\InstallAction;
use oat\tao\model\ClientLibConfigRegistry;
use oat\tao\model\modules\DynamicModule;
use common_exception_InconsistentData as InconsistentData;
use oat\oatbox\service\exception\InvalidServiceManagerException;
use oat\taoTests\models\preview\TestPreviewerRegistryServiceInterface;

/**
* Class RegisterTestPreviewer
*
* @package oat\taoQtiTestPreviewer\scripts\install
*/
class RegisterTestPreviewer extends InstallAction
{
/**
* Sets the test previewer.
* @param array $params
*
* @param $params
* @throws InconsistentData
* @throws InvalidServiceManagerException
* @throws Exception
*
* @return \common_report_Report
* @return Report
*/
public function __invoke($params)
{
ClientLibConfigRegistry::getRegistry()->register(
'taoTests/previewer/factory', array(
'previewers' => array(
'taoQtiTestPreviewer/previewer/adapter/test/qtiTest' => array(
'id' => 'qtiTest',
'module' => 'taoQtiTestPreviewer/previewer/adapter/test/qtiTest',
'bundle' => 'taoQtiTestPreviewer/loader/qtiPreviewer.min',
'position' => null,
'name' => 'QTI Test Previewer',
'description' => 'QTI implementation of the test previewer',
'category' => 'previewer',
'active' => true,
'tags' => array(
'core',
'qti',
'previewer'
)
)
)
)
/** @var TestPreviewerRegistryServiceInterface $testPreviewerService */
$testPreviewerService = $this->getServiceManager()->get(
TestPreviewerRegistryServiceInterface::SERVICE_ID
);
$testPreviewerService->registerAdapter(DynamicModule::fromArray([
'id' => 'qtiTest',
'module' => 'taoQtiTestPreviewer/previewer/adapter/test/qtiTest',
'bundle' => 'taoQtiTestPreviewer/loader/qtiPreviewer.min',
'position' => null,
'name' => 'QTI Test Previewer',
'description' => 'QTI implementation of the test previewer',
'category' => 'previewer',
'active' => true,
'tags' => [
'core',
'qti',
'previewer',
],
]));

return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, 'The QTI Test Previewer is registered');
return Report::createSuccess('The QTI Test Previewer is registered');
}
}
}
Loading

0 comments on commit 50660dc

Please sign in to comment.