ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor.
 init ()
 Init.
 setInstallId ($a_val)
 Set installation id.
 getInstallId ()
 Get installation id.
 setInstallUrl ($a_val)
 Set installation url.
 getInstallUrl ()
 Get installation url.
 setSchemaVersion ($a_val)
 Set schema version.
 getSchemaVersion ()
 Get schema version.
 setImportDirectory ($a_val)
 Set import directory.
 getImportDirectory ()
 Get import directory.
 setSkipEntities ($a_val)
 Set skip entities.
 getSkipEntities ()
 Get skip entities.
 finalProcessing ($a_mapping)
 Final processing.

Protected Member Functions

 parseXmlFileNames ()
 Create qti and xml file name.

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

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

Import XML.

Parameters
@return

Reimplemented from ilXmlImporter.

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

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

{
// Container import => test object already created
if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
{
$newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
#$newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(),'/')));
}
else // case ii, non container
{
// Shouldn't happen
$GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
return false;
}
include_once "./Services/Survey/classes/class.SurveyImportParser.php";
list($xml_file) = $this->parseXmlFileNames();
if(!@file_exists($xml_file))
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
return false;
}
$import = new SurveyImportParser(-1, $xml_file, TRUE);
$import->setSurveyObject($newObj);
$import->startParsing();
if (is_array($_SESSION["import_mob_xhtml"]))
{
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
include_once "./Services/RTE/classes/class.ilRTE.php";
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
foreach ($_SESSION["import_mob_xhtml"] as $mob)
{
$importfile = dirname($xml_file) . "/" . $mob["uri"];
if (file_exists($importfile))
{
$media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $newObj->getId());
$newObj->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $newObj->getIntroduction()));
$newObj->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $newObj->getOutro()));
}
else
{
global $ilLog;
$ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
}
}
$newObj->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($newObj->getIntroduction(), 1));
$newObj->setOutro(ilRTE::_replaceMediaObjectImageSrc($newObj->getOutro(), 1));
$newObj->saveToDb();
}
$a_mapping->addMapping("Modules/Survey", "svy", $a_id, $newObj->getId());
return true;
}

+ Here is the call graph for this function:

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().

{
$GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory());
$basename = basename($this->getImportDirectory());
$xml = $this->getImportDirectory().'/'.$basename.'.xml';
return array($xml);
}

+ 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: