Skip to content

Commit

Permalink
fix: Update TextReader OAT & IMS PCIs to use clone in Sleep (#162)
Browse files Browse the repository at this point in the history
* fix: Update TextReader OAT & IMS PCIs to use clone in Sleep

* fix: Sleep now removes audio/video data attributes to prevent autoplay
  • Loading branch information
Karol-Stelmaczonek authored Jun 13, 2024
1 parent 7a4a806 commit beb36b2
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 30 deletions.
38 changes: 38 additions & 0 deletions migrations/Version202406120835514106_pciSamples.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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\tao\scripts\tools\migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*
* phpcs:disable Squiz.Classes.ValidClassName
*/
final class Version202406120835514106_pciSamples extends AbstractMigration
{
public function getDescription(): string
{
return 'Update TextReader OAT & IMS PCIs to use clone in Sleep';
}

public function up(Schema $schema): void
{
$this->runAction(new RegisterPciTextReaderIMS(), ['1.2.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
)
);
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/**
* 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) 2024 (original work) Open Assessment Technologies;
*
*/
define([
'core/promise',
'taoQtiItem/qtiCreator/widgets/states/factory',
Expand All @@ -25,20 +7,38 @@ define([
Promise,
stateFactory,
Sleep,
xincludeLoader,
xincludeLoader
) {
'use strict';

function removeMediaDataAttributes(pages) {
pages.forEach(page => {
page.content.forEach(contentItem => {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = contentItem;
const mediaObjects = tempDiv.querySelectorAll('object[type*="video"], object[type*="audio"]');
mediaObjects.forEach(obj => {
obj.removeAttribute('data');
});
page.content = [tempDiv.innerHTML];
});
});
return pages;
}

return stateFactory.extend(
Sleep,
function () {
const widget = this.widget;
const interaction = widget.element;
return xincludeLoader.loadByElementPages(interaction.properties.pages, interaction.renderer.getOption('baseUrl'))
.then(pagesWithInclusionsResolved => {
interaction.properties.pages = pagesWithInclusionsResolved;
interaction.widgetRenderer.renderAll(interaction.properties);
});
const pages = structuredClone(interaction.properties.pages);
return xincludeLoader.loadByElementPages(pages, interaction.renderer.getOption('baseUrl'))
.then(pagesWithInclusionsResolved => {
let properties = structuredClone(interaction.properties);
properties.pages = removeMediaDataAttributes(pagesWithInclusionsResolved);
interaction.widgetRenderer.renderAll(properties);
});
},
function () {},
function () {}
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"typeIdentifier": "textReaderInteraction",
"label": "Text reader",
"description": "The Paging widget combines a scrolling widget with additional paging controls.",
"version": "1.2.0",
"version": "1.2.1",
"author": "Aleh Hutnikau",
"email": "contact@taotesting.com",
"tags": [
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit beb36b2

Please sign in to comment.