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)) {
37 $newObj->setOnline(
true);
41 $newObj->setOnline(
true);
42 } elseif ($new_id = $a_mapping->getMapping(
'Modules/TestQuestionPool',
'qpl',
"new_id")) {
47 $DIC[
'ilLog']->write(__METHOD__ .
': non container and no tax mapping, perhaps old qpl export');
56 if (!@file_exists($xml_file)) {
57 $DIC[
'ilLog']->write(__METHOD__ .
': Cannot find xml definition: ' . $xml_file);
60 if (!@file_exists($qti_file)) {
61 $DIC[
'ilLog']->write(__METHOD__ .
': Cannot find qti definition: ' . $qti_file);
65 $this->poolOBJ = $newObj;
67 $newObj->fromXML($xml_file);
70 if (isset(
$_POST[
"qpl_new"]) && strlen(
$_POST[
"qpl_new"])) {
71 $newObj->setTitle(
$_POST[
"qpl_new"]);
82 $DIC[
'ilLog']->write(__METHOD__ .
': xml file: ' . $xml_file .
", qti file:" . $qti_file);
84 if (isset(
$_SESSION[
"qpl_import_idents"])) {
92 include_once
"./Services/QTI/classes/class.ilQTIParser.php";
94 $result = $qtiParser->startParsing();
97 if (strlen($xml_file)) {
98 include_once(
"./Modules/LearningModule/classes/class.ilContObjParser.php");
100 $contParser->setQuestionMapping($qtiParser->getImportMapping());
101 $contParser->startParsing();
103 foreach ($qtiParser->getImportMapping() as $k => $v) {
104 $oldQuestionId = substr($k, strpos($k,
'qst_') + strlen(
'qst_'));
105 $newQuestionId = $v[
'pool'];
107 $a_mapping->addMapping(
110 "qpl:quest:$oldQuestionId",
114 $a_mapping->addMapping(
117 "qpl:quest:$oldQuestionId",
121 $a_mapping->addMapping(
122 "Modules/TestQuestionPool",
132 $a_mapping->addMapping(
"Modules/TestQuestionPool",
"qpl", $a_id, $newObj->getId());
149 include_once(
"./Services/Taxonomy/classes/class.ilObjTaxonomy.php");
150 $maps = $a_mapping->getMappingsOfEntity(
"Modules/TestQuestionPool",
"qpl");
151 foreach ($maps as $old => $new) {
152 if ($old !=
"new_id" && (
int) $old > 0) {
154 $new_tax_ids = $a_mapping->getMapping(
"Services/Taxonomy",
"tax_usage_of_obj", $old);
155 if ($new_tax_ids !==
false) {
156 $tax_ids = explode(
":", $new_tax_ids);
157 foreach ($tax_ids as $tid) {
162 $taxMappings = $a_mapping->getMappingsOfEntity(
'Services/Taxonomy',
'tax');
163 foreach ($taxMappings as $oldTaxId => $newTaxId) {
164 if ($oldTaxId == $this->poolOBJ->getNavTaxonomyId()) {
165 $this->poolOBJ->setNavTaxonomyId($newTaxId);
166 $this->poolOBJ->saveToDb();
186 $qti = $this->
getImportDirectory() .
'/' . preg_replace(
'/qpl/',
'qti', $basename) .
'.xml';
188 return array(
$xml,$qti);
194 $dir = dirname($dir);
201 $name = basename($dir);
207 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentXmlParser.php';
211 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImporter.php';
213 $importer->setTargetParentObjId($targetParentObjId);
214 $importer->setImportInstallationId($this->
getInstallId());
215 $importer->setImportMappingRegistry($mappingRegistry);
216 $importer->setImportMappingComponent(
'Modules/TestQuestionPool');
217 $importer->setImportAssignmentList(
$parser->getAssignmentList());
221 if ($importer->getFailedImportAssignmentList()->assignmentsExist()) {
222 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
224 $qsaImportFails->registerFailedImports($importer->getFailedImportAssignmentList());
226 $this->poolOBJ->setOnline(
false);
Importer class for question pools.
getImportDirectory()
Get import directory.
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
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)