ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules 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. 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...
 

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$

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

Member Function Documentation

◆ getImportDirectoryContainer()

ilTestQuestionPoolImporter::getImportDirectoryContainer ( )
private

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

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

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

◆ getImportPackageName()

ilTestQuestionPoolImporter::getImportPackageName ( )
private

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

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

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

◆ importXmlRepresentation()

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

Import XML.

Parameters

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

23  {
24  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
26 
27  // Container import => test object already created
28  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_id))
29  {
30  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
31 
32  $_SESSION['qpl_import_subdir'] = $this->getImportPackageName();
33  }
34  else // case ii, non container
35  {
36  // Shouldn't happen
37  $GLOBALS['ilLog']->write(__METHOD__.': Called in non container mode');
38  return false;
39  }
40 
41  list($xml_file,$qti_file) = $this->parseXmlFileNames();
42 
43  if(!@file_exists($xml_file))
44  {
45  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $xml_file);
46  return false;
47  }
48  if(!@file_exists($qti_file))
49  {
50  $GLOBALS['ilLog']->write(__METHOD__.': Cannot find xml definition: '. $qti_file);
51  return false;
52  }
53 
54  // FIXME: Copied from ilObjQuestionPoolGUI::importVerifiedFileObject
55  // TODO: move all logic to ilObjQuestionPoolGUI::importVerifiedFile and call
56  // this method from ilObjQuestionPoolGUI and ilTestImporter
57 
58  $GLOBALS['ilLog']->write(__METHOD__.': xml file: '. $xml_file . ", qti file:" . $qti_file);
59 
60  $newObj->setOnline(true);
61  $newObj->saveToDb();
62 
63  // start parsing of QTI files
64  include_once "./Services/QTI/classes/class.ilQTIParser.php";
65  $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, $newObj->getId(), null);
66  $result = $qtiParser->startParsing();
67 
68  // import page data
69  if (strlen($xml_file))
70  {
71  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
72  $contParser = new ilContObjParser($newObj, $xml_file, basename($this->getImportDirectory()));
73  $contParser->setQuestionMapping($qtiParser->getImportMapping());
74  $contParser->startParsing();
75  }
76 
77  $a_mapping->addMapping("Modules/TestQuestionPool", "qpl", $a_id, $newObj->getId());
79  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
Content Object Parser.
$result
getImportDirectory()
Get import directory.
_setImportDirectory($a_import_dir=null)
set import directory
$GLOBALS['ct_recipient']
const IL_MO_PARSE_QTI
parseXmlFileNames()
Create qti and xml file name.
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()

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

87  {
88  $GLOBALS['ilLog']->write(__METHOD__.': '.$this->getImportDirectory());
89 
90  $basename = basename($this->getImportDirectory());
91 
92  $xml = $this->getImportDirectory().'/'.$basename.'.xml';
93  $qti = $this->getImportDirectory().'/'.preg_replace('/qpl/', 'qti', $basename).'.xml';
94 
95  return array($xml,$qti);
96  }
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: