scripts/tools/RecompileItemsElements.php
protected function getAssessmentsFromDelivery(\core_kernel_classes_Resource $compiledDelivery)
    {
        /** @var UnionAssignmentService $unionAssignmentService */
        $unionAssignmentService = $this->getServiceLocator()->get(UnionAssignmentService::SERVICE_ID);
        $runtime = $unionAssignmentService->getRuntime($compiledDelivery);

        $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, []);
        $testDefinition = \taoQtiTest_helpers_Utils::getTestDefinition($inputParameters['QtiTestCompilation']);

        $assessmentItemRefs = $testDefinition->getComponentsByClassName('assessmentItemRef');

        $this->report->add(
            new Report(
                Report::TYPE_INFO,
                "Starting to recompile items for delivery {$compiledDelivery->getLabel()} with identifier {$compiledDelivery->getUri()}:"
            )
        );

        $count = 0;

        /** @var AssessmentItemRef $assessmentItemRef */
        foreach ($assessmentItemRefs as $assessmentItemRef) {
            $directoryIds = explode('|', $assessmentItemRef->getHref());
            $item = $this->getResource($directoryIds[0]);
            $properties = [];
            foreach ($item->getRdfTriples() as $triple) {
                $properties[$triple->predicate] = $triple->object;
            }

            if ($properties) {
                $directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[2]);
                $languages = $item->getUsedLanguages(
                    $this->getProperty(\taoItems_models_classes_ItemsService::PROPERTY_ITEM_CONTENT)
                );
                foreach ($languages as $lang) {
                    $path = $lang.DIRECTORY_SEPARATOR.QtiJsonItemCompiler::METADATA_FILE_NAME;
                    if (!$directory->has($path)) {
                        $this->writeMetadata($item, $directory, $path, $properties);
                        $count++;
                    }
                }
            }
        }
        $this->report->add(new Report(Report::TYPE_INFO, "Was updated {$count} items."));
    }
protected function getAssessmentsFromDelivery(\core_kernel_classes_Resource $compiledDelivery)
    {
        /** @var UnionAssignmentService $unionAssignmentService */
        $unionAssignmentService = $this->getServiceLocator()->get(UnionAssignmentService::SERVICE_ID);
        $runtime = $unionAssignmentService->getRuntime($compiledDelivery);

        $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, []);
        $testDefinition = \taoQtiTest_helpers_Utils::getTestDefinition($inputParameters['QtiTestCompilation']);

        $assessmentItemRefs = $testDefinition->getComponentsByClassName('assessmentItemRef');

        $this->report->add(
            new Report(
                Report::TYPE_INFO,
                "Starting to recompile items for delivery {$compiledDelivery->getLabel()} with identifier {$compiledDelivery->getUri()}:"
            )
        );

        $count = 0;

        /** @var AssessmentItemRef $assessmentItemRef */
        foreach ($assessmentItemRefs as $assessmentItemRef) {
            $directoryIds = explode('|', $assessmentItemRef->getHref());
            $item = $this->getResource($directoryIds[0]);
            $properties = [];
            foreach ($item->getRdfTriples() as $triple) {
                $properties[$triple->predicate] = $triple->object;
            }

            if ($properties) {
                $directory = \tao_models_classes_service_FileStorage::singleton()->getDirectoryById($directoryIds[2]);
                $languages = $item->getUsedLanguages(
                    $this->getProperty(\taoItems_models_classes_ItemsService::PROPERTY_ITEM_CONTENT)
                );
                foreach ($languages as $lang) {
                    $path = $lang.DIRECTORY_SEPARATOR.QtiJsonItemCompiler::METADATA_FILE_NAME;
                    if (!$directory->has($path)) {
                        $this->writeMetadata($item, $directory, $path, $properties);
                        $count++;
                    }
                }
            }
        }
        $this->report->add(new Report(Report::TYPE_INFO, "Was updated {$count} items."));
    }
Get assessmentItemRef from delivery

@param \core_kernel_classes_Resource $compiledDelivery

@throws \common_Exception
@throws \common_exception_Error