Skip to content
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
25 changes: 16 additions & 9 deletions components/ILIAS/Scorm2004/classes/class.ilSCORM13PlayerGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ public function getPlayer(): void
global $DIC;
$lng = $DIC->language();
$ilSetting = $DIC->settings();
ilWACSignedPath::signFolderOfStartFile($this->getDataDirectory() . '/imsmanifest.xml');
if (!$this->slm->hasContainerResource()) {
ilWACSignedPath::signFolderOfStartFile($this->getDataDirectory() . '/imsmanifest.xml');
}

// player basic config data

Expand Down Expand Up @@ -419,7 +421,7 @@ public function getPlayer(): void
$config['scorm_player_unload_url'] = $unload_url;
$config['post_log_url'] = $DIC->ctrl()->getLinkTarget($this, 'postLogEntry');
$config['livelog_url'] = $DIC->ctrl()->getLinkTarget($this, 'liveLogContent');
$config['package_url'] = $this->getDataDirectory() . "/";
$config['package_url'] = $this->slm->getContainerBaseUri() ?? ($this->getDataDirectory() . "/");

//editor
$config['envEditor'] = 0;
Expand Down Expand Up @@ -454,12 +456,15 @@ public function getPlayer(): void
$jQueryPath = str_replace('.min', '', iljQueryUtil::getLocaljQueryPath());
$this->tpl->setVariable("JS_FILE", $jQueryPath);

