ILIAS  release_4-4 Revision
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. 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.ilTestImporter.php.

Member Function Documentation

◆ importXmlRepresentation()

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

Import XML.

Parameters

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

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

22  {
23  // Container import => test object already created
24  include_once "./Modules/Test/classes/class.ilObjTest.php";
26 
27  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
28  {
29  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
30  }
31  else // case ii, non container
32  {
33  // Shouldn't happen
34  $GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
35  return false;
36  }
37 
38  list($xml_file,$qti_file) = $this->parseXmlFileNames();
39 
40  if(!@file_exists($xml_file))
41  {
42  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
43  return false;
44  }
45  if(!@file_exists($qti_file))
46  {
47  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $qti_file);
48  return false;
49  }
50 
51  // FIXME: Copied from ilObjTestGUI::importVerifiedFileObject
52  // TODO: move all logic to ilObjTest::importVerifiedFile and call
53  // this method from ilObjTestGUI and ilTestImporter
54  $newObj->mark_schema->flush();
55 
56  // 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
57  // filesystem path determinations
58  $qpl_id = $newObj->getId();
59 
60  // start parsing of QTI files
61  include_once "./Services/QTI/classes/class.ilQTIParser.php";
62  $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, $qpl_id , array());
63  $qtiParser->setTestObject($newObj);
64  $result = $qtiParser->startParsing();
65  $newObj->saveToDb();
66 
67  // import page data
68  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
69  $contParser = new ilContObjParser($newObj, $xml_file, basename($this->getImportDirectory()));
70  $contParser->setQuestionMapping($qtiParser->getImportMapping());
71  $contParser->startParsing();
72 
73  $a_mapping->addMapping("Modules/Test", "tst", $a_id, $newObj->getId());
74 
76  }
Content Object Parser.
$result
getImportDirectory()
Get import directory.
parseXmlFileNames()
Create qti and xml file name.
$GLOBALS['ct_recipient']
const IL_MO_PARSE_QTI
_setImportDirectory($a_import_dir=null)
set import directory
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()

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

83  {
84  $GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory());
85 
86  $basename = basename($this->getImportDirectory());
87 
88  $xml = $this->getImportDirectory().'/'.$basename.'.xml';
89  $qti = $this->getImportDirectory().'/'.preg_replace('/test|tst/', 'qti', $basename).'.xml';
90 
91  return array($xml,$qti);
92  }
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: