Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/aut 4109/restricted properties #527

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions controller/MediaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
use oat\taoMediaManager\model\fileManagement\FileManagement;
use oat\tao\model\Lists\Business\Validation\DependsOnPropertyValidator;
use core_kernel_classes_Resource;
use oat\taoMediaManager\model\TaoMediaOntology;
use oat\taoMediaManager\model\transcription\TranscriptionMimeTypesProvider;
use tao_actions_form_Instance;
use tao_actions_SaSModule;
use tao_helpers_form_FormContainer as FormContainer;
use tao_helpers_Uri;
Expand Down Expand Up @@ -198,6 +201,12 @@ private function getFormInstance(
$this->getDependsOnPropertyValidator(),
],
],
tao_actions_form_Instance::RESTRICTED_PROPERTIES => [
TaoMediaOntology::PROPERTY_TRANSCRIPTION => [
TaoMediaOntology::PROPERTY_MIME_TYPE =>
$this->getPsrContainer()->get(TranscriptionMimeTypesProvider::class)->getAll(),
]
]
]
);
}
Expand Down
2 changes: 2 additions & 0 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use oat\taoMediaManager\model\relation\service\MediaContainerProvider;
use oat\taoMediaManager\model\sharedStimulus\encoder\SharedStimulusMediaEncoder;
use oat\taoMediaManager\scripts\install\AddAssetClassEditorRolePermission;
use oat\taoMediaManager\scripts\install\ConfigFactoryExtension;
use oat\taoMediaManager\scripts\install\RegisterMediaRelationEvents;
use oat\taoMediaManager\scripts\install\RegisterMediaResourcePreparer;
use oat\taoMediaManager\scripts\install\RegisterSharedStimulusMediaEncoder;
Expand Down Expand Up @@ -181,6 +182,7 @@
[RegisterSharedStimulusMediaEncoder::class, ['service' => SharedStimulusMediaEncoder::class]],
AddAssetClassEditorRolePermission::class,
RegisterMediaRelationEvents::class,
ConfigFactoryExtension::class
]
],
'update' => 'oat\\taoMediaManager\\scripts\\update\\Updater',
Expand Down
34 changes: 34 additions & 0 deletions migrations/Version202502241322561888_taoMediaManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace oat\taoMediaManager\migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\Exception\IrreversibleMigration;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\taoMediaManager\scripts\install\ConfigFactoryExtension;
use oat\taoQtiItem\model\service\CreatorConfigFactory;

/**
* Auto-generated Migration: Please modify to your needs!
*
* phpcs:disable Squiz.Classes.ValidClassName
*/
final class Version202502241322561888_taoMediaManager extends AbstractMigration
{
public function getDescription(): string
{
return 'Register FE MediaManager details';
}

public function up(Schema $schema): void
{
$this->runAction(new ConfigFactoryExtension());
}

public function down(Schema $schema): void
{
throw new IrreversibleMigration();
}
}
1 change: 1 addition & 0 deletions model/TaoMediaOntology.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ interface TaoMediaOntology
public const PROPERTY_MD5 = 'http://www.tao.lu/Ontologies/TAOMedia.rdf#md5';

public const PROPERTY_MIME_TYPE = 'http://www.tao.lu/Ontologies/TAOMedia.rdf#mimeType';
public const PROPERTY_TRANSCRIPTION = 'http://www.tao.lu/Ontologies/TAOMedia.rdf#Transcription';
}
5 changes: 5 additions & 0 deletions model/classes/ServiceProvider/MediaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use oat\taoMediaManager\model\sharedStimulus\specification\SharedStimulusResourceSpecification;
use oat\taoMediaManager\model\TaoMediaOntology;
use oat\taoMediaManager\model\Specification\MediaClassSpecification;
use oat\taoMediaManager\model\transcription\TranscriptionMimeTypesProvider;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
Expand Down Expand Up @@ -214,5 +215,9 @@ public function __invoke(ContainerConfigurator $configurator): void
service(RdfMediaRelationRepository::class),
]
);


$services->set(TranscriptionMimeTypesProvider::class)
->public();
}
}
9 changes: 9 additions & 0 deletions model/ontology/taomedia.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
<generis:is_language_dependent rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>

<rdf:Description rdf:about="http://www.tao.lu/Ontologies/TAOMedia.rdf#Transcription">
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
<rdfs:label xml:lang="en-US"><![CDATA[Transcription]]></rdfs:label>
<rdfs:comment xml:lang="en-US"><![CDATA[Transcription]]></rdfs:comment>
<rdfs:domain rdf:resource="http://www.tao.lu/Ontologies/TAOMedia.rdf#Media"/>
<widget:widget rdf:resource="http://www.tao.lu/datatypes/WidgetDefinitions.rdf#TextArea"/>
<generis:is_language_dependent rdf:resource="http://www.tao.lu/Ontologies/generis.rdf#True"/>
</rdf:Description>

<rdf:Description rdf:about="http://www.tao.lu/Ontologies/TAOMedia.rdf#Language">
<rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/>
<rdfs:label xml:lang="en-US"><![CDATA[Language]]></rdfs:label>
Expand Down
31 changes: 31 additions & 0 deletions model/transcription/TranscriptionMimeTypesProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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) 2025 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\taoMediaManager\model\transcription;

class TranscriptionMimeTypesProvider
{
public function getAll(): array
{
return ['audio/mpeg', 'audio/ogg', 'audio/wav', 'video/mp4', 'video/webm', 'video/ogg'];
}
}
52 changes: 52 additions & 0 deletions scripts/install/ConfigFactoryExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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) 2025 (original work) Open Assessment Technologies SA;
*/

declare(strict_types=1);

namespace oat\taoMediaManager\scripts\install;

use oat\oatbox\extension\InstallAction;
use oat\taoMediaManager\model\MediaSource;
use oat\taoMediaManager\model\TaoMediaOntology;
use oat\taoQtiItem\model\service\CreatorConfigFactory;

class ConfigFactoryExtension extends InstallAction
{
public function __invoke($params)
{
$creatorConfigFactory = $this->getServiceManager()->get(CreatorConfigFactory::SERVICE_ID);

$extendedProperties = $creatorConfigFactory->getOption(CreatorConfigFactory::OPTION_EXTENDED_PROPERTIES, []);
$extendedProperties['transcriptionMetadata'] = TaoMediaOntology::PROPERTY_TRANSCRIPTION;
$extendedProperties['mediaManagerUriPrefix'] = MediaSource::SCHEME_NAME;

$extendedControlEndpoints = $creatorConfigFactory
->getOption(CreatorConfigFactory::OPTION_EXTENDED_CONTROL_ENDPOINTS, []);
$extendedControlEndpoints['resourceMetadataUrl'] = ['tao', 'ResourceMetadata', 'get'];

$creatorConfigFactory
->setOption(CreatorConfigFactory::OPTION_EXTENDED_PROPERTIES, $extendedProperties);

$creatorConfigFactory
->setOption(CreatorConfigFactory::OPTION_EXTENDED_CONTROL_ENDPOINTS, $extendedControlEndpoints);

$this->getServiceManager()->register(CreatorConfigFactory::SERVICE_ID, $creatorConfigFactory);
}
}
Loading