ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestQuestionPoolImporter Class Reference

Importer class for question pools. More...

+ Inheritance diagram for ilTestQuestionPoolImporter:
+ Collaboration diagram for ilTestQuestionPoolImporter:

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.
 finalProcessing ($a_mapping)
 Final processing.

Protected Member Functions

 parseXmlFileNames ()
 Create qti and xml file name.

Detailed Description

Importer class for question pools.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 14 of file class.ilTestQuestionPoolImporter.php.

Member Function Documentation

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

Import XML.

Parameters
@return

Reimplemented from ilXmlImporter.

Definition at line 22 of file class.ilTestQuestionPoolImporter.php.

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

{
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
// Container import => test object already created
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;
}
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
// FIXME: Copied from ilObjQuestionPoolGUI::importVerifiedFileObject
// TODO: move all logic to ilObjQuestionPoolGUI::importVerifiedFile and call
// this method from ilObjQuestionPoolGUI and ilTestImporter
$GLOBALS['ilLog']->write(__METHOD__.': xml file: '. $xml_file . ", qti file:" . $qti_file);
$newObj->setOnline(true);
$newObj->saveToDb();
// start parsing of QTI files
include_once "./Services/QTI/classes/class.ilQTIParser.php";
$qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, $newObj->getId(), null);
$result = $qtiParser->startParsing();
// import page data
if (strlen($xml_file))
{
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/TestQuestionPool", "qpl", $a_id, $newObj->getId());
}

+ Here is the call graph for this function:

ilTestQuestionPoolImporter::parseXmlFileNames ( )
protected

Create qti and xml file name.

Returns
array

Definition at line 87 of file class.ilTestQuestionPoolImporter.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('/qpl/', '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: