Skip to content

Commit

Permalink
Merge branch 'master' into unand
Browse files Browse the repository at this point in the history
  • Loading branch information
wildanm committed May 18, 2022
2 parents 7eaa633 + d675366 commit f591bec
Show file tree
Hide file tree
Showing 23 changed files with 737 additions and 56 deletions.
39 changes: 21 additions & 18 deletions locales/ja-JP/messages.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: TAO 2021.10\n"
"PO-Revision-Date: 2021-11-29T18:00:52\n"
"Project-Id-Version: TAO 2021.11\n"
"PO-Revision-Date: 2022-02-15T09:44:49\n"
"Last-Translator: TAO Translation Team <[email protected]>\n"
"MIME-Version: 1.0\n"
"Language: ja-JP\n"
Expand All @@ -14,25 +14,25 @@ msgstr ""
"X-Poedit-SearchPath-0: .\n"

msgid "Add page"
msgstr ""
msgstr "ページ追加"

msgid "Allow multi pages"
msgstr ""
msgstr "マルチページ"

msgid "Bottom"
msgstr ""
msgstr "下部"

msgid "Button based"
msgstr ""
msgstr "ボタン"

msgid "Button labels"
msgstr ""
msgstr "ボタンラベル"

msgid "Button labels."
msgstr ""
msgstr "ボタンラベル."

msgid "Columns:"
msgstr ""
msgstr "カラム:"

msgid "Delete"
msgstr ""
Expand All @@ -41,28 +41,31 @@ msgid "Display"
msgstr ""

msgid "If this box is checked the text reader will allow to display more than one page and to navigate between them."
msgstr ""
msgstr "このボックスをチェックすると、テキストリーダーで複数のページを表示したり、ページ間を移動したりすることができます。"

msgid "Left"
msgstr ""

msgid "Navigation"
msgstr ""
msgstr "ナビゲーション"

msgid "Navigation."
msgstr ""
msgstr "ナビゲーション."

msgid "Next"
msgstr ""

msgid "Page"
msgstr ""

msgid "page %d column %d"
msgstr "ページ %d カラム %d"

msgid "Page height (px)"
msgstr ""
msgstr "ページ高さ (px)"

msgid "Page height (px)."
msgstr ""
msgstr "ページ高さ (px)."

msgid "Previous"
msgstr ""
Expand All @@ -74,16 +77,16 @@ msgid "Right"
msgstr ""

msgid "Tab based"
msgstr ""
msgstr "タブ"

msgid "Tabs + buttons"
msgstr ""
msgstr "タブ + ボタン"

msgid "Tabs position"
msgstr ""
msgstr "タブ位置"

msgid "Tabs position."
msgstr ""
msgstr "タブ位置."

msgid "Tooltips"
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion locales/ja-JP/messages_po.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*
*
*/

use oat\pciSamples\model\ServiceProvider\UpgradeProcessServiceProvider;
use oat\pciSamples\scripts\install\RegisterPciTextReaderIMS;
use oat\pciSamples\scripts\install\RegisterPciTextReaderOAT;

Expand Down Expand Up @@ -54,5 +56,8 @@

#BASE URL (usually the domain root)
'BASE_URL' => ROOT_URL.'pciSamples/',
)
),
'containerServiceProviders' => [
UpgradeProcessServiceProvider::class,
],
);
10 changes: 6 additions & 4 deletions migrations/Version202103160949554106_pciSamples.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@
namespace oat\pciSamples\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\qtiItemPci\model\IMSPciModel;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use oat\qtiItemPci\model\PciModel;
use oat\pciSamples\scripts\install\RegisterPciTextReaderIMS;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version202103160949554106_pciSamples extends AbstractMigration
{

public function getDescription(): string
{
return 'Convert Text Reader interaction to IMS compliant';
}

public function up(Schema $schema): void
{
$registry = (new PciModel())->getRegistry();
$registry = (new IMSPciModel())->getRegistry();
if ($registry->has('textReaderInteraction')) {
/** @noinspection PhpUnhandledExceptionInspection */
$registry->removeAllVersions('textReaderInteraction');
Expand All @@ -41,7 +40,10 @@ public function up(Schema $schema): void
public function down(Schema $schema): void
{
throw new IrreversibleMigration(
'In order to undo this migration, please revert the client-side changes and run ' . RegisterPciTextReaderIMS::class
sprintf(
'In order to undo this migration, please revert the client-side changes and run %s',
RegisterPciTextReaderIMS::class
)
);
}
}
14 changes: 8 additions & 6 deletions migrations/Version202110280904504106_pciSamples.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\pciSamples\scripts\install\RegisterPciTextReaderIMS;
use oat\qtiItemPci\model\PciModel;
use oat\qtiItemPci\model\IMSPciModel;
use oat\tao\scripts\tools\migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version202110280904504106_pciSamples extends AbstractMigration
{

public function getDescription(): string
{
return 'Add basic keyboard navigation to the TextReaderInteraction';
}

public function up(Schema $schema): void
{
$registry = (new PciModel())->getRegistry();
$registry = (new IMSPciModel())->getRegistry();
if ($registry->has('textReaderInteraction')) {
$registry->removeAllVersions('textReaderInteraction');
}
Expand All @@ -38,8 +37,11 @@ public function up(Schema $schema): void

public function down(Schema $schema): void
{
throw new IrreversibleMigration('In order to undo this migration, please revert the client-side changes and run ' . RegisterPciTextReaderIMS::class
throw new IrreversibleMigration(
sprintf(
'In order to undo this migration, please revert the client-side changes and run %s',
RegisterPciTextReaderIMS::class
)
);

}
}
43 changes: 43 additions & 0 deletions migrations/Version202201111538504106_pciSamples.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace oat\pciSamples\migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use oat\qtiItemPci\model\IMSPciModel;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\pciSamples\scripts\install\RegisterPciTextReaderIMS;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version202201111538504106_pciSamples extends AbstractMigration
{
public function getDescription(): string
{
return 'Fix text reader PCI destroy lifecycle';
}

public function up(Schema $schema): void
{
$registry = (new IMSPciModel())->getRegistry();
if ($registry->has('textReaderInteraction')) {
$registry->removeAllVersions('textReaderInteraction');
}
$this->addReport(
$this->propagate(new RegisterPciTextReaderIMS())(['1.1.1'])
);
}

public function down(Schema $schema): void
{
throw new IrreversibleMigration(
sprintf(
'In order to undo this migration, please revert the client-side changes and run %s',
RegisterPciTextReaderIMS::class
)
);
}
}
69 changes: 69 additions & 0 deletions migrations/Version202203161157144106_pciSamples.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

namespace oat\pciSamples\migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use oat\pciSamples\scripts\install\RegisterPciTextReaderIMS;
use oat\pciSamples\scripts\install\RegisterPciTextReaderOAT;
use oat\qtiItemPci\model\IMSPciModel;
use oat\qtiItemPci\model\PciModel;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\taoQtiItem\model\portableElement\action\RegisterPortableElement;
use oat\taoQtiItem\model\portableElement\model\PortableElementModel;

final class Version202203161157144106_pciSamples extends AbstractMigration
{
private const RESTORED_PORTABLE_ELEMENT_IDENTIFIER = 'textReaderInteraction';
private const RESTORED_OAT_PORTABLE_ELEMENT_VERSION = '0.9.0';
private const RESTORED_IMS_PORTABLE_ELEMENT_VERSION = '1.1.1';

public function getDescription(): string
{
return sprintf(
'Restore PciModel of `%s` versions `%s`',
self::RESTORED_PORTABLE_ELEMENT_IDENTIFIER,
implode(
', ',
[self::RESTORED_OAT_PORTABLE_ELEMENT_VERSION, self::RESTORED_IMS_PORTABLE_ELEMENT_VERSION]
)
);
}

public function up(Schema $schema): void
{
$this->restoreInteraction(
new PciModel(),
new RegisterPciTextReaderOAT(),
self::RESTORED_OAT_PORTABLE_ELEMENT_VERSION
);
$this->restoreInteraction(
new IMSPciModel(),
new RegisterPciTextReaderIMS(),
self::RESTORED_IMS_PORTABLE_ELEMENT_VERSION
);
}

public function down(Schema $schema): void
{
throw new IrreversibleMigration();
}

private function restoreInteraction(
PortableElementModel $model,
RegisterPortableElement $registerPortableElement,
string $version
): void {
$registry = $model->getRegistry();
if ($registry->has('textReaderInteraction')) {
/** @noinspection PhpUnhandledExceptionInspection */
$registry->removeAllVersions('textReaderInteraction');
}

$this->addReport(
$this->propagate($registerPortableElement)([$version])
);
}
}
81 changes: 81 additions & 0 deletions model/LegacyPciHelper/ImageToPropertiesHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?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) 2022 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\pciSamples\model\LegacyPciHelper;

use oat\oatbox\filesystem\Directory;
use oat\taoMediaManager\model\fileManagement\FileManagement;
use oat\taoMediaManager\model\MediaSource;

class ImageToPropertiesHelper
{
/** @var MediaSource */
private $mediaSource;

/** @var FileManagement */
private $fileManagement;

public function __construct(MediaSource $mediaSource, FileManagement $fileManagement)
{
$this->mediaSource = $mediaSource;
$this->fileManagement = $fileManagement;
}

public function addImagesToProperties(array $images, array $properties, Directory $itemDirectory): array
{
foreach ($images as $image) {
if ($this->isImageMediaManager($image['fileName'])) {
$fileInfo = $this->mediaSource->getFileInfo($image['fileName']);
$properties = $this->addBase64Image(
$properties,
$image['fileName'],
$this->fileManagement->getFileStream(
$fileInfo['link']
)->read(1024 * 8)
);
continue;
}
$properties = $this->addBase64Image(
$properties,
$image['fileName'],
$itemDirectory->getFile($image['fileName'])->read()
);
}

return $properties;
}

private function addBase64Image(array $properties, string $fileName, string $image): array
{
$properties['content-' . $fileName] = sprintf(
"data:image/png;base64,%s",
base64_encode($image)
);

return $properties;
}

private function isImageMediaManager(string $fileName): bool
{
return false !== strpos($fileName, 'taomedia://');
}
}
Loading

0 comments on commit f591bec

Please sign in to comment.