5require_once(
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
 
   40                $this->ref_id =& $a_ref_id;
 
   45                $this->inst_id = IL_INST_ID;
 
   47                $this->preview_mode = $a_preview_mode;
 
   49                $this->tpl = 
new ilTemplate(
"tpl.question_export.html", 
true, 
true, 
"Modules/Scorm2004");
 
   54                        $this->tpl->setVariable(
"FORM_BEGIN", 
"<form onsubmit='return false;'>");
 
   55                        $this->tpl->setVariable(
"FORM_END", 
"</form>");
 
   61        public function exportQuestion($a_ref_id, $a_image_path = 
null, $a_output_mode = 
"presentation") {
 
   74                if (!is_object($this->q_gui->object))
 
   76                        return "Error: Question not found.";
 
   79                $type = $this->q_gui->object->getQuestionType();
 
   80                if (method_exists($this,$type))
 
   82                        $this->q_gui->object->setExportImagePath($a_image_path);
 
   83                        $this->q_gui->object->feedbackOBJ->setPageObjectOutputMode($a_output_mode);
 
   84                        $this->json = $this->q_gui->object->toJSON();
 
   85                        $this->json_decoded = json_decode($this->json);
 
   86                        self::$exported[$this->json_decoded->id] = 
$this->json;
 
   87                        self::$mobs[$this->json_decoded->id] = $this->json_decoded->mobs;
 
   88                        return $this->$type();
 
   90                        return "Error: Question Type not implemented/Question editing not finished";
 
   95                self::$exported = array();
 
   97                self::$media_files = array(); 
 
  103                        for ($i=0;$i<count(
$mobs[$key]);$i++) {
 
  104                                array_push($allmobs,
$mobs[$key][$i]);
 
  116                if(!is_array($a_qids)) {
 
  117                        $exportstring =
'var questions = new Array();';
 
  119                foreach (self::$exported as $key => $value) {
 
  120                        if(!is_array($a_qids) || in_array($key, $a_qids)) {
 
  121                                $exportstring .= 
"questions[$key]= $value;";
 
  124                return $exportstring;
 
  129                $this->tpl->setCurrentBlock(
"common");
 
  130                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  131                $this->tpl->setVariable(
"VAL_TYPE", $this->json_decoded->type);
 
  132                $this->tpl->parseCurrentBlock();
 
  137                $this->tpl->setCurrentBlock(
"singlechoice");
 
  138                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  139                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  140                if ($this->preview_mode) {
 
  141                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  143                if($this->json_decoded->path)
 
  145                        $this->tpl->setVariable(
"HANDLE_IMAGES",
 
  146                                "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
 
  148                $this->tpl->parseCurrentBlock();
 
  149                foreach ($this->json_decoded->answers as $answer) {
 
  150                        if ($answer->image!=
"") {
 
  151                                array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
 
  152                                if (is_file($this->q_gui->object->getImagePath().
"thumb.".$answer->image))
 
  154                                        array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->image);
 
  159                return $this->tpl->get();
 
  163                $this->tpl->setCurrentBlock(
"multiplechoice");
 
  164                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  165                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  166                if ($this->preview_mode) {
 
  167                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  169                if($this->json_decoded->path)
 
  171                        $this->tpl->setVariable(
"HANDLE_IMAGES",
 
  172                                "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
 
  174                $this->tpl->parseCurrentBlock();
 
  175                foreach ($this->json_decoded->answers as $answer) {
 
  176                        if ($answer->image!=
"") {
 
  177                                array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->image);
 
  178                                array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->image);
 
  182                return $this->tpl->get();
 
  189                $tpl->addCss(
'Modules/Test/templates/default/ta.css');
 
  191                $this->tpl->setCurrentBlock(
"kprimchoice");
 
  193                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  194                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  196                if( $this->preview_mode )
 
  198                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  201                if( $this->json_decoded->path )
 
  203                        $this->tpl->setVariable(
"HANDLE_IMAGES",
 
  204                                "ilias.questions.handleMCImages(".$this->json_decoded->id.
");");
 
  207                $this->tpl->setVariable(
'OPTION_LABEL_TRUE', $this->json_decoded->trueOptionLabel);
 
  208                $this->tpl->setVariable(
'OPTION_LABEL_FALSE', $this->json_decoded->falseOptionLabel);
 
  210                $this->tpl->setVariable(
'VALUE_TRUE', 1);
 
  211                $this->tpl->setVariable(
'VALUE_FALSE', 0);
 
  213                $this->tpl->parseCurrentBlock();
 
  215                foreach( $this->json_decoded->answers as $answer )
 
  217                        if( $answer->image != 
"" )
 
  219                                self::$media_files[] = $answer->getImageFsPath();
 
  220                                self::$media_files[] = $answer->getThumbFsPath();
 
  226                return $this->tpl->get();
 
  230                $maxlength = $this->json_decoded->maxlength == 0 ? 4096 : $this->json_decoded->maxlength;
 
  231                $this->tpl->setCurrentBlock(
"textquestion");
 
  232                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  233                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  234                $this->tpl->setVariable(
"VAL_MAXLENGTH", $maxlength);
 
  235                if ($this->preview_mode) {
 
  236                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  238                $this->tpl->parseCurrentBlock();
 
  240                return $this->tpl->get();
 
  244                $this->tpl->setCurrentBlock(
"clozequestion");
 
  245                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  246                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  247                if ($this->preview_mode) {
 
  248                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  250                $this->tpl->parseCurrentBlock();
 
  252                return $this->tpl->get();
 
  256                $this->tpl->setCurrentBlock(
"longmenu");
 
  257                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  258                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  259                if ($this->preview_mode) {
 
  260                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  262                $this->tpl->parseCurrentBlock();
 
  264                return $this->tpl->get();
 
  268                $this->tpl->setCurrentBlock(
"orderingquestion");
 
  269                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  270                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  271                if ($this->preview_mode) {
 
  272                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  274                if($this->q_gui->object->getOrderingType() == 
OQ_PICTURES)
 
  276                        $this->tpl->setVariable(
"VAL_SUBTYPE", 
"_images");
 
  277                        $this->tpl->setVariable(
"HANDLE_IMAGES",
 
  278                                "ilias.questions.handleOrderingImages(".$this->json_decoded->id.
");");
 
  280                        foreach ($this->json_decoded->answers as $answer) {
 
  281                                if ($answer->answertext!=
"") {
 
  282                                        array_push(self::$media_files,$this->q_gui->object->getImagePath().$answer->answertext);
 
  283                                        array_push(self::$media_files,$this->q_gui->object->getImagePath().
"thumb.".$answer->answertext);
 
  289                        $this->tpl->setVariable(
"VAL_SUBTYPE", 
"_terms");
 
  291                $this->tpl->parseCurrentBlock();
 
  293                return $this->tpl->get();       
 
  298                $tpl->addJavaScript(
'Modules/TestQuestionPool/js/ilMatchingQuestion.js');
 
  299                $tpl->addCss(
'Modules/TestQuestionPool/templates/default/test_javascript.css');
 
  300                $this->tpl->setCurrentBlock(
"matchingquestion");
 
  301                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  302                $this->tpl->setVariable(
"BTN_LABEL_RESET", $this->lng->txt(
"reset_terms"));
 
  303                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  304                if ($this->preview_mode) {
 
  305                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  307                $this->tpl->parseCurrentBlock();
 
  309                return $this->tpl->get();       
 
  313                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  314                array_push(self::$media_files,$this->q_gui->object->getImagePath().$this->q_gui->object->getImageFilename());
 
  315                $this->tpl->setCurrentBlock(
"mapareas");
 
  316                $areas = $this->json_decoded->answers;
 
  318                foreach ($areas as $area) {
 
  319                        $this->tpl->setVariable(
"VAL_TOOLTIP", htmlspecialchars($area->answertext));
 
  320                        $this->tpl->setVariable(
"VAL_COORDS", $area->coords);
 
  321                        $this->tpl->setVariable(
"VAL_ORDER", $area->order);
 
  322                        $this->tpl->setVariable(
"VAL_AREA", $area->area);
 
  323                        $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  324                        $this->tpl->parseCurrentBlock();        
 
  326                $this->tpl->setCurrentBlock(
"imagemapquestion");
 
  327                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  328                if ($this->preview_mode) {
 
  329                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  331                $this->tpl->parseCurrentBlock();
 
  333                return $this->tpl->get();
 
  337                $this->tpl->setCurrentBlock(
"textsubset");
 
  338                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  339                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  340                $this->tpl->setVariable(
"VAL_MAXLENGTH", $maxlength);
 
  341                if ($this->preview_mode) {
 
  342                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  344                $this->tpl->parseCurrentBlock();
 
  346                return $this->tpl->get();
 
  350                $this->tpl->setCurrentBlock(
"orderinghorizontal");
 
  351                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  352                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  353                if ($this->preview_mode) {
 
  354                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  356                $this->tpl->parseCurrentBlock();
 
  358                return $this->tpl->get();       
 
  362                $this->tpl->setCurrentBlock(
"errortext");
 
  363                $this->tpl->setVariable(
"VAL_ID", $this->json_decoded->id);
 
  364                $this->tpl->setVariable(
"TXT_SUBMIT_ANSWERS", $this->lng->txt(
"cont_submit_answers"));
 
  365                if ($this->preview_mode) {
 
  366                        $this->tpl->setVariable(
"VAL_NO_DISPLAY", 
"style=\"display:none\"");
 
  368                $this->tpl->parseCurrentBlock();
 
  370                return $this->tpl->get();
 
& _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
_extractObjIdOfTarget($a_target)
Extract object id out of target.
_extractInstOfTarget($a_target)
Extract installation id out of target.
Scorm 2004 Question Exporter.
exportQuestion($a_ref_id, $a_image_path=null, $a_output_mode="presentation")
static questionsJS(array $a_qids=null)
ilQuestionExporter($a_preview_mode=false)
Constructor @access public.
special template class to simplify handling of ITX/PEAR
const OQ_PICTURES
Ordering question constants.