ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
assFormulaQuestionImport Class Reference

Class for formula question imports. More...

+ Inheritance diagram for assFormulaQuestionImport:
+ Collaboration diagram for assFormulaQuestionImport:

Public Member Functions

 fromXML (&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file.
- Public Member Functions inherited from assQuestionImport
 assQuestionImport (&$a_object)
 assQuestionImport constructor
 getFeedbackGeneric ($item)

Additional Inherited Members

- Data Fields inherited from assQuestionImport
 $object
- Protected Member Functions inherited from assQuestionImport
 addGeneralMetadata (ilQTIItem $item)
 getQplImportArchivDirectory ()
 returns the full path to extracted qpl import archiv (qpl import dir + qpl archiv subdir)
 getTstImportArchivDirectory ()
 returns the full path to extracted tst import archiv (tst import dir + tst archiv subdir)
 fetchAdditionalContentEditingModeInformation ($qtiItem)
 fetches the "additional content editing mode" information from qti item and falls back to ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT when no or invalid information is given

Detailed Description

Class for formula question imports.

assFormulaQuestionImport is a class for formula question imports

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id:
class.assFormulaQuestionImport.php 1185 2010-02-02 08:36:26Z hschottm

Definition at line 15 of file class.assFormulaQuestionImport.php.

Member Function Documentation

assFormulaQuestionImport::fromXML ( $item,
  $questionpool_id,
$tst_id,
$tst_object,
$question_counter,
$import_mapping 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters
object$itemThe QTI item object
integer$questionpool_idThe id of the parent questionpool
integer$tst_idThe id of the parent test if the question is part of a test
object$tst_objectA reference to the parent test object
integer$question_counterA reference to a question counter to count the questions of an imported question pool
array$import_mappingAn array containing references to included ILIAS objects public

Reimplemented from assQuestionImport.

Definition at line 30 of file class.assFormulaQuestionImport.php.

References $_SESSION, $ilUser, $result, ilObjQuestionPool\_getImportDirectory(), ilObjTest\_getImportDirectory(), ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), and assQuestionImport\fetchAdditionalContentEditingModeInformation().

{
global $ilUser;
// empty session variable for imported xhtml mobs
unset($_SESSION["import_mob_xhtml"]);
$presentation = $item->getPresentation();
$duration = $item->getDuration();
$now = getdate();
$created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
$feedbacksgeneric = array();
$this->object->setTitle($item->getTitle());
$this->object->setComment($item->getComment());
$this->object->setAuthor($item->getAuthor());
$this->object->setOwner($ilUser->getId());
$this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
$this->object->setObjId($questionpool_id);
$this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
if (preg_match_all("/(\\\$v\\d+)/ims", $this->object->getQuestion(), $matches))
{
foreach ($matches[1] as $variable)
{
$data = unserialize($item->getMetadataEntry($variable));
$unit = $this->object->getUnitRepository()->getUnit($data["unitvalue"]);
require_once 'Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php';
$varObj = new assFormulaQuestionVariable($variable, $data["rangemin"], $data["rangemax"], $unit, $data["precision"], $data["intprecision"]);
$this->object->addVariable($varObj);
}
}
if (preg_match_all("/(\\\$r\\d+)/ims", $this->object->getQuestion(), $rmatches))
{
foreach ($rmatches[1] as $result)
{
$data = unserialize($item->getMetadataEntry($result));
$unit = $this->object->getUnitRepository()->getUnit($data["unitvalue"]);
require_once 'Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php';
if (!is_array($data["rating"]))
{
$resObj = new assFormulaQuestionResult($result, $data["rangemin"], $data["rangemax"], $data["tolerance"], $unit, $data["formula"], $data["points"], $data["precision"], TRUE);
}
else
{
$resObj = new assFormulaQuestionResult($result, $data["rangemin"], $data["rangemax"], $data["tolerance"], $unit, $data["formula"], $data["points"], $data["precision"], FALSE, $data["rating"]["sign"], $data["rating"]["value"], $data["rating"]["unit"]);
}
$this->object->addResult($resObj);
if (is_array($data["resultunits"]))
{
foreach ($data["resultunits"] as $resu)
{
$ru = $this->object->getUnitRepository()->getUnit($resu["unitvalue"]);
if (is_object($ru))
{
$this->object->addResultUnit($resObj, $ru);
}
}
}
}
}
$this->object->setPoints($item->getMetadataEntry("points"));
$this->addGeneralMetadata($item);
// additional content editing mode information
$this->object->setAdditionalContentEditingMode(
);
$this->object->saveToDb();
// handle the import of media objects in XHTML code
$questiontext = $this->object->getQuestion();
if (is_array($_SESSION["import_mob_xhtml"]))
{
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
include_once "./Services/RTE/classes/class.ilRTE.php";
foreach ($_SESSION["import_mob_xhtml"] as $mob)
{
if ($tst_id > 0)
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$importfile = ilObjTest::_getImportDirectory() . "/" . $_SESSION["tst_import_subdir"] . "/" . $mob["uri"];
}
else
{
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
$importfile = ilObjQuestionPool::_getImportDirectory() . "/" . $_SESSION["qpl_import_subdir"] . "/" . $mob["uri"];
}
$media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
$questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
}
}
$this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
// additional content editing mode information
$this->object->setAdditionalContentEditingMode(
);
$this->object->saveToDb();
if (count($item->suggested_solutions))
{
foreach ($item->suggested_solutions as $suggested_solution)
{
$this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
}
$this->object->saveToDb();
}
if ($tst_id > 0)
{
$q_1_id = $this->object->getId();
$question_id = $this->object->duplicate(true);
$tst_object->questions[$question_counter++] = $question_id;
$import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
}
else
{
$import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
}
}

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: