ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 
 setImport ($a_val)
 Set import. More...
 
 getImport ()
 Get import. 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...
 
 exportedFromSameInstallation ()
 Is exporting and importing installation identical? More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 Called after all container objects have been implemented. More...
 

Protected Member Functions

 parseXmlFileNames ()
 Create qti and xml file name. More...
 

Private Member Functions

 getImportDirectoryContainer ()
 
 getImportPackageName ()
 

Additional Inherited Members

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

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

◆ getImportDirectoryContainer()

ilTestImporter::getImportDirectoryContainer ( )
private

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

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

97  {
98  $dir = $this->getImportDirectory();
99  $dir = dirname($dir);
100  return $dir;
101  }
getImportDirectory()
Get import directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImportPackageName()

ilTestImporter::getImportPackageName ( )
private

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

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

104  {
105  $dir = $this->getImportDirectory();
106  $name = basename($dir);
107  return $name;
108  }
getImportDirectory()
Get import directory.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importXmlRepresentation()

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

Import XML.

Parameters

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

References $_SESSION, $GLOBALS, $result, ilObjTest\_setImportDirectory(), ilXmlImporter\getImportDirectory(), getImportDirectoryContainer(), getImportPackageName(), 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  $_SESSION['tst_import_subdir'] = $this->getImportPackageName();
32  }
33  else // case ii, non container
34  {
35  // Shouldn't happen
36  $GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
37  return false;
38  }
39 
40  list($xml_file,$qti_file) = $this->parseXmlFileNames();
41 
42  if(!@file_exists($xml_file))
43  {
44  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
45  return false;
46  }
47  if(!@file_exists($qti_file))
48  {
49  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $qti_file);
50  return false;
51  }
52 
53  // FIXME: Copied from ilObjTestGUI::importVerifiedFileObject
54  // TODO: move all logic to ilObjTest::importVerifiedFile and call
55  // this method from ilObjTestGUI and ilTestImporter
56  $newObj->mark_schema->flush();
57 
58  // 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
59  // filesystem path determinations
60  $qpl_id = $newObj->getId();
61 
62  // start parsing of QTI files
63  include_once "./Services/QTI/classes/class.ilQTIParser.php";
64  $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, $qpl_id , array());
65  $qtiParser->setTestObject($newObj);
66  $result = $qtiParser->startParsing();
67  $newObj->saveToDb();
68 
69  // import page data
70  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
71  $contParser = new ilContObjParser($newObj, $xml_file, basename($this->getImportDirectory()));
72  $contParser->setQuestionMapping($qtiParser->getImportMapping());
73  $contParser->startParsing();
74 
75  $a_mapping->addMapping("Modules/Test", "tst", $a_id, $newObj->getId());
76 
78  }
Content Object Parser.
$_SESSION["AccountId"]
$result
getImportDirectory()
Get import directory.
parseXmlFileNames()
Create qti and xml file name.
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
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the call graph for this function:

◆ parseXmlFileNames()

ilTestImporter::parseXmlFileNames ( )
protected

Create qti and xml file name.

Returns
array

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

References $GLOBALS, and ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

85  {
86  $GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory());
87 
88  $basename = basename($this->getImportDirectory());
89 
90  $xml = $this->getImportDirectory().'/'.$basename.'.xml';
91  $qti = $this->getImportDirectory().'/'.preg_replace('/test|tst/', 'qti', $basename).'.xml';
92 
93  return array($xml,$qti);
94  }
getImportDirectory()
Get import directory.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ 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: