4 include_once(
"./Services/Export/classes/class.ilXmlImporter.php");
31 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
35 if($new_id = $a_mapping->getMapping(
'Services/Container',
'objs',$a_id))
38 $newObj->setOnline(
true);
42 $newObj->setOnline(
true);
44 else if ($new_id = $a_mapping->getMapping(
'Modules/TestQuestionPool',
'qpl',
"new_id"))
51 $GLOBALS[
'ilLog']->write(__METHOD__.
': non container and no tax mapping, perhaps old qpl export' );
59 if(!@file_exists($xml_file))
61 $GLOBALS[
'ilLog']->write(__METHOD__.
': Cannot find xml definition: '. $xml_file);
64 if(!@file_exists($qti_file))
66 $GLOBALS[
'ilLog']->write(__METHOD__.
': Cannot find qti definition: '. $qti_file);
70 $this->poolOBJ = $newObj;
72 $newObj->fromXML($xml_file);
75 if( isset(
$_POST[
"qpl_new"]) && strlen(
$_POST[
"qpl_new"]) )
77 $newObj->setTitle(
$_POST[
"qpl_new"]);
87 $GLOBALS[
'ilLog']->write(__METHOD__.
': xml file: '. $xml_file .
", qti file:" . $qti_file);
89 if( isset(
$_SESSION[
"qpl_import_idents"]) )
100 include_once
"./Services/QTI/classes/class.ilQTIParser.php";
102 $result = $qtiParser->startParsing();
105 if (strlen($xml_file))
107 include_once (
"./Modules/LearningModule/classes/class.ilContObjParser.php");
109 $contParser->setQuestionMapping($qtiParser->getImportMapping());
110 $contParser->startParsing();
112 foreach ($qtiParser->getImportMapping() as $k => $v)
114 $oldQuestionId = substr($k, strpos($k,
'qst_')+strlen(
'qst_'));
115 $newQuestionId = $v[
'pool'];
117 $a_mapping->addMapping(
118 "Services/Taxonomy",
"tax_item",
"qpl:quest:$oldQuestionId", $newQuestionId
121 $a_mapping->addMapping(
122 "Services/Taxonomy",
"tax_item_obj_id",
"qpl:quest:$oldQuestionId", $newObj->getId()
125 $a_mapping->addMapping(
126 "Modules/TestQuestionPool",
"quest", $oldQuestionId, $newQuestionId
133 $a_mapping->addMapping(
"Modules/TestQuestionPool",
"qpl", $a_id, $newObj->getId());
150 include_once(
"./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
151 $maps = $a_mapping->getMappingsOfEntity(
"Modules/TestQuestionPool",
"qpl");
154 if (
$old !=
"new_id" && (
int)
$old > 0)
157 $new_tax_ids = $a_mapping->getMapping(
"Services/Taxonomy",
"tax_usage_of_obj",
$old);
158 if($new_tax_ids !==
false)
160 $tax_ids = explode(
":", $new_tax_ids);
161 foreach($tax_ids as $tid)
167 $taxMappings = $a_mapping->getMappingsOfEntity(
'Services/Taxonomy',
'tax');
168 foreach($taxMappings as $oldTaxId => $newTaxId)
170 if( $oldTaxId == $this->poolOBJ->getNavTaxonomyId() )
172 $this->poolOBJ->setNavTaxonomyId($newTaxId);
173 $this->poolOBJ->saveToDb();
187 $GLOBALS[
'ilLog']->write(__METHOD__.
': '.$this->getImportDirectory());
192 $qti = $this->
getImportDirectory().
'/'.preg_replace(
'/qpl/',
'qti', $basename).
'.xml';
194 return array($xml,$qti);
200 $dir = dirname($dir);
207 $name = basename($dir);
213 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentXmlParser.php';
217 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImporter.php';
219 $importer->setTargetParentObjId($targetParentObjId);
220 $importer->setImportInstallationId($this->
getInstallId());
221 $importer->setImportMappingRegistry($mappingRegistry);
222 $importer->setImportMappingComponent(
'Modules/TestQuestionPool');
223 $importer->setImportAssignmentList(
$parser->getAssignmentList());
227 if( $importer->getFailedImportAssignmentList()->assignmentsExist() )
229 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
231 $qsaImportFails->registerFailedImports($importer->getFailedImportAssignmentList());
233 $this->poolOBJ->setOnline(
false);
Importer class for question pools.
getImportDirectory()
Get import directory.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
Import XML.
parseXmlFileNames()
Create qti and xml file name.
static _setImportDirectory($a_import_dir=null)
set import directory
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
finalProcessing($a_mapping)
Final processing.
static saveUsage($a_tax_id, $a_obj_id)
Save Usage.
getImportDirectoryContainer()
getInstallId()
Get installation id.
importQuestionSkillAssignments($xmlFile, ilImportMapping $mappingRegistry, $targetParentObjId)