19declare(strict_types=1);
49 private readonly DataFactory $data_factory,
51 private readonly \
ilTree $tree,
55 private readonly IRSS $irss,
57 private readonly ResultsRepository $results_repository,
58 private readonly QuestionsRepository $questions_repository,
66 $context->
logger()->info(
'Preparing test export (1/3)...');
68 $context->
setPhase(ExportPhase::Prepare);
71 if ($object_id ===
null) {
76 $this->participant_repository,
77 $this->results_repository,
78 $this->questions_repository,
79 $this->general_questions_repository,
84 $this->component_repository,
89 $transformations = $this->builder->forExport(
102 $context->
logger()->info(
'...Finished preparing test export (1/3)');
107 $target_ids = $context->
target()->getObjectIds();
109 if ($target_ids === []) {
110 $context->
logger()->warning(
'No target object IDs found for test export');
114 if (count($target_ids) > 1) {
115 $context->
logger()->warning(
116 'Multiple target object IDs found for test export. Only the first one will be used.'
120 return $this->data_factory->objId(array_shift($target_ids));
127 throw new \LogicException(
'Unexpected test collector');
135 $context->
logger()->info(
'Processing test export (2/3)...');
137 $context->
setPhase(ExportPhase::Process);
167 'question_set_config',
175 'additional_working_times',
199 if ($context->
getOption() === Types::XML_WITH_RESULTS->value) {
200 $context->
logger()->info(
'Processing test results export ...');
202 $context->
logger()->info(
'...Finished processing test results export');
205 $context->
logger()->info(
'...Finished processing test export (2/3)');
230 $context->
logger()->info(
'Writing test export (3/3)...');
234 $export_dir = $context->
path()->getPathToComponentExpDirInContainer();
236 ->normalizationProcessor(CollectQuestionImages::class);
238 throw new \LogicException(
'Unexpected question image processor');
242 ->normalizationProcessor(CollectResources::class);
244 throw new \LogicException(
'Unexpected resource processor');
247 foreach ($question_image_collector->getFiles() as $file) {
248 if (!file_exists($file[
'from'])) {
249 $context->
logger()->warning(
'Question image file not found: ' . $file[
'from']);
253 $context->
writer()->writeFileByFilePath(
255 "{$export_dir}/" . $file[
'to']
259 foreach ($resource_collector->getResources() as
$id => $resource) {
260 $clean_id = str_replace([
'-',
'_'],
'',
$id);
261 $file =
"{$clean_id}.{$resource->getCurrentRevision()->getInformation()->getSuffix()}";
263 $context->
writer()->writeFilesByResourceId(
265 "{$export_dir}/resources/{$file}"
275 $context->
logger()->info(
'...Finished writing test export (3/3)');
285 $serializer->append(
'object', $transformations->normalize($collector->getObject()));
288 $context->
addDependency(
'components/ILIAS/ILIASObject',
'common', [$obj_id]);
289 $context->
addDependency(
'components/ILIAS/MetaData',
'tst', [
"{$obj_id}:0:tst"]);
291 'components/ILIAS/Taxonomy',
293 $this->taxonomy->getUsageOfObject($obj_id)
295 $context->
addDependency(
'components/ILIAS/Tracking',
'lpsettings', [$obj_id]);
304 $test = $collector->getObject();
305 $main_settings = $test->getMainSettings();
307 $serializer->
append(
'main', $transformations->
normalize($main_settings));
308 $serializer->
append(
'scoring', $transformations->
normalize($test->getScoreSettings()));
309 $serializer->
append(
'marks', $transformations->
normalize($test->getMarkSchema()));
311 $intro_page_id = $main_settings->getIntroductionSettings()->getIntroductionPageId();
312 if ($intro_page_id !==
null && $intro_page_id !== 0) {
313 $context->
addDependency(
'components/ILIAS/COPage',
'pg', [
"tst:{$intro_page_id}"]);
315 $concluding_page_id = $main_settings->getFinishingSettings()->getConcludingRemarksPageId();
316 if ($concluding_page_id !==
null && $concluding_page_id !== 0) {
317 $context->
addDependency(
'components/ILIAS/COPage',
'pg', [
"tst:{$concluding_page_id}"]);
327 $question_properties = $collector->getTestQuestionProperties();
329 foreach ($collector->getQuestionObjects() as $question) {
331 ... $transformations->
normalize($question),
332 'feedback' => $transformations->
normalize(
333 $collector->getFeedback($question)
335 'sequence' => $question_properties[$question->getId()]->getSequenceInformation()?->getPlaceInSequence(),
339 $data = $collector->getUnitsAndCategories($question->getId());
343 $serializer->
append(
'question', $normalized);
344 $context->
addDependency(
'components/ILIAS/COPage',
'pg', [
"qpl:{$question->getId()}"]);
354 'question_set_config',
355 $transformations->normalize($collector->getQuestionSetConfig())
365 $serializer->
append(
'skill_assignment', $transformations->
normalize($assignment));
374 foreach ($collector->getSkillLevelThresholds() as $threshold) {
375 $serializer->
append(
'skill_level_threshold', $transformations->
normalize($threshold));
384 $additional_data = $collector->getAdditionalParticipantData($collector->getParticipantsIds());
387 $normalized = $transformations->
normalize($participant);
388 if ($participant->getActiveId() !==
null) {
389 $normalized = array_merge($normalized, $additional_data[$participant->getActiveId()]);
392 $serializer->
append(
'participant', $normalized);
401 foreach ($collector->getParticipantsIds() as $participant_id) {
416 foreach ($collector->getAdditionalWorkingTimes() as $additional_working_time) {
417 $serializer->
append(
'time', $transformations->
normalize($additional_working_time));
427 $serializer->createDocument(
'Test Export Mappings');
432 throw new \LogicException(
'Unexpected user ID processor');
434 $user_ids = $user_id_processor->getIds();
439 throw new \LogicException(
'Unexpected resource processor');
441 $resources = $resource_processor->getResources();
444 array_map($transformations->
normalize(...), $resources)
449 $context->
writer()->writeFileByStream(
450 Streams::ofString($serializer->
write()),
451 "{$context->path()->getPathToComponentDirInContainer()}/mappings.xml"
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Stream factory which enables the user to create streams without the knowledge of the concrete class.
setCollector(object $collector)
assertPhase(ExportPhase $phase)
setTransformations(Transformations $transformations)
addDependency(string $component, string $entity, array $ids)
setPhase(ExportPhase $phase)
Collects resources during normalization and replaces mapped IDs during denormalization.
Collects user IDs during normalization.
Collector to aggregate data from the test object for export.
getUserMapping(array $user_ids)
Create a mapping of user IDs to the user identifier field specified in the test object's global setti...
getResults(int $participant_id)
extractObjectId(ExportContext $context)
processResults(ExportContext $context)
exportAdditionalWorkingTimes(TestCollector $collector, Transformations $transformations, Serializer $serializer,)
prepare(ExportContext $context)
exportSkillAssignments(TestCollector $collector, Transformations $transformations, Serializer $serializer,)
exportSkillLevelThresholds(TestCollector $collector, Transformations $transformations, Serializer $serializer,)
exportQuestions(TestCollector $collector, Transformations $transformations, Serializer $serializer, ExportContext $context)
exportQuestionSetConfig(TestCollector $collector, Transformations $transformations, Serializer $serializer,)
process(ExportContext $context)
writeMappings(TestCollector $collector, Transformations $transformations, ExportContext $context)
exportObject(TestCollector $collector, Transformations $transformations, Serializer $serializer, ExportContext $context)
exportResults(TestCollector $collector, Transformations $transformations, Serializer $serializer)
exportParticipants(TestCollector $collector, Transformations $transformations, Serializer $serializer)
exportSettings(TestCollector $collector, Transformations $transformations, Serializer $serializer, ExportContext $context)
collector(ExportContext $context)
__construct(private readonly TransformationsBuilder $builder, private readonly DataFactory $data_factory, private readonly \ilDBInterface $db, private readonly \ilTree $tree, private readonly Language $lng, private readonly TestLogger $logger, private readonly \ilComponentRepository $component_repository, private readonly IRSS $irss, private readonly ParticipantRepository $participant_repository, private readonly ResultsRepository $results_repository, private readonly QuestionsRepository $questions_repository, private readonly GeneralQuestionPropertiesRepository $general_questions_repository, private readonly Taxonomy $taxonomy)
write(ExportContext $context)
Enriches question images with UUIDs and records their source-to-target file mappings.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
foreach( $report as $row)
An Exporter is responsible for orchestrating the export process.
Writes data in a specific format.
append(string $name, array $data)
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...