/**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     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->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($item->getMetadataEntry("points"));
     $this->object->setOrderText($item->getMetadataEntry("ordertext"));
     $this->object->setTextSize($item->getMetadataEntry("textsize"));
     $this->object->setSeparator($item->getMetadataEntry("separator"));
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     $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) {
                 $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);
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     $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, 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);
     }
 }
 protected function parse()
 {
     $peer_data = array();
     if ($this->show_peer_review) {
         $peer_data = $this->ass->getAllPeerReviews();
     }
     include_once "Services/User/classes/class.ilUserUtil.php";
     include_once "Services/RTE/classes/class.ilRTE.php";
     foreach (ilExAssignment::getAllDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId()) as $file) {
         if (trim($file["atext"])) {
             $data[$file["user_id"]] = array("uid" => $file["user_id"], "uname" => ilUserUtil::getNamePresentation($file["user_id"]), "udate" => $file["ts"], "utext" => ilRTE::_replaceMediaObjectImageSrc($file["atext"], 1));
             if (isset($peer_data[$file["user_id"]])) {
                 $data[$file["user_id"]]["peer"] = $peer_data[$file["user_id"]];
             }
         }
     }
     $this->setData($data);
 }
Пример #3
0
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     // Container import => test object already created
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
         #$newObj->setImportDirectory(dirname(rtrim($this->getImportDirectory(),'/')));
     } else {
         // Shouldn't happen
         $GLOBALS['ilLog']->write(__METHOD__ . ': Called in non container mode');
         return false;
     }
     include_once "./Services/Survey/classes/class.SurveyImportParser.php";
     list($xml_file) = $this->parseXmlFileNames();
     if (!@file_exists($xml_file)) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot find xml definition: ' . $xml_file);
         return false;
     }
     $import = new SurveyImportParser(-1, $xml_file, TRUE);
     $import->setSurveyObject($newObj);
     $import->startParsing();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             $importfile = dirname($xml_file) . "/" . $mob["uri"];
             if (file_exists($importfile)) {
                 $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                 ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $newObj->getId());
                 $newObj->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $newObj->getIntroduction()));
                 $newObj->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $newObj->getOutro()));
             } else {
                 global $ilLog;
                 $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File {$importfile} does not exist!");
             }
         }
         $newObj->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($newObj->getIntroduction(), 1));
         $newObj->setOutro(ilRTE::_replaceMediaObjectImageSrc($newObj->getOutro(), 1));
         $newObj->saveToDb();
     }
     $a_mapping->addMapping("Modules/Survey", "svy", $a_id, $newObj->getId());
     return true;
 }
Пример #4
0
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['text'] = (string) ilRTE::_replaceMediaObjectImageSrc($this->getErrorText(), 0);
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array('onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)), 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)));
     $answers = array();
     foreach ($this->getErrorData() as $idx => $answer_obj) {
         array_push($answers, array("answertext_wrong" => (string) $answer_obj->text_wrong, "answertext_correct" => (string) $answer_obj->text_correct, "points" => (double) $answer_obj->points, "order" => (int) $idx + 1));
     }
     $result['correct_answers'] = $answers;
     $answers = array();
     $textarray = preg_split("/[\n\r]+/", $this->getErrorText());
     foreach ($textarray as $textidx => $text) {
         $items = preg_split("/\\s+/", trim($text));
         foreach ($items as $idx => $item) {
             if (substr($item, 0, 1) == "#") {
                 $item = substr($item, 1);
                 // #14115 - add position to correct answer
                 foreach ($result["correct_answers"] as $aidx => $answer) {
                     if ($answer["answertext_wrong"] == $item && !$answer["pos"]) {
                         $result["correct_answers"][$aidx]["pos"] = $this->getId() . "_" . $textidx . "_" . ($idx + 1);
                         break;
                     }
                 }
             }
             array_push($answers, array("answertext" => (string) ilUtil::prepareFormOutput($item), "order" => $this->getId() . "_" . $textidx . "_" . ($idx + 1)));
         }
         if ($textidx != sizeof($textarray) - 1) {
             array_push($answers, array("answertext" => "###", "order" => $this->getId() . "_" . $textidx . "_" . ($idx + 2)));
         }
     }
     $result['answers'] = $answers;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['feedback'] = array("onenotcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false), "allcorrect" => $this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true));
     $answers = array();
     $has_image = false;
     foreach ($this->getAnswers() as $key => $answer_obj) {
         if ((string) $answer_obj->getImage()) {
             $has_image = true;
         }
         array_push($answers, array("answertext" => (string) $answer_obj->getAnswertext(), "points" => (double) $answer_obj->getPoints(), "order" => (int) $answer_obj->getOrder(), "image" => (string) $answer_obj->getImage(), "feedback" => ilRTE::_replaceMediaObjectImageSrc($this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0)));
     }
     $result['answers'] = $answers;
     if ($has_image) {
         $result['path'] = $this->getImagePathWeb();
         $result['thumb'] = $this->getThumbSize();
     }
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $shuffle = 0;
     $idents = array();
     $now = getdate();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $gaps = array();
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "response":
                 $response = $presentation->response[$entry["index"]];
                 if ($response->getResponseType() == RT_RESPONSE_STR) {
                     array_push($idents, $response->getIdent());
                 }
                 break;
         }
     }
     $responses = array();
     $feedbacksgeneric = array();
     foreach ($item->resprocessing as $resprocessing) {
         foreach ($resprocessing->respcondition as $respcondition) {
             $ident = "";
             $correctness = 1;
             $conditionvar = $respcondition->getConditionvar();
             foreach ($conditionvar->order as $order) {
                 switch ($order["field"]) {
                     case "varsubset":
                         $respident = $conditionvar->varsubset[$order["index"]]->getRespident();
                         $content = $conditionvar->varsubset[$order["index"]]->getContent();
                         if (!is_array($responses[$respident])) {
                             $responses[$respident] = array();
                         }
                         $vars = split(",", $content);
                         foreach ($vars as $var) {
                             array_push($responses[$respident], array("solution" => $var, "points" => ""));
                         }
                         break;
                 }
             }
             foreach ($respcondition->setvar as $setvar) {
                 if (strcmp($setvar->getVarname(), "matches") == 0 && $setvar->getAction() == ACTION_ADD) {
                     foreach ($responses[$respident] as $idx => $solutionarray) {
                         if (strlen($solutionarray["points"] == 0)) {
                             $responses[$respident][$idx]["points"] = $setvar->getContent();
                         }
                     }
                 }
             }
             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->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"]);
     $textrating = $item->getMetadataEntry("textrating");
     if (strlen($textrating) == 0) {
         $textrating = "ci";
     }
     $this->object->setTextRating($textgap_rating);
     $this->object->setCorrectAnswers($item->getMetadataEntry("correctanswers"));
     $response = current($responses);
     $counter = 0;
     if (is_array($response)) {
         foreach ($response as $answer) {
             $this->object->addAnswer($answer["solution"], $answer["points"], $counter);
             $counter++;
         }
     }
     $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->saveFeedbackGeneric($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);
     }
 }
 /**
  * Loads a assJavaApplet object from a database
  *
  * Loads a assJavaApplet object from a database (experimental)
  *
  * @param object $db A pear DB object
  * @param integer $question_id A unique key which defines the multiple choice test in the database
  * @access public
  */
 function loadFromDb($question_id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s", array("integer"), array($question_id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($question_id);
         $this->setObjId($data["obj_fi"]);
         $this->setNrOfTries($data['nr_of_tries']);
         $this->setTitle($data["title"]);
         $this->setComment($data["description"]);
         $this->setOriginalId($data["original_id"]);
         $this->setAuthor($data["author"]);
         $this->setPoints($data["points"]);
         $this->setOwner($data["owner"]);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
         $this->setJavaAppletFilename($data["image_file"]);
         $this->splitParams($data["params"]);
         $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
     }
     parent::loadFromDb($question_id);
 }
Пример #8
0
 /**
  * Loads a assTextSubset object from a database
  *
  * @param object $db A pear DB object
  * @param integer $question_id A unique key which defines the multiple choice test in the database
  * @access public
  */
 function loadFromDb($question_id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s", array("integer"), array($question_id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($question_id);
         $this->setObjId($data["obj_fi"]);
         $this->setNrOfTries($data['nr_of_tries']);
         $this->setTitle($data["title"]);
         $this->setComment($data["description"]);
         $this->setOriginalId($data["original_id"]);
         $this->setAuthor($data["author"]);
         $this->setPoints($data["points"]);
         $this->setOwner($data["owner"]);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
         $this->setCorrectAnswers($data["correctanswers"]);
         $this->setTextRating($data["textgap_rating"]);
         $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
         try {
             $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
         } catch (ilTestQuestionPoolException $e) {
         }
     }
     $result = $ilDB->queryF("SELECT * FROM qpl_a_textsubset WHERE question_fi = %s ORDER BY aorder ASC", array('integer'), array($question_id));
     include_once "./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
     if ($result->numRows() > 0) {
         while ($data = $ilDB->fetchAssoc($result)) {
             array_push($this->answers, new ASS_AnswerBinaryStateImage($data["answertext"], $data["points"], $data["aorder"]));
         }
     }
     parent::loadFromDb($question_id);
 }
 public function showItems()
 {
     global $ilObjDataCache, $ilUser, $ilToolbar;
     include_once './Services/Payment/classes/class.ilPaymentPrices.php';
     include_once './Services/Payment/classes/class.ilPaymentCurrency.php';
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.pay_shopping_cart.html', 'Services/Payment');
     //		var_dump($_SESSION['shop_user_id']);
     //		if(isset($_SESSION['shop_user_id']))
     //		{
     //
     //			$this->user_obj->_toggleActiveStatusOfUsers(array($this->user_obj->getId()), 1);
     //		}
     if ($_SESSION['forceShoppingCartRedirect'] == '1') {
         $_SESSION['forceShoppingCartRedirect'] = 0;
         $this->tpl->touchBlock("close_js");
         return true;
     }
     $this->initShoppingCartObject();
     include_once './Services/Payment/classes/class.ilPaymentSettings.php';
     $genSet = ilPaymentSettings::_getInstance();
     $pay_methods = $this->_getPayMethods(true);
     $num_items = 0;
     $desc = array();
     //course_objects
     $is_crs_object = false;
     $crs_obj_ids = array();
     //file_objects,exercise_objects
     $is_file_object = false;
     // learning_modules,
     $is_lm_object = false;
     $lm_obj_ids = array();
     if ($genSet->get('show_sr_shoppingcart') == 1) {
         require_once 'Services/RTE/classes/class.ilRTE.php';
         $regulations = ilRTE::_replaceMediaObjectImageSrc($genSet->get('statutory_regulations'), 1);
         $this->tpl->setVariable('REGULATIONS_TITLE', $this->lng->txt('statutory_regulations'));
         $this->tpl->setVariable('REGULATIONS', $regulations);
     }
     $ilToolbar->addButton($this->lng->txt('payment_back_to_shop'), 'ilias.php?baseClass=ilShopController');
     foreach ($pay_methods as $pay_method) {
         $this->totalVat = 0;
         $tpl = new ilTemplate($this->_getTemplateFilename($pay_method['pm_title']), true, 'Services/Payment');
         $coupon_session_id = $pay_method['pm_title'];
         if (count($items = $this->psc_obj->getEntries($pay_method['pm_id']))) {
             $counter = 0;
             $paypal_counter = 0;
             $total_price = 0;
             foreach ($items as $item) {
                 $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']);
                 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
                 $obj_type = $ilObjDataCache->lookupType($obj_id);
                 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
                 $desc[] = "[" . $obj_type . "] " . $obj_title;
                 $price_arr = ilPaymentPrices::_getPrice($item['price_id']);
                 # checks object_type: needed for purchasing file or crs objects without login
                 switch ($obj_type) {
                     case 'crs':
                         // if is_crs there an user-account will be autogenerated
                         $is_crs_object = true;
                         $_SESSION['is_crs_object'] = true;
                         $crs_obj_ids[] = $obj_id;
                         $_SESSION['crs_obj_ids'] = $crs_obj_ids;
                         break;
                     case 'lm':
                     case 'sahs':
                     case 'htlm':
                     case 'tst':
                         $is_lm_object = true;
                         $_SESSION['is_lm_object'] = true;
                         $lm_obj_ids[] = $obj_id;
                         $_SESSION['lm_obj_ids'] = $lm_obj_ids;
                         break;
                     case 'exc':
                     case 'file':
                         $is_file_object = true;
                         break;
                     default:
                         break;
                 }
                 $direct_paypal_info_output = true;
                 $assigned_coupons = '';
                 if (!empty($_SESSION['coupons'][$coupon_session_id])) {
                     $price = $price_arr['price'];
                     $item['math_price'] = (double) $price;
                     foreach ($_SESSION['coupons'][$coupon_session_id] as $key => $coupon) {
                         $this->coupon_obj->setId($coupon['pc_pk']);
                         $this->coupon_obj->setCurrentCoupon($coupon);
                         if ($this->coupon_obj->isObjectAssignedToCoupon($tmp_pobject->getRefId())) {
                             $assigned_coupons .= $this->lng->txt('paya_coupons_coupon') . ': ' . $coupon['pcc_code'];
                             $_SESSION['coupons'][$coupon_session_id][$key]['total_objects_coupon_price'] += (double) $price;
                             $_SESSION['coupons'][$coupon_session_id][$key]['items'][] = $item;
                             $direct_paypal_info_output = false;
                         }
                     }
                 }
                 $f_result[$counter]['item'] = ilUtil::formCheckBox(0, 'item[]', $item['psc_id']);
                 $subtype = '';
                 if ($obj_type == 'exc') {
                     $subtype = ' (' . $this->lng->txt($tmp_pobject->getSubtype()) . ')';
                     $f_result[$counter]['title'] = "<a href=\"goto.php?target=" . $obj_type . "_" . $tmp_pobject->getRefId() . "\">" . $obj_title . "</a>" . $subtype;
                 } else {
                     $f_result[$counter]['title'] = "<a href=\"ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=" . $tmp_pobject->getRefId() . "\">" . $obj_title . "</a>" . $subtype;
                 }
                 if ($assigned_coupons != '') {
                     // !!! $f_result[$counter][count($f_result[$counter]) - 1] .= $assigned_coupons;
                     $f_result[$counter]['assigned_coupons'] .= $assigned_coupons;
                 }
                 switch ($price_arr['price_type']) {
                     case ilPaymentPrices::TYPE_DURATION_MONTH:
                         $f_result[$counter]['duration'] = $price_arr['duration'] . ' ' . $this->lng->txt('paya_months');
                         break;
                     case ilPaymentPrices::TYPE_DURATION_DATE:
                         $f_result[$counter]['duration'] = ilDatePresentation::formatDate(new ilDate($price_arr['duration_from'], IL_CAL_DATE)) . ' - ' . ilDatePresentation::formatDate(new ilDate($price_arr['duration_until'], IL_CAL_DATE));
                         break;
                     case ilPaymentPrices::TYPE_UNLIMITED_DURATION:
                         $f_result[$counter]['duration'] = $this->lng->txt('unlimited_duration');
                         break;
                 }
                 $float_price = $price_arr['price'];
                 $total_price += $float_price;
                 $oVAT = new ilShopVats((int) $tmp_pobject->getVatId());
                 $f_result[$counter]['vat_rate'] = ilShopUtils::_formatVAT($oVAT->getRate());
                 $this->totalVat = $this->totalVat + $tmp_pobject->getVat($float_price);
                 $f_result[$counter]['price'] = ilPaymentPrices::_getPriceString($item['price_id']) . ' ' . $genSet->get('currency_unit');
                 $f_result[$counter]['vat_unit'] = ilPaymentPrices::_getGUIPrice($tmp_pobject->getVat($float_price, 'CALCULATION')) . ' ' . $genSet->get('currency_unit');
                 if ($pay_method['pm_title'] == 'paypal') {
                     if ($direct_paypal_info_output == true) {
                         $tpl->setCurrentBlock('loop_items');
                         $tpl->setVariable('LOOP_ITEMS_NO', ++$paypal_counter);
                         $tpl->setVariable('LOOP_ITEMS_NAME', "[" . $obj_id . "]: " . $obj_title);
                         $tpl->setVariable('LOOP_ITEMS_AMOUNT', $float_price);
                         $tpl->parseCurrentBlock('loop_items');
                     }
                 }
                 ++$counter;
                 unset($tmp_pobject);
             }
             // foreach
             $this->showItemsTable($tpl, $f_result, $pay_method);
             if (!(bool) $genSet->get('hide_coupons')) {
                 $tpl->setVariable('COUPON_TABLE', $this->showCouponInput($pay_method['pm_title']));
             }
             $tpl->setCurrentBlock('buy_link');
             #				$tpl->setCurrentBlock('terms_checkbox');
             $link_target = $this->ctrl->getLinkTargetByClass('iltermsconditionsgui', '');
             $terms_link = '<a href="' . $link_target . '">' . $this->lng->txt('terms_conditions') . '</a>';
             $tpl->setVariable('TERMS_CONDITIONS', sprintf($this->lng->txt('accept_terms_conditions'), $terms_link));
             switch ($pay_method['pm_title']) {
                 case 'bill':
                     if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID == $this->user_obj->getId()) {
                         $tpl->setVariable('TXT_UNLOCK', $this->lng->txt('pay_click_to_buy'));
                         $tpl->setVariable('LINK_UNLOCK', $this->ctrl->getLinkTarget($this, 'unlockBillObjectsInShoppingCart'));
                     } else {
                         # Anonymous user has to login
                         if (ANONYMOUS_USER_ID == $this->user_obj->getId()) {
                             ilUtil::sendInfo($this->lng->txt('click_to_continue_info'));
                             $tpl->touchBlock('attach_submit_event_bill');
                             $tpl->setVariable('TXT_BUY', $this->lng->txt('continue'));
                             $tpl->setVariable('SCRIPT_LINK', 'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
                         } else {
                             ilUtil::sendInfo($this->lng->txt('click_to_buy_info'));
                             $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                             $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTargetByClass('ilPurchaseBillGUI', ''));
                             $tpl->parseCurrentBlock('terms_checkbox');
                         }
                     }
                     break;
                 case 'bmf':
                     #$tpl->setVariable("SCRIPT_LINK", './payment.php?view=start_bmf');
                     if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId()) {
                         $tpl->setVariable('TXT_UNLOCK', $this->lng->txt('pay_click_to_buy'));
                         $tpl->setVariable('LINK_UNLOCK', $this->ctrl->getLinkTarget($this, 'unlockBMFObjectsInShoppingCart'));
                     } else {
                         # Anonymous user has to login
                         if (ANONYMOUS_USER_ID == $this->user_obj->getId()) {
                             ilUtil::sendInfo($this->lng->txt('click_to_continue_info'));
                             $tpl->setVariable('TXT_BUY', $this->lng->txt('continue'));
                             $tpl->setVariable('SCRIPT_LINK', 'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
                         } else {
                             $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                             $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTargetByClass('ilPurchaseBMFGUI', ''));
                         }
                     }
                     break;
                 case 'epay':
                     # Anonymous user has to login
                     //						if(ANONYMOUS_USER_ID == $ilUser->getId())
                     //						{
                     //							$tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                     //							$tpl->setVariable('SCRIPT_LINK','login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
                     //						}
                     //						else
                     //						{
                     //							/// http://uk.epay.dk/support/docs.asp?solution=2#pfinput
                     //							$tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                     //							$tpl->setVariable('SCRIPT_LINK', 'https://'.$this->epayConfig['server_host'].$this->epayConfig['server_path']);
                     //							$tpl->setVariable('MERCHANT_NUMBER', $this->epayConfig['merchant_number']);
                     //							$tpl->setVariable('AMOUNT', $total_price * 100);
                     //							$tpl->setVariable('CURRENCY', "208");
                     //							$tpl->setVariable('ORDERID', $ilUser->getId()."_".uniqid());
                     //							$tpl->setVariable('ACCEPT_URL', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'finishEPay'));
                     //							$tpl->setVariable('DECLINE_URL', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'cancelEPay'));
                     //							$tpl->setVariable('INSTANT_CAPTURE', $this->epayConfig['instant_capture'] ? "1" : "0");
                     //							$tpl->setVariable('ADDFEE', 1);
                     //							$tpl->setVariable('LANGUAGE', 1);
                     //							$tpl->setVariable('GROUP', "");
                     //							$tpl->setVariable('CARDTYPE', "");
                     //							$tpl->setVariable("CALLBACK_URL", ILIAS_HTTP_PATH . "/Services/Payment/classes/class.ilCallback.php?ilUser="******"&pay_method=". PAY_METHOD_EPAY);
                     //
                     //							$tpl->setVariable('DESCRIPTION', $ilUser->getFullName() . " (" . $ilUser->getEmail() . ") #" . $ilUser->getId() . " " . implode(",", $desc));
                     //							$tpl->setVariable('AUTH_MAIL', $this->epayConfig['auth_email']);
                     //							$tpl->setVariable('MD5KEY', $this->epSet->generateKeyForEpay(208, $total_price*100, $ilUser->getId()."_".uniqid()));
                     //						}
                     break;
                 case 'paypal':
                     if ($this->totalAmount[$pay_method['pm_id']] <= 0 && ANONYMOUS_USER_ID != $this->user_obj->getId()) {
                         $tpl->touchBlock('attach_submit_event');
                         $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                         $tpl->setVariable('SCRIPT_LINK', $this->ctrl->getLinkTarget($this, 'unlockPAYPALObjectsInShoppingCart'));
                     } else {
                         if (ANONYMOUS_USER_ID == $this->user_obj->getId()) {
                             ilUtil::sendInfo($this->lng->txt('click_to_continue_info'));
                             $tpl->touchBlock('attach_submit_event');
                             $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                             $tpl->setVariable('SCRIPT_LINK', 'login.php?cmd=force_login&login_to_purchase_object=1&forceShoppingCartRedirect=1');
                         } else {
                             $tpl->setCurrentBlock('terms_checkbox');
                             ilUtil::sendInfo($this->lng->txt('click_to_buy_info'));
                             $tpl->setVariable('TXT_BUY', $this->lng->txt('pay_click_to_buy'));
                             $tpl->setVariable('SCRIPT_LINK', 'https://' . $this->paypalConfig['server_host'] . $this->paypalConfig['server_path']);
                             $tpl->parseCurrentBlock('terms_checkbox');
                         }
                     }
                     $tpl->setVariable('POPUP_BLOCKER', $this->lng->txt('popup_blocker'));
                     $tpl->setVariable('VENDOR', $this->paypalConfig['vendor']);
                     $tpl->setVariable('RETURN', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'finishPaypal'));
                     $tpl->setVariable('CANCEL_RETURN', ILIAS_HTTP_PATH . "/" . $this->ctrl->getLinkTarget($this, 'cancelPaypal'));
                     $tpl->setVariable('CUSTOM', $this->user_obj->getId());
                     $tpl->setVariable('CURRENCY', $genSet->get('currency_unit'));
                     $tpl->setVariable('PAGE_STYLE', $this->paypalConfig['page_style']);
                     if (!empty($_SESSION['coupons'][$coupon_session_id])) {
                         $coupon_discount_items = $this->psc_obj->calcDiscountPrices($_SESSION['coupons'][$coupon_session_id]);
                         if (is_array($coupon_discount_items) && !empty($coupon_discount_items)) {
                             foreach ($coupon_discount_items as $item) {
                                 $tmp_pobject = new ilPaymentObject($this->user_obj, $item['pobject_id']);
                                 $obj_id = $ilObjDataCache->lookupObjId($tmp_pobject->getRefId());
                                 $obj_title = $ilObjDataCache->lookupTitle($obj_id);
                                 $tmp_amount = round($item['discount_price'], 2);
                                 $loop_items_amount = str_replace(',', '.', $tmp_amount);
                                 $tpl->setCurrentBlock('loop_items');
                                 $tpl->setVariable('LOOP_ITEMS_NO', ++$paypal_counter);
                                 $tpl->setVariable('LOOP_ITEMS_NAME', "[" . $obj_id . "]: " . $obj_title);
                                 $tpl->setVariable('LOOP_ITEMS_AMOUNT', $loop_items_amount);
                                 $tpl->parseCurrentBlock('loop_items');
                                 unset($tmp_pobject);
                             }
                         }
                     }
                     break;
             }
             if ($pay_method['pm_title'] == 'paypal') {
                 $tpl->setVariable('PAYPAL_HINT', $this->lng->txt('pay_hint_paypal'));
                 $tpl->setVariable('PAYPAL_INFO', $this->lng->txt('pay_info_paypal'));
             } else {
                 if ($pay_method['pm_title'] == 'epay') {
                     $tpl->setVariable('EPAY_HINT', $this->lng->txt('pay_hint_epay'));
                     $tpl->setVariable('EPAY_INFO', $this->lng->txt('pay_info_epay'));
                 }
             }
             $tpl->parseCurrentBlock('buy_link');
             $tpl->setCurrentBlock('loop');
             unset($f_result);
             $tpl->parseCurrentBlock('loop');
             $this->tpl->setVariable('' . strtoupper($pay_method['pm_title']) . '', $tpl->get());
             $num_items += $counter;
         }
     }
     if ($num_items == 0) {
         #		ilUtil::sendInfo($this->lng->txt('pay_shopping_cart_empty'));
         return false;
     }
     return true;
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $applet = NULL;
     $maxpoints = 0;
     $javacode = "";
     $javacodebase = "";
     $javaarchive = "";
     $params = array();
     $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
     $answers = array();
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "material":
                 $material = $presentation->material[$entry["index"]];
                 for ($i = 0; $i < $material->getMaterialCount(); $i++) {
                     $mat = $material->getMaterial($i);
                     if (strcmp($mat["type"], "mattext") == 0) {
                         $mattext = $mat["material"];
                         if (strlen($mattext->getLabel()) == 0 && strlen($this->object->QTIMaterialToString($item->getQuestiontext())) == 0) {
                             $item->setQuestiontext($mattext->getContent());
                         }
                         if (strcmp($mattext->getLabel(), "points") == 0) {
                             $maxpoints = $mattext->getContent();
                         } else {
                             if (strcmp($mattext->getLabel(), "java_code") == 0) {
                                 $javacode = $mattext->getContent();
                             } else {
                                 if (strcmp($mattext->getLabel(), "java_codebase") == 0) {
                                     $javacodebase = $mattext->getContent();
                                 } else {
                                     if (strcmp($mattext->getLabel(), "java_archive") == 0) {
                                         $javaarchive = $mattext->getContent();
                                     } else {
                                         if (strlen($mattext->getLabel()) > 0) {
                                             array_push($params, array("key" => $mattext->getLabel(), "value" => $mattext->getContent()));
                                         }
                                     }
                                 }
                             }
                         }
                     } elseif (strcmp($mat["type"], "matapplet") == 0) {
                         $applet = $mat["material"];
                     }
                 }
                 break;
         }
     }
     $feedbacksgeneric = array();
     foreach ($item->resprocessing as $resprocessing) {
         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->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->setJavaAppletFilename($applet->getUri());
     $this->object->setJavaWidth($applet->getWidth());
     $this->object->setJavaHeight($applet->getHeight());
     $this->object->setJavaCode($javacode);
     $this->object->setJavaCodebase($javacodebase);
     $this->object->setJavaArchive($javaarchive);
     $this->object->setPoints($maxpoints);
     foreach ($params as $pair) {
         $this->object->addParameter($pair["key"], $pair["value"]);
     }
     $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();
     }
     $javaapplet =& base64_decode($applet->getContent());
     $javapath = $this->object->getJavaPath();
     if (!file_exists($javapath)) {
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::makeDirParents($javapath);
     }
     $javapath .= $this->object->getJavaAppletFilename();
     $fh = fopen($javapath, "wb");
     if ($fh == false) {
         //									global $ilErr;
         //									$ilErr->raiseError($this->object->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
         //									return;
     } else {
         $javafile = fwrite($fh, $javaapplet);
         fclose($fh);
     }
     // handle the import of media objects in XHTML code
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     $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->saveFeedbackGeneric($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);
     }
 }
Пример #11
0
 /**
  * Loads a assClozeTest object from a database
  *
  * @param integer $question_id A unique key which defines the cloze test in the database
  *
  */
 public function loadFromDb($question_id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s", array("integer"), array($question_id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($question_id);
         $this->setNrOfTries($data['nr_of_tries']);
         $this->setObjId($data["obj_fi"]);
         $this->setTitle($data["title"]);
         $this->setComment($data["description"]);
         $this->setOriginalId($data["original_id"]);
         $this->setAuthor($data["author"]);
         $this->setPoints($data["points"]);
         $this->setOwner($data["owner"]);
         $this->setQuestion($this->cleanQuestiontext($data["question_text"]));
         $this->setFixedTextLength($data["fixed_textlen"]);
         $this->setIdenticalScoring($data['tstamp'] == 0 ? true : $data["identical_scoring"]);
         // replacement of old syntax with new syntax
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->question = ilRTE::_replaceMediaObjectImageSrc($this->question, 1);
         $this->setTextgapRating($data["textgap_rating"]);
         $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
         try {
             $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
         } catch (ilTestQuestionPoolException $e) {
         }
         // open the cloze gaps with all answers
         include_once "./Modules/TestQuestionPool/classes/class.assAnswerCloze.php";
         include_once "./Modules/TestQuestionPool/classes/class.assClozeGap.php";
         $result = $ilDB->queryF("SELECT * FROM qpl_a_cloze WHERE question_fi = %s ORDER BY gap_id, aorder ASC", array("integer"), array($question_id));
         if ($result->numRows() > 0) {
             $this->gaps = array();
             while ($data = $ilDB->fetchAssoc($result)) {
                 switch ($data["cloze_type"]) {
                     case CLOZE_TEXT:
                         if (!array_key_exists($data["gap_id"], $this->gaps)) {
                             $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_TEXT);
                         }
                         $answer = new assAnswerCloze($data["answertext"], $data["points"], $data["aorder"]);
                         $this->gaps[$data["gap_id"]]->addItem($answer);
                         break;
                     case CLOZE_SELECT:
                         if (!array_key_exists($data["gap_id"], $this->gaps)) {
                             $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_SELECT);
                             $this->gaps[$data["gap_id"]]->setShuffle($data["shuffle"]);
                         }
                         $answer = new assAnswerCloze($data["answertext"], $data["points"], $data["aorder"]);
                         $this->gaps[$data["gap_id"]]->addItem($answer);
                         break;
                     case CLOZE_NUMERIC:
                         if (!array_key_exists($data["gap_id"], $this->gaps)) {
                             $this->gaps[$data["gap_id"]] = new assClozeGap(CLOZE_NUMERIC);
                         }
                         $answer = new assAnswerCloze($data["answertext"], $data["points"], $data["aorder"]);
                         $answer->setLowerBound($data["lowerlimit"]);
                         $answer->setUpperBound($data["upperlimit"]);
                         $this->gaps[$data["gap_id"]]->addItem($answer);
                         break;
                 }
             }
         }
     }
     parent::loadFromDb($question_id);
 }
 /**
  * Export to HTML.
  *
  */
 function exportHTML()
 {
     global $lng, $tpl, $ilUser, $ilAccess, $ilias;
     if (!$ilAccess->checkAccess('read,visible', '', $_GET['ref_id'])) {
         $ilias->raiseError($lng->txt('permission_denied'), $ilias->error_obj->MESSAGE);
     }
     $tplEx = new ilTemplate('tpl.forums_export_html.html', true, true, 'Modules/Forum');
     // threads
     //for ($j = 0; $j < count($_POST['forum_id']); $j++)
     for ($j = 0; $j < count($_POST['thread_ids']); $j++) {
         //$objCurrentTopic = new ilForumTopic(addslashes($_POST['forum_id'][$j]), $ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id']));
         $objCurrentTopic = new ilForumTopic(addslashes($_POST['thread_ids'][$j]), $ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id']));
         // get forum- and thread-data
         $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($objCurrentTopic->getForumId()));
         if (is_array($frmData = $this->frm->getOneTopic())) {
             $objFirstPostNode = $objCurrentTopic->getFirstPostNode();
             $objCurrentTopic->setOrderField('frm_posts_tree.rgt');
             $postTree = $objCurrentTopic->getPostTree($objFirstPostNode);
             $posNum = count($postTree);
             $z = 0;
             foreach ($postTree as $post) {
                 $tplEx->setCurrentBlock('posts_row');
                 $rowCol = ilUtil::switchColor($z++, 'tblrow2', 'tblrow1');
                 $tplEx->setVariable('ROWCOL', $rowCol);
                 $authorinfo = new ilForumAuthorInformation($post->getUserId(), $post->getUserAlias(), $post->getImportName());
                 $tplEx->setVariable('AUTHOR', $authorinfo->getAuthorName());
                 if ($post->getUserId()) {
                     // get create- and update-dates
                     if ($post->getUpdateUserId()) {
                         $authorinfo = new ilForumAuthorInformation($post->getUpdateUserId(), '', '');
                         $tplEx->setVariable('POST_UPDATE', "<br />[" . $lng->txt('edited_on') . ": " . $this->frm->convertDate($post->getChangeDate()) . " - " . strtolower($lng->txt('from')) . " " . $authorinfo->getAuthorName() . "]");
                     }
                     if ($authorinfo->getAuthor()->getPref('public_profile') != 'n') {
                         $tplEx->setVariable('TXT_REGISTERED', $lng->txt('registered_since'));
                         $tplEx->setVariable('REGISTERED_SINCE', $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate()));
                     }
                     if ($ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id'])) {
                         $numPosts = $this->frm->countUserArticles($post->getUserId());
                     } else {
                         $numPosts = $this->frm->countActiveUserArticles($post->getUserId());
                     }
                     $tplEx->setVariable('TXT_NUM_POSTS', $lng->txt('forums_posts'));
                     $tplEx->setVariable('NUM_POSTS', $numPosts);
                 }
                 $tplEx->setVariable('SUBJECT', $post->getSubject());
                 $tplEx->setVariable('TXT_CREATE_DATE', $lng->txt('forums_thread_create_date'));
                 $tplEx->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate()));
                 $tplEx->setVariable('SPACER', "<hr noshade width=\"100%\" size=\"1\" align=\"center\" />");
                 if ($post->isCensored()) {
                     $tplEx->setVariable('POST', nl2br(stripslashes($post->getCensorshipComment())));
                 } else {
                     /** @todo mjansen: possible bugfix for mantis #8223 */
                     if ($post->getMessage() == strip_tags($post->getMessage())) {
                         // We can be sure, that there are not html tags
                         $post->setMessage(nl2br($post->getMessage()));
                     }
                     $tplEx->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($this->frm->prepareText($post->getMessage(), 0, '', 'export'), 1));
                 }
                 $tplEx->parseCurrentBlock('posts_row');
                 unset($author);
             }
             // foreach ($postTree as $post)
             $tplEx->setCurrentBlock('posttable');
             $tplEx->setVariable('TXT_AUTHOR', $lng->txt('author'));
             $tplEx->setVariable('TXT_POST', $lng->txt('forums_thread') . ': ' . $objCurrentTopic->getSubject());
             $tplEx->parseCurrentBlock('posttable');
             // Thread Headline
             $tplEx->setCurrentBlock('thread_headline');
             $tplEx->setVariable('T_TITLE', $objCurrentTopic->getSubject());
             if ($ilAccess->checkAccess('moderate_frm', '', $_GET['ref_id'])) {
                 $tplEx->setVariable('T_NUM_POSTS', $objCurrentTopic->countPosts());
             } else {
                 $tplEx->setVariable('T_NUM_POSTS', $objCurrentTopic->countActivePosts());
             }
             $tplEx->setVariable('T_NUM_VISITS', $objCurrentTopic->getVisits());
             $tplEx->setVariable('T_FORUM', $frmData['top_name']);
             $authorinfo = new ilForumAuthorInformation($objCurrentTopic->getUserId(), $objCurrentTopic->getUserAlias(), $objCurrentTopic->getImportName());
             $tplEx->setVariable('T_AUTHOR', $authorinfo->getAuthorName());
             $tplEx->setVariable('T_TXT_FORUM', $lng->txt('forum') . ': ');
             $tplEx->setVariable('T_TXT_TOPIC', $lng->txt('forums_thread') . ': ');
             $tplEx->setVariable('T_TXT_AUTHOR', $lng->txt('forums_thread_create_from') . ': ');
             $tplEx->setVariable('T_TXT_NUM_POSTS', $lng->txt('forums_articles') . ': ');
             $tplEx->setVariable('T_TXT_NUM_VISITS', $lng->txt('visits') . ': ');
             $tplEx->parseCurrentBlock('thread_headline');
             $tplEx->setCurrentBlock('thread_block');
             $tplEx->parseCurrentBlock('thread_block');
             $tplEx->setCurrentBlock('forum_block');
             $tplEx->parseCurrentBlock('forum_block');
         }
         // if (is_array($frmData = $this->frm->getOneTopic()))
     }
     // for ($j = 0; $j < count($_POST["forum_id"]); $j++)
     ilUtil::deliverData($tplEx->get(), 'forum_html_export_' . $_GET['ref_id'] . '.html');
     exit;
 }
 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     unset($_SESSION["import_mob_xhtml"]);
     $duration = $item->getDuration();
     $shuffle = 0;
     $answers = array();
     $presentation = $item->getPresentation();
     foreach ($presentation->order as $entry) {
         switch ($entry["type"]) {
             case "response":
                 $response = $presentation->response[$entry["index"]];
                 $rendertype = $response->getRenderType();
                 switch (strtolower(get_class($response->getRenderType()))) {
                     case "ilqtirenderchoice":
                         $shuffle = $rendertype->getShuffle();
                         $answerorder = 0;
                         $foundimage = FALSE;
                         foreach ($rendertype->response_labels as $response_label) {
                             $ident = $response_label->getIdent();
                             $answertext = "";
                             $answerimage = array();
                             foreach ($response_label->material as $mat) {
                                 $embedded = false;
                                 for ($m = 0; $m < $mat->getMaterialCount(); $m++) {
                                     $foundmat = $mat->getMaterial($m);
                                     if (strcmp($foundmat["type"], "mattext") == 0) {
                                     }
                                     if (strcmp($foundmat["type"], "matimage") == 0) {
                                         if (strlen($foundmat["material"]->getEmbedded())) {
                                             $embedded = true;
                                         }
                                     }
                                 }
                                 if ($embedded) {
                                     for ($m = 0; $m < $mat->getMaterialCount(); $m++) {
                                         $foundmat = $mat->getMaterial($m);
                                         if (strcmp($foundmat["type"], "mattext") == 0) {
                                             $answertext .= $foundmat["material"]->getContent();
                                         }
                                         if (strcmp($foundmat["type"], "matimage") == 0) {
                                             $foundimage = TRUE;
                                             $answerimage = array("imagetype" => $foundmat["material"]->getImageType(), "label" => $foundmat["material"]->getLabel(), "content" => $foundmat["material"]->getContent());
                                         }
                                     }
                                 } else {
                                     $answertext = $this->object->QTIMaterialToString($mat);
                                 }
                             }
                             $answers[$ident] = array("answertext" => $answertext, "imagefile" => $answerimage, "answerorder" => $ident);
                         }
                         break;
                 }
                 break;
         }
     }
     $feedbacks = array();
     $feedbacksgeneric = array();
     foreach ($item->resprocessing as $resprocessing) {
         foreach ($resprocessing->outcomes->decvar as $decvar) {
             if ($decvar->getVarname() == 'SCORE') {
                 $this->object->setPoints($decvar->getMaxvalue());
                 if ($decvar->getMinvalue() > 0) {
                     $this->object->setScorePartialSolutionEnabled(true);
                 }
             }
         }
         foreach ($resprocessing->respcondition as $respcondition) {
             if (!count($respcondition->setvar)) {
                 foreach ($respcondition->getConditionvar()->varequal as $varequal) {
                     $ident = $varequal->respident;
                     $answers[$ident]['correctness'] = (bool) $varequal->getContent();
                     break;
                 }
                 foreach ($respcondition->displayfeedback as $feedbackpointer) {
                     if (strlen($feedbackpointer->getLinkrefid())) {
                         foreach ($item->itemfeedback as $ifb) {
                             if (strcmp($ifb->getIdent(), $feedbackpointer->getLinkrefid()) == 0) {
                                 // found a feedback for the identifier
                                 if (count($ifb->material)) {
                                     foreach ($ifb->material as $material) {
                                         $feedbacks[$ident] = $material;
                                     }
                                 }
                                 if (count($ifb->flow_mat) > 0) {
                                     foreach ($ifb->flow_mat as $fmat) {
                                         if (count($fmat->material)) {
                                             foreach ($fmat->material as $material) {
                                                 $feedbacks[$ident] = $material;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 foreach ($respcondition->displayfeedback as $feedbackpointer) {
                     if (strlen($feedbackpointer->getLinkrefid())) {
                         foreach ($item->itemfeedback as $ifb) {
                             if ($ifb->getIdent() == "response_allcorrect") {
                                 // 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 ($ifb->getIdent() == "response_onenotcorrect") {
                                     // 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->setShuffleAnswersEnabled($shuffle);
     $this->object->setAnswerType($item->getMetadataEntry("answer_type"));
     $this->object->setOptionLabel($item->getMetadataEntry("option_label_setting"));
     $this->object->setCustomTrueOptionLabel($item->getMetadataEntry("custom_true_option_label"));
     $this->object->setCustomFalseOptionLabel($item->getMetadataEntry("custom_false_option_label"));
     $this->object->setThumbSize($item->getMetadataEntry("thumb_size"));
     $this->object->saveToDb();
     foreach ($answers as $answerData) {
         $answer = new ilAssKprimChoiceAnswer();
         $answer->setImageFsDir($this->object->getImagePath());
         $answer->setImageWebDir($this->object->getImagePathWeb());
         $answer->setPosition($answerData['answerorder']);
         $answer->setAnswertext($answerData['answertext']);
         $answer->setCorrectness($answerData['correctness']);
         if (isset($answerData['imagefile']['label'])) {
             $answer->setImageFile($answerData['imagefile']['label']);
         }
         $this->object->addAnswer($answer);
     }
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     $this->object->saveToDb();
     foreach ($answers as $answer) {
         if (is_array($answer["imagefile"]) && count($answer["imagefile"]) > 0) {
             $image =& base64_decode($answer["imagefile"]["content"]);
             $imagepath = $this->object->getImagePath();
             include_once "./Services/Utilities/classes/class.ilUtil.php";
             if (!file_exists($imagepath)) {
                 ilUtil::makeDirParents($imagepath);
             }
             $imagepath .= $answer["imagefile"]["label"];
             if ($fh = fopen($imagepath, "wb")) {
                 $imagefile = fwrite($fh, $image);
                 fclose($fh);
             }
         }
     }
     $feedbackSetting = $item->getMetadataEntry('feedback_setting');
     if (!is_null($feedbackSetting)) {
         $this->object->feedbackOBJ->saveSpecificFeedbackSetting($this->object->getId(), $feedbackSetting);
     }
     // handle the import of media objects in XHTML code
     foreach ($feedbacks as $ident => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacks[$ident] = $m;
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     $questiontext = $this->object->getQuestion();
     $answers =& $this->object->getAnswers();
     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 ($answers as $key => $value) {
                 $answer_obj =& $answers[$key];
                 $answer_obj->setAnswertext(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $answer_obj->getAnswertext()));
             }
             foreach ($feedbacks as $ident => $material) {
                 $feedbacks[$ident] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
             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 ($answers as $key => $value) {
         $answer_obj =& $answers[$key];
         $answer_obj->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($answer_obj->getAnswertext(), 1));
     }
     foreach ($feedbacks as $ident => $material) {
         $this->object->feedbackOBJ->importSpecificAnswerFeedback($this->object->getId(), $ident, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->feedbackOBJ->importGenericFeedback($this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $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, 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);
     }
     //$ilLog->write(strftime("%D %T") . ": finished import multiple choice question (single response)");
 }
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) true;
     $result['points'] = (bool) $this->getPoints();
     $result['feedback'] = array("onenotcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(0), 0)), "allcorrect" => nl2br(ilRTE::_replaceMediaObjectImageSrc($this->getFeedbackGeneric(1), 0)));
     if ($this->getOrderingType() == OQ_PICTURES) {
         $result['path'] = $this->getImagePathWeb();
     }
     $counter = 1;
     $answers = array();
     foreach ($this->getAnswers() as $answer_obj) {
         $answers[$counter] = $answer_obj->getAnswertext();
         $counter++;
     }
     $answers = $this->pcArrayShuffle($answers);
     $arr = array();
     foreach ($answers as $order => $answer) {
         array_push($arr, array("answertext" => (string) $answer, "order" => (int) $order));
     }
     $result['answers'] = $arr;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
Пример #15
0
 /**
  * Loads a assOrderingQuestion object from a database
  *
  * @param object $db A pear DB object
  * @param integer $question_id A unique key which defines the multiple choice test in the database
  * @access public
  */
 function loadFromDb($question_id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s", array("integer"), array($question_id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($question_id);
         $this->setObjId($data["obj_fi"]);
         $this->setTitle($data["title"]);
         $this->setComment($data["description"]);
         $this->setOriginalId($data["original_id"]);
         $this->setAuthor($data["author"]);
         $this->setNrOfTries($data['nr_of_tries']);
         $this->setPoints($data["points"]);
         $this->setOwner($data["owner"]);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
         $this->ordering_type = strlen($data["ordering_type"]) ? $data["ordering_type"] : OQ_TERMS;
         $this->thumb_geometry = $data["thumb_geometry"];
         $this->element_height = $data["element_height"];
         $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
         try {
             $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
         } catch (ilTestQuestionPoolException $e) {
         }
     }
     $result = $ilDB->queryF("SELECT * FROM qpl_a_ordering WHERE question_fi = %s ORDER BY solution_order ASC", array('integer'), array($question_id));
     include_once "./Modules/TestQuestionPool/classes/class.assAnswerOrdering.php";
     if ($result->numRows() > 0) {
         while ($data = $ilDB->fetchAssoc($result)) {
             include_once "./Services/RTE/classes/class.ilRTE.php";
             $data["answertext"] = ilRTE::_replaceMediaObjectImageSrc($data["answertext"], 1);
             array_push($this->answers, new ASS_AnswerOrdering($data["answertext"], $data["random_id"], $data['depth'] ? $data['depth'] : 0));
         }
     }
     parent::loadFromDb($question_id);
 }
Пример #16
0
 /**
  * Loads a assFormulaQuestion object from a database
  * @param integer $question_id A unique key which defines the question in the database
  */
 public function loadFromDb($question_id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT qpl_questions.* FROM qpl_questions WHERE question_id = %s", array('integer'), array($question_id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($question_id);
         $this->setTitle($data["title"]);
         $this->setComment($data["description"]);
         $this->setSuggestedSolution($data["solution_hint"]);
         $this->setOriginalId($data["original_id"]);
         $this->setObjId($data["obj_fi"]);
         $this->setAuthor($data["author"]);
         $this->setOwner($data["owner"]);
         try {
             $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
         } catch (ilTestQuestionPoolException $e) {
         }
         $this->unitrepository = new ilUnitConfigurationRepository($question_id);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
         $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
         // load variables
         $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_var WHERE question_fi = %s", array('integer'), array($question_id));
         if ($result->numRows() > 0) {
             while ($data = $ilDB->fetchAssoc($result)) {
                 $varObj = new assFormulaQuestionVariable($data["variable"], $data["range_min"], $data["range_max"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["varprecision"], $data["intprecision"]);
                 $varObj->setRangeMinTxt($data['range_min_txt']);
                 $varObj->setRangeMaxTxt($data['range_max_txt']);
                 $this->addVariable($varObj);
             }
         }
         // load results
         $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res WHERE question_fi = %s", array('integer'), array($question_id));
         if ($result->numRows() > 0) {
             while ($data = $ilDB->fetchAssoc($result)) {
                 $resObj = new assFormulaQuestionResult($data["result"], $data["range_min"], $data["range_max"], $data["tolerance"], $this->getUnitrepository()->getUnit($data["unit_fi"]), $data["formula"], $data["points"], $data["resprecision"], $data["rating_simple"], $data["rating_sign"], $data["rating_value"], $data["rating_unit"]);
                 $resObj->setResultType($data['result_type']);
                 $resObj->setRangeMinTxt($data['range_min_txt']);
                 $resObj->setRangeMaxTxt($data['range_max_txt']);
                 $this->addResult($resObj);
             }
         }
         // load result units
         $result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res_unit WHERE question_fi = %s", array('integer'), array($question_id));
         if ($result->numRows() > 0) {
             while ($data = $ilDB->fetchAssoc($result)) {
                 $unit = $this->getUnitrepository()->getUnit($data["unit_fi"]);
                 $resObj = $this->getResult($data["result"]);
                 $this->addResultUnit($resObj, $unit);
             }
         }
     }
     parent::loadFromDb($question_id);
 }
 /**
  * Returns the feedback for a single selected answer
  *
  * @param integer $answer_index The index of the answer
  * @return string Feedback text
  * @access public
  */
 function getFeedbackSingleAnswer($answer_index)
 {
     global $ilDB;
     $feedback = "";
     $result = $ilDB->queryF("SELECT * FROM qpl_fb_cloze WHERE question_fi = %s AND answer = %s", array('integer', 'integer'), array($this->getId(), $answer_index));
     if ($result->numRows()) {
         $row = $ilDB->fetchAssoc($result);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $feedback = ilRTE::_replaceMediaObjectImageSrc($row["feedback"], 1);
     }
     return $feedback;
 }
 /**
  * Loads a assNumeric object from a database
  *
  * @param object $db A pear DB object
  * @param integer $question_id A unique key which defines the multiple choice test in the database
  * @access public
  */
 function loadFromDb($question_id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s", array("integer"), array($question_id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($question_id);
         $this->setObjId($data["obj_fi"]);
         $this->setTitle($data["title"]);
         $this->setComment($data["description"]);
         $this->setNrOfTries($data['nr_of_tries']);
         $this->setOriginalId($data["original_id"]);
         $this->setAuthor($data["author"]);
         $this->setPoints($data["points"]);
         $this->setOwner($data["owner"]);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
         $this->setMaxChars($data["maxnumofchars"]);
         $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
     }
     $result = $ilDB->queryF("SELECT * FROM qpl_num_range WHERE question_fi = %s ORDER BY aorder ASC", array('integer'), array($question_id));
     include_once "./Modules/TestQuestionPool/classes/class.assNumericRange.php";
     if ($result->numRows() > 0) {
         while ($data = $ilDB->fetchAssoc($result)) {
             $this->setPoints($data['points']);
             $this->setLowerLimit($data['lowerlimit']);
             $this->setUpperLimit($data['upperlimit']);
         }
     }
     parent::loadFromDb($question_id);
 }
Пример #19
0
 /**
  * Saves the manual feedback for a question in a test
  *
  * @param integer $active_id Active ID of the user
  * @param integer $question_id Question ID
  * @param integer $pass Pass number
  * @param string $feedback The feedback text
  * @return boolean TRUE if the operation succeeds, FALSE otherwise
  * @access public
  */
 function saveManualFeedback($active_id, $question_id, $pass, $feedback)
 {
     global $ilDB;
     $affectedRows = $ilDB->manipulateF("DELETE FROM tst_manual_fb WHERE active_fi = %s AND question_fi = %s AND pass = %s", array('integer', 'integer', 'integer'), array($active_id, $question_id, $pass));
     if (strlen($feedback)) {
         $next_id = $ilDB->nextId('tst_manual_fb');
         /** @var ilDB $ilDB */
         $result = $ilDB->insert('tst_manual_fb', array('manual_feedback_id' => array('integer', $next_id), 'active_fi' => array('integer', $active_id), 'question_fi' => array('integer', $question_id), 'pass' => array('integer', $pass), 'feedback' => array('clob', ilRTE::_replaceMediaObjectImageSrc($feedback, 0)), 'tstamp' => array('integer', time())));
         include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
         if (ilObjAssessmentFolder::_enabledAssessmentLogging()) {
             global $lng, $ilUser;
             include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
             $username = ilObjTestAccess::_getParticipantData($active_id);
             include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
             $this->logAction(sprintf($lng->txtlng("assessment", "log_manual_feedback", ilObjAssessmentFolder::_getLogLanguage()), $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")", $username, assQuestion::_getQuestionTitle($question_id), $feedback));
         }
     }
     if (PEAR::isError($result)) {
         global $ilias;
         $ilias->raiseError($result->getMessage());
     } else {
         return TRUE;
     }
 }
 /**
 * Loads a SurveyMetricQuestion object from the database
 *
 * @param integer $id The database id of the metric survey question
 * @access public
 */
 function loadFromDb($id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = svy_question.question_id WHERE svy_question.question_id = %s", array('integer'), array($id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($data["question_id"]);
         $this->setTitle($data["title"]);
         $this->setDescription($data["description"]);
         $this->setObjId($data["obj_fi"]);
         $this->setAuthor($data["author"]);
         $this->setOwner($data["owner_fi"]);
         $this->label = $data['label'];
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
         $this->setObligatory($data["obligatory"]);
         $this->setComplete($data["complete"]);
         $this->setOriginalId($data["original_id"]);
         $this->setSubtype($data["subtype"]);
         $result = $ilDB->queryF("SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s", array('integer'), array($id));
         if ($result->numRows() > 0) {
             if ($data = $ilDB->fetchAssoc($result)) {
                 $this->minimum = $data["value1"];
                 if ($data["value2"] < 0 or strcmp($data["value2"], "") == 0) {
                     $this->maximum = "";
                 } else {
                     $this->maximum = $data["value2"];
                 }
             }
         }
     }
     parent::loadFromDb($id);
 }
 /**
 * Loads a SurveyMultipleChoiceQuestion object from the database
 *
 * @param integer $id The database id of the multiple choice survey question
 * @access public
 */
 function loadFromDb($id)
 {
     global $ilDB;
     $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = svy_question.question_id WHERE svy_question.question_id = %s", array('integer'), array($id));
     if ($result->numRows() == 1) {
         $data = $ilDB->fetchAssoc($result);
         $this->setId($data["question_id"]);
         $this->setTitle($data["title"]);
         $this->label = $data['label'];
         $this->setDescription($data["description"]);
         $this->setObjId($data["obj_fi"]);
         $this->setAuthor($data["author"]);
         $this->setOwner($data["owner_fi"]);
         include_once "./Services/RTE/classes/class.ilRTE.php";
         $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
         $this->setObligatory($data["obligatory"]);
         $this->setComplete($data["complete"]);
         $this->setOriginalId($data["original_id"]);
         $this->setOrientation($data["orientation"]);
         $this->use_min_answers = $data['use_min_answers'] ? true : false;
         $this->nr_min_answers = $data['nr_min_answers'];
         $this->nr_max_answers = $data['nr_max_answers'];
         $this->categories->flushCategories();
         $result = $ilDB->queryF("SELECT svy_variable.*, svy_category.title, svy_category.neutral FROM svy_variable, svy_category WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ORDER BY sequence ASC", array('integer'), array($id));
         if ($result->numRows() > 0) {
             while ($data = $ilDB->fetchAssoc($result)) {
                 $this->categories->addCategory($data["title"], $data["other"], $data["neutral"], null, $data['scale'] ? $data['scale'] : $data['sequence'] + 1);
             }
         }
     }
     parent::loadFromDb($id);
 }
Пример #22
0
 /**
  * Creates an XML material tag from a plain text or xhtml text
  *
  * @param object $a_xml_writer Reference to the ILIAS XML writer
  * @param string $a_material plain text or html text containing the material
  * @return string XML material tag
  * @access public
  */
 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $a_xml_writer->xmlStartTag("material", $attribs);
     $attrs = array("type" => "text/plain");
     if ($this->isHTML($a_material)) {
         $attrs["type"] = "text/xhtml";
     }
     $mattext = ilRTE::_replaceMediaObjectImageSrc($a_material, 0);
     $a_xml_writer->xmlElement("mattext", $attrs, $mattext);
     if ($add_mobs) {
         $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
         foreach ($mobs as $mob) {
             $mob_id = "il_" . IL_INST_ID . "_mob_" . $mob;
             if (strpos($mattext, $mob_id) !== FALSE) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $imgattrs = array("label" => $mob_id, "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle());
                 $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
             }
         }
     }
     if ($close_material_tag) {
         $a_xml_writer->xmlEndTag("material");
     }
 }
 public function saveStatutoryRegulationsObject()
 {
     require_once 'Services/RTE/classes/class.ilRTE.php';
     if (isset($_POST['statutory_regulations']) && $_POST['statutory_regulations'] != NULL) {
         $this->genSetData->set('statutory_regulations', ilRTE::_replaceMediaObjectImageSrc($_POST['statutory_regulations'], 0), 'regulations');
         // copy temporary media objects (frm~)
         include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
         $mediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
         $myMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
         foreach ($mediaObjects as $mob) {
             foreach ($myMediaObjects as $myMob) {
                 if ($mob == $myMob) {
                     // change usage
                     ilObjMediaObject::_removeUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
                     break;
                 }
             }
             ilObjMediaObject::_saveUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
         }
     } else {
         $this->genSetData->set('statutory_regulations', NULL, 'regulations');
     }
     // remove usage of deleted media objects
     include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
     $oldMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
     $curMediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
     foreach ($oldMediaObjects as $oldMob) {
         $found = false;
         foreach ($curMediaObjects as $curMob) {
             if ($oldMob == $curMob) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             if (ilObjMediaObject::_exists($oldMob)) {
                 ilObjMediaObject::_removeUsage($oldMob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
                 $mob_obj = new ilObjMediaObject($oldMob);
                 $mob_obj->delete();
             }
         }
     }
     $this->genSetData->set('show_sr_shoppingcart', isset($_POST['show_sr_shoppingcart']) ? 1 : 0, 'regulations');
     $this->genSetData->set('attach_sr_invoice', isset($_POST['attach_sr_invoice']) ? 1 : 0, 'regulations');
     $this->StatutoryRegulationsObject();
     ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
     return true;
 }
 /**
  * saves GENERIC feedback content for the given question id to the database.
  * Generic feedback is either feedback for the completed solution (all answers correct)
  * of the question or at least onen incorrect answer.
  *
  * @final
  * @access public
  * @param integer $questionId
  * @param boolean $solutionCompleted
  * @param string $feedbackContent
  * @return integer $feedbackId
  */
 public final function saveGenericFeedbackContent($questionId, $solutionCompleted, $feedbackContent)
 {
     require_once 'Services/RTE/classes/class.ilRTE.php';
     $correctness = $solutionCompleted ? 1 : 0;
     $feedbackId = $this->getGenericFeedbackId($questionId, $solutionCompleted);
     if (strlen($feedbackContent)) {
         $feedbackContent = ilRTE::_replaceMediaObjectImageSrc($feedbackContent, 0);
     }
     if ($feedbackId) {
         $this->db->update($this->getGenericFeedbackTableName(), array('feedback' => array('clob', $feedbackContent), 'tstamp' => array('integer', time())), array('feedback_id' => array('integer', $feedbackId)));
     } else {
         $feedbackId = $this->db->nextId($this->getGenericFeedbackTableName());
         $this->db->insert($this->getGenericFeedbackTableName(), array('feedback_id' => array('integer', $feedbackId), 'question_fi' => array('integer', $questionId), 'correctness' => array('text', $correctness), 'feedback' => array('clob', $feedbackContent), 'tstamp' => array('integer', time())));
     }
     return $feedbackId;
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     global $ilUser;
     // empty session variable for imported xhtml mobs
     unset($_SESSION["import_mob_xhtml"]);
     $presentation = $item->getPresentation();
     $duration = $item->getDuration();
     $now = getdate();
     $maxchars = 0;
     $points = 0;
     $upperlimit = 0;
     $lowerlimit = 0;
     $feedbacksgeneric = array();
     $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;
         }
     }
     foreach ($item->resprocessing as $resprocessing) {
         foreach ($resprocessing->respcondition as $respcondition) {
             $conditionvar = $respcondition->getConditionvar();
             foreach ($conditionvar->order as $order) {
                 switch ($order["field"]) {
                     case "varlte":
                         $upperlimit = $conditionvar->varlte[$order["index"]]->getContent();
                         break;
                     case "vargte":
                         $lowerlimit = $conditionvar->vargte[$order["index"]]->getContent();
                         break;
                 }
             }
             foreach ($respcondition->setvar as $setvar) {
                 $points = $setvar->getContent();
             }
             if (count($respcondition->displayfeedback)) {
                 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->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->setMaxChars($maxchars);
     $this->object->setPoints($points);
     $this->object->setLowerLimit($lowerlimit);
     $this->object->setUpperLimit($upperlimit);
     $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->saveFeedbackGeneric($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);
     }
 }
Пример #26
0
 protected function processNonAbstractedImageReferences($text, $sourceNic)
 {
     $reg = '/<img.*src=".*\\/mm_(\\d+)\\/(.*?)".*>/m';
     $matches = null;
     if (preg_match_all($reg, $text, $matches)) {
         for ($i = 0, $max = count($matches[1]); $i < $max; $i++) {
             $mobSrcId = $matches[1][$i];
             $mobSrcName = $matches[2][$i];
             $mobSrcLabel = 'il_' . $sourceNic . '_mob_' . $mobSrcId;
             if (!is_array($_SESSION["import_mob_xhtml"])) {
                 $_SESSION["import_mob_xhtml"] = array();
             }
             $_SESSION["import_mob_xhtml"][] = array("mob" => $mobSrcLabel, "uri" => 'objects/' . $mobSrcLabel . '/' . $mobSrcName);
         }
     }
     include_once "./Services/RTE/classes/class.ilRTE.php";
     return ilRTE::_replaceMediaObjectImageSrc($text, 0, $sourceNic);
 }
Пример #27
0
 function showAssignmentTextObject()
 {
     global $ilCtrl, $ilUser, $lng, $tpl;
     if (!$this->ass || $this->ass->getType() != ilExAssignment::TYPE_TEXT) {
         $ilCtrl->redirect($this, "showOverview");
     }
     $add_rating = null;
     // tutor
     if ((int) $_GET["grd"]) {
         $this->checkPermission("write");
         if ((int) $_GET["grd"] == 1) {
             $user_id = (int) $_GET["member_id"];
             $cancel_cmd = "members";
         } else {
             $user_id = (int) $_GET["part_id"];
             $cancel_cmd = "showParticipant";
         }
     } else {
         if ($this->ass->hasPeerReviewAccess((int) $_GET["member_id"])) {
             $this->checkPermission("read");
             $user_id = (int) $_GET["member_id"];
             $cancel_cmd = "editPeerReview";
             // rating
             $add_rating = "updatePeerReviewText";
             $ilCtrl->setParameter($this, "peer_id", $user_id);
             include_once './Services/Rating/classes/class.ilRatingGUI.php';
             $rating = new ilRatingGUI();
             $rating->setObject($this->ass->getId(), "ass", $user_id, "peer");
             $rating->setUserId($ilUser->getId());
             $rating = '<div id="rtr_widget">' . $rating->getHTML(false, true, "il.ExcPeerReview.saveSingleRating(" . $user_id . ", %rating%)") . '</div>';
             $ilCtrl->setParameter($this, "ssrtg", 1);
             $tpl->addJavaScript("Modules/Exercise/js/ilExcPeerReview.js");
             $tpl->addOnLoadCode("il.ExcPeerReview.setAjax('" . $ilCtrl->getLinkTarget($this, "updatePeerReviewComments", "", true, false) . "')");
             $ilCtrl->setParameter($this, "ssrtg", "");
         } else {
             $this->checkPermission("read");
             $user_id = $ilUser->getId();
             $cancel_cmd = "showOverview";
         }
     }
     $this->tabs_gui->clearTargets();
     $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTarget($this, $cancel_cmd));
     $a_form = $this->initAssignmentTextForm($this->ass, true, $cancel_cmd, $add_rating, $rating);
     if ($user_id != $ilUser->getId() || (bool) $_GET["grd"]) {
         if (!stristr($cancel_cmd, "peer")) {
             include_once "Services/User/classes/class.ilUserUtil.php";
             $a_form->setDescription(ilUserUtil::getNamePresentation($user_id));
         } else {
             if (!$this->ass->hasPeerReviewPersonalized()) {
                 $a_form->setDescription($lng->txt("id") . ": " . (int) $_GET["seq"]);
             } else {
                 include_once "Services/User/classes/class.ilUserUtil.php";
                 $a_form->setDescription(ilUserUtil::getNamePresentation($user_id));
             }
             foreach ($this->ass->getPeerReviewsByPeerId($user_id) as $item) {
                 if ($item["giver_id"] == $ilUser->getId()) {
                     $a_form->getItemByPostVar("comm")->setValue($item["pcomment"]);
                     break;
                 }
             }
         }
     }
     $files = ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $user_id);
     if ($files) {
         $files = array_shift($files);
         if (trim($files["atext"])) {
             $text = $a_form->getItemByPostVar("atxt");
             // mob id to mob src
             $text->setValue(ilRTE::_replaceMediaObjectImageSrc($files["atext"], 1));
         }
     }
     $this->tpl->setContent($a_form->getHTML());
 }
 /**
  * Creates a question from a QTI file
  *
  * Receives parameters from a QTI parser and creates a valid ILIAS question object
  *
  * @param object $item The QTI item object
  * @param integer $questionpool_id The id of the parent questionpool
  * @param integer $tst_id The id of the parent test if the question is part of a test
  * @param object $tst_object A reference to the parent test object
  * @param integer $question_counter A reference to a question counter to count the questions of an imported question pool
  * @param array $import_mapping An array containing references to included ILIAS objects
  * @access public
  */
 function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 {
     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->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->setWidth($item->getMetadataEntry("width"));
     $this->object->setHeight($item->getMetadataEntry("height"));
     $this->object->setApplet($item->getMetadataEntry("applet"));
     $this->object->setParameters(unserialize($item->getMetadataEntry("params")));
     $this->object->setPoints($item->getMetadataEntry("points"));
     $this->object->saveToDb();
     $flashapplet =& base64_decode($item->getMetadataEntry("swf"));
     if (!file_exists($this->object->getFlashPath())) {
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::makeDirParents($this->object->getFlashPath());
     }
     $filename = $this->object->getFlashPath() . $this->object->getApplet();
     $fh = fopen($filename, "wb");
     if ($fh == false) {
         //									global $ilErr;
         //									$ilErr->raiseError($this->object->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
         //									return;
     } else {
         fwrite($fh, $flashapplet);
         fclose($fh);
     }
     $feedbacksgeneric = $this->getFeedbackGeneric($item);
     // 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->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $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, 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);
     }
 }
Пример #29
0
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->getShuffle();
     $result['is_multiple'] = (bool) $this->getIsMultipleChoice();
     $result['feedback'] = array('onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)), 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)));
     $result['image'] = (string) $this->getImagePathWeb() . $this->getImageFilename();
     $answers = array();
     $order = 0;
     foreach ($this->getAnswers() as $key => $answer_obj) {
         array_push($answers, array("answertext" => (string) $answer_obj->getAnswertext(), "points" => (double) $answer_obj->getPoints(), "points_unchecked" => (double) $answer_obj->getPointsUnchecked(), "order" => (int) $order, "coords" => $answer_obj->getCoords(), "state" => $answer_obj->getState(), "area" => $answer_obj->getArea(), "feedback" => ilRTE::_replaceMediaObjectImageSrc($this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0)));
         $order++;
     }
     $result['answers'] = $answers;
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }
Пример #30
0
 /**
  * Returns a JSON representation of the question
  */
 public function toJSON()
 {
     $this->lng->loadLanguageModule('assessment');
     require_once './Services/RTE/classes/class.ilRTE.php';
     $result = array();
     $result['id'] = (int) $this->getId();
     $result['type'] = (string) $this->getQuestionType();
     $result['title'] = (string) $this->getTitle();
     $result['question'] = $this->formatSAQuestion($this->getQuestion());
     $result['instruction'] = $this->getInstructionTextTranslation($this->lng, $this->getOptionLabel());
     $result['nr_of_tries'] = (int) $this->getNrOfTries();
     $result['shuffle'] = (bool) $this->isShuffleAnswersEnabled();
     $result['feedback'] = array('onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)), 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true)));
     $result['trueOptionLabel'] = $this->getTrueOptionLabelTranslation($this->lng, $this->getOptionLabel());
     $result['falseOptionLabel'] = $this->getFalseOptionLabelTranslation($this->lng, $this->getOptionLabel());
     $result['num_allowed_failures'] = $this->getNumAllowedFailures();
     $answers = array();
     $has_image = false;
     foreach ($this->getAnswers() as $key => $answer) {
         if (strlen((string) $answer->getImageFile())) {
             $has_image = true;
         }
         $answers[] = array('answertext' => (string) $this->formatSAQuestion($answer->getAnswertext()), 'correctness' => (bool) $answer->getCorrectness(), 'order' => (int) $answer->getPosition(), 'image' => (string) $answer->getImageFile(), 'feedback' => ilRTE::_replaceMediaObjectImageSrc($this->feedbackOBJ->getSpecificAnswerFeedbackExportPresentation($this->getId(), $key), 0));
     }
     $result['answers'] = $answers;
     if ($has_image) {
         $result['path'] = $this->getImagePathWeb();
         $result['thumb'] = $this->getThumbSize();
     }
     $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId());
     $result['mobs'] = $mobs;
     return json_encode($result);
 }