当前位置: 首页>>代码示例>>PHP>>正文


PHP ilObjMediaObject::_saveTempFileAsMediaObject方法代码示例

本文整理汇总了PHP中ilObjMediaObject::_saveTempFileAsMediaObject方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::_saveTempFileAsMediaObject方法的具体用法?PHP ilObjMediaObject::_saveTempFileAsMediaObject怎么用?PHP ilObjMediaObject::_saveTempFileAsMediaObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilObjMediaObject的用法示例。


在下文中一共展示了ilObjMediaObject::_saveTempFileAsMediaObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fromXML

 /**
  * 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);
     }
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:73,代码来源:class.assOrderingHorizontalImport.php

示例2: importXmlRepresentation

 /**
  * 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;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:49,代码来源:class.ilSurveyImporter.php

示例3: importObject

 /**
  * Imports a survey from XML into the ILIAS database
  *
  * @return boolean True, if the import succeeds, false otherwise
  * @access public
  */
 function importObject($file_info, $svy_qpl_id)
 {
     if ($svy_qpl_id < 1) {
         $svy_qpl_id = -1;
     }
     // check if file was uploaded
     $source = $file_info["tmp_name"];
     $error = "";
     if ($source == 'none' || !$source || $file_info["error"] > UPLOAD_ERR_OK) {
         $error = $this->lng->txt("import_no_file_selected");
     }
     // check correct file type
     $isXml = FALSE;
     $isZip = FALSE;
     if (strcmp($file_info["type"], "text/xml") == 0 || strcmp($file_info["type"], "application/xml") == 0) {
         $isXml = TRUE;
     }
     // too many different mime-types, so we use the suffix
     $suffix = pathinfo($file_info["name"]);
     if (strcmp(strtolower($suffix["extension"]), "zip") == 0) {
         $isZip = TRUE;
     }
     if (!$isXml && !$isZip) {
         $error = $this->lng->txt("import_wrong_file_type");
         global $ilLog;
         $ilLog->write("Survey: Import error. Filetype was \"" . $file_info["type"] . "\"");
     }
     if (strlen($error) == 0) {
         // import file as a survey
         $import_dir = $this->getImportDirectory();
         $import_subdir = "";
         $importfile = "";
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         if ($isZip) {
             $importfile = $import_dir . "/" . $file_info["name"];
             ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
             ilUtil::unzip($importfile);
             $found = $this->locateImportFiles($import_dir);
             if (!(strlen($found["dir"]) > 0 && strlen($found["xml"]) > 0)) {
                 $error = $this->lng->txt("wrong_import_file_structure");
                 return $error;
             }
             $importfile = $found["xml"];
             $import_subdir = $found["dir"];
         } else {
             $importfile = tempnam($import_dir, "survey_import");
             ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
         }
         $fh = fopen($importfile, "r");
         if (!$fh) {
             $error = $this->lng->txt("import_error_opening_file");
             return $error;
         }
         $xml = fread($fh, filesize($importfile));
         $result = fclose($fh);
         if (!$result) {
             $error = $this->lng->txt("import_error_closing_file");
             return $error;
         }
         unset($_SESSION["import_mob_xhtml"]);
         if (strpos($xml, "questestinterop")) {
             include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
             $import = new SurveyImportParserPre38($svy_qpl_id, "", TRUE);
             $import->setSurveyObject($this);
             $import->setXMLContent($xml);
             $import->startParsing();
         } else {
             include_once "./Services/Survey/classes/class.SurveyImportParser.php";
             $import = new SurveyImportParser($svy_qpl_id, "", TRUE);
             $import->setSurveyObject($this);
             $import->setXMLContent($xml);
             $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 = $import_subdir . "/" . $mob["uri"];
                 if (file_exists($importfile)) {
                     $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                     ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $this->getId());
                     $this->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getIntroduction()));
                     $this->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getOutro()));
                 } else {
                     global $ilLog;
                     $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File {$importfile} does not exist!");
                 }
             }
             $this->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 1));
             $this->setOutro(ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 1));
             $this->saveToDb();
         }
         // delete import directory
//.........这里部分代码省略.........
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilObjSurvey.php

示例4: fromXML


//.........这里部分代码省略.........
                                 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);
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:class.assJavaAppletImport.php

示例5: fromXML


//.........这里部分代码省略.........
     $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)");
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.assKprimChoiceImport.php

示例6: fromXML


//.........这里部分代码省略.........
                     }
                 }
             }
         }
     }
     // set question properties
     $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->setAccountsXML(base64_decode($item->getMetadataEntry('accounts_content')));
     $this->object->setPoints($item->getMetadataEntry("points"));
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     // first save the question  without its parts (to get a new question id)
     $this->object->saveToDb('', false);
     // then create the parts
     $parts = unserialize($item->getMetadataEntry('booking_parts'));
     if (is_array($parts)) {
         for ($i = 0; $i < count($parts); $i++) {
             $part = $parts[$i];
             // since plugin version 1.1.7 the text of the questions parts is added as material to the presentation
             // this enables images in the parts text
             // the material index 0 is used for the question text
             if (isset($item->presentation->material[$i + 1])) {
                 $part['text'] = $this->object->QTIMaterialToString($item->presentation->material[$i + 1]);
             }
             // create and add a new part
             $part_obj = $this->object->getPart();
             $part_obj->setPosition($part['position']);
             $part_obj->setText($part['text']);
             $part_obj->setMaxPoints($part['max_points']);
             $part_obj->setMaxLines($part['max_lines']);
             $part_obj->setBookingXML(base64_decode($part['booking_def']));
             $part_obj->write();
         }
     }
     // convert the generic feedback
     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"];
             }
             global $ilLog;
             $ilLog->write($importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             // images in question text
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             // images in question parts
             foreach ($this->object->getParts() as $part_obj) {
                 $part_obj->setText(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $part_obj->getText()));
             }
             // images in feedback
             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 ($this->object->getParts() as $part_obj) {
         $part_obj->setText(ilRTE::_replaceMediaObjectImageSrc($part_obj->getText(), 1));
         $part_obj->write();
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->feedbackOBJ->importGenericFeedback($this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
     }
     // Now save the question again
     // (this also recalculates the maximum points)
     $this->object->saveToDb('', true);
     // import mapping for tests
     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);
     }
 }
开发者ID:ilifau,项目名称:assAccountingQuestion,代码行数:101,代码来源:class.assAccountingQuestionImport.php

示例7: fromXML


//.........这里部分代码省略.........
     $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->setShuffle($shuffle);
     $this->object->setThumbSize($item->getMetadataEntry("thumb_size"));
     foreach ($answers as $answer) {
         if (is_array($answer["imagefile"]) && count($answer["imagefile"]) > 0) {
             $this->object->isSingleline = true;
         }
         $this->object->addAnswer($answer["answertext"], $answer["points"], $answer["answerorder"], $answer["imagefile"]["label"]);
     }
     // 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"];
             $fh = fopen($imagepath, "wb");
             if ($fh == false) {
             } else {
                 $imagefile = fwrite($fh, $image);
                 fclose($fh);
             }
         }
     }
     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;
     }
     // handle the import of media objects in XHTML code
     $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);
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.assSingleChoiceImport.php

示例8: fromXML

 /**
  * 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->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->setOptionString($item->getMetadataEntry("option_string"));
     $this->object->setSampleSolution($item->getMetadataEntry("sample_solution"));
     $this->object->saveToDb('', false);
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 include_once "./Modules/Test/classes/class.ilObjTest.php";
                 $importfile = ilObjTest::_getImportDirectory() . '/' . $mob["uri"];
             } else {
                 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                 $importfile = ilObjQuestionPool::_getImportDirectory() . '/' . $mob["uri"];
             }
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     // feedback
     $feedbacksgeneric = array();
     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;
                             }
                         }
                     }
                 }
             }
         }
     }
     // genericFeedback
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         //$this->object->saveFeedbackGeneric($correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
         $this->object->feedbackOBJ->importGenericFeedback($this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
//.........这里部分代码省略.........
开发者ID:ba-al,项目名称:ILIAS-ChemistryQuestion44,代码行数:101,代码来源:class.assJSMEQuestionImport.php

示例9: fromXML


//.........这里部分代码省略.........
                                     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);
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:class.assTextSubsetImport.php

示例10: fromXML


//.........这里部分代码省略.........
             case "show_marker":
                 $this->setShowMarker($metadata["entry"]);
                 break;
             case "fixed_participants":
                 $this->setFixedParticipants($metadata["entry"]);
                 break;
             case "score_reporting":
                 $this->setScoreReporting($metadata["entry"]);
                 break;
             case "shuffle_questions":
                 $this->setShuffleQuestions($metadata["entry"]);
                 break;
             case "count_system":
                 $this->setCountSystem($metadata["entry"]);
                 break;
             case "mc_scoring":
                 $this->setMCScoring($metadata["entry"]);
                 break;
             case "mailnotification":
                 $this->setMailNotification($metadata["entry"]);
                 break;
             case "mailnottype":
                 $this->setMailNotificationType($metadata["entry"]);
                 break;
             case "exportsettings":
                 $this->setExportSettings($metadata['exportsettings']);
                 break;
             case "score_cutting":
                 $this->setScoreCutting($metadata["entry"]);
                 break;
             case "password":
                 $this->setPassword($metadata["entry"]);
                 break;
             case "allowedUsers":
                 $this->setAllowedUsers($metadata["entry"]);
                 break;
             case "allowedUsersTimeGap":
                 $this->setAllowedUsersTimeGap($metadata["entry"]);
                 break;
             case "pass_scoring":
                 $this->setPassScoring($metadata["entry"]);
                 break;
             case "show_summary":
                 $this->setListOfQuestionsSettings($metadata["entry"]);
                 break;
             case "reporting_date":
                 $iso8601period = $metadata["entry"];
                 if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT(\\d+)H(\\d+)M(\\d+)S/", $iso8601period, $matches)) {
                     $this->setReportingDate(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
                 }
                 break;
             case "processing_time":
                 $this->setProcessingTime($metadata['entry']);
                 break;
             case "starting_time":
                 $iso8601period = $metadata["entry"];
                 if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT(\\d+)H(\\d+)M(\\d+)S/", $iso8601period, $matches)) {
                     $this->setStartingTime(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
                 }
                 break;
             case "ending_time":
                 $iso8601period = $metadata["entry"];
                 if (preg_match("/P(\\d+)Y(\\d+)M(\\d+)DT(\\d+)H(\\d+)M(\\d+)S/", $iso8601period, $matches)) {
                     $this->setEndingTime(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
                 }
                 break;
         }
         if (preg_match("/mark_step_\\d+/", $metadata["label"])) {
             $xmlmark = $metadata["entry"];
             preg_match("/<short>(.*?)<\\/short>/", $xmlmark, $matches);
             $mark_short = $matches[1];
             preg_match("/<official>(.*?)<\\/official>/", $xmlmark, $matches);
             $mark_official = $matches[1];
             preg_match("/<percentage>(.*?)<\\/percentage>/", $xmlmark, $matches);
             $mark_percentage = $matches[1];
             preg_match("/<passed>(.*?)<\\/passed>/", $xmlmark, $matches);
             $mark_passed = $matches[1];
             $this->mark_schema->addMarkStep($mark_short, $mark_official, $mark_percentage, $mark_passed);
         }
     }
     // handle the import of media objects in XHTML code
     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 = ilObjTest::_getImportDirectory() . '/' . $mob["uri"];
             if (file_exists($importfile)) {
                 $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                 ilObjMediaObject::_saveUsage($media_object->getId(), "tst:html", $this->getId());
                 $this->setIntroduction(ilRTE::_replaceMediaObjectImageSrc(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getIntroduction()), 1));
                 $this->setFinalStatement(ilRTE::_replaceMediaObjectImageSrc(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getFinalStatement()), 1));
             } else {
                 global $ilLog;
                 $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File {$importfile} does not exist!");
             }
         }
         $this->saveToDb();
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:class.ilObjTest.php

示例11: handlerEndTag


//.........这里部分代码省略.........
         case 'Post':
             break;
         case 'Censorship':
             $x['Censorship'] = $this->cdata;
             break;
         case 'CensorshipMessage':
             $x['CensorshipMessage'] = $this->cdata;
             break;
         case 'Notification':
             $x['Notification'] = $this->cdata;
             break;
         case 'ImportName':
             $x['ImportName'] = $this->cdata;
             break;
         case 'Status':
             $x['Status'] = $this->cdata;
             break;
         case 'Message':
             $x['Message'] = $this->cdata;
             break;
         case 'Lft':
             $x['Lft'] = $this->cdata;
             break;
         case 'Rgt':
             $x['Rgt'] = $this->cdata;
             break;
         case 'Depth':
             $x['Depth'] = $this->cdata;
             break;
         case 'ParentId':
             $x['ParentId'] = $this->cdata;
             if ($this->entity == 'post' && $this->postArray) {
                 require_once 'Modules/Forum/classes/class.ilForumPost.php';
                 $this->forumPost = new ilForumPost();
                 $this->forumPost->setId($this->postArray['Id']);
                 $this->forumPost->setCensorship($this->postArray['Censorship']);
                 $this->forumPost->setCensorshipComment($this->postArray['CensorshipMessage']);
                 $this->forumPost->setNotification($this->postArray['Notification']);
                 $this->forumPost->setImportName($this->postArray['ImportName']);
                 $this->forumPost->setStatus($this->postArray['Status']);
                 $this->forumPost->setMessage($this->postArray['Message']);
                 $this->forumPost->setSubject($this->postArray['Subject']);
                 $this->forumPost->setLft($this->postArray['Lft']);
                 $this->forumPost->setRgt($this->postArray['Rgt']);
                 $this->forumPost->setDepth($this->postArray['Depth']);
                 $this->forumPost->setParentId($this->postArray['ParentId']);
                 $this->forumPost->setThread($this->forumThread);
                 $this->forumPost->setThreadId($this->lastHandledThreadId);
                 $this->forumPost->setForumId($this->lastHandledForumId);
                 $this->forumPost->setCreateDate($this->postArray['CreateDate']);
                 $this->forumPost->setChangeDate($this->postArray['UpdateDate']);
                 $usr_data = $this->getUserIdAndAlias($this->postArray['UserId'], $this->postArray['Alias']);
                 $update_usr_data = $this->getUserIdAndAlias($this->postArray['UpdateUserId']);
                 $this->forumPost->setUserId($usr_data['usr_id']);
                 $this->forumPost->setUserAlias($usr_data['usr_alias']);
                 $this->forumPost->setUpdateUserId($update_usr_data['usr_id']);
                 $this->forumPost->insert();
                 if ($this->mapping['pos'][$this->postArray['ParentId']]) {
                     $parentId = $this->mapping['pos'][$this->postArray['ParentId']];
                 } else {
                     $parentId = 0;
                 }
                 $postTreeNodeId = $ilDB->nextId('frm_posts_tree');
                 $ilDB->insert('frm_posts_tree', array('fpt_pk' => array('integer', $postTreeNodeId), 'thr_fk' => array('integer', $this->lastHandledThreadId), 'pos_fk' => array('integer', $this->forumPost->getId()), 'parent_pos' => array('integer', $parentId), 'lft' => array('integer', $this->postArray['Lft']), 'rgt' => array('integer', $this->postArray['Rgt']), 'depth' => array('integer', $this->postArray['Depth']), 'fpt_date' => array('timestamp', date('Y-m-d H:i:s'))));
                 $this->mapping['pos'][$this->postArray['Id']] = $this->forumPost->getId();
                 $this->lastHandledPostId = $this->forumPost->getId();
                 $media_objects_found = false;
                 foreach ($this->mediaObjects as $mob_attr) {
                     $importfile = $this->getImportDirectory() . '/' . $mob_attr['uri'];
                     if (file_exists($importfile)) {
                         $mob = ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, false);
                         ilObjMediaObject::_saveUsage($mob->getId(), "frm:html", $this->forumPost->getId());
                         $this->forumPost->setMessage(str_replace(array("src=\"" . $mob_attr["label"] . "\"", "src=\"" . preg_replace("/(il)_[\\d]+_(mob)_([\\d]+)/", "\$1_0_\$2_\$3", $mob_attr["label"]) . "\""), "src=\"" . "il_" . IL_INST_ID . "_mob_" . $mob->getId() . "\"", $this->forumPost->getMessage()));
                         $media_objects_found = true;
                     }
                 }
                 if ($media_objects_found) {
                     $this->forumPost->update();
                 }
                 unset($this->postArray);
             }
             break;
         case 'Content':
             $x['content'] = $this->cdata;
             break;
         case 'Attachment':
             $filedata = new ilFileDataForum($this->forum->getId(), $this->lastHandledPostId);
             $importPath = $this->contentArray['content'];
             if (strlen($importPath)) {
                 $importPath = $this->getImportDirectory() . '/' . $importPath;
                 $newFilename = preg_replace("/^\\d+_\\d+(_.*)/ims", $this->forum->getId() . "_" . $this->lastHandledPostId . "\$1", basename($importPath));
                 $path = $filedata->getForumPath();
                 $newPath = $path . '/' . $newFilename;
                 @copy($importPath, $newPath);
             }
             break;
     }
     $this->cdata = '';
     return;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilForumXMLParser.php

示例12: fromXML


//.........这里部分代码省略.........
                                                         foreach ($fmat->material as $material) {
                                                             $feedbacks[$ident] = $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"]);
     $areas = array("2" => "rect", "1" => "circle", "3" => "poly");
     $this->object->setImageFilename($questionimage["label"]);
     foreach ($answers as $answer) {
         $this->object->addAnswer($answer["answerhint"], $answer["points"], $answer["answerorder"], $answer["coordinates"], $areas[$answer["areatype"]]);
     }
     $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();
     }
     $image =& base64_decode($questionimage["content"]);
     $imagepath = $this->object->getImagePath();
     if (!file_exists($imagepath)) {
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::makeDirParents($imagepath);
     }
     $imagepath .= $questionimage["label"];
     $fh = fopen($imagepath, "wb");
     if ($fh == false) {
         //									global $ilErr;
         //									$ilErr->raiseError($this->object->lng->txt("error_save_image_file") . ": $php_errormsg", $ilErr->MESSAGE);
         //									return;
     } else {
         $imagefile = fwrite($fh, $image);
         fclose($fh);
     }
     // 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();
     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 ($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 ($feedbacks as $ident => $material) {
         $this->object->saveFeedbackSingleAnswer($ident, ilRTE::_replaceMediaObjectImageSrc($material, 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);
     }
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:class.assImagemapQuestionImport.php

示例13: fromXML


//.........这里部分代码省略.........
     $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"]);
     $extended_shuffle = $item->getMetadataEntry("shuffle");
     $this->object->setThumbGeometry($item->getMetadataEntry("thumb_geometry"));
     $this->object->setElementHeight($item->getMetadataEntry("element_height"));
     // save images
     foreach ($terms as $term) {
         if (count($term['answerimage'])) {
             $this->saveImage($term['answerimage']['content'], $term['answerimage']['label']);
         }
     }
     foreach ($definitions as $definition) {
         if (count($definition['answerimage'])) {
             $this->saveImage($definition['answerimage']['content'], $definition['answerimage']['label']);
         }
     }
     foreach ($terms as $termindex => $term) {
         $this->object->addTerm(new assAnswerMatchingTerm($term["term"], $term['answerimage']['label'], $term["ident"]));
     }
     foreach ($definitions as $definitionindex => $definition) {
         $this->object->addDefinition(new assAnswerMatchingDefinition($definition["answertext"], $definition['answerimage']['label'], $definition["answerorder"]));
     }
     if (strlen($extended_shuffle) > 0) {
         $shuffle = $extended_shuffle;
     }
     $this->object->setShuffle($shuffle);
     foreach ($responses as $response) {
         $subset = $response["subset"];
         foreach ($subset as $ident) {
             if (array_key_exists($ident, $definitions)) {
                 $definition = $definitions[$ident];
             }
             if (array_key_exists($ident, $terms)) {
                 $term = $terms[$ident];
             }
         }
         $this->object->addMatchingPair(new assAnswerMatchingTerm('', '', $term["ident"]), new assAnswerMatchingDefinition('', '', $definition["answerorder"]), $response['points']);
     }
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     $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 ($responses as $response) {
         $subset = $response["subset"];
         foreach ($subset as $ident) {
             if (array_key_exists($ident, $definitions)) {
                 $definition = $definitions[$ident];
             }
             if (array_key_exists($ident, $terms)) {
                 $term = $terms[$ident];
             }
         }
     }
     foreach ($feedbacksgeneric as $correctness => $material) {
         $m = $this->object->QTIMaterialToString($material);
         $feedbacksgeneric[$correctness] = $m;
     }
     // handle the import of media objects in XHTML code
     $questiontext = $this->object->getQuestion();
     if (is_array($_SESSION["import_mob_xhtml"])) {
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Services/RTE/classes/class.ilRTE.php";
         foreach ($_SESSION["import_mob_xhtml"] as $mob) {
             if ($tst_id > 0) {
                 $importfile = $this->getTstImportArchivDirectory() . '/' . $mob["uri"];
             } else {
                 $importfile = $this->getQplImportArchivDirectory() . '/' . $mob["uri"];
             }
             $GLOBALS['ilLog']->write(__METHOD__ . ': import mob from dir: ' . $importfile);
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
             foreach ($feedbacksgeneric as $correctness => $material) {
                 $feedbacksgeneric[$correctness] = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $material);
             }
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     foreach ($feedbacksgeneric as $correctness => $material) {
         $this->object->feedbackOBJ->importGenericFeedback($this->object->getId(), $correctness, ilRTE::_replaceMediaObjectImageSrc($material, 1));
     }
     $this->object->saveToDb();
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true, null, null, null, $tst_id);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.assMatchingQuestionImport.php

示例14: fromXML

 /**
  * 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->setComment($item->getComment());
     $this->object->setAuthor($item->getAuthor());
     $this->object->setOwner($ilUser->getId());
     $this->object->setQuestion($this->object->QTIMaterialToString($item->getQuestiontext()));
     $this->object->setObjId($questionpool_id);
     $this->object->setEstimatedWorkingTime($duration["h"], $duration["m"], $duration["s"]);
     if (preg_match_all("/(\\\$v\\d+)/ims", $this->object->getQuestion(), $matches)) {
         foreach ($matches[1] as $variable) {
             $data = unserialize($item->getMetadataEntry($variable));
             $unit = $this->object->getUnitRepository()->getUnit($data["unitvalue"]);
             require_once 'Modules/TestQuestionPool/classes/class.assFormulaQuestionVariable.php';
             $varObj = new assFormulaQuestionVariable($variable, $data["rangemin"], $data["rangemax"], $unit, $data["precision"], $data["intprecision"]);
             $this->object->addVariable($varObj);
         }
     }
     if (preg_match_all("/(\\\$r\\d+)/ims", $this->object->getQuestion(), $rmatches)) {
         foreach ($rmatches[1] as $result) {
             $data = unserialize($item->getMetadataEntry($result));
             $unit = $this->object->getUnitRepository()->getUnit($data["unitvalue"]);
             require_once 'Modules/TestQuestionPool/classes/class.assFormulaQuestionResult.php';
             if (!is_array($data["rating"])) {
                 $resObj = new assFormulaQuestionResult($result, $data["rangemin"], $data["rangemax"], $data["tolerance"], $unit, $data["formula"], $data["points"], $data["precision"], TRUE);
             } else {
                 $resObj = new assFormulaQuestionResult($result, $data["rangemin"], $data["rangemax"], $data["tolerance"], $unit, $data["formula"], $data["points"], $data["precision"], FALSE, $data["rating"]["sign"], $data["rating"]["value"], $data["rating"]["unit"]);
             }
             $this->object->addResult($resObj);
             if (is_array($data["resultunits"])) {
                 foreach ($data["resultunits"] as $resu) {
                     $ru = $this->object->getUnitRepository()->getUnit($resu["unitvalue"]);
                     if (is_object($ru)) {
                         $this->object->addResultUnit($resObj, $ru);
                     }
                 }
             }
         }
     }
     $this->object->setPoints($item->getMetadataEntry("points"));
     $this->addGeneralMetadata($item);
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->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) {
                 include_once "./Modules/Test/classes/class.ilObjTest.php";
                 $importfile = ilObjTest::_getImportDirectory() . "/" . $_SESSION["tst_import_subdir"] . "/" . $mob["uri"];
             } else {
                 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                 $importfile = ilObjQuestionPool::_getImportDirectory() . "/" . $_SESSION["qpl_import_subdir"] . "/" . $mob["uri"];
             }
             $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
             ilObjMediaObject::_saveUsage($media_object->getId(), "qpl:html", $this->object->getId());
             $questiontext = str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $questiontext);
         }
     }
     $this->object->setQuestion(ilRTE::_replaceMediaObjectImageSrc($questiontext, 1));
     // additional content editing mode information
     $this->object->setAdditionalContentEditingMode($this->fetchAdditionalContentEditingModeInformation($item));
     $this->object->saveToDb();
     if (count($item->suggested_solutions)) {
         foreach ($item->suggested_solutions as $suggested_solution) {
             $this->object->setSuggestedSolution($suggested_solution["solution"]->getContent(), $suggested_solution["gap_index"], true);
         }
         $this->object->saveToDb();
     }
     if ($tst_id > 0) {
         $q_1_id = $this->object->getId();
         $question_id = $this->object->duplicate(true);
         $tst_object->questions[$question_counter++] = $question_id;
         $import_mapping[$item->getIdent()] = array("pool" => $q_1_id, "test" => $question_id);
     } else {
         $import_mapping[$item->getIdent()] = array("pool" => $this->object->getId(), "test" => 0);
//.........这里部分代码省略.........
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.assFormulaQuestionImport.php

示例15: saveTempFileAsMediaObject

 function saveTempFileAsMediaObject($sid, $name, $tmp_name)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     return ilObjMediaObject::_saveTempFileAsMediaObject($name, $tmp_name);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:10,代码来源:class.ilSoapUtils.php


注:本文中的ilObjMediaObject::_saveTempFileAsMediaObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。