ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
assTextQuestionImport Class Reference

Class for essay question imports. More...

+ Inheritance diagram for assTextQuestionImport:
+ Collaboration diagram for assTextQuestionImport:

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)

Protected Member Functions

 fetchTermScoring ($item)
- 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)
 processNonAbstractedImageReferences ($text, $sourceNic)
 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

Additional Inherited Members

- Data Fields inherited from assQuestionImport
 $object

Detailed Description

Class for essay question imports.

assTextQuestionImport is a class for essay 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.assTextQuestionImport.php 59506 2015-06-16 14:01:19Z gitmgr

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

Member Function Documentation

assTextQuestionImport::fetchTermScoring (   $item)
protected

Definition at line 245 of file class.assTextQuestionImport.php.

Referenced by fromXML().

{
$termScoringString = $item->getMetadataEntry('termscoring');
if( !strlen($termScoringString) )
{
return array();
}
$termScoring = unserialize($termScoringString);
if( is_array($termScoring) )
{
return $termScoring;
}
$termScoringString = base64_decode($termScoringString);
$termScoring = unserialize($termScoringString);
if( is_array($termScoring) )
{
return $termScoring;
}
return array();
}

+ Here is the caller graph for this function:

assTextQuestionImport::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.assTextQuestionImport.php.

References $_SESSION, $GLOBALS, $ilUser, ilRTE\_replaceMediaObjectImageSrc(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilObjMediaObject\_saveUsage(), assQuestionImport\addGeneralMetadata(), assQuestionImport\fetchAdditionalContentEditingModeInformation(), fetchTermScoring(), assQuestionImport\getQplImportArchivDirectory(), and assQuestionImport\getTstImportArchivDirectory().

{
global $ilUser;
// empty session variable for imported xhtml mobs
unset($_SESSION["import_mob_xhtml"]);
$presentation = $item->getPresentation();
$duration = $item->getDuration();
$now = getdate();
$maxchars = 0;
$maxpoints = 0;
$created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
foreach ($presentation->order as $entry)
{
switch ($entry["type"])
{
case "response":
$response = $presentation->response[$entry["index"]];
$rendertype = $response->getRenderType();
switch (strtolower(get_class($rendertype)))
{
case "ilqtirenderfib":
$maxchars = $rendertype->getMaxchars();
break;
}
break;
}
}
$feedbacksgeneric = array();
foreach ($item->resprocessing as $resprocessing)
{
$outcomes = $resprocessing->getOutcomes();
foreach ($outcomes->decvar as $decvar)
{
$maxpoints = $decvar->getMaxvalue();
}
foreach ($resprocessing->respcondition as $respcondition)
{
foreach ($respcondition->displayfeedback as $feedbackpointer)
{
if (strlen($feedbackpointer->getLinkrefid()))
{
foreach ($item->itemfeedback as $ifb)
{
if (strcmp($ifb->getIdent(), "response_allcorrect") == 0)
{
// found a feedback for the identifier
if (count($ifb->material))
{
foreach ($ifb->material as $material)
{
$feedbacksgeneric[1] = $material;
}
}
if ((count($ifb->flow_mat) > 0))
{
foreach ($ifb->flow_mat as $fmat)
{
if (count($fmat->material))
{
foreach ($fmat->material as $material)
{
$feedbacksgeneric[1] = $material;
}
}
}
}
}
else if (strcmp($ifb->getIdent(), "response_onenotcorrect") == 0)
{
// found a feedback for the identifier
if (count($ifb->material))
{
foreach ($ifb->material as $material)
{
$feedbacksgeneric[0] = $material;
}
}
if ((count($ifb->flow_mat) > 0))
{
foreach ($ifb->flow_mat as $fmat)
{
if (count($fmat->material))
{
foreach ($fmat->material as $material)
{
$feedbacksgeneric[0] = $material;
}
}
}
}
}
}
}
}
}
}
$this->addGeneralMetadata($item);
$this->object->setTitle($item->getTitle());
$this->object->setNrOfTries($item->getMaxattempts());
$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"]);
$this->object->setPoints($maxpoints);
$this->object->setMaxNumOfChars($maxchars);
$textrating = $item->getMetadataEntry("textrating");
if (strlen($textrating))
{
$this->object->setTextRating($textrating);
}
$this->object->matchcondition = (strlen($item->getMetadataEntry('matchcondition'))) ? $item->getMetadataEntry('matchcondition') : 0;
require_once './Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php';
$no_keywords_found=true;
$termscoring = $this->fetchTermScoring($item);
for ($i = 0; $i < count($termscoring); $i++ )
{
$this->object->addAnswer($termscoring[$i]->getAnswertext(), $termscoring[$i]->getPoints() );
$no_keywords_found=false;
}
if(count($termscoring))
{
$this->object->setKeywordRelation($item->getMetadataEntry('termrelation'));
}
$keywords = $item->getMetadataEntry("keywords");
if (strlen($keywords))
{
#$this->object->setKeywords($keywords);
$answers = explode(' ', $keywords);
foreach ($answers as $answer)
{
$this->object->addAnswer($answer, 0);
}
$this->object->setKeywordRelation('one');
$no_keywords_found=false;
}
if($no_keywords_found)
{
$this->object->setKeywordRelation('non');
}
// 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();
}
foreach ($feedbacksgeneric as $correctness => $material)
{
$m = $this->object->QTIMaterialToString($material);
$feedbacksgeneric[$correctness] = $m;
}
// 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)
{
$importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
}
else
{
$importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
}
$GLOBALS['ilLog']->write(__METHOD__.': import mob from dir: '. $importfile);
$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);
foreach ($feedbacksgeneric as $correctness => $material)
{
$feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
}
}
}
$this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
foreach ($feedbacksgeneric as $correctness => $material)
{
$this->object->feedbackOBJ->importGenericFeedback(
$this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1)
);
}
$this->object->saveToDb();
if ($tst_id > 0)
{
$q_1_id = $this->object->getId();
$question_id = $this->object->duplicate(true, null, null, null, $tst_id);
$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: