ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestImporter Class Reference

Importer class for files. More...

+ Inheritance diagram for ilTestImporter:
+ Collaboration diagram for ilTestImporter:

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:
class.ilTestImporter.php 46451 2013-11-27 16:34:46Z mbecker

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

Member Function Documentation

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

Import XML.

Parameters
@return

Reimplemented from ilXmlImporter.

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

References $GLOBALS, $result, ilObjTest\_setImportDirectory(), ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), IL_MO_PARSE_QTI, and parseXmlFileNames().

{
// Container import => test object already created
include_once "./Modules/Test/classes/class.ilObjTest.php";
if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
{
$newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
}
else // case ii, non container
{
// Shouldn't happen
$GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
return false;
}
list($xml_file,$qti_file) = $this->parseXmlFileNames();
if(!@file_exists($xml_file))
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
return false;
}
if(!@file_exists($qti_file))
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $qti_file);
return false;
}
// FIXME: Copied from ilObjTestGUI::importVerifiedFileObject
// TODO: move all logic to ilObjTest::importVerifiedFile and call
// this method from ilObjTestGUI and ilTestImporter
$newObj->mark_schema->flush();
// Important: The container question pool is the test object implicitly. If we do not pass a valid object id here, there will be problems concerning
// filesystem path determinations
$qpl_id = $newObj->getId();
// start parsing of QTI files
include_once "./Services/QTI/classes/class.ilQTIParser.php";
$qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, $qpl_id , array());
$qtiParser->setTestObject($newObj);
$result = $qtiParser->startParsing();
$newObj->saveToDb();
// import page data
include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
$contParser = new ilContObjParser($newObj, $xml_file, basename($this->getImportDirectory()));
$contParser->setQuestionMapping($qtiParser->getImportMapping());
$contParser->startParsing();
$a_mapping->addMapping("Modules/Test", "tst", $a_id, $newObj->getId());
}

+ Here is the call graph for this function:

ilTestImporter::parseXmlFileNames ( )
protected

Create qti and xml file name.

Returns
array

Definition at line 82 of file class.ilTestImporter.php.

References $GLOBALS, and ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

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

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