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

Scorm 2004 Question Exporter. More...

+ Collaboration diagram for ilQuestionExporter:

Public Member Functions

 ilQuestionExporter ($a_preview_mode=false)
 Constructor public.
 exportQuestion ($a_ref_id, $a_image_path=null, $a_output_mode="presentation")

Static Public Member Functions

static indicateNewSco ()
static getMobs ()
static getFiles ()
static questionsJS (array $a_qids=null)

Data Fields

 $db
 $ilias
 $ref_id
 $inst_id
 $q_gui
 $tpl
 $json
 $json_decoded
 $preview_mode

Static Public Attributes

static $exported = array()
static $mobs = array()
static $media_files = array()

Private Member Functions

 setHeaderFooter ()
 assSingleChoice ()
 assMultipleChoice ()
 assKprimChoice ()
 assTextQuestion ()
 assClozeTest ()
 assOrderingQuestion ()
 assMatchingQuestion ()
 assImagemapQuestion ()
 assTextSubset ()
 assOrderingHorizontal ()
 assErrorText ()

Detailed Description

Scorm 2004 Question Exporter.

Author
Hendrik Holtmann holtm.nosp@m.ann@.nosp@m.me.co.nosp@m.m
Version
Id:
class.ilQuestionExporter.php 12658 2006-11-29 08:51:48Z akill

Definition at line 16 of file class.ilQuestionExporter.php.

Member Function Documentation

ilQuestionExporter::assClozeTest ( )
private

Definition at line 243 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("clozequestion");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assErrorText ( )
private

Definition at line 348 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("errortext");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assImagemapQuestion ( )
private

Definition at line 300 of file class.ilQuestionExporter.php.

{
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
array_push(self::$media_files,$this->q_gui->object->getImagePath().$this->q_gui->object->getImageFilename());
$this->tpl->setCurrentBlock("mapareas");
$areas = $this->json_decoded->answers;
//set areas in PHP cause of inteference between pure and highlighter
foreach ($areas as $area) {
$this->tpl->setVariable("VAL_COORDS", $area->coords);
$this->tpl->setVariable("VAL_ORDER", $area->order);
$this->tpl->setVariable("VAL_AREA", $area->area);
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock("imagemapquestion");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assKprimChoice ( )
private

Definition at line 186 of file class.ilQuestionExporter.php.

References $tpl.

{
global $tpl;
$tpl->addCss('Modules/Test/templates/default/ta.css');
$this->tpl->setCurrentBlock("kprimchoice");
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
if( $this->preview_mode )
{
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
if( $this->json_decoded->path )
{
$this->tpl->setVariable("HANDLE_IMAGES",
"ilias.questions.handleMCImages(".$this->json_decoded->id.");");
}
$this->tpl->setVariable('OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
$this->tpl->setVariable('OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
$this->tpl->setVariable('VALUE_TRUE', 1);
$this->tpl->setVariable('VALUE_FALSE', 0);
$this->tpl->parseCurrentBlock();
foreach( $this->json_decoded->answers as $answer )
{
if( $answer->image != "" )
{
self::$media_files[] = $answer->getImageFsPath();
self::$media_files[] = $answer->getThumbFsPath();
}
}
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assMatchingQuestion ( )
private

Definition at line 284 of file class.ilQuestionExporter.php.

References $tpl.

{
global $tpl;
$tpl->addJavaScript('Modules/TestQuestionPool/js/ilMatchingQuestion.js');
$tpl->addCss('Modules/TestQuestionPool/templates/default/test_javascript.css');
$this->tpl->setCurrentBlock("matchingquestion");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("BTN_LABEL_RESET", $this->lng->txt("reset_terms"));
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assMultipleChoice ( )
private

Definition at line 162 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("multiplechoice");
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
if($this->json_decoded->path)
{
$this->tpl->setVariable("HANDLE_IMAGES",
"ilias.questions.handleMCImages(".$this->json_decoded->id.");");
}
$this->tpl->parseCurrentBlock();
foreach ($this->json_decoded->answers as $answer) {
if ($answer->image!="") {
array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->image);
}
}
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assOrderingHorizontal ( )
private

Definition at line 336 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("orderinghorizontal");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assOrderingQuestion ( )
private

Definition at line 255 of file class.ilQuestionExporter.php.

References OQ_PICTURES.

{
$this->tpl->setCurrentBlock("orderingquestion");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
if($this->q_gui->object->getOrderingType() == OQ_PICTURES)
{
$this->tpl->setVariable("VAL_SUBTYPE", "_images");
$this->tpl->setVariable("HANDLE_IMAGES",
"ilias.questions.handleOrderingImages(".$this->json_decoded->id.");");
foreach ($this->json_decoded->answers as $answer) {
if ($answer->answertext!="") {
array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->answertext);
array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->answertext);
}
}
}
else
{
$this->tpl->setVariable("VAL_SUBTYPE", "_terms");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assSingleChoice ( )
private

Definition at line 135 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("singlechoice");
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
if($this->json_decoded->path)
{
$this->tpl->setVariable("HANDLE_IMAGES",
"ilias.questions.handleMCImages(".$this->json_decoded->id.");");
}
$this->tpl->parseCurrentBlock();
foreach ($this->json_decoded->answers as $answer) {
if ($answer->image!="") {
array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
if (is_file($this->q_gui->object->getImagePath()."thumb.".$answer->image))
{
array_push(self::$media_files,$this->q_gui->object->getImagePath()."thumb.".$answer->image);
}
}
}
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assTextQuestion ( )
private

Definition at line 229 of file class.ilQuestionExporter.php.

{
$maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
$this->tpl->setCurrentBlock("textquestion");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
$this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::assTextSubset ( )
private

Definition at line 323 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("textsubset");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("cont_submit_answers"));
$this->tpl->setVariable("VAL_MAXLENGTH", $maxlength);
if ($this->preview_mode) {
$this->tpl->setVariable("VAL_NO_DISPLAY", "style=\"display:none\"");
}
$this->tpl->parseCurrentBlock();
// $this->setHeaderFooter();
return $this->tpl->get();
}
ilQuestionExporter::exportQuestion (   $a_ref_id,
  $a_image_path = null,
  $a_output_mode = "presentation" 
)

Definition at line 61 of file class.ilQuestionExporter.php.

References $inst_id, $json, $mobs, ilInternalLink\_extractInstOfTarget(), ilInternalLink\_extractObjIdOfTarget(), and assQuestionGUI\_getQuestionGUI().

{
if ($a_ref_id != "")
{
if (!($inst_id > 0))
{
}
}
$this->q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
if (!is_object($this->q_gui->object))
{
return "Error: Question not found.";
}
$type = $this->q_gui->object->getQuestionType();
if (method_exists($this,$type))
{
$this->q_gui->object->setExportImagePath($a_image_path);
$this->q_gui->object->feedbackOBJ->setPageObjectOutputMode($a_output_mode);
$this->json = $this->q_gui->object->toJSON();
$this->json_decoded = json_decode($this->json);
self::$exported[$this->json_decoded->id] = $this->json;
self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
return $this->$type();
} else {
return "Error: Question Type not implemented/Question editing not finished";
}
}

+ Here is the call graph for this function:

static ilQuestionExporter::getFiles ( )
static

Definition at line 110 of file class.ilQuestionExporter.php.

References $media_files.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

{
}

+ Here is the caller graph for this function:

static ilQuestionExporter::getMobs ( )
static

Definition at line 100 of file class.ilQuestionExporter.php.

References $mobs, and $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

{
$allmobs = array();
foreach (self::$mobs as $key => $value) {
for ($i=0;$i<count($mobs[$key]);$i++) {
array_push($allmobs,$mobs[$key][$i]);
}
}
return $allmobs;
}

+ Here is the caller graph for this function:

ilQuestionExporter::ilQuestionExporter (   $a_preview_mode = false)

Constructor public.

Definition at line 36 of file class.ilQuestionExporter.php.

References $ilDB, $ilias, and $lng.

{
global $ilDB, $ilias, $lng;
$this->ref_id =& $a_ref_id;
$this->db =& $ilDB;
$this->lng = $lng;
$this->inst_id = IL_INST_ID;
$this->preview_mode = $a_preview_mode;
$this->tpl = new ilTemplate("tpl.question_export.html", true, true, "Modules/Scorm2004");
// fix for bug 5386, alex 29.10.2009
if (!$a_preview_mode)
{
$this->tpl->setVariable("FORM_BEGIN", "<form onsubmit='return false;'>");
$this->tpl->setVariable("FORM_END", "</form>");
}
}
static ilQuestionExporter::indicateNewSco ( )
static

Definition at line 94 of file class.ilQuestionExporter.php.

References $mobs.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

{
self::$exported = array();
self::$mobs = array();
self::$media_files = array();
}

+ Here is the caller graph for this function:

static ilQuestionExporter::questionsJS ( array  $a_qids = null)
static

Definition at line 114 of file class.ilQuestionExporter.php.

Referenced by ilSCORM2004Asset\exportHTMLPageObjects().

{
$exportstring = '';
if(!is_array($a_qids)) {
$exportstring ='var questions = new Array();';
}
foreach (self::$exported as $key => $value) {
if(!is_array($a_qids) || in_array($key, $a_qids)) {
$exportstring .= "questions[$key]= $value;";
}
}
return $exportstring;
}

+ Here is the caller graph for this function:

ilQuestionExporter::setHeaderFooter ( )
private

Definition at line 127 of file class.ilQuestionExporter.php.

{
$this->tpl->setCurrentBlock("common");
$this->tpl->setVariable("VAL_ID", $this->json_decoded->id);
$this->tpl->setVariable("VAL_TYPE", $this->json_decoded->type);
$this->tpl->parseCurrentBlock();
}

Field Documentation

ilQuestionExporter::$db

Definition at line 22 of file class.ilQuestionExporter.php.

ilQuestionExporter::$exported = array()
static

Definition at line 18 of file class.ilQuestionExporter.php.

ilQuestionExporter::$ilias

Definition at line 23 of file class.ilQuestionExporter.php.

Referenced by ilQuestionExporter().

ilQuestionExporter::$inst_id

Definition at line 25 of file class.ilQuestionExporter.php.

Referenced by exportQuestion().

ilQuestionExporter::$json

Definition at line 28 of file class.ilQuestionExporter.php.

Referenced by exportQuestion().

ilQuestionExporter::$json_decoded

Definition at line 29 of file class.ilQuestionExporter.php.

ilQuestionExporter::$media_files = array()
static

Definition at line 20 of file class.ilQuestionExporter.php.

Referenced by getFiles().

ilQuestionExporter::$mobs = array()
static

Definition at line 19 of file class.ilQuestionExporter.php.

Referenced by getMobs().

ilQuestionExporter::$preview_mode

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

ilQuestionExporter::$q_gui

Definition at line 26 of file class.ilQuestionExporter.php.

ilQuestionExporter::$ref_id

Definition at line 24 of file class.ilQuestionExporter.php.

ilQuestionExporter::$tpl

Definition at line 27 of file class.ilQuestionExporter.php.

Referenced by assKprimChoice(), and assMatchingQuestion().


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