// include ilias rte css, if given
$rte_css = $this->slm->getDataDirectory() . "/ilias_css_4_2/css/style.css";
if (is_file($rte_css)) {
$this->tpl->setCurrentBlock("rte_css");
$this->tpl->setVariable("RTE_CSS", $rte_css);
$this->tpl->parseCurrentBlock();
// include ilias rte css, if given (only legacy on-disk modules carry the
// ilias_css_4_2 editor stylesheet; imported/migrated packages do not)
if (!$this->slm->hasContainerResource()) {
$rte_css = $this->slm->getDataDirectory() . "/ilias_css_4_2/css/style.css";
if (is_file($rte_css)) {
$this->tpl->setCurrentBlock("rte_css");
$this->tpl->setVariable("RTE_CSS", $rte_css);
$this->tpl->parseCurrentBlock();
}
}


Expand Down Expand Up @@ -607,7 +612,9 @@ public function getADLActData(): void

public function pingSession(): void
{
ilWACSignedPath::signFolderOfStartFile($this->getDataDirectory() . '/imsmanifest.xml');
if (!$this->slm->hasContainerResource()) {
ilWACSignedPath::signFolderOfStartFile($this->getDataDirectory() . '/imsmanifest.xml');
}
//do nothing except returning header
header('Content-Type: text/plain; charset=UTF-8');
print("");
Expand Down
5 changes: 5 additions & 0 deletions components/ILIAS/ScormAicc/ScormAicc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function init(
array | \ArrayAccess &$pull,
array | \ArrayAccess &$internal,
): void {
$contribute[\ILIAS\Setup\Agent::class] = static fn() =>
new \ilScormAiccSetupAgent(
$pull[\ILIAS\Refinery\Factory::class]
);

$contribute[Component\Resource\PublicAsset::class] = static fn() => new class () implements Component\Resource\PublicAsset {
public function getSource(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public static function getIliasScormVars(ilObjSCORMLearningModule $slm_obj): str
. '"b_debug":' . $b_debug . ','
. '"a_itemParameter":' . json_encode($a_man) . ','
. '"status":' . json_encode(self::getStatus($slm_obj->getId(), $ilUser->getID(), $slm_obj->getAuto_last_visited())) . ','
. '"dataDirectory":"' . self::encodeURIComponent($slm_obj->getDataDirectory("output") . '/') . '",'
. '"dataDirectory":"' . self::encodeURIComponent($slm_obj->getContainerBaseUri() ?? ($slm_obj->getDataDirectory("output") . '/')) . '",'
. '"img":{'
. '"asset":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/asset.svg')) . '",'
. '"browsed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/browsed.svg')) . '",'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ public function frameset(): void
// }

$this->increase_attemptAndsave_module_version();
ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
if (!$this->slm->hasContainerResource()) {
ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
}

$debug = $this->slm->getDebug();
if (count($items) > 1) {
Expand Down Expand Up @@ -487,7 +489,9 @@ public function apiInitData(): void

public function pingSession(): bool
{
ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
if (!$this->slm->hasContainerResource()) {
ilWACSignedPath::signFolderOfStartFile($this->slm->getDataDirectory() . '/imsmanifest.xml');
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

use ILIAS\Setup\Environment;
use ILIAS\Setup\Migration;

/**
* Moves the on-disk content of SCORM/AICC learning modules
* (public/data/lm_data/lm_<id>) into a container resource of the
* Resource Storage Service and stores the resulting rid in sahs_lm.
*
* Covers all c_type values (scorm, scorm2004, aicc) since they share
* the same lm_data/lm_<id> directory layout.
*/
class ilSAHSMigration implements Migration
{
protected ilResourceStorageMigrationHelper $helper;

public function getLabel(): string
{
return 'Migration of SCORM/AICC Learning Modules to the Resource Storage Service.';
}

public function getDefaultAmountOfStepsPerRun(): int
{
return 10000;
}

public function getPreconditions(Environment $environment): array
{
return array_merge(
ilResourceStorageMigrationHelper::getPreconditions(),
[
new ilDatabaseUpdateStepsExecutedObjective(
new \ILIAS\ScormAicc\Setup\ScormAiccDatabaseUpdateSteps()
)
]
);
}

public function prepare(Environment $environment): void
{
$this->helper = new ilResourceStorageMigrationHelper(
new ilSAHSStakeholder(),
$environment
);
}

public function step(Environment $environment): void
{
$r = $this->helper->getDatabase()->query(
"SELECT sahs_lm.id, object_data.owner AS owner_id
FROM sahs_lm
LEFT JOIN object_data ON object_data.obj_id = sahs_lm.id
WHERE rid IS NULL OR rid = ''
LIMIT 1;"
);

$d = $this->helper->getDatabase()->fetchObject($r);
$object_id = (int) ($d->id ?? null);

$resource_owner_id = (int) ($d->owner_id ?? 6);

$lm_path = $this->buildBasePath($object_id);

$rid = $this->helper->moveDirectoryToContainerResource(
$lm_path,
$resource_owner_id
);

if ($rid !== null) {
$this->helper->getDatabase()->update(
'sahs_lm',
['rid' => ['text', $rid->serialize()]],
['id' => ['integer', $object_id],]
);

$this->recursiveRmDir($lm_path);
} else {
$this->helper->getDatabase()->update(
'sahs_lm',
['rid' => ['text', '-']],
['id' => ['integer', $object_id],]
);
}
}

private function recursiveRmDir(string $path): void
{
if (!is_dir($path)) {
return;
}
// recursively remove directory
$files = array_diff(scandir($path), ['.', '..']);
foreach ($files as $file) {
(is_dir("$path/$file")) ? $this->recursiveRmDir("$path/$file") : unlink("$path/$file");
}
rmdir($path);
}

public function getRemainingAmountOfSteps(): int
{
$r = $this->helper->getDatabase()->query(
"SELECT COUNT(id) AS amount FROM sahs_lm WHERE rid IS NULL OR rid = ''"
);
$d = $this->helper->getDatabase()->fetchObject($r) ?? new stdClass();

return (int) ($d->amount ?? 0);
}

protected function buildBasePath(int $object_id): string
{
return CLIENT_WEB_DIR . '/lm_data/lm_' . $object_id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

use ILIAS\Setup;
use ILIAS\ScormAicc\Setup\ScormAiccDatabaseUpdateSteps;

class ilScormAiccSetupAgent extends Setup\Agent\NullAgent
{
public function getUpdateObjective(?Setup\Config $config = null): Setup\Objective
{
return new ilDatabaseUpdateStepsExecutedObjective(new ScormAiccDatabaseUpdateSteps());
}

public function getStatusObjective(Setup\Metrics\Storage $storage): Setup\Objective
{
return new ilDatabaseUpdateStepsMetricsCollectedObjective($storage, new ScormAiccDatabaseUpdateSteps());
}

public function getMigrations(): array
{
return [
new ilSAHSMigration()
];
}
}
Loading
Loading