ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilSurveyImporter Class Reference

Importer class for files. More...

+ Inheritance diagram for ilSurveyImporter:
+ Collaboration diagram for ilSurveyImporter:

Public Member Functions

 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import XML. More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 

Protected Member Functions

 parseXmlFileNames ()
 Create qti and xml file name. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 

Detailed Description

Importer class for files.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id

Definition at line 13 of file class.ilSurveyImporter.php.

Member Function Documentation

◆ importXmlRepresentation()

ilSurveyImporter::importXmlRepresentation (   $a_entity,
  $a_id,
  $a_xml,
  $a_mapping 
)

Import XML.

Parameters

Definition at line 21 of file class.ilSurveyImporter.php.

References $_SESSION, $GLOBALS, $ilLog, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), ilObjectFactory\getInstanceByObjId(), and parseXmlFileNames().

22  {
23  // Container import => test object already created
24  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
25  {
26  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
27  #$newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(),'/')));
28  }
29  else // case ii, non container
30  {
31  // Shouldn't happen
32  $GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
33  return false;
34  }
35 
36 
37  include_once "./Services/Survey/classes/class.SurveyImportParser.php";
38 
39  list($xml_file) = $this->parseXmlFileNames();
40 
41  if(!@file_exists($xml_file))
42  {
43  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
44  return false;
45  }
46 
47  $import = new SurveyImportParser(-1, $xml_file, TRUE);
48  $import->setSurveyObject($newObj);
49  $import->startParsing();
50 
51  if (is_array($_SESSION["import_mob_xhtml"]))
52  {
53  include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
54  include_once "./Services/RTE/classes/class.ilRTE.php";
55  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
56  foreach ($_SESSION["import_mob_xhtml"] as $mob)
57  {
58  $importfile = dirname($xml_file) . "/" . $mob["uri"];
59  if (file_exists($importfile))
60  {
61  $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
62  ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $newObj->getId());
63  $newObj->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $newObj->getIntroduction()));
64  $newObj->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $newObj->getOutro()));
65  }
66  else
67  {
68  global $ilLog;
69  $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
70  }
71  }
72  $newObj->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($newObj->getIntroduction(), 1));
73  $newObj->setOutro(ilRTE::_replaceMediaObjectImageSrc($newObj->getOutro(), 1));
74  $newObj->saveToDb();
75  }
76 
77  $a_mapping->addMapping("Modules/Survey", "svy", $a_id, $newObj->getId());
78 
79  return true;
80 
81  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
& _saveTempFileAsMediaObject($name, $tmp_name, $upload=TRUE)
Create new media object and update page in db and return new media object.
Survey Question Import Parser.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
$GLOBALS['ct_recipient']
parseXmlFileNames()
Create qti and xml file name.
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ parseXmlFileNames()

ilSurveyImporter::parseXmlFileNames ( )
protected

Create qti and xml file name.

Returns
array

Definition at line 88 of file class.ilSurveyImporter.php.

References $GLOBALS, and ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

89  {
90  $GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory());
91 
92  $basename = basename($this->getImportDirectory());
93  $xml = $this->getImportDirectory().'/'.$basename.'.xml';
94 
95  return array($xml);
96  }
getImportDirectory()
Get import directory.
$GLOBALS['ct_recipient']
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: