/**
  * Overwriten Metadata update listener for ECS functionalities
  *
  * @access public
  * 
  */
 public function MDUpdateListener($a_element)
 {
     global $ilLog;
     parent::MDUpdateListener($a_element);
     $md = new ilMD($this->getId(), 0, $this->getType());
     if (!is_object($md_gen = $md->getGeneral())) {
         return false;
     }
     $title = $md_gen->getTitle();
     foreach ($md_gen->getDescriptionIds() as $id) {
         $md_des = $md_gen->getDescription($id);
         $description = $md_des->getDescription();
         break;
     }
     switch ($a_element) {
         case 'General':
             include_once './Modules/WebResource/classes/class.ilLinkResourceItems.php';
             if (ilLinkResourceItems::lookupNumberOfLinks($this->getId()) == 1) {
                 $link_arr = ilLinkResourceItems::_getFirstLink($this->getId());
                 $link = new ilLinkResourceItems($this->getId());
                 $link->readItem($link_arr['link_id']);
                 $link->setTitle($title);
                 $link->setDescription($description);
                 $link->update();
             }
             break;
         default:
             return true;
     }
     return true;
 }
 /**
  * copy chapter
  */
 function copy($a_target_lm)
 {
     $chap = new ilStructureObject($a_target_lm);
     $chap->setTitle($this->getTitle());
     if ($this->getLMId() != $a_target_lm->getId()) {
         $chap->setImportId("il__st_" . $this->getId());
     }
     $chap->setLMId($a_target_lm->getId());
     $chap->setType($this->getType());
     $chap->setDescription($this->getDescription());
     $chap->create(true);
     $a_copied_nodes[$this->getId()] = $chap->getId();
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getLMId(), $this->getId(), $this->getType());
     $new_md =& $md->cloneMD($a_target_lm->getId(), $chap->getId(), $this->getType());
     return $chap;
 }
 /**
  * @param ilPropertyFormGUI $form
  */
 private function addGeneralProperties(ilPropertyFormGUI $form)
 {
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("tst_general_properties"));
     $form->addItem($header);
     // title & description (meta data)
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
     $md_section = $md_obj->getGeneral();
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setRequired(true);
     $title->setValue($md_section->getTitle());
     $form->addItem($title);
     $ids = $md_section->getDescriptionIds();
     if ($ids) {
         $desc_obj = $md_section->getDescription(array_pop($ids));
         $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
         $desc->setCols(50);
         $desc->setRows(4);
         $desc->setValue($desc_obj->getDescription());
         $form->addItem($desc);
     }
     // pool usage
     $pool_usage = new ilRadioGroupInputGUI($this->lng->txt('test_question_pool_usage'), 'use_pool');
     $optional_qpl = new ilRadioOption($this->lng->txt('test_question_pool_usage_optional'), 1);
     $optional_qpl->setInfo($this->lng->txt('test_question_pool_usage_optional_info'));
     $pool_usage->addOption($optional_qpl);
     $tst_directly = new ilRadioOption($this->lng->txt('test_question_pool_usage_tst_directly'), 0);
     $tst_directly->setInfo($this->lng->txt('test_question_pool_usage_tst_directly_info'));
     $pool_usage->addOption($tst_directly);
     $pool_usage->setValue($this->testOBJ->getPoolUsage() ? 1 : 0);
     $form->addItem($pool_usage);
     // test mode (question set type)
     $questSetType = new ilRadioGroupInputGUI($this->lng->txt("tst_question_set_type"), 'question_set_type');
     $questSetTypeFixed = new ilRadioOption($this->lng->txt("tst_question_set_type_fixed"), ilObjTest::QUESTION_SET_TYPE_FIXED, $this->lng->txt("tst_question_set_type_fixed_desc"));
     $questSetType->addOption($questSetTypeFixed);
     $questSetTypeRandom = new ilRadioOption($this->lng->txt("tst_question_set_type_random"), ilObjTest::QUESTION_SET_TYPE_RANDOM, $this->lng->txt("tst_question_set_type_random_desc"));
     $questSetType->addOption($questSetTypeRandom);
     $questSetTypeContinues = new ilRadioOption($this->lng->txt("tst_question_set_type_dynamic"), ilObjTest::QUESTION_SET_TYPE_DYNAMIC, $this->lng->txt("tst_question_set_type_dynamic_desc"));
     $questSetType->addOption($questSetTypeContinues);
     $questSetType->setValue($this->testOBJ->getQuestionSetType());
     if ($this->testOBJ->participantDataExist()) {
         $questSetType->setDisabled(true);
     }
     $form->addItem($questSetType);
 }
 /**
  * Paste item (tree) from clipboard or other learning module to target scorm learning module
  *
  * @param object $a_target_slm target scorm 2004 learning module object
  * @param int $a_item_id id of item that should be pasted
  * @param int $a_parent_id parent id in target tree,
  * @param int $a_target predecessor target node, no ID means: last child
  * @param string $a_insert_time cliboard insert time (not needed, if $a_from_cliboard is false)
  * @param array $a_copied_nodes array of IDs od copied nodes, key is ID of source node, value is ID of copied node
  * @param bool $a_as_copy if true, items are copied otherwise they are moved
  * @param bool $a_from_clipboard if true, child node information is read from clipboard, otherwise from source tree
  */
 static function pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy = false, $a_from_clipboard = true)
 {
     global $ilUser, $ilias, $ilLog;
     // source lm id, item type and lm object
     $item_slm_id = ilSCORM2004Node::_lookupSLMID($a_item_id);
     $item_type = ilSCORM2004Node::_lookupType($a_item_id);
     //$slm_obj = $ilias->obj_factory->getInstanceByObjId($item_slm_id);
     include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
     $slm_obj = new ilObjSCORM2004LearningModule($item_slm_id, false);
     if ($item_type == "chap") {
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php";
         $item = new ilSCORM2004Chapter($slm_obj, $a_item_id);
     } else {
         if ($item_type == "page") {
             include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php";
             $item = new ilSCORM2004PageNode($slm_obj, $a_item_id);
         } else {
             if ($item_type == "sco") {
                 include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
                 $item = new ilSCORM2004Sco($slm_obj, $a_item_id);
             } else {
                 if ($item_type == "ass") {
                     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php";
                     $item = new ilSCORM2004Asset($slm_obj, $a_item_id);
                 }
             }
         }
     }
     $ilLog->write("Getting from clipboard type " . $item_type . ", " . "Item ID: " . $a_item_id . ", of original SLM: " . $item_slm_id);
     if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy) {
         // @todo: check whether st is NOT in tree
         // "move" metadata to new lm
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($item_slm_id, $item->getId(), $item->getType());
         $new_md = $md->cloneMD($a_target_slm->getId(), $item->getId(), $item->getType());
         // update lm object
         $item->setSLMId($a_target_slm->getId());
         $item->setSLMObject($a_target_slm);
         $item->update();
         // delete old meta data set
         $md->deleteAll();
         if ($item_type == "page") {
             $page = $item->getPageObject();
             $page->buildDom($a_from_clipboard);
             $page->setParentId($a_target_slm->getId());
             $page->update();
         }
     }
     if ($a_as_copy) {
         $target_item = $item->copy($a_target_slm);
         $a_copied_nodes[$item->getId()] = $target_item->getId();
     } else {
         $target_item = $item;
     }
     $ilLog->write("Putting into tree type " . $target_item->getType() . "Item ID: " . $target_item->getId() . ", Parent: " . $a_parent_id . ", " . "Target: " . $a_target . ", Item LM:" . $target_item->getContentObject()->getId());
     ilSCORM2004Node::putInTree($target_item, $a_parent_id, $a_target);
     if ($a_from_clipboard) {
         $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time);
     } else {
         // get childs of source tree
         $source_tree = $slm_obj->getTree();
         $childs = $source_tree->getChilds($a_item_id);
     }
     foreach ($childs as $child) {
         $child_id = $a_from_clipboard ? $child["id"] : $child["child"];
         ilSCORM2004Node::pasteTree($a_target_slm, $child_id, $target_item->getId(), IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy);
     }
     return $target_item->getId();
 }
 /**
  * copy page node
  */
 function copy($a_target_slm)
 {
     // copy page
     $slm_page = new ilSCORM2004PageNode($a_target_slm);
     $slm_page->setTitle($this->getTitle());
     $slm_page->setSLMId($a_target_slm->getId());
     $slm_page->setType($this->getType());
     $slm_page->setDescription($this->getDescription());
     $slm_page->setImportId("il__page_" . $this->getId());
     $slm_page->create(true);
     // setting "upload" flag to true prevents creating of meta data
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
     $new_md = $md->cloneMD($a_target_slm->getId(), $slm_page->getId(), $this->getType());
     // copy page content
     $page = $slm_page->getPageObject();
     // clone media objects, if source and target lm are not the same
     $clone_mobs = $this->getSLMId() == $a_target_slm->getId() ? false : true;
     $this->page_object->copy($page->getId(), $page->getParentType(), $page->getParentId(), $clone_mobs);
     //$page->setXMLContent($this->page_object->copyXMLContent($clone_mobs));
     //$page->buildDom();
     //$page->update();
     return $slm_page;
 }
 /**
 * Creates a 1:1 copy of the object and places the copy in a given repository
 *
 * @access public
 */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     $newObj->setOnline($this->getOnline());
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQplQuestions();
     foreach ($questions as $question_id) {
         $newObj->copyQuestion($question_id, $newObj->getId());
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     return $newObj;
 }
 /**
  * Init survey settings form
  * 
  * @return ilPropertyFormGUI
  */
 function initPropertiesForm()
 {
     $template_settings = $hide_rte_switch = null;
     $template = $this->object->getTemplate();
     if ($template) {
         include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
         $template = new ilSettingsTemplate($template);
         $template_settings = $template->getSettings();
         $hide_rte_switch = $template_settings["rte_switch"]["hide"];
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTableWidth("100%");
     $form->setId("survey_properties");
     // general properties
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("settings"));
     $form->addItem($header);
     // title & description (meta data)
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md_obj = new ilMD($this->object->getId(), 0, "svy");
     $md_section = $md_obj->getGeneral();
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setRequired(true);
     $title->setValue($md_section->getTitle());
     $form->addItem($title);
     $ids = $md_section->getDescriptionIds();
     if ($ids) {
         $desc_obj = $md_section->getDescription(array_pop($ids));
         $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
         $desc->setCols(50);
         $desc->setRows(4);
         $desc->setValue($desc_obj->getDescription());
         $form->addItem($desc);
     }
     // pool usage
     $pool_usage = new ilRadioGroupInputGUI($this->lng->txt("survey_question_pool_usage"), "use_pool");
     $opt = new ilRadioOption($this->lng->txt("survey_question_pool_usage_active"), 1);
     $opt->setInfo($this->lng->txt("survey_question_pool_usage_active_info"));
     $pool_usage->addOption($opt);
     $opt = new ilRadioOption($this->lng->txt("survey_question_pool_usage_inactive"), 0);
     $opt->setInfo($this->lng->txt("survey_question_pool_usage_inactive_info"));
     $pool_usage->addOption($opt);
     $pool_usage->setValue($this->object->getPoolUsage());
     $form->addItem($pool_usage);
     // 360°: appraisees
     if ($this->object->get360Mode()) {
         $self_eval = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_evaluation"), "self_eval");
         $self_eval->setInfo($this->lng->txt("survey_360_self_evaluation_info"));
         $self_eval->setChecked($this->object->get360SelfEvaluation());
         $form->addItem($self_eval);
         $self_rate = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_raters"), "self_rate");
         $self_rate->setInfo($this->lng->txt("survey_360_self_raters_info"));
         $self_rate->setChecked($this->object->get360SelfRaters());
         $form->addItem($self_rate);
         $self_appr = new ilCheckboxInputGUI($this->lng->txt("survey_360_self_appraisee"), "self_appr");
         $self_appr->setInfo($this->lng->txt("survey_360_self_appraisee_info"));
         $self_appr->setChecked($this->object->get360SelfAppraisee());
         $form->addItem($self_appr);
     }
     // activation
     include_once "Services/Object/classes/class.ilObjectActivation.php";
     $this->lng->loadLanguageModule('rep');
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('rep_activation_availability'));
     $form->addItem($section);
     // additional info only with multiple references
     $act_obj_info = $act_ref_info = "";
     if (sizeof(ilObject::_getAllReferences($this->object->getId())) > 1) {
         $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
         $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
     }
     $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
     $online->setInfo($this->lng->txt('svy_activation_online_info') . $act_obj_info);
     $online->setChecked($this->object->isOnline());
     $form->addItem($online);
     $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'), 'access_type');
     // $act_type->setInfo($this->lng->txt('svy_availability_until_info'));
     $act_type->setChecked($this->object->isActivationLimited());
     $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
     include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
     $dur = new ilDateDurationInputGUI($this->lng->txt('rep_time_period'), "access_period");
     $dur->setShowTime(true);
     $date = $this->object->getActivationStartDate();
     $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
     $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
     $date = $this->object->getActivationEndDate();
     $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
     $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
     $act_type->addSubItem($dur);
     $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'access_visiblity');
     $visible->setInfo($this->lng->txt('svy_activation_limited_visibility_info'));
     $visible->setChecked($this->object->getActivationVisibility());
     $act_type->addSubItem($visible);
     $form->addItem($act_type);
     // before start
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('svy_settings_section_before_start'));
     $form->addItem($section);
     // introduction
     $intro = new ilTextAreaInputGUI($this->lng->txt("introduction"), "introduction");
     $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
     $intro->setRows(10);
     $intro->setCols(80);
     $intro->setUseRte(TRUE);
     $intro->setInfo($this->lng->txt("survey_introduction_info"));
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $intro->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
     $intro->addPlugin("latex");
     $intro->addButton("latex");
     $intro->addButton("pastelatex");
     $intro->setRTESupport($this->object->getId(), "svy", "survey", null, $hide_rte_switch);
     $form->addItem($intro);
     // access
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('svy_settings_section_access'));
     $form->addItem($section);
     // enable start date
     $start = $this->object->getStartDate();
     $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("start_date"), "enabled_start_date");
     $enablestartingtime->setValue(1);
     // $enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
     $enablestartingtime->setChecked($start);
     // start date
     $startingtime = new ilDateTimeInputGUI('', 'start_date');
     $startingtime->setShowTime(true);
     if ($start) {
         $startingtime->setDate(new ilDate($start, IL_CAL_TIMESTAMP));
     }
     $enablestartingtime->addSubItem($startingtime);
     $form->addItem($enablestartingtime);
     // enable end date
     $end = $this->object->getEndDate();
     $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("end_date"), "enabled_end_date");
     $enableendingtime->setValue(1);
     // $enableendingtime->setOptionTitle($this->lng->txt("enabled"));
     $enableendingtime->setChecked($end);
     // end date
     $endingtime = new ilDateTimeInputGUI('', 'end_date');
     $endingtime->setShowTime(true);
     if ($end) {
         $endingtime->setDate(new ilDate($end, IL_CAL_TIMESTAMP));
     }
     $enableendingtime->addSubItem($endingtime);
     $form->addItem($enableendingtime);
     // anonymization
     if (!$this->object->get360Mode()) {
         $codes = new ilCheckboxInputGUI($this->lng->txt("survey_access_codes"), "acc_codes");
         $codes->setInfo($this->lng->txt("survey_access_codes_info"));
         $codes->setChecked(!$this->object->isAccessibleWithoutCode());
         $form->addItem($codes);
         if ($this->object->_hasDatasets($this->object->getSurveyId())) {
             $codes->setDisabled(true);
         }
     }
     // question behaviour
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('svy_settings_section_question_behaviour'));
     $form->addItem($section);
     // show question titles
     $show_question_titles = new ilCheckboxInputGUI($this->lng->txt("svy_show_questiontitles"), "show_question_titles");
     $show_question_titles->setValue(1);
     $show_question_titles->setChecked($this->object->getShowQuestionTitles());
     $form->addItem($show_question_titles);
     // finishing
     $info = new ilFormSectionHeaderGUI();
     $info->setTitle($this->lng->txt("svy_settings_section_finishing"));
     $form->addItem($info);
     $view_own = new ilCheckboxInputGUI($this->lng->txt("svy_results_view_own"), "view_own");
     $view_own->setInfo($this->lng->txt("svy_results_view_own_info"));
     $view_own->setChecked($this->object->hasViewOwnResults());
     $form->addItem($view_own);
     $mail_own = new ilCheckboxInputGUI($this->lng->txt("svy_results_mail_own"), "mail_own");
     $mail_own->setInfo($this->lng->txt("svy_results_mail_own_info"));
     $mail_own->setChecked($this->object->hasMailOwnResults());
     $form->addItem($mail_own);
     // final statement
     $finalstatement = new ilTextAreaInputGUI($this->lng->txt("outro"), "outro");
     $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getOutro()));
     $finalstatement->setRows(10);
     $finalstatement->setCols(80);
     $finalstatement->setUseRte(TRUE);
     $finalstatement->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
     $finalstatement->addPlugin("latex");
     $finalstatement->addButton("latex");
     $finalstatement->addButton("pastelatex");
     $finalstatement->setRTESupport($this->object->getId(), "svy", "survey", null, $hide_rte_switch);
     $form->addItem($finalstatement);
     // mail notification
     $mailnotification = new ilCheckboxInputGUI($this->lng->txt("mailnotification"), "mailnotification");
     // $mailnotification->setOptionTitle($this->lng->txt("activate"));
     $mailnotification->setInfo($this->lng->txt("svy_result_mail_notification_info"));
     // #11762
     $mailnotification->setValue(1);
     $mailnotification->setChecked($this->object->getMailNotification());
     // addresses
     $mailaddresses = new ilTextInputGUI($this->lng->txt("mailaddresses"), "mailaddresses");
     $mailaddresses->setValue($this->object->getMailAddresses());
     $mailaddresses->setSize(80);
     $mailaddresses->setInfo($this->lng->txt('mailaddresses_info'));
     $mailaddresses->setRequired(true);
     // participant data
     $participantdata = new ilTextAreaInputGUI($this->lng->txt("mailparticipantdata"), "mailparticipantdata");
     $participantdata->setValue($this->object->getMailParticipantData());
     $participantdata->setRows(6);
     $participantdata->setCols(80);
     $participantdata->setUseRte(false);
     $participantdata->setInfo($this->lng->txt("mailparticipantdata_info"));
     // #12755 - because of privacy concerns we restrict user data to a minimum
     $placeholders = array("FIRST_NAME" => "firstname", "LAST_NAME" => "lastname", "LOGIN" => "login");
     $txt = array();
     foreach ($placeholders as $placeholder => $caption) {
         $txt[] = "[" . strtoupper($placeholder) . "]: " . $this->lng->txt($caption);
     }
     $txt = implode("<br />", $txt);
     $participantdatainfo = new ilNonEditableValueGUI($this->lng->txt("mailparticipantdata_placeholder"), "", true);
     $participantdatainfo->setValue($txt);
     $mailnotification->addSubItem($mailaddresses);
     $mailnotification->addSubItem($participantdata);
     $mailnotification->addSubItem($participantdatainfo);
     $form->addItem($mailnotification);
     // tutor notification - currently not available for 360°
     if (!$this->object->get360Mode()) {
         // parent course?
         global $tree;
         $has_parent = $tree->checkForParentType($this->object->getRefId(), "grp");
         if (!$has_parent) {
             $has_parent = $tree->checkForParentType($this->object->getRefId(), "crs");
         }
         $num_inv = sizeof($this->object->getInvitedUsers());
         // notification
         $tut = new ilCheckboxInputGUI($this->lng->txt("survey_notification_tutor_setting"), "tut");
         $tut->setChecked($this->object->getTutorNotificationStatus());
         $form->addItem($tut);
         $tut_logins = array();
         $tuts = $this->object->getTutorNotificationRecipients();
         if ($tuts) {
             foreach ($tuts as $tut_id) {
                 $tmp = ilObjUser::_lookupName($tut_id);
                 if ($tmp["login"]) {
                     $tut_logins[] = $tmp["login"];
                 }
             }
         }
         $tut_ids = new ilTextInputGUI($this->lng->txt("survey_notification_tutor_recipients"), "tut_ids");
         $tut_ids->setDataSource($this->ctrl->getLinkTarget($this, "doAutoComplete", "", true));
         $tut_ids->setRequired(true);
         $tut_ids->setMulti(true);
         $tut_ids->setMultiValues($tut_logins);
         $tut_ids->setValue(array_shift($tut_logins));
         $tut->addSubItem($tut_ids);
         $tut_grp = new ilRadioGroupInputGUI($this->lng->txt("survey_notification_target_group"), "tut_grp");
         $tut_grp->setRequired(true);
         $tut_grp->setValue($this->object->getTutorNotificationTarget());
         $tut->addSubItem($tut_grp);
         $tut_grp_crs = new ilRadioOption($this->lng->txt("survey_notification_target_group_parent_course"), ilObjSurvey::NOTIFICATION_PARENT_COURSE);
         if (!$has_parent) {
             $tut_grp_crs->setInfo($this->lng->txt("survey_notification_target_group_parent_course_inactive"));
         }
         $tut_grp->addOption($tut_grp_crs);
         $tut_grp_inv = new ilRadioOption($this->lng->txt("survey_notification_target_group_invited"), ilObjSurvey::NOTIFICATION_INVITED_USERS);
         $tut_grp_inv->setInfo(sprintf($this->lng->txt("survey_notification_target_group_invited_info"), $num_inv));
         $tut_grp->addOption($tut_grp_inv);
     }
     // reminders
     // reminder - currently not available for 360°
     if (!$this->object->get360Mode()) {
         $info = new ilFormSectionHeaderGUI();
         $info->setTitle($this->lng->txt("svy_settings_section_reminders"));
         $form->addItem($info);
         $rmd = new ilCheckboxInputGUI($this->lng->txt("survey_reminder_setting"), "rmd");
         $rmd->setChecked($this->object->getReminderStatus());
         $form->addItem($rmd);
         $rmd_start = new ilDateTimeInputGUI($this->lng->txt("survey_reminder_start"), "rmd_start");
         $rmd_start->setRequired(true);
         $start = $this->object->getReminderStart();
         if ($start) {
             $rmd_start->setDate($start);
         }
         $rmd->addSubItem($rmd_start);
         $end = $this->object->getReminderEnd();
         $rmd_end = new ilDateTimeInputGUI($this->lng->txt("survey_reminder_end"), "rmd_end");
         $rmd_end->enableDateActivation("", "rmd_end_tgl", (bool) $end);
         if ($end) {
             $rmd_end->setDate($end);
         }
         $rmd->addSubItem($rmd_end);
         $rmd_freq = new ilNumberInputGUI($this->lng->txt("survey_reminder_frequency"), "rmd_freq");
         $rmd_freq->setRequired(true);
         $rmd_freq->setSize(3);
         $rmd_freq->setSuffix($this->lng->txt("survey_reminder_frequency_days"));
         $rmd_freq->setValue($this->object->getReminderFrequency());
         $rmd_freq->setMinValue(1);
         $rmd->addSubItem($rmd_freq);
         $rmd_grp = new ilRadioGroupInputGUI($this->lng->txt("survey_notification_target_group"), "rmd_grp");
         $rmd_grp->setRequired(true);
         $rmd_grp->setValue($this->object->getReminderTarget());
         $rmd->addSubItem($rmd_grp);
         $rmd_grp_crs = new ilRadioOption($this->lng->txt("survey_notification_target_group_parent_course"), ilObjSurvey::NOTIFICATION_PARENT_COURSE);
         if (!$has_parent) {
             $rmd_grp_crs->setInfo($this->lng->txt("survey_notification_target_group_parent_course_inactive"));
         }
         $rmd_grp->addOption($rmd_grp_crs);
         $rmd_grp_inv = new ilRadioOption($this->lng->txt("survey_notification_target_group_invited"), ilObjSurvey::NOTIFICATION_INVITED_USERS);
         $rmd_grp_inv->setInfo(sprintf($this->lng->txt("survey_notification_target_group_invited_info"), $num_inv));
         $rmd_grp->addOption($rmd_grp_inv);
     }
     // results
     $results = new ilFormSectionHeaderGUI();
     $results->setTitle($this->lng->txt("results"));
     $form->addItem($results);
     // evaluation access
     if (!$this->object->get360Mode()) {
         $evaluation_access = new ilRadioGroupInputGUI($this->lng->txt('evaluation_access'), "evaluation_access");
         $option = new ilCheckboxOption($this->lng->txt("evaluation_access_off"), ilObjSurvey::EVALUATION_ACCESS_OFF, '');
         $option->setInfo($this->lng->txt("svy_evaluation_access_off_info"));
         $evaluation_access->addOption($option);
         $option = new ilCheckboxOption($this->lng->txt("evaluation_access_all"), ilObjSurvey::EVALUATION_ACCESS_ALL, '');
         $option->setInfo($this->lng->txt("svy_evaluation_access_all_info"));
         $evaluation_access->addOption($option);
         $option = new ilCheckboxOption($this->lng->txt("evaluation_access_participants"), ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS, '');
         $option->setInfo($this->lng->txt("svy_evaluation_access_participants_info"));
         $evaluation_access->addOption($option);
         $evaluation_access->setValue($this->object->getEvaluationAccess());
         $form->addItem($evaluation_access);
         $anonymization_options = new ilRadioGroupInputGUI($this->lng->txt("survey_results_anonymization"), "anonymization_options");
         $option = new ilCheckboxOption($this->lng->txt("survey_results_personalized"), "statpers");
         $option->setInfo($this->lng->txt("survey_results_personalized_info"));
         $anonymization_options->addOption($option);
         $option = new ilCheckboxOption($this->lng->txt("survey_results_anonymized"), "statanon");
         $option->setInfo($this->lng->txt("survey_results_anonymized_info"));
         $anonymization_options->addOption($option);
         $anonymization_options->setValue($this->object->hasAnonymizedResults() ? "statanon" : "statpers");
         $form->addItem($anonymization_options);
         if ($this->object->_hasDatasets($this->object->getSurveyId())) {
             $anonymization_options->setDisabled(true);
         }
     } else {
         $ts_results = new ilRadioGroupInputGUI($this->lng->txt("survey_360_results"), "ts_res");
         $ts_results->setValue($this->object->get360Results());
         $option = new ilRadioOption($this->lng->txt("survey_360_results_none"), ilObjSurvey::RESULTS_360_NONE);
         $option->setInfo($this->lng->txt("survey_360_results_none_info"));
         $ts_results->addOption($option);
         $option = new ilRadioOption($this->lng->txt("survey_360_results_own"), ilObjSurvey::RESULTS_360_OWN);
         $option->setInfo($this->lng->txt("survey_360_results_own_info"));
         $ts_results->addOption($option);
         $option = new ilRadioOption($this->lng->txt("survey_360_results_all"), ilObjSurvey::RESULTS_360_ALL);
         $option->setInfo($this->lng->txt("survey_360_results_all_info"));
         $ts_results->addOption($option);
         $form->addItem($ts_results);
     }
     // competence service activation for 360 mode
     include_once "./Services/Skill/classes/class.ilSkillManagementSettings.php";
     $skmg_set = new ilSkillManagementSettings();
     if ($this->object->get360Mode() && $skmg_set->isActivated()) {
         $other = new ilFormSectionHeaderGUI();
         $other->setTitle($this->lng->txt("other"));
         $form->addItem($other);
         $skill_service = new ilCheckboxInputGUI($this->lng->txt("survey_activate_skill_service"), "skill_service");
         $skill_service->setInfo($this->lng->txt("survey_activate_skill_service_info"));
         $skill_service->setChecked($this->object->get360SkillService());
         $form->addItem($skill_service);
     }
     $form->addCommandButton("saveProperties", $this->lng->txt("save"));
     // remove items when using template
     if ($template_settings) {
         foreach ($template_settings as $id => $item) {
             if ($item["hide"]) {
                 $form->removeItemByPostVar($id);
             }
         }
     }
     return $form;
 }
 private function buildForm()
 {
     require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt("save"));
     $form->setTableWidth("100%");
     $form->setId("test_properties");
     if (!$this->settingsTemplate || $this->formShowGeneralSection($this->settingsTemplate->getSettings())) {
         // general properties
         $header = new ilFormSectionHeaderGUI();
         $header->setTitle($this->lng->txt("tst_general_properties"));
         $form->addItem($header);
     }
     // title & description (meta data)
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
     $md_section = $md_obj->getGeneral();
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setRequired(true);
     $title->setValue($md_section->getTitle());
     $form->addItem($title);
     $ids = $md_section->getDescriptionIds();
     if ($ids) {
         $desc_obj = $md_section->getDescription(array_pop($ids));
         $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
         $desc->setCols(50);
         $desc->setRows(4);
         $desc->setValue($desc_obj->getDescription());
         $form->addItem($desc);
     }
     // anonymity
     $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
     if ($this->testOBJ->participantDataExist()) {
         $anonymity->setDisabled(true);
     }
     $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
     $anonymity->addOption($rb);
     $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
     $anonymity->addOption($rb);
     $anonymity->setValue((int) $this->testOBJ->getAnonymity());
     $form->addItem($anonymity);
     // test mode (question set type)
     $questSetType = new ilRadioGroupInputGUI($this->lng->txt("tst_question_set_type"), 'question_set_type');
     $questSetTypeFixed = new ilRadioOption($this->lng->txt("tst_question_set_type_fixed"), ilObjTest::QUESTION_SET_TYPE_FIXED, $this->lng->txt("tst_question_set_type_fixed_desc"));
     $questSetType->addOption($questSetTypeFixed);
     $questSetTypeRandom = new ilRadioOption($this->lng->txt("tst_question_set_type_random"), ilObjTest::QUESTION_SET_TYPE_RANDOM, $this->lng->txt("tst_question_set_type_random_desc"));
     $questSetType->addOption($questSetTypeRandom);
     $questSetTypeContinues = new ilRadioOption($this->lng->txt("tst_question_set_type_dynamic"), ilObjTest::QUESTION_SET_TYPE_DYNAMIC, $this->lng->txt("tst_question_set_type_dynamic_desc"));
     $questSetType->addOption($questSetTypeContinues);
     $questSetType->setValue($this->testOBJ->getQuestionSetType());
     if ($this->testOBJ->participantDataExist()) {
         $questSetType->setDisabled(true);
     }
     $form->addItem($questSetType);
     // pool usage
     $pool_usage = new ilCheckboxInputGUI($this->lng->txt("test_question_pool_usage"), "use_pool");
     $pool_usage->setValue(1);
     $pool_usage->setChecked($this->testOBJ->getPoolUsage());
     $form->addItem($pool_usage);
     // enable_archiving
     $enable_archiving = new ilCheckboxInputGUI($this->lng->txt('test_enable_archiving'), 'enable_archiving');
     $enable_archiving->setValue(1);
     $enable_archiving->setChecked($this->testOBJ->getEnableArchiving());
     $form->addItem($enable_archiving);
     // activation/availability  (no template support yet)
     include_once "Services/Object/classes/class.ilObjectActivation.php";
     $this->lng->loadLanguageModule('rep');
     $section = new ilFormSectionHeaderGUI();
     $section->setTitle($this->lng->txt('rep_activation_availability'));
     $form->addItem($section);
     // additional info only with multiple references
     $act_obj_info = $act_ref_info = "";
     if (sizeof(ilObject::_getAllReferences($this->testOBJ->getId())) > 1) {
         $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
         $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
     }
     $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
     $online->setChecked($this->testOBJ->isOnline());
     $online->setInfo($this->lng->txt('tst_activation_online_info') . $act_obj_info);
     $form->addItem($online);
     $act_type = new ilRadioGroupInputGUI($this->lng->txt('rep_activation_access'), 'activation_type');
     $act_type->setInfo($act_ref_info);
     $act_type->setValue($this->testOBJ->isActivationLimited() ? ilObjectActivation::TIMINGS_ACTIVATION : ilObjectActivation::TIMINGS_DEACTIVATED);
     $opt = new ilRadioOption($this->lng->txt('rep_visibility_limitless'), ilObjectActivation::TIMINGS_DEACTIVATED);
     $opt->setInfo($this->lng->txt('tst_availability_limitless_info'));
     $act_type->addOption($opt);
     $opt = new ilRadioOption($this->lng->txt('rep_visibility_until'), ilObjectActivation::TIMINGS_ACTIVATION);
     $opt->setInfo($this->lng->txt('tst_availability_until_info'));
     $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
     include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
     $dur = new ilDateDurationInputGUI("", "access_period");
     $dur->setShowTime(true);
     $date = $this->testOBJ->getActivationStartingTime();
     $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
     $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
     $date = $this->testOBJ->getActivationEndingTime();
     $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
     $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
     $opt->addSubItem($dur);
     $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'activation_visibility');
     $visible->setInfo($this->lng->txt('tst_activation_limited_visibility_info'));
     $visible->setChecked($this->testOBJ->getActivationVisibility());
     $opt->addSubItem($visible);
     $act_type->addOption($opt);
     $form->addItem($act_type);
     if (!$this->settingsTemplate || $this->formShowBeginningEndingInformation($this->settingsTemplate->getSettings())) {
         // general properties
         $header = new ilFormSectionHeaderGUI();
         $header->setTitle($this->lng->txt("tst_beginning_ending_information"));
         $form->addItem($header);
     }
     // introduction
     $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction"), "introduction");
     $intro->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getIntroduction()));
     $intro->setRows(10);
     $intro->setCols(80);
     $intro->setUseRte(TRUE);
     $intro->addPlugin("latex");
     $intro->addButton("latex");
     $intro->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
     $intro->setRteTagSet('full');
     $intro->setInfo($this->lng->txt('intro_desc'));
     // showinfo
     $showinfo = new ilCheckboxInputGUI('', "showinfo");
     $showinfo->setValue(1);
     $showinfo->setChecked($this->testOBJ->getShowInfo());
     $showinfo->setOptionTitle($this->lng->txt("showinfo"));
     $showinfo->setInfo($this->lng->txt("showinfo_desc"));
     $intro->addSubItem($showinfo);
     $form->addItem($intro);
     // final statement
     $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
     $finalstatement->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getFinalStatement()));
     $finalstatement->setRows(10);
     $finalstatement->setCols(80);
     $finalstatement->setUseRte(TRUE);
     $finalstatement->addPlugin("latex");
     $finalstatement->addButton("latex");
     $finalstatement->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
     $finalstatement->setRteTagSet('full');
     // show final statement
     $showfinal = new ilCheckboxInputGUI('', "showfinalstatement");
     $showfinal->setValue(1);
     $showfinal->setChecked($this->testOBJ->getShowFinalStatement());
     $showfinal->setOptionTitle($this->lng->txt("final_statement_show"));
     $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
     $finalstatement->addSubItem($showfinal);
     $form->addItem($finalstatement);
     // examview
     $enable_examview = new ilCheckboxInputGUI($this->lng->txt("enable_examview"), 'enable_examview');
     $enable_examview->setValue(1);
     $enable_examview->setChecked($this->testOBJ->getEnableExamview());
     $enable_examview->setInfo($this->lng->txt("enable_examview_desc"));
     $show_examview_html = new ilCheckboxInputGUI('', 'show_examview_html');
     $show_examview_html->setValue(1);
     $show_examview_html->setChecked($this->testOBJ->getShowExamviewHtml());
     $show_examview_html->setOptionTitle($this->lng->txt("show_examview_html"));
     $show_examview_html->setInfo($this->lng->txt("show_examview_html_desc"));
     $enable_examview->addSubItem($show_examview_html);
     $show_examview_pdf = new ilCheckboxInputGUI('', 'show_examview_pdf');
     $show_examview_pdf->setValue(1);
     $show_examview_pdf->setChecked($this->testOBJ->getShowExamviewPdf());
     $show_examview_pdf->setOptionTitle($this->lng->txt("show_examview_pdf"));
     $show_examview_pdf->setInfo($this->lng->txt("show_examview_pdf_desc"));
     $enable_examview->addSubItem($show_examview_pdf);
     $form->addItem($enable_examview);
     if (!$this->settingsTemplate || $this->formShowSessionSection($this->settingsTemplate->getSettings())) {
         // session properties
         $sessionheader = new ilFormSectionHeaderGUI();
         $sessionheader->setTitle($this->lng->txt("tst_session_settings"));
         $form->addItem($sessionheader);
     }
     // max. number of passes
     $nr_of_tries = new ilTextInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
     $nr_of_tries->setSize(3);
     $nr_of_tries->setValue($this->testOBJ->getNrOfTries());
     $nr_of_tries->setRequired(true);
     $nr_of_tries->setSuffix($this->lng->txt("0_unlimited"));
     $total = $this->testOBJ->evalTotalPersons();
     if ($total) {
         $nr_of_tries->setDisabled(true);
     }
     $form->addItem($nr_of_tries);
     // enable max. processing time
     $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
     $processing->setValue(1);
     //$processing->setOptionTitle($this->lng->txt("enabled"));
     if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_processing_time')) {
         $processing->setChecked(true);
     } else {
         $processing->setChecked($this->testOBJ->getEnableProcessingTime());
     }
     // max. processing time
     $processingtime = new ilDurationInputGUI('', 'processing_time');
     $ptime = $this->testOBJ->getProcessingTimeAsArray();
     $processingtime->setHours($ptime['hh']);
     $processingtime->setMinutes($ptime['mm']);
     $processingtime->setSeconds($ptime['ss']);
     $processingtime->setShowMonths(false);
     $processingtime->setShowDays(false);
     $processingtime->setShowHours(true);
     $processingtime->setShowMinutes(true);
     $processingtime->setShowSeconds(true);
     $processingtime->setInfo($this->lng->txt("tst_processing_time_desc"));
     $processing->addSubItem($processingtime);
     // reset max. processing time
     $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
     $resetprocessing->setValue(1);
     $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
     $resetprocessing->setChecked($this->testOBJ->getResetProcessingTime());
     $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
     $processing->addSubItem($resetprocessing);
     $form->addItem($processing);
     // enable starting time
     $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
     $enablestartingtime->setValue(1);
     //$enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
     if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_starting_time')) {
         $enablestartingtime->setChecked(true);
     } else {
         $enablestartingtime->setChecked(strlen($this->testOBJ->getStartingTime()));
     }
     // starting time
     $startingtime = new ilDateTimeInputGUI('', 'starting_time');
     $startingtime->setShowDate(true);
     $startingtime->setShowTime(true);
     if (strlen($this->testOBJ->getStartingTime())) {
         $startingtime->setDate(new ilDateTime($this->testOBJ->getStartingTime(), IL_CAL_TIMESTAMP));
     } else {
         $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
     }
     $enablestartingtime->addSubItem($startingtime);
     $form->addItem($enablestartingtime);
     if ($this->testOBJ->participantDataExist()) {
         $enablestartingtime->setDisabled(true);
         $startingtime->setDisabled(true);
     }
     // enable ending time
     $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
     $enableendingtime->setValue(1);
     //$enableendingtime->setOptionTitle($this->lng->txt("enabled"));
     if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_ending_time')) {
         $enableendingtime->setChecked(true);
     } else {
         $enableendingtime->setChecked(strlen($this->testOBJ->getEndingTime()));
     }
     // ending time
     $endingtime = new ilDateTimeInputGUI('', 'ending_time');
     $endingtime->setShowDate(true);
     $endingtime->setShowTime(true);
     if (strlen($this->testOBJ->getEndingTime())) {
         $endingtime->setDate(new ilDateTime($this->testOBJ->getEndingTime(), IL_CAL_TIMESTAMP));
     } else {
         $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
     }
     $enableendingtime->addSubItem($endingtime);
     $form->addItem($enableendingtime);
     // test password
     $password = new ilTextInputGUI($this->lng->txt("tst_password"), "password");
     $password->setSize(20);
     $password->setValue($this->testOBJ->getPassword());
     $password->setInfo($this->lng->txt("tst_password_details"));
     $form->addItem($password);
     if (!$this->settingsTemplate || $this->formShowPresentationSection($this->settingsTemplate->getSettings())) {
         // sequence properties
         $seqheader = new ilFormSectionHeaderGUI();
         $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
         $form->addItem($seqheader);
     }
     // use previous answers
     $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
     $prevanswers->setValue(1);
     $prevanswers->setChecked($this->testOBJ->getUsePreviousAnswers());
     $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
     $form->addItem($prevanswers);
     // force js
     $forcejs = new ilCheckboxInputGUI($this->lng->txt("forcejs_short"), "forcejs");
     $forcejs->setValue(1);
     $forcejs->setChecked($this->testOBJ->getForceJS());
     $forcejs->setOptionTitle($this->lng->txt("forcejs"));
     $forcejs->setInfo($this->lng->txt("forcejs_desc"));
     $form->addItem($forcejs);
     // question title output
     $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
     $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
     $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
     $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
     $title_output->setValue($this->testOBJ->getTitleOutput());
     $title_output->setInfo($this->lng->txt("tst_title_output_description"));
     $form->addItem($title_output);
     // selector for unicode characters
     global $ilSetting;
     if ($ilSetting->get('char_selector_availability') > 0) {
         require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
         $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST);
         $char_selector->getConfig()->setAvailability($this->testOBJ->getCharSelectorAvailability());
         $char_selector->getConfig()->setDefinition($this->testOBJ->getCharSelectorDefinition());
         $char_selector->addFormProperties($form);
         $char_selector->setFormValues($form);
     }
     // Autosave
     $autosave_output = new ilCheckboxInputGUI($this->lng->txt('autosave'), 'autosave');
     $autosave_output->setValue(1);
     $autosave_output->setChecked($this->testOBJ->getAutosave());
     $autosave_output->setInfo($this->lng->txt('autosave_info'));
     $autosave_interval = new ilTextInputGUI($this->lng->txt('autosave_ival'), 'autosave_ival');
     $autosave_interval->setSize(10);
     $autosave_interval->setValue($this->testOBJ->getAutosaveIval() / 1000);
     $autosave_interval->setInfo($this->lng->txt('autosave_ival_info'));
     $autosave_output->addSubItem($autosave_interval);
     $form->addItem($autosave_output);
     if (!$this->settingsTemplate || $this->formShowSequenceSection($this->settingsTemplate->getSettings())) {
         // sequence properties
         $seqheader = new ilFormSectionHeaderGUI();
         $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
         $form->addItem($seqheader);
     }
     // postpone questions
     $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
     $postpone->setValue(1);
     $postpone->setChecked($this->testOBJ->getSequenceSettings());
     $postpone->setInfo($this->lng->txt("tst_postpone_description"));
     $form->addItem($postpone);
     // shuffle questions
     $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
     $shuffle->setValue(1);
     $shuffle->setChecked($this->testOBJ->getShuffleQuestions());
     $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
     $form->addItem($shuffle);
     // show list of questions
     $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
     //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
     $list_of_questions->setValue(1);
     $list_of_questions->setChecked($this->testOBJ->getListOfQuestions());
     $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
     $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
     $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
     $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
     $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
     $values = array();
     if ($this->testOBJ->getListOfQuestionsStart()) {
         array_push($values, 'chb_list_of_questions_start');
     }
     if ($this->testOBJ->getListOfQuestionsEnd()) {
         array_push($values, 'chb_list_of_questions_end');
     }
     if ($this->testOBJ->getListOfQuestionsDescription()) {
         array_push($values, 'chb_list_of_questions_with_description');
     }
     $list_of_questions_options->setValue($values);
     $list_of_questions->addSubItem($list_of_questions_options);
     $form->addItem($list_of_questions);
     // show question marking
     $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
     $marking->setValue(1);
     $marking->setChecked($this->testOBJ->getShowMarker());
     $marking->setInfo($this->lng->txt("question_marking_description"));
     $form->addItem($marking);
     // show suspend test
     $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
     $cancel->setValue(1);
     $cancel->setChecked($this->testOBJ->getShowCancel());
     $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
     $form->addItem($cancel);
     if (!$this->settingsTemplate || $this->formShowNotificationSection($this->settingsTemplate->getSettings())) {
         // notifications
         $notifications = new ilFormSectionHeaderGUI();
         $notifications->setTitle($this->lng->txt("tst_mail_notification"));
         $form->addItem($notifications);
     }
     // mail notification
     $mailnotification = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
     $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_no"), 0, ''));
     $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
     $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
     $mailnotification->setValue($this->testOBJ->getMailNotification());
     $form->addItem($mailnotification);
     $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
     $mailnottype->setValue(1);
     $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
     $mailnottype->setChecked($this->testOBJ->getMailNotificationType());
     $form->addItem($mailnottype);
     /* This options always active (?) */
     $highscore_head = new ilFormSectionHeaderGUI();
     $highscore_head->setTitle($this->lng->txt("tst_highscore_options"));
     $form->addItem($highscore_head);
     $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
     $highscore->setValue(1);
     $highscore->setChecked($this->testOBJ->getHighscoreEnabled());
     $highscore->setInfo($this->lng->txt("tst_highscore_description"));
     $form->addItem($highscore);
     $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
     $highscore_anon->setValue(1);
     $highscore_anon->setChecked($this->testOBJ->getHighscoreAnon());
     $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
     $highscore->addSubItem($highscore_anon);
     $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
     $highscore_achieved_ts->setValue(1);
     $highscore_achieved_ts->setChecked($this->testOBJ->getHighscoreAchievedTS());
     $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
     $highscore->addSubItem($highscore_achieved_ts);
     $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
     $highscore_score->setValue(1);
     $highscore_score->setChecked($this->testOBJ->getHighscoreScore());
     $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
     $highscore->addSubItem($highscore_score);
     $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
     $highscore_percentage->setValue(1);
     $highscore_percentage->setChecked($this->testOBJ->getHighscorePercentage());
     $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
     $highscore->addSubItem($highscore_percentage);
     $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
     $highscore_hints->setValue(1);
     $highscore_hints->setChecked($this->testOBJ->getHighscoreHints());
     $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
     $highscore->addSubItem($highscore_hints);
     $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
     $highscore_wtime->setValue(1);
     $highscore_wtime->setChecked($this->testOBJ->getHighscoreWTime());
     $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
     $highscore->addSubItem($highscore_wtime);
     $highscore_own_table = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_own_table"), "highscore_own_table");
     $highscore_own_table->setValue(1);
     $highscore_own_table->setChecked($this->testOBJ->getHighscoreOwnTable());
     $highscore_own_table->setInfo($this->lng->txt("tst_highscore_own_table_description"));
     $highscore->addSubItem($highscore_own_table);
     $highscore_top_table = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_top_table"), "highscore_top_table");
     $highscore_top_table->setValue(1);
     $highscore_top_table->setChecked($this->testOBJ->getHighscoreTopTable());
     $highscore_top_table->setInfo($this->lng->txt("tst_highscore_top_table_description"));
     $highscore->addSubItem($highscore_top_table);
     $highscore_top_num = new ilTextInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
     $highscore_top_num->setSize(4);
     $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
     $highscore_top_num->setValue($this->testOBJ->getHighscoreTopNum());
     $highscore_top_num->setInfo($this->lng->txt("tst_highscore_top_num_description"));
     $highscore->addSubItem($highscore_top_num);
     if (!$this->settingsTemplate || $this->formShowTestExecutionSection($this->settingsTemplate->getSettings())) {
         $testExecution = new ilFormSectionHeaderGUI();
         $testExecution->setTitle($this->lng->txt("tst_test_execution"));
         $form->addItem($testExecution);
     }
     // kiosk mode
     $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
     $kiosk->setValue(1);
     $kiosk->setChecked($this->testOBJ->getKioskMode());
     $kiosk->setInfo($this->lng->txt("kiosk_description"));
     // kiosk mode options
     $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
     $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
     $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
     $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt('examid_in_kiosk'), 'examid_in_kiosk'));
     $values = array();
     if ($this->testOBJ->getShowKioskModeTitle()) {
         array_push($values, 'kiosk_title');
     }
     if ($this->testOBJ->getShowKioskModeParticipant()) {
         array_push($values, 'kiosk_participant');
     }
     if ($this->testOBJ->getExamidInKiosk()) {
         array_push($values, 'examid_in_kiosk');
     }
     $kiosktitle->setValue($values);
     $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
     $kiosk->addSubItem($kiosktitle);
     $form->addItem($kiosk);
     $redirection_mode = $this->testOBJ->getRedirectionMode();
     $rm_enabled = new ilCheckboxInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_enabled');
     $rm_enabled->setChecked($redirection_mode == '0' ? false : true);
     $radio_rm = new ilRadioGroupInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_mode');
     $always = new ilRadioOption($this->lng->txt('tst_results_access_always'), REDIRECT_ALWAYS);
     $radio_rm->addOption($always);
     $kiosk = new ilRadioOption($this->lng->txt('redirect_in_kiosk_mode'), REDIRECT_KIOSK);
     $radio_rm->addOption($kiosk);
     $radio_rm->setValue(in_array($redirection_mode, array(REDIRECT_ALWAYS, REDIRECT_KIOSK)) ? $redirection_mode : REDIRECT_ALWAYS);
     $rm_enabled->addSubItem($radio_rm);
     $redirection_url = new ilTextInputGUI($this->lng->txt('redirection_url'), 'redirection_url');
     $redirection_url->setValue((string) $this->testOBJ->getRedirectionUrl());
     $redirection_url->setRequired(true);
     $rm_enabled->addSubItem($redirection_url);
     $form->addItem($rm_enabled);
     // Sign submission
     $sign_submission = $this->testOBJ->getSignSubmission();
     $sign_submission_enabled = new ilCheckboxInputGUI($this->lng->txt('sign_submission'), 'sign_submission');
     $sign_submission_enabled->setChecked($sign_submission);
     $sign_submission_enabled->setInfo($this->lng->txt('sign_submission_info'));
     $form->addItem($sign_submission_enabled);
     if (!$this->settingsTemplate || $this->formShowParticipantSection($this->settingsTemplate->getSettings())) {
         // participants properties
         $restrictions = new ilFormSectionHeaderGUI();
         $restrictions->setTitle($this->lng->txt("tst_max_allowed_users"));
         $form->addItem($restrictions);
     }
     $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
     $fixedparticipants->setValue(1);
     $fixedparticipants->setChecked($this->testOBJ->getFixedParticipants());
     $fixedparticipants->setOptionTitle($this->lng->txt("tst_allow_fixed_participants"));
     $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
     $invited_users = $this->testOBJ->getInvitedUsers();
     if ($total && count($invited_users) == 0) {
         $fixedparticipants->setDisabled(true);
     }
     $form->addItem($fixedparticipants);
     // simultaneous users
     $simul = new ilTextInputGUI($this->lng->txt("tst_allowed_users"), "allowedUsers");
     $simul->setSize(3);
     $simul->setValue($this->testOBJ->getAllowedUsers() ? $this->testOBJ->getAllowedUsers() : '');
     $form->addItem($simul);
     // idle time
     $idle = new ilTextInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
     $idle->setSize(4);
     $idle->setSuffix($this->lng->txt("seconds"));
     $idle->setValue($this->testOBJ->getAllowedUsersTimeGap() ? $this->testOBJ->getAllowedUsersTimeGap() : '');
     $form->addItem($idle);
     // Edit ecs export settings
     include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
     $ecs = new ilECSTestSettings($this->testOBJ);
     $ecs->addSettingsToForm($form, 'tst');
     // remove items when using template
     if ($this->settingsTemplate) {
         foreach ($this->settingsTemplate->getSettings() as $id => $item) {
             if ($item["hide"]) {
                 $form->removeItemByPostVar($id);
             }
         }
     }
     return $form;
 }
 /**
  * Returns a QTI xml representation of the survey
  *
  * @return string The QTI xml representation of the survey
  * @access public
  */
 function toXML()
 {
     include_once "./Services/Xml/classes/class.ilXmlWriter.php";
     $a_xml_writer = new ilXmlWriter();
     // set xml header
     $a_xml_writer->xmlHeader();
     $attrs = array("xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd");
     $a_xml_writer->xmlStartTag("surveyobject", $attrs);
     $attrs = array("id" => $this->getSurveyId(), "title" => $this->getTitle());
     $a_xml_writer->xmlStartTag("survey", $attrs);
     $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
     $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
     $a_xml_writer->xmlStartTag("objectives");
     $attrs = array("label" => "introduction");
     $this->addMaterialTag($a_xml_writer, $this->getIntroduction(), TRUE, TRUE, $attrs);
     $attrs = array("label" => "outro");
     $this->addMaterialTag($a_xml_writer, $this->getOutro(), TRUE, TRUE, $attrs);
     $a_xml_writer->xmlEndTag("objectives");
     if ($this->getAnonymize()) {
         $attribs = array("enabled" => "1");
     } else {
         $attribs = array("enabled" => "0");
     }
     $a_xml_writer->xmlElement("anonymisation", $attribs);
     $a_xml_writer->xmlStartTag("restrictions");
     if ($this->getAnonymize() == 2) {
         $attribs = array("type" => "free");
     } else {
         $attribs = array("type" => "restricted");
     }
     $a_xml_writer->xmlElement("access", $attribs);
     if ($this->getStartDate()) {
         $attrs = array("type" => "date");
         preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->getStartDate(), $matches);
         $a_xml_writer->xmlElement("startingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
     }
     if ($this->getEndDate()) {
         $attrs = array("type" => "date");
         preg_match("/(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/", $this->getEndDate(), $matches);
         $a_xml_writer->xmlElement("endingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
     }
     $a_xml_writer->xmlEndTag("restrictions");
     // constraints
     $pages =& $this->getSurveyPages();
     $hasconstraints = FALSE;
     foreach ($pages as $question_array) {
         foreach ($question_array as $question) {
             if (count($question["constraints"])) {
                 $hasconstraints = TRUE;
             }
         }
     }
     if ($hasconstraints) {
         $a_xml_writer->xmlStartTag("constraints");
         foreach ($pages as $question_array) {
             foreach ($question_array as $question) {
                 if (count($question["constraints"])) {
                     // found constraints
                     foreach ($question["constraints"] as $constraint) {
                         $attribs = array("sourceref" => $question["question_id"], "destref" => $constraint["question"], "relation" => $constraint["short"], "value" => $constraint["value"], "conjunction" => $constraint["conjunction"]);
                         $a_xml_writer->xmlElement("constraint", $attribs);
                     }
                 }
             }
         }
         $a_xml_writer->xmlEndTag("constraints");
     }
     // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
     $a_xml_writer->xmlStartTag("metadata");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "evaluation_access");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEvaluationAccess());
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "status");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getStatus());
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "display_question_titles");
     $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowQuestionTitles());
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $writer = new ilXmlWriter();
     $md->toXml($writer);
     $metadata = $writer->xmlDumpMem();
     $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlEndTag("metadata");
     $a_xml_writer->xmlEndTag("survey");
     $attribs = array("id" => $this->getId());
     $a_xml_writer->xmlStartTag("surveyquestions", $attribs);
     // add questionblock descriptions
     $obligatory_states =& $this->getObligatoryStates();
     foreach ($pages as $question_array) {
         if (count($question_array) > 1) {
             $attribs = array("id" => $question_array[0]["question_id"]);
             $attribs = array("showQuestiontext" => $question_array[0]["questionblock_show_questiontext"], "showBlocktitle" => $question_array[0]["questionblock_show_blocktitle"]);
             $a_xml_writer->xmlStartTag("questionblock", $attribs);
             if (strlen($question_array[0]["questionblock_title"])) {
                 $a_xml_writer->xmlElement("questionblocktitle", NULL, $question_array[0]["questionblock_title"]);
             }
         }
         foreach ($question_array as $question) {
             if (strlen($question["heading"])) {
                 $a_xml_writer->xmlElement("textblock", NULL, $question["heading"]);
             }
             $questionObject =& $this->_instanciateQuestion($question["question_id"]);
             if ($questionObject !== FALSE) {
                 $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question["question_id"]]);
             }
         }
         if (count($question_array) > 1) {
             $a_xml_writer->xmlEndTag("questionblock");
         }
     }
     $a_xml_writer->xmlEndTag("surveyquestions");
     $a_xml_writer->xmlEndTag("surveyobject");
     $xml = $a_xml_writer->xmlDumpMem(FALSE);
     return $xml;
 }
 /**
 * Creates a 1:1 copy of the object and places the copy in a given repository
 *
 * @access public
 */
 function cloneObject($a_target_id, $a_copy_id = 0)
 {
     global $ilLog;
     $newObj = parent::cloneObject($a_target_id, $a_copy_id);
     //copy online status if object is not the root copy object
     $cp_options = ilCopyWizardOptions::_getInstance($a_copy_id);
     if (!$cp_options->isRootNode($this->getRefId())) {
         $newObj->setOnline($this->getOnline());
     }
     $newObj->setShowTaxonomies($this->getShowTaxonomies());
     $newObj->saveToDb();
     // clone the questions in the question pool
     $questions =& $this->getQplQuestions();
     $questionIdsMap = array();
     foreach ($questions as $question_id) {
         $newQuestionId = $newObj->copyQuestion($question_id, $newObj->getId());
         $questionIdsMap[$question_id] = $newQuestionId;
     }
     // clone meta data
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $new_md =& $md->cloneMD($newObj->getId(), 0, $newObj->getType());
     // update the metadata with the new title of the question pool
     $newObj->updateMetaData();
     require_once 'Modules/TestQuestionPool/classes/class.ilQuestionPoolTaxonomiesDuplicator.php';
     $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
     $duplicator->setSourceObjId($this->getId());
     $duplicator->setSourceObjType($this->getType());
     $duplicator->setTargetObjId($newObj->getId());
     $duplicator->setTargetObjType($newObj->getType());
     $duplicator->setQuestionIdMapping($questionIdsMap);
     $duplicator->duplicate();
     $duplicatedTaxKeyMap = $duplicator->getDuplicatedTaxonomiesKeysMap();
     $newObj->setNavTaxonomyId($duplicatedTaxKeyMap->getMappedTaxonomyId($this->getNavTaxonomyId()));
     $newObj->saveToDb();
     return $newObj;
 }
 /**
  * SCO preview
  */
 function sco_preview()
 {
     global $tpl, $ilCtrl, $lng;
     // init main template
     $tpl = new ilTemplate("tpl.main.html", true, true);
     include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
     $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $tpl->setBodyClass("");
     $tpl->setCurrentBlock("ContentStyle");
     $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId()));
     $tpl->parseCurrentBlock();
     // get javascript
     include_once "./Services/jQuery/classes/class.iljQueryUtil.php";
     iljQueryUtil::initjQuery();
     iljQueryUtil::initjQueryUI();
     $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js");
     $tpl->addJavaScript("./Modules/Scorm2004/scripts/pager.js");
     $tpl->addOnLoadCode("pager.Init();");
     $tree = new ilTree($this->slm_object->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php";
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
     $desc_ids = $meta->getGeneral()->getDescriptionIds();
     $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
     // get sco template
     $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004");
     // navigation
     $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
     ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk);
     // meta page (description and objectives)
     ilSCORM2004Asset::renderMetaPage($sco_tpl, $this->node_object, $this->node_object->getType());
     // init export (this initialises glossary template)
     ilSCORM2004PageGUI::initExport();
     $terms = $this->node_object->getGlossaryTermIds();
     // render page
     foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) {
         $page_obj = new ilSCORM2004PageGUI($this->node_object->getType(), $page["obj_id"], 0, $this->slm_object->getId());
         $page_obj->setPresentationTitle($page["title"]);
         $page_obj->setOutputMode(IL_PAGE_PREVIEW);
         $page_obj->setStyleId($this->slm_object->getStyleSheetId());
         if (count($terms) > 1) {
             $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this->node_object);
         }
         $sco_tpl->setCurrentBlock("page_preview");
         $html = $ilCtrl->getHTML($page_obj);
         //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export"));
         $sco_tpl->setVariable("PAGE_PRV", $html);
         $sco_tpl->parseCurrentBlock();
     }
     $output = $sco_tpl->get();
     // append glossary entries on the sco level
     $output .= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object);
     //insert questions
     require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
     $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output);
     //		$output = preg_replace("/&#123;/","",$output);
     //		$output = preg_replace("/&#125;/","",$output);
     $output = "<script>var ScormApi=null;" . ilQuestionExporter::questionsJS() . "</script>" . $output;
     $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId());
     //		include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php");
     //		ilSCORM2004PageGUI::addPreparationJavascript($tpl, $lk);
     $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
     $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css");
     include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
     ilOverlayGUI::initJavascript();
     //inline JS
     $output .= '<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>';
     $tpl->setVariable("CONTENT", $output);
 }
 /**
  * Copy meta data
  *
  * @access public
  * @param object target object
  * 
  */
 public function cloneMetaData($target_obj)
 {
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $md->cloneMD($target_obj->getId(), 0, $target_obj->getType());
     return true;
 }
 function updateCourse($sid, $course_id, $xml)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!is_numeric($course_id)) {
         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course', 'Client');
     }
     global $rbacsystem;
     if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
         if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
             return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
         }
     }
     if (!($tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false))) {
         return $this->__raiseError('Cannot create course instance!', 'Server');
     }
     if (!$rbacsystem->checkAccess('write', $course_id)) {
         return $this->__raiseError('Check access failed. No permission to write course', 'Server');
     }
     // First delete old meta data
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md = new ilMD($tmp_course->getId(), 0, 'crs');
     $md->deleteAll();
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     ilCourseParticipants::_deleteAllEntries($tmp_course->getId());
     include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
     ilCourseWaitingList::_deleteAll($tmp_course->getId());
     include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
     $xml_parser = new ilCourseXMLParser($tmp_course);
     $xml_parser->setXMLContent($xml);
     $xml_parser->startParsing();
     $tmp_course->MDUpdateListener('General');
     return true;
 }
 /**
  * Copy a term to a glossary
  *
  * @param
  * @return
  */
 function _copyTerm($a_term_id, $a_glossary_id)
 {
     $old_term = new ilGlossaryTerm($a_term_id);
     // copy the term
     $new_term = new ilGlossaryTerm();
     $new_term->setTerm($old_term->getTerm());
     $new_term->setLanguage($old_term->getLanguage());
     $new_term->setGlossaryId($a_glossary_id);
     $new_term->create();
     // copy the definitions
     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     $def_list = ilGlossaryDefinition::getDefinitionList($a_term_id);
     foreach ($def_list as $def) {
         $old_def = new ilGlossaryDefinition($def["id"]);
         $new_def = new ilGlossaryDefinition();
         $new_def->setShortText($old_def->getShortText());
         $new_def->setNr($old_def->getNr());
         $new_def->setTermId($new_term->getId());
         $new_def->create();
         // copy meta data
         include_once "Services/MetaData/classes/class.ilMD.php";
         $md = new ilMD($old_term->getGlossaryId(), $old_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         $new_md = $md->cloneMD($a_glossary_id, $new_def->getPageObject()->getId(), $old_def->getPageObject()->getParentType());
         // page content
         $new_def->getPageObject()->setXMLContent($old_def->getPageObject()->copyXmlContent(true));
         $new_def->getPageObject()->buildDom();
         $new_def->getPageObject()->update();
     }
     return $new_term->getId();
 }
 function updateQuickEdit_scorm_propagate($request, $type)
 {
     $module_id = $this->md_obj->obj_id;
     if ($this->md_obj->obj_type == 'sco') {
         $module_id = $this->md_obj->rbac_id;
     }
     $tree = new ilTree($module_id);
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $sco) {
         $sco_md = new ilMD($module_id, $sco['obj_id'], 'sco');
         if ($_POST[$request] != "") {
             $sco_md_section;
             if (!is_object($sco_md_section = $sco_md->getLifecycle())) {
                 $sco_md_section = $sco_md->addLifecycle();
                 $sco_md_section->save();
             }
             // determine all entered authors
             $auth_arr = explode(",", $_POST[$request]);
             for ($i = 0; $i < count($auth_arr); $i++) {
                 $auth_arr[$i] = trim($auth_arr[$i]);
             }
             $md_con_author = "";
             // update existing author entries (delete if not entered)
             foreach ($ids = $sco_md_section->getContributeIds() as $con_id) {
                 $md_con = $sco_md_section->getContribute($con_id);
                 if ($md_con->getRole() == $type) {
                     foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                         $md_ent = $md_con->getEntity($ent_id);
                         // entered author already exists
                         if (in_array($md_ent->getEntity(), $auth_arr)) {
                             unset($auth_arr[array_search($md_ent->getEntity(), $auth_arr)]);
                         } else {
                             $md_ent->delete();
                         }
                     }
                     $md_con_author = $md_con;
                 }
             }
             // insert enterd, but not existing authors
             if (count($auth_arr) > 0) {
                 if (!is_object($md_con_author)) {
                     $md_con_author = $sco_md_section->addContribute();
                     $md_con_author->setRole($type);
                     $md_con_author->save();
                 }
                 foreach ($auth_arr as $auth) {
                     $md_ent = $md_con_author->addEntity();
                     $md_ent->setEntity(ilUtil::stripSlashes($auth));
                     $md_ent->save();
                 }
             }
         } else {
             if (is_object($sco_md_section = $sco_md->getLifecycle())) {
                 foreach ($ids = $sco_md_section->getContributeIds() as $con_id) {
                     $md_con = $sco_md_section->getContribute($con_id);
                     if ($md_con->getRole() == $type) {
                         $md_con->delete();
                     }
                 }
             }
         }
         $sco_md->update();
     }
     $this->updateQuickEdit_scorm();
 }
 /**
  * add standard meta data sections
  */
 function addMetaDataSections($a_rep_obj_id, $a_obj_id, $a_type)
 {
     global $lng;
     $lng->loadLanguageModule("meta");
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($a_rep_obj_id, $a_obj_id, $a_type);
     if ($md_gen = $md->getGeneral()) {
         // get first descrption
         // The description is shown on the top of the page.
         // Thus it is not necessary to show it again.
         foreach ($md_gen->getDescriptionIds() as $id) {
             $md_des = $md_gen->getDescription($id);
             $description = $md_des->getDescription();
             break;
         }
         // get language(s)
         $langs = array();
         foreach ($ids = $md_gen->getLanguageIds() as $id) {
             $md_lan = $md_gen->getLanguage($id);
             if ($md_lan->getLanguageCode() != "") {
                 $langs[] = $lng->txt("meta_l_" . $md_lan->getLanguageCode());
             }
         }
         $langs = implode($langs, ", ");
         // keywords
         $keywords = array();
         foreach ($ids = $md_gen->getKeywordIds() as $id) {
             $md_key = $md_gen->getKeyword($id);
             $keywords[] = $md_key->getKeyword();
         }
         $keywords = implode($keywords, ", ");
     }
     // authors
     if (is_object($lifecycle = $md->getLifecycle())) {
         $sep = $author = "";
         foreach ($ids = $lifecycle->getContributeIds() as $con_id) {
             $md_con = $lifecycle->getContribute($con_id);
             if ($md_con->getRole() == "Author") {
                 foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                     $md_ent = $md_con->getEntity($ent_id);
                     $author = $author . $sep . $md_ent->getEntity();
                     $sep = ", ";
                 }
             }
         }
     }
     // copyright
     $copyright = "";
     if (is_object($rights = $md->getRights())) {
         include_once 'Services/MetaData/classes/class.ilMDUtils.php';
         $copyright = ilMDUtils::_parseCopyright($rights->getDescription());
     }
     // learning time
     #if(is_object($educational = $md->getEducational()))
     #{
     #	$learning_time = $educational->getTypicalLearningTime();
     #}
     $learning_time = "";
     if (is_object($educational = $md->getEducational())) {
         if ($seconds = $educational->getTypicalLearningTimeSeconds()) {
             $learning_time = ilFormat::_secondsToString($seconds);
         }
     }
     // output
     // description
     if ($description != "") {
         $this->addSection($lng->txt("description"));
         $this->addProperty("", nl2br($description));
     }
     // general section
     $this->addSection($lng->txt("meta_general"));
     if ($langs != "") {
         $this->addProperty($lng->txt("language"), $langs);
     }
     if ($keywords != "") {
         $this->addProperty($lng->txt("keywords"), $keywords);
     }
     if ($author != "") {
         $this->addProperty($lng->txt("author"), $author);
     }
     if ($copyright != "") {
         $this->addProperty($lng->txt("meta_copyright"), $copyright);
     }
     if ($learning_time != "") {
         $this->addProperty($lng->txt("meta_typical_learning_time"), $learning_time);
     }
 }
 /**
  * handler for begin of element
  *
  * @param	resource	$a_xml_parser		xml parser
  * @param	string		$a_name				element name
  * @param	array		$a_attribs			element attributes array
  */
 public function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
 {
     global $ilErr;
     if ($this->in_metadata) {
         parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
         return;
     }
     switch ($a_name) {
         case "MetaData":
             $this->in_metadata = true;
             // Delete old meta data
             $md = new ilMD($this->getWebLink()->getId(), 0, 'webr');
             $md->deleteAll();
             parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
             break;
         case 'WebLink':
             $this->current_link_update = false;
             $this->current_link_delete = false;
             $this->current_parameters = array();
             if ($this->getMode() == self::MODE_CREATE or isset($a_attribs['action']) and $a_attribs['action'] == 'Create') {
                 // New weblink
                 $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
             } elseif ($this->getMode() == self::MODE_UPDATE and $a_attribs['action'] == 'Delete') {
                 $this->current_link_delete = true;
                 $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
                 $this->current_link->delete($a_attribs['id']);
                 break;
             } elseif ($this->getMode() == self::MODE_UPDATE and ($a_attribs['action'] == 'Update' or !isset($a_attribs['action']))) {
                 $this->current_link = new ilLinkResourceItems($this->getWebLink()->getId());
                 $this->current_link->readItem($a_attribs['id']);
                 $this->current_link_update = true;
                 // Delete all dynamic parameter
                 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
                 foreach (ilParameterAppender::getParameterIds($this->getWebLink()->getId(), $a_attribs['id']) as $param_id) {
                     $param = new ilParameterAppender($this->getWebLink()->getId());
                     $param->delete($param_id);
                 }
             } else {
                 throw new ilWebLinkXmlParserException('Invalid action given for element "Weblink"');
             }
             // Active
             $this->current_link->setActiveStatus($a_attribs['active'] ? 1 : 0);
             // Valid
             if (!isset($a_attribs['valid'])) {
                 $valid = 1;
             } else {
                 $valid = $a_attribs['valid'] ? 1 : 0;
             }
             $this->current_link->setValidStatus($valid);
             // Disable check
             $this->current_link->setDisableCheckStatus($a_attribs['disableValidation'] ? 1 : 0);
             break;
         case 'Sorting':
             include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
             $sort = new ilContainerSortingSettings($this->getWebLink()->getId());
             $sort->delete();
             switch ($a_attribs['type']) {
                 case 'Manual':
                     $sort->setSortMode(ilContainer::SORT_MANUAL);
                     break;
                 case 'Title':
                 default:
                     $sort->setSortMode(ilContainer::SORT_TITLE);
             }
             $sort->save();
             break;
         case 'WebLinks':
         case 'Title':
         case 'Description':
         case 'Target':
             // Nothing to do
             break;
         case 'DynamicParameter':
             $param = new ilParameterAppender($this->getWebLink()->getId());
             $param->setName($a_attribs['name']);
             switch ($a_attribs['type']) {
                 case 'userName':
                     #						$GLOBALS['ilLog']->write("VALUE: ".LINKS_LOGIN);
                     $param->setValue(LINKS_LOGIN);
                     break;
                 case 'userId':
                     #						$GLOBALS['ilLog']->write("VALUE: ".LINKS_USER_ID);
                     $param->setValue(LINKS_USER_ID);
                     break;
                 case 'matriculation':
                     #						$GLOBALS['ilLog']->write("VALUE: ".LINKS_MATRICULATION);
                     $param->setValue(LINKS_MATRICULATION);
                     break;
                 default:
                     throw new ilWebLinkXmlParserException('Invalid attribute "type" given for element "Dynamic parameter". Aborting');
                     break;
             }
             $this->current_parameters[] = $param;
             break;
     }
 }
 /**
  * show download list
  */
 function showDownloadList()
 {
     //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
     $this->tpl->setCurrentBlock("ContentStyle");
     if (!$this->offlineMode()) {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId()));
     } else {
         $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
     }
     $this->tpl->parseCurrentBlock();
     $this->renderPageTitle();
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->getStandardTemplate();
     $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu($this->offlineMode(), $this->getExportFormat(), "download", true));
     $this->ilLocator();
     //$this->tpl->stopTitleFloating();
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_download_list.html", "Modules/LearningModule");
     // set title header
     $this->tpl->setTitle($this->lm->getTitle());
     $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg"));
     /*
     		$this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
     		$this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
     		$this->tpl->setVariable("LINK_BACK",
     			$this->ctrl->getLinkTarget($this, "")); */
     // output copyright information
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
     if (is_object($md_rights = $md->getRights())) {
         $copyright = $md_rights->getDescription();
         include_once 'Services/MetaData/classes/class.ilMDUtils.php';
         $copyright = ilMDUtils::_parseCopyright($copyright);
         if ($copyright != "") {
             $this->lng->loadLanguageModule("meta");
             $this->tpl->setCurrentBlock("copyright");
             $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
             $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
             $this->tpl->parseCurrentBlock();
         }
     }
     // create table
     require_once "./Services/Table/classes/class.ilTableGUI.php";
     $tbl = new ilTableGUI();
     // load files templates
     $this->tpl->addBlockfile("DOWNLOAD_TABLE", "download_table", "tpl.table.html");
     // load template for table content data
     $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.download_file_row.html", "Modules/LearningModule");
     $export_files = array();
     $types = array("xml", "html", "scorm");
     foreach ($types as $type) {
         if ($this->lm->getPublicExportFile($type) != "") {
             if (is_file($this->lm->getExportDirectory($type) . "/" . $this->lm->getPublicExportFile($type))) {
                 $dir = $this->lm->getExportDirectory($type);
                 $size = filesize($this->lm->getExportDirectory($type) . "/" . $this->lm->getPublicExportFile($type));
                 $export_files[] = array("type" => $type, "file" => $this->lm->getPublicExportFile($type), "size" => $size);
             }
         }
     }
     $num = 0;
     $tbl->setTitle($this->lng->txt("download"));
     $tbl->setHeaderNames(array($this->lng->txt("cont_format"), $this->lng->txt("cont_file"), $this->lng->txt("size"), $this->lng->txt("date"), ""));
     $cols = array("format", "file", "size", "date", "download");
     $header_params = array("ref_id" => $_GET["ref_id"], "obj_id" => $_GET["obj_id"], "cmd" => "showDownloadList", "cmdClass" => strtolower(get_class($this)));
     $tbl->setHeaderVars($cols, $header_params);
     $tbl->setColumnWidth(array("10%", "30%", "20%", "20%", "20%"));
     $tbl->disable("sort");
     // control
     $tbl->setOrderColumn($_GET["sort_by"]);
     $tbl->setOrderDirection($_GET["sort_order"]);
     $tbl->setLimit($_GET["limit"]);
     $tbl->setOffset($_GET["offset"]);
     $tbl->setMaxCount($this->maxcount);
     // ???
     //$this->tpl->setVariable("COLUMN_COUNTS", 5);
     // footer
     //$tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
     $tbl->disable("footer");
     $tbl->setMaxCount(count($export_files));
     $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
     $tbl->render();
     if (count($export_files) > 0) {
         $i = 0;
         foreach ($export_files as $exp_file) {
             if (!$exp_file["size"] > 0) {
                 continue;
             }
             $this->tpl->setCurrentBlock("tbl_content");
             $this->tpl->setVariable("TXT_FILENAME", $exp_file["file"]);
             $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
             $this->tpl->setVariable("CSS_ROW", $css_row);
             $this->tpl->setVariable("TXT_SIZE", $exp_file["size"]);
             $this->tpl->setVariable("TXT_FORMAT", strtoupper($exp_file["type"]));
             $this->tpl->setVariable("CHECKBOX_ID", $exp_file["type"] . ":" . $exp_file["file"]);
             $file_arr = explode("__", $exp_file["file"]);
             $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s", $file_arr[0]));
             $this->tpl->setVariable("TXT_DOWNLOAD", $this->lng->txt("download"));
             $this->ctrl->setParameter($this, "type", $exp_file["type"]);
             $this->tpl->setVariable("LINK_DOWNLOAD", $this->ctrl->getLinkTarget($this, "downloadExportFile"));
             $this->tpl->parseCurrentBlock();
         }
     } else {
         $this->tpl->setCurrentBlock("notfound");
         $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
         $this->tpl->setVariable("NUM_COLS", 5);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->show();
 }
 /**
  * Duplicate media object, return new media object
  */
 function duplicate()
 {
     $new_obj = new ilObjMediaObject();
     $new_obj->setTitle($this->getTitle());
     $new_obj->setDescription($this->getDescription());
     // media items
     foreach ($this->getMediaItems() as $key => $val) {
         $new_obj->addMediaItem($val);
     }
     $new_obj->create(false, true);
     // files
     $new_obj->createDirectory();
     self::_createThumbnailDirectory($new_obj->getId());
     ilUtil::rCopy(ilObjMediaObject::_getDirectory($this->getId()), ilObjMediaObject::_getDirectory($new_obj->getId()));
     ilUtil::rCopy(ilObjMediaObject::_getThumbnailDirectory($this->getId()), ilObjMediaObject::_getThumbnailDirectory($new_obj->getId()));
     // meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD(0, $this->getId(), "mob");
     $new_md = $md->cloneMD(0, $new_obj->getId(), "mob");
     return $new_obj;
 }
 /**
  * Render meta page (description/objectives at beginning)
  *
  * @param object $a_tpl template
  * @param object $a_sco SCO
  * @param string $a_asset_type asset type
  * @param string $a_mode mode
  */
 static function renderMetaPage($a_tpl, $a_sco, $a_asset_type = "", $mode = "")
 {
     global $lng;
     if ($a_sco->getType() != "sco" || $a_sco->getHideObjectivePage()) {
         return;
     }
     if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") {
         $meta = new ilMD($a_sco->getSLMId(), $a_sco->getId(), $a_sco->getType());
         $desc_ids = $meta->getGeneral()->getDescriptionIds();
         $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription();
     }
     if ($mode != 'pdf') {
         // title
         if ($a_asset_type != "entry_asset" && $a_asset_type != "final_asset") {
             $a_tpl->setCurrentBlock("title");
             $a_tpl->setVariable("SCO_TITLE", $a_sco->getTitle());
             $a_tpl->parseCurrentBlock();
         }
     } else {
         // title
         $a_tpl->setCurrentBlock("pdf_title");
         $a_tpl->setVariable("SCO_TITLE", $a_sco->getTitle());
         $a_tpl->parseCurrentBlock();
         $a_tpl->touchBlock("pdf_break");
     }
     // sco description
     if (trim($sco_description) != "") {
         $a_tpl->setCurrentBlock("sco_desc");
         $a_tpl->setVariable("TXT_DESC", $lng->txt("description"));
         include_once "./Services/COPage/classes/class.ilPCParagraph.php";
         $a_tpl->setVariable("VAL_DESC", self::convertLists($sco_description));
         $a_tpl->parseCurrentBlock();
     }
     if ($a_asset_type == "sco") {
         // sco objective(s)
         $objs = $a_sco->getObjectives();
         if (count($objs) > 0) {
             foreach ($objs as $objective) {
                 $a_tpl->setCurrentBlock("sco_obj");
                 $a_tpl->setVariable("VAL_OBJECTIVE", self::convertLists($objective->getObjectiveID()));
                 $a_tpl->parseCurrentBlock();
             }
             $a_tpl->setCurrentBlock("sco_objs");
             $a_tpl->setVariable("TXT_OBJECTIVES", $lng->txt("sahs_objectives"));
             $a_tpl->parseCurrentBlock();
         }
     }
     $a_tpl->setCurrentBlock("meta_page");
     $a_tpl->parseCurrentBlock();
 }
 /**
  * delete meta data entry
  */
 function deleteMetaData()
 {
     // Delete meta data
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $glo_id = ilGlossaryTerm::_lookGlossaryID($this->getTermId());
     $md = new ilMD($glo_id, $this->getId(), $this->getType());
     $md->deleteAll();
 }
 /**
  * Save all titles of chapters/scos/pages
  */
 function saveAllTitles($a_redirect = true)
 {
     global $ilCtrl;
     if (is_array($_POST["title"])) {
         include_once "./Services/MetaData/classes/class.ilMD.php";
         include_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
         foreach ($_POST["title"] as $id => $title) {
             $node_obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
             if (is_object($node_obj)) {
                 // Update Title and description
                 $md = new ilMD($this->object->getId(), $id, $node_obj->getType());
                 $md_gen = $md->getGeneral();
                 $md_gen->setTitle(ilUtil::stripSlashes($title));
                 $md_gen->update();
                 $md->update();
                 ilSCORM2004Node::_writeTitle($id, ilUtil::stripSlashes($title));
             }
         }
     }
     if ($a_redirect) {
         $ilCtrl->redirect($this, "showOrganization");
     }
 }
 public function getMDSection()
 {
     // general section available?
     include_once 'Services/MetaData/classes/class.ilMD.php';
     $md_obj = new ilMD($this->getBlogId(), $this->getId(), "blp");
     if (!is_object($md_section = $md_obj->getGeneral())) {
         $md_section = $md_obj->addGeneral();
         $md_section->save();
     }
     return $md_section;
 }
 function &executeCommand()
 {
     global $tpl, $ilCtrl, $lng;
     $next_class = $this->ctrl->getNextClass($this);
     $cmd = $this->ctrl->getCmd();
     // content style
     $this->tpl->setCurrentBlock("ContentStyle");
     $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->glossary->getStyleSheetId()));
     $this->tpl->parseCurrentBlock();
     // syntax style
     $this->tpl->setCurrentBlock("SyntaxStyle");
     $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
     $this->tpl->parseCurrentBlock();
     require_once "./Modules/Glossary/classes/class.ilGlossaryLocatorGUI.php";
     $gloss_loc =& new ilGlossaryLocatorGUI();
     $gloss_loc->setTerm($this->term);
     $gloss_loc->setGlossary($this->glossary);
     $gloss_loc->setDefinition($this->definition);
     $this->tpl->getStandardTemplate();
     $this->tpl->setTitle($this->term->getTerm() . " - " . $this->lng->txt("cont_definition") . " " . $this->definition->getNr());
     if ($this->ctrl->getNextClass() == "ilpageobjectgui") {
         $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_def_b.png"));
     }
     switch ($next_class) {
         case "ilpageobjectgui":
             // output number of usages
             if ($ilCtrl->getCmd() == "edit" && $ilCtrl->getCmdClass() == "ilpageobjectgui") {
                 $nr = ilGlossaryTerm::getNumberOfUsages($_GET["term_id"]);
                 if ($nr > 0) {
                     $link = "[<a href='" . $ilCtrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") . "'>" . $lng->txt("glo_list_usages") . "</a>]";
                     ilUtil::sendInfo(sprintf($lng->txt("glo_term_is_used_n_times"), $nr) . " " . $link);
                 }
             }
             // not so nice, to do: revise locator handling
             if ($this->ctrl->getNextClass() == "ilpageobjectgui" || $this->ctrl->getCmdClass() == "ileditclipboardgui") {
                 $gloss_loc->display();
             }
             $this->setTabs();
             $this->ctrl->setReturnByClass("ilPageObjectGUI", "edit");
             $this->ctrl->setReturn($this, "listDefinitions");
             $page_gui =& new ilPageObjectGUI("gdf", $this->definition->getId());
             $page = $page_gui->getPageObject();
             $this->definition->assignPageObject($page);
             $page->addUpdateListener($this, "saveShortText");
             $page_gui->setEditPreview(true);
             // metadata
             // ... set title to term, if no title is given
             include_once "./Services/MetaData/classes/class.ilMD.php";
             $md = new ilMD($this->glossary->getId(), $this->definition->getId(), "gdf");
             $md_gen = $md->getGeneral();
             if ($md_gen->getTitle() == "") {
                 $md_gen->setTitle($this->term->getTerm());
                 $md_gen->update();
             }
             $page_gui->activateMetaDataEditor($this->glossary->getId(), $this->definition->getId(), "gdf");
             //	$this->obj, "MDUpdateListener");
             $page_gui->setSourcecodeDownloadScript("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $_GET["ref_id"]);
             $page_gui->setFullscreenLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=fullscreen&amp;ref_id=" . $_GET["ref_id"]);
             $page_gui->setTemplateTargetVar("ADM_CONTENT");
             $page_gui->setOutputMode("edit");
             $page_gui->setEnableKeywords(true);
             $page_gui->setStyleId($this->glossary->getStyleSheetId());
             $page_gui->setLocator($gloss_loc);
             $page_gui->setEnabledInternalLinks(true);
             $page_gui->setIntLinkHelpDefault("GlossaryItem", $_GET["ref_id"]);
             $page_gui->setIntLinkReturn($this->ctrl->getLinkTargetByClass("ilobjglossarygui", "quickList", "", false, false));
             $page_gui->setPageBackTitle($this->lng->txt("cont_definition"));
             $page_gui->setLinkParams("ref_id=" . $_GET["ref_id"]);
             $page_gui->setHeader($this->term->getTerm());
             $page_gui->setFileDownloadLink("ilias.php?baseClass=ilGlossaryPresentationGUI&amp;cmd=downloadFile&amp;ref_id=" . $_GET["ref_id"]);
             $page_gui->setPresentationTitle($this->term->getTerm());
             $ret =& $this->ctrl->forwardCommand($page_gui);
             $tpl->setContent($ret);
             break;
         default:
             $this->setTabs();
             $gloss_loc->display();
             $ret =& $this->{$cmd}();
             break;
     }
 }
 private function renderItems($oContainerTpl, $results, $topic)
 {
     // main shop_content
     global $ilUser;
     $items_counter = 0;
     $cur_obj_type = '';
     $tpl = $this->newBlockTemplate();
     foreach ($this->type_ordering as $act_type) {
         $item_html = array();
         if (count($results[(int) $topic['id']][$act_type])) {
             foreach ($results[$topic['id']][$act_type] as $key => $item) {
                 // price presentation
                 $oPaymentObject = new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id']));
                 $oPrice = new ilPaymentPrices((int) $oPaymentObject->getPobjectId());
                 $lowest_price = $oPrice->getLowestPrice();
                 $special_icon = ' ';
                 if ($oPaymentObject->getSpecial() == '1') {
                     $special_icon = ilShopUtils::_getSpecialObjectSymbol();
                 }
                 $results[$topic['id']][$act_type][$key]['title'] = $item['title'] . ' ' . ($results[$topic['id']][$act_type][$key]['special_icon'] = $special_icon);
                 $results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price'];
                 $paymethod_icon = ilShopUtils::_getPaymethodSymbol($oPaymentObject->getPayMethod());
                 $shoppingcart_icon = ilShopUtils::_addToShoppingCartSymbol($item['ref_id']);
                 $results[$topic['id']][$act_type][$key]['price_string'] = ($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from') . ' ' : '') . ilPaymentPrices::_formatPriceToString($lowest_price['price']) . ' ' . ($results[$topic['id']][$act_type][$key]['shoppingcart_icon'] = $shoppingcart_icon . ' ' . ($results[$topic['id']][$act_type][$key]['paymethod_icon'] = $paymethod_icon));
                 // authors
                 include_once 'Services/MetaData/classes/class.ilMD.php';
                 $md_obj = new ilMD($item['obj_id'], 0, $item['type']);
                 if (is_object($md_section = $md_obj->getLifecycle())) {
                     $sep = $ent_str = "";
                     foreach ($ids = $md_section->getContributeIds() as $con_id) {
                         $md_con = $md_section->getContribute($con_id);
                         if ($md_con->getRole() == "Author") {
                             foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                                 $md_ent = $md_con->getEntity($ent_id);
                                 $ent_str = $ent_str . $sep . $md_ent->getEntity();
                                 $sep = ", ";
                             }
                         }
                     }
                     $results[$topic['id']][$act_type][$key]['author'] = $ent_str;
                 }
             }
             $results[$topic['id']][$act_type] = $this->sortResult($results[$topic['id']][$act_type]);
             foreach ($results[$topic['id']][$act_type] as $key => $item) {
                 // get list gui class for each object type
                 list($item, $html) = $this->getObjectListItem($cur_obj_type, $item);
                 if ($html) {
                     $item_html[$item['ref_id']] = $html;
                 }
             }
             // output block for resource type
             if (count($item_html) > 0) {
                 // add a header for each resource type
                 $tpl->setCurrentBlock("container_header_row_image");
                 $tpl->setVariable("HEADER_IMG", ilObject::_getIcon('', '', $act_type));
                 $tpl->setVariable("HEADER_ALT", $this->lng->txt("objs_" . $act_type));
                 $tpl->setVariable("BLOCK_HEADER_CONTENT", $this->lng->txt("objs_" . $act_type));
                 $this->resetRowType();
                 // content row
                 foreach ($item_html as $ref_id => $html) {
                     $this->addStandardRow($tpl, $html);
                 }
                 ++$items_counter;
             }
         }
     }
     if ($items_counter > 0) {
         $oContainerTpl->setCurrentBlock('loop_item');
         $oContainerTpl->setCurrentBlock('topic_title');
         $oContainerTpl->setVariable('TOPIC_TITLE', $topic['title']);
         $oContainerTpl->parseCurrentBlock('topic_title');
         $oContainerTpl->setVariable('CONTAINER_LIST_BLOCK', $html);
         $oContainerTpl->parseCurrentBlock('loop_item');
         $tpl->setContent($oContainerTpl->get());
         $container_html = $tpl->get();
         return $container_html;
     }
 }
 /**
  * Copy sco
  */
 function copy($a_target_slm)
 {
     $sco = new ilSCORM2004Sco($a_target_slm);
     $sco->setTitle($this->getTitle());
     if ($this->getSLMId() != $a_target_slm->getId()) {
         $sco->setImportId("il__sco_" . $this->getId());
     }
     $sco->setSLMId($a_target_slm->getId());
     $sco->setType($this->getType());
     $sco->setDescription($this->getDescription());
     $sco->create(true);
     $a_copied_nodes[$this->getId()] = $sco->getId();
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType());
     $new_md =& $md->cloneMD($a_target_slm->getId(), $sco->getId(), $this->getType());
     return $sco;
 }
 /**
  * export questions to xml
  */
 function toXML($questions)
 {
     if (!is_array($questions)) {
         $questions =& $this->getQuestions();
     }
     if (count($questions) == 0) {
         $questions =& $this->getQuestions();
     }
     $xml = "";
     include_once "./Services/Xml/classes/class.ilXmlWriter.php";
     $a_xml_writer = new ilXmlWriter();
     // set xml header
     $a_xml_writer->xmlHeader();
     $attrs = array("xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd");
     $a_xml_writer->xmlStartTag("surveyobject", $attrs);
     $attrs = array("id" => "qpl_" . $this->getId(), "label" => $this->getTitle(), "online" => $this->getOnline());
     $a_xml_writer->xmlStartTag("surveyquestions", $attrs);
     $a_xml_writer->xmlElement("dummy", NULL, "dummy");
     // add ILIAS specific metadata
     $a_xml_writer->xmlStartTag("metadata");
     $a_xml_writer->xmlStartTag("metadatafield");
     $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($this->getId(), 0, $this->getType());
     $writer = new ilXmlWriter();
     $md->toXml($writer);
     $metadata = $writer->xmlDumpMem();
     $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
     $a_xml_writer->xmlEndTag("metadatafield");
     $a_xml_writer->xmlEndTag("metadata");
     $a_xml_writer->xmlEndTag("surveyquestions");
     $a_xml_writer->xmlEndTag("surveyobject");
     $xml = $a_xml_writer->xmlDumpMem(FALSE);
     $questionxml = "";
     foreach ($questions as $key => $value) {
         $questiontype = $this->getQuestiontype($value);
         include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
         SurveyQuestion::_includeClass($questiontype);
         $question = new $questiontype();
         $question->loadFromDb($value);
         $questionxml .= $question->toXML(false);
     }
     $xml = str_replace("<dummy>dummy</dummy>", $questionxml, $xml);
     return $xml;
 }
 /**
  * split page at hierarchical id
  *
  * the main reason for this method being static is that a lm page
  * object is not available within ilPageContentGUI where this method
  * is called
  */
 function _splitPage($a_page_id, $a_pg_parent_type, $a_hier_id)
 {
     // get content object (learning module / digilib book)
     $lm_id = ilLMObject::_lookupContObjID($a_page_id);
     $type = ilObject::_lookupType($lm_id, false);
     switch ($type) {
         case "lm":
             include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
             $cont_obj = new ilObjLearningModule($lm_id, false);
             break;
         case "dbk":
             include_once "./Modules/LearningModule/classes/class.ilObjDlBook.php";
             $cont_obj = new ilObjDlBook($lm_id, false);
             break;
     }
     $source_lm_page = new ilLMPageObject($cont_obj, $a_page_id);
     // create new page
     $lm_page = new ilLMPageObject($cont_obj);
     $lm_page->setTitle($source_lm_page->getTitle());
     $lm_page->setLMId($source_lm_page->getLMId());
     $lm_page->setType($source_lm_page->getType());
     $lm_page->setDescription($source_lm_page->getDescription());
     $lm_page->create(true);
     // copy complete content of source page to new page
     $source_page = $source_lm_page->getPageObject();
     $page = $lm_page->getPageObject();
     $page->setXMLContent($source_page->copyXMLContent());
     //echo htmlentities($source_page->copyXMLContent());
     $page->buildDom(true);
     $page->update();
     //		echo "-".$page->getId()."-".$page->getParentType()."-";
     // copy meta data
     include_once "Services/MetaData/classes/class.ilMD.php";
     $md = new ilMD($source_lm_page->getLMId(), $a_page_id, $source_lm_page->getType());
     $md->cloneMD($source_lm_page->getLMId(), $lm_page->getId(), $source_lm_page->getType());
     // insert new page in tree (after original page)
     $tree = new ilTree($cont_obj->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($tree->isInTree($source_lm_page->getId())) {
         $parent_node = $tree->getParentNodeData($source_lm_page->getId());
         $tree->insertNode($lm_page->getId(), $parent_node["child"], $source_lm_page->getId());
     }
     // remove all nodes < hierarchical id from new page (incl. update)
     $page->addHierIds();
     $page->deleteContentBeforeHierId($a_hier_id);
     //		$page->update();
     // remove all nodes >= hierarchical id from source page
     $source_page->buildDom();
     $source_page->addHierIds();
     $source_page->deleteContentFromHierId($a_hier_id);
     return $lm_page;
 }
Beispiel #29
0
 /**
  * Save export id
  *
  * @param
  * @return
  */
 public static function saveExportId($a_lm_id, $a_lmobj_id, $a_exp_id, $a_type = "pg")
 {
     global $ilDB;
     include_once "Services/MetaData/classes/class.ilMDIdentifier.php";
     if (trim($a_exp_id) == "") {
         // delete export ids, if existing
         $entries = ilMDIdentifier::_getEntriesForObj($a_lm_id, $a_lmobj_id, $a_type);
         foreach ($entries as $id => $e) {
             if ($e["catalog"] == "ILIAS_NID") {
                 $identifier = new ilMDIdentifier();
                 $identifier->setMetaId($id);
                 $identifier->delete();
             }
         }
     } else {
         // update existing entry
         $entries = ilMDIdentifier::_getEntriesForObj($a_lm_id, $a_lmobj_id, $a_type);
         $updated = false;
         foreach ($entries as $id => $e) {
             if ($e["catalog"] == "ILIAS_NID") {
                 $identifier = new ilMDIdentifier();
                 $identifier->setMetaId($id);
                 $identifier->read();
                 $identifier->setEntry($a_exp_id);
                 $identifier->update();
                 $updated = true;
             }
         }
         // nothing updated? create a new one
         if (!$updated) {
             include_once "./Services/MetaData/classes/class.ilMD.php";
             $md = new ilMD($a_lm_id, $a_lmobj_id, $a_type);
             $md_gen = $md->getGeneral();
             $identifier = $md_gen->addIdentifier();
             $identifier->setEntry($a_exp_id);
             $identifier->setCatalog("ILIAS_NID");
             $identifier->save();
         }
     }
 }
 /**
  * save all keywords
  *
  * @param	string		$a_xml		xml data of page
  */
 function saveMetaKeywords($a_xml)
 {
     // not nice, should be set by context per method
     if ($this->getParentType() == "gdf" || $this->getParentType() == "lm" || $this->getParentType() == "dbk") {
         $doc = domxml_open_mem($a_xml);
         // get existing keywords
         $keywords = array();
         // find all Keyw tags
         $xpc = xpath_new_context($doc);
         $path = "//Keyw";
         $res = xpath_eval($xpc, $path);
         for ($i = 0; $i < count($res->nodeset); $i++) {
             $k = trim(strip_tags($res->nodeset[$i]->get_content()));
             if (!in_array($k, $keywords)) {
                 $keywords[] = $k;
             }
         }
         $meta_type = $this->getParentType() == "gdf" ? "gdf" : "pg";
         $meta_rep_id = $this->getParentId();
         $meta_id = $this->getId();
         include_once "./Services/MetaData/classes/class.ilMD.php";
         $md_obj = new ilMD($meta_rep_id, $meta_id, $meta_type);
         $mkeywords = array();
         $lang = "";
         if (is_object($md_section = $md_obj->getGeneral())) {
             foreach ($ids = $md_section->getKeywordIds() as $id) {
                 $md_key = $md_section->getKeyword($id);
                 $mkeywords[] = strtolower($md_key->getKeyword());
                 if ($lang == "") {
                     $lang = $md_key->getKeywordLanguageCode();
                 }
             }
         }
         if ($lang == "") {
             foreach ($ids = $md_section->getLanguageIds() as $id) {
                 $md_lang = $md_section->getLanguage($id);
                 if ($lang == "") {
                     $lang = $md_lang->getLanguageCode();
                 }
             }
         }
         foreach ($keywords as $k) {
             if (!in_array(strtolower($k), $mkeywords)) {
                 if (trim($k) != "" && $lang != "") {
                     $md_key = $md_section->addKeyword();
                     $md_key->setKeyword(ilUtil::stripSlashes($k));
                     $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
                     $md_key->save();
                 }
                 $mkeywords[] = strtolower($k);
             }
         }
     }
 }