コード例 #1
0
 /**
  * form for new survey object import
  */
 public function importFileObject()
 {
     global $tpl, $ilErr;
     $parent_id = $_GET["ref_id"];
     $new_type = $_REQUEST["new_type"];
     // create permission is already checked in createObject. This check here is done to prevent hacking attempts
     if (!$this->checkPermissionBool("create", "", $new_type)) {
         $ilErr->raiseError($this->lng->txt("no_create_permission"));
     }
     $this->lng->loadLanguageModule($new_type);
     $this->ctrl->setParameter($this, "new_type", $new_type);
     $form = $this->initImportForm($new_type);
     if ($form->checkInput()) {
         include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
         $newObj = new ilObjSurveyQuestionPool();
         $newObj->setType($new_type);
         $newObj->setTitle("dummy");
         $newObj->create(true);
         $this->putObjectInTree($newObj);
         $newObj->createImportDirectory();
         // copy uploaded file to import directory
         $upload = $_FILES["importfile"];
         $file = pathinfo($upload["name"]);
         $full_path = $newObj->getImportDirectory() . "/" . $upload["name"];
         include_once "./Services/Utilities/classes/class.ilUtil.php";
         ilUtil::moveUploadedFile($upload["tmp_name"], $upload["name"], $full_path);
         // import qti data
         $qtiresult = $newObj->importObject($full_path);
         ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
         ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjSurveyQuestionPoolGUI");
     }
     // display form to correct errors
     $form->setValuesByPost();
     $tpl->setContent($form->getHtml());
 }
コード例 #2
0
 protected function createQuestionPool($name = "dummy")
 {
     global $tree;
     $parent_ref = $tree->getParentId($this->object->getRefId());
     include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
     $qpl = new ilObjSurveyQuestionPool();
     $qpl->setType("spl");
     $qpl->setTitle($name);
     $qpl->setDescription("");
     $qpl->create();
     $qpl->createReference();
     $qpl->putInTree($parent_ref);
     $qpl->setPermissions($parent_ref);
     $qpl->setOnline(1);
     // must be online to be available
     $qpl->saveToDb();
     return $qpl->getRefId();
 }