ILIAS  Release_5_0_x_branch Revision 61816
 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.
 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.

Private Member Functions

 getImportDirectoryContainer ()
 getImportPackageName ()

Additional Inherited Members

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

Detailed Description

Importer class for question pools.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
Id:
class.ilTestQuestionPoolImporter.php 61803 2016-04-21 09:00:17Z gitmgr

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

Member Function Documentation

ilTestQuestionPoolImporter::getImportDirectoryContainer ( )
private

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

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

{
$dir = $this->getImportDirectory();
$dir = dirname($dir);
return $dir;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTestQuestionPoolImporter::getImportPackageName ( )
private

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

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

{
$dir = $this->getImportDirectory();
$name = basename($dir);
return $name;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 $_SESSION, $GLOBALS, $result, ilObjQuestionPool\_setImportDirectory(), ilXmlImporter\getImportDirectory(), getImportDirectoryContainer(), getImportPackageName(), 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);
$_SESSION['qpl_import_subdir'] = $this->getImportPackageName();
}
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 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 86 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: