当前位置: 首页>>代码示例>>PHP>>正文


PHP XmlDocument::includeAssessmentSectionRefs方法代码示例

本文整理汇总了PHP中qtism\data\storage\xml\XmlDocument::includeAssessmentSectionRefs方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlDocument::includeAssessmentSectionRefs方法的具体用法?PHP XmlDocument::includeAssessmentSectionRefs怎么用?PHP XmlDocument::includeAssessmentSectionRefs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qtism\data\storage\xml\XmlDocument的用法示例。


在下文中一共展示了XmlDocument::includeAssessmentSectionRefs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: importTest

 /**
  * Import a QTI Test and its dependent Items into the TAO Platform.
  *
  * @param core_kernel_classes_Class $targetClass The RDFS Class where Ontology resources must be created.
  * @param oat\taoQtiItem\model\qti\Resource $qtiTestResource The QTI Test Resource representing the IMS QTI Test to be imported.
  * @param taoQtiTest_models_classes_ManifestParser $manifestParser The parser used to retrieve the IMS Manifest.
  * @param string $folder The absolute path to the folder where the IMS archive containing the test content
  * @return common_report_Report A report about how the importation behaved.
  */
 protected function importTest(core_kernel_classes_Class $targetClass, Resource $qtiTestResource, taoQtiTest_models_classes_ManifestParser $manifestParser, $folder)
 {
     $itemImportService = ImportService::singleton();
     $itemService = taoItems_models_classes_ItemsService::singleton();
     $testClass = $targetClass;
     $qtiTestResourceIdentifier = $qtiTestResource->getIdentifier();
     // Create an RDFS resource in the knowledge base that will hold
     // the information about the imported QTI Test.
     $testResource = $this->createInstance($testClass);
     $qtiTestModelResource = new core_kernel_classes_Resource(INSTANCE_TEST_MODEL_QTI);
     $modelProperty = new core_kernel_classes_Property(PROPERTY_TEST_TESTMODEL);
     $testResource->editPropertyValues($modelProperty, $qtiTestModelResource);
     // Create the report that will hold information about the import
     // of $qtiTestResource in TAO.
     $report = new common_report_Report(common_report_Report::TYPE_INFO);
     // The class where the items that belong to the test will be imported.
     $itemClass = new core_kernel_classes_Class(TAO_ITEM_CLASS);
     $targetClass = $itemClass->createSubClass($testResource->getLabel());
     // Load and validate the manifest
     $qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($folder . 'imsmanifest.xml');
     $qtiManifestParser->validate();
     // Prepare Metadata mechanisms.
     $metadataMapping = oat\taoQtiItem\model\qti\Service::singleton()->getMetadataRegistry()->getMapping();
     $metadataInjectors = array();
     $metadataGuardians = array();
     $metadataClassLookups = array();
     $metadataValues = array();
     $domManifest = new DOMDocument('1.0', 'UTF-8');
     $domManifest->load($folder . 'imsmanifest.xml');
     foreach ($metadataMapping['injectors'] as $injector) {
         $metadataInjectors[] = new $injector();
         \common_Logger::i("Metadata Injector '{$injector}' registered.");
     }
     foreach ($metadataMapping['guardians'] as $guardian) {
         $metadataGuardians[] = new $guardian();
         \common_Logger::i("Metadata Guardian '{$guardian}' registered.");
     }
     foreach ($metadataMapping['classLookups'] as $classLookup) {
         $metadataClassLookups[] = new $classLookup();
         \common_Logger::i("Metadata Class Lookup '{$classLookup}' registered.");
     }
     $extractors = array();
     foreach ($metadataMapping['extractors'] as $extractor) {
         $metadataExtractor = new $extractor();
         $extractors[] = $metadataExtractor;
         \common_Logger::i("Metatada Extractor '{$extractor}' registered.");
         $metadataValues = array_merge($metadataValues, $metadataExtractor->extract($domManifest));
     }
     $metadataCount = count($metadataValues, COUNT_RECURSIVE);
     \common_Logger::i("{$metadataCount} Metadata Values found in manifest by extractor(s).");
     // Set up $report with useful information for client code (especially for rollback).
     $reportCtx = new stdClass();
     $reportCtx->manifestResource = $qtiTestResource;
     $reportCtx->rdfsResource = $testResource;
     $reportCtx->itemClass = $targetClass;
     $reportCtx->items = array();
     $reportCtx->testMetadata = isset($metadataValues[$qtiTestResourceIdentifier]) ? $metadataValues[$qtiTestResourceIdentifier] : array();
     $reportCtx->createdClasses = array();
     $report->setData($reportCtx);
     // Expected test.xml file location.
     $expectedTestFile = $folder . str_replace('/', DIRECTORY_SEPARATOR, $qtiTestResource->getFile());
     // Already imported test items (qti xml file paths).
     $alreadyImportedTestItemFiles = array();
     // -- Check if the file referenced by the test QTI resource exists.
     if (is_readable($expectedTestFile) === false) {
         $report->add(common_report_Report::createFailure(__('No file found at location "%s".', $qtiTestResource->getFile())));
     } else {
         // -- Load the test in a QTISM flavour.
         $testDefinition = new XmlDocument();
         try {
             $testDefinition->load($expectedTestFile, true);
             // If any, assessmentSectionRefs will be resolved and included as part of the main test definition.
             $testDefinition->includeAssessmentSectionRefs(true);
             // -- Load all items related to test.
             $itemError = false;
             // discover test's base path.
             $dependencies = taoQtiTest_helpers_Utils::buildAssessmentItemRefsTestMap($testDefinition, $manifestParser, $folder);
             // Build a DOM version of the fully resolved AssessmentTest for later usage.
             $transitionalDoc = new DOMDocument('1.0', 'UTF-8');
             $transitionalDoc->loadXML($testDefinition->saveToString());
             if (count($dependencies['items']) > 0) {
                 $sharedFiles = array();
                 foreach ($dependencies['items'] as $assessmentItemRefId => $qtiDependency) {
                     if ($qtiDependency !== false) {
                         if (Resource::isAssessmentItem($qtiDependency->getType())) {
                             $resourceIdentifier = $qtiDependency->getIdentifier();
                             // Check if the item is already stored in the bank.
                             foreach ($metadataGuardians as $guardian) {
                                 if (isset($metadataValues[$resourceIdentifier]) === true) {
                                     if (($guard = $guardian->guard($metadataValues[$resourceIdentifier])) !== false) {
                                         common_Logger::i("Item with identifier '{$resourceIdentifier}' already in Item Bank.");
//.........这里部分代码省略.........
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:101,代码来源:class.QtiTestService.php


注:本文中的qtism\data\storage\xml\XmlDocument::includeAssessmentSectionRefs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。