Skip to content

Commit

Permalink
Merge branch 'release-3.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed May 3, 2023
2 parents 3593001 + 754e7e5 commit 5036564
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 37 deletions.
35 changes: 18 additions & 17 deletions manifest.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 @@ -25,38 +26,38 @@

return array(
'name' => 'pciSamples',
'label' => 'QTI PCI samples',
'description' => '',
'label' => 'QTI PCI samples',
'description' => '',
'license' => 'GPL-2.0',
'author' => 'Open Assessment Technologies',
'managementRole' => 'http://www.tao.lu/Ontologies/generis.rdf#pciSamplesManager',
'author' => 'Open Assessment Technologies',
'managementRole' => 'http://www.tao.lu/Ontologies/generis.rdf#pciSamplesManager',
'acl' => array(
array('grant', 'http://www.tao.lu/Ontologies/generis.rdf#pciSamplesManager', array('ext'=>'pciSamples')),
array('grant', 'http://www.tao.lu/Ontologies/generis.rdf#pciSamplesManager', array('ext' => 'pciSamples')),
),
'install' => array(
'php' => array(
RegisterPciTextReaderOAT::class,
RegisterPciTextReaderIMS::class
)
'php' => array(
RegisterPciTextReaderOAT::class,
RegisterPciTextReaderIMS::class
)
),
'update' => 'oat\\pciSamples\\scripts\\update\\Updater',
'uninstall' => array(
),
'autoload' => array (
'autoload' => array(
'psr-4' => array(
'oat\\pciSamples\\' => dirname(__FILE__).DIRECTORY_SEPARATOR
'oat\\pciSamples\\' => dirname(__FILE__) . DIRECTORY_SEPARATOR
)
),
'routes' => array(
'/pciSamples' => 'oat\\pciSamples\\controller'
),
'constants' => array(
# views directory
"DIR_VIEWS" => dirname(__FILE__).DIRECTORY_SEPARATOR."views".DIRECTORY_SEPARATOR,
'constants' => array(
# views directory
"DIR_VIEWS" => dirname(__FILE__) . DIRECTORY_SEPARATOR . "views" . DIRECTORY_SEPARATOR,

#BASE URL (usually the domain root)
'BASE_URL' => ROOT_URL.'pciSamples/',
),
#BASE URL (usually the domain root)
'BASE_URL' => ROOT_URL . 'pciSamples/',
),
'containerServiceProviders' => [
UpgradeProcessServiceProvider::class,
],
Expand Down
2 changes: 0 additions & 2 deletions migrations/Version202107081305304106_pciSamples.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
final class Version202107081305304106_pciSamples extends AbstractMigration
{

public function getDescription(): string
{
return 'Restore the previous version of the Text Reader interaction';
Expand Down Expand Up @@ -43,7 +42,6 @@ public function up(Schema $schema): void
['1.0.0']
)
);

}

public function down(Schema $schema): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ private function upgradeItemPCIsWithImages(Item $xmlItem): void
$properties = $pciInteraction->getProperties();
foreach ($properties['pages'] as $page) {
$images = $this->extractImages($page['content']);
$properties = $this->getImageToPropertyHelper()->addImagesToProperties($images, $properties, $this->itemDirectory);
$properties = $this->getImageToPropertyHelper()->addImagesToProperties(
$images,
$properties,
$this->itemDirectory
);
}

$this->setUpgradedNamespace($pciInteraction);
Expand Down
2 changes: 1 addition & 1 deletion model/ServiceProvider/UpgradeProcessServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
use oat\taoMediaManager\model\MediaSource;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use taoItems_models_classes_ItemsService;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

class UpgradeProcessServiceProvider implements ContainerServiceProviderInterface
{

public function __invoke(ContainerConfigurator $configurator): void
{
$services = $configurator->services();
Expand Down
15 changes: 9 additions & 6 deletions model/update/ItemFixTextReaderDefaultValue.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 Down Expand Up @@ -45,19 +46,21 @@ protected function updateItem(Item $item, $itemFile)
$requireFix = false;
$interactions = $item->getInteractions();
foreach ($interactions as $interaction) {
if ($interaction instanceof PortableCustomInteraction && $interaction->getTypeIdentifier() === 'textReaderInteraction') {

if (
$interaction instanceof PortableCustomInteraction
&& $interaction->getTypeIdentifier() === 'textReaderInteraction'
) {
$response = $interaction->getResponse();
$currentDefaultVal = $response->getDefaultValue();

if(!is_array($currentDefaultVal) || empty($currentDefaultVal) || count($currentDefaultVal) !== 1){
if (!is_array($currentDefaultVal) || empty($currentDefaultVal) || count($currentDefaultVal) !== 1) {
$requireFix = true;
}else{
} else {
$val = $currentDefaultVal[0];
$requireFix = !($val instanceof Value && $val->getValue() === 'true');
}

if($requireFix){
if ($requireFix) {
$defaultValue = new Value();
$defaultValue->setValue('true');
$response->setDefaultValue([$defaultValue]);
Expand All @@ -67,4 +70,4 @@ protected function updateItem(Item $item, $itemFile)
}
return $changed;
}
}
}
6 changes: 4 additions & 2 deletions scripts/install/RegisterPciTextReaderIMS.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 @@ -24,8 +25,9 @@

class RegisterPciTextReaderIMS extends RegisterPortableElement
{
protected function getSourceDirectory(){
protected function getSourceDirectory()
{
$viewDir = \common_ext_ExtensionsManager::singleton()->getExtensionById('pciSamples')->getConstant('DIR_VIEWS');
return $viewDir.implode(DIRECTORY_SEPARATOR, ['js', 'pciCreator', 'ims', 'textReaderInteraction']);
return $viewDir . implode(DIRECTORY_SEPARATOR, ['js', 'pciCreator', 'ims', 'textReaderInteraction']);
}
}
6 changes: 4 additions & 2 deletions scripts/install/RegisterPciTextReaderOAT.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 @@ -24,8 +25,9 @@

class RegisterPciTextReaderOAT extends RegisterPortableElement
{
protected function getSourceDirectory(){
protected function getSourceDirectory()
{
$viewDir = \common_ext_ExtensionsManager::singleton()->getExtensionById('pciSamples')->getConstant('DIR_VIEWS');
return $viewDir.implode(DIRECTORY_SEPARATOR, ['js', 'pciCreator', 'dev', 'textReaderInteraction']);
return $viewDir . implode(DIRECTORY_SEPARATOR, ['js', 'pciCreator', 'dev', 'textReaderInteraction']);
}
}
5 changes: 2 additions & 3 deletions scripts/tool/FixTextReaderDefaultValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
class FixTextReaderDefaultValue implements Action
{

public function __invoke($params)
{
$run = false;
Expand All @@ -28,7 +27,7 @@ public function __invoke($params)
// maybe it's a dirty way but it's quicker. too much modification would have been required in ItemUpdater
$adapter = $dir->getFileSystem()->getAdapter();
if (!$adapter instanceof Local) {
throw new \Exception(__CLASS__.' can only handle local files');
throw new \Exception(__CLASS__ . ' can only handle local files');
}

$itemUpdater = new ItemFixTextReaderDefaultValue($adapter->getPathPrefix());
Expand All @@ -39,4 +38,4 @@ public function __invoke($params)
return \common_report_Report::createInfo('Item to be fixed ' . count($res));
}
}
}
}
5 changes: 2 additions & 3 deletions scripts/update/Updater.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 Down Expand Up @@ -30,7 +31,6 @@
*/
class Updater extends \common_ext_ExtensionUpdater
{

/**
*
* @param string $currentVersion
Expand All @@ -44,7 +44,6 @@ public function update($initialVersion)
}

if ($this->isVersion('0.2.1')) {

HookRegistry::getRegistry()->remove('pciSamplesCreator');

$this->setVersion('1.0.0');
Expand All @@ -66,7 +65,7 @@ public function update($initialVersion)

if ($this->isVersion('2.1.0')) {
$registry = (new IMSPciModel())->getRegistry();
if($registry->has('textReaderInteraction')){
if ($registry->has('textReaderInteraction')) {
$registry->removeAllVersions('textReaderInteraction');
}
call_user_func(new RegisterPciTextReaderOAT(), ['0.5.0']);
Expand Down
Empty file added test/unit/.gitkeep
Empty file.

0 comments on commit 5036564

Please sign in to comment.