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
30 changes: 30 additions & 0 deletions components/ILIAS/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

declare(strict_types=1);

use ILIAS\MediaObjects\MediaObjectRepository;
use ILIAS\ResourceStorage\Identification\ResourceIdentification;
use ILIAS\ResourceStorage\Services as ResourceStorage;
use ILIAS\Test\Participants\ParticipantRepository;
use ILIAS\Test\Results\Data\Repository;
use ILIAS\Test\TestDIC;
Expand Down Expand Up @@ -49,6 +52,9 @@
use ILIAS\Refinery\Factory as Refinery;
use ILIAS\Filesystem\Filesystem;
use ILIAS\MetaData\Services\ServicesInterface as LOMetadata;
use ILIAS\UI\Factory as UIFactory;
use ILIAS\UI\Renderer as UIRenderer;
use ILIAS\UICore\GlobalTemplate;

/**
* Class ilObjTest
Expand Down Expand Up @@ -145,6 +151,11 @@ class ilObjTest extends ilObject
protected Repository $test_result_repository;

protected LOMetadata $lo_metadata;
protected MediaObjectRepository $media_object_repository;
protected ResourceStorage $irss;
protected UIFactory $ui_factory;
protected UIRenderer $ui_renderer;
protected ilGlobalTemplateInterface $tpl;

/**
* Constructor
Expand All @@ -166,6 +177,11 @@ public function __construct(int $id = 0, bool $a_call_by_reference = true)
$this->component_factory = $DIC['component.factory'];
$this->filesystem_web = $DIC->filesystem()->web();
$this->lo_metadata = $DIC->learningObjectMetadata();
$this->media_object_repository = $DIC->mediaObjects()->internal()->repo()->mediaObject();
$this->irss = $DIC->resourceStorage();
$this->ui_factory = $DIC->ui()->factory();
$this->ui_renderer = $DIC->ui()->renderer();
$this->tpl = $DIC->ui()->mainTemplate();

$local_dic = $this->getLocalDIC();
$this->participant_access_filter = $local_dic['participant.access_filter.factory'];
Expand Down Expand Up @@ -3732,6 +3748,7 @@ public function exportXMLPageObjects(&$a_xml_writer, $inst, &$expLog)
*/
public function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
{
$not_found_resources = [];
foreach ($this->mob_ids as $mob_id) {
$expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
if (ilObjMediaObject::_exists((int) $mob_id)) {
Expand All @@ -3740,14 +3757,27 @@ public function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$
ilFileUtils::createDirectory($target_dir);
$media_obj = new ilObjMediaObject((int) $mob_id);
$media_obj->exportXML($a_xml_writer, (int) $a_inst);
/** @var ilMediaItem $item */
foreach ($media_obj->getMediaItems() as $item) {
$rid = $this->media_object_repository->getById($item->getMobId())['rid'] ?? null;
if (!is_string($rid) || !$this->irss->manage()->find($rid) instanceof ResourceIdentification) {
$expLog->write(date('[y-m-d H:i:s] ') . "The resource for Media Object {$item->getMobId()} does not exist (skipping)");
$not_found_resources[] = "({$item->getMobId()}) {$item->getLocation()}";
continue;
}
$stream = $item->getLocationStream();
file_put_contents($target_dir . DIRECTORY_SEPARATOR . $item->getLocation(), $stream);
$stream->close();
}
unset($media_obj);
}
}

if ($not_found_resources !== []) {
$message = $this->lng->txt('missing_media_resources_export_skipped');
$message .= $this->ui_renderer->render($this->ui_factory->listing()->unordered($not_found_resources));
$this->tpl->setOnScreenMessage(GlobalTemplate::MESSAGE_TYPE_INFO, $message, true);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ assessment#:#min_auto_complete#:#Autovervollständigung
assessment#:#min_ip_label#:#Kleinste IP mit Zugriff
assessment#:#min_percentage_ne_0#:#Das Notenschema muss mindestens eine Stufe mit einem minimalen Prozentsatz von 0 Prozent enthalten.
assessment#:#misc#:#Verschiedene Optionen
assessment#:#missing_media_resources_export_skipped#:#Die Ressourcen der folgenden Medienobjekte konnten nicht gefunden werden und wurden beim Export übersprungen.
assessment#:#mode_allatonce#:#Alle
assessment#:#mode_onebyone#:#Nacheinander
assessment#:#mode_question#:#Nach Frage
Expand Down
1 change: 1 addition & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ assessment#:#min_auto_complete#:#Autocomplete
assessment#:#min_ip_label#:#Lowest IP With Access
assessment#:#min_percentage_ne_0#:#One of your grade categories needs to start at the ‘Minimum Score Required (in %)’ level of 0% Your grading system hasn’t been saved.
assessment#:#misc#:#Misc Options
assessment#:#missing_media_resources_export_skipped#:#The resources for the following media objects could not be found and were skipped during export.
assessment#:#mode_allatonce#:#All
assessment#:#mode_onebyone#:#One by One
assessment#:#mode_question#:#Question oriented
Expand Down