public static function getGroupedItems($a_obj_id, $a_use_subtree_by_id = false) { static $cache = array(); if (isset($cache[$a_obj_id])) { return $cache[$a_obj_id]; } return $cache[$a_obj_id] = ilLPCollections::getGroupedItems($a_obj_id, $a_use_subtree_by_id); }
/** * Clone object dependencies (crs items, preconditions) * * @access public * @param int target ref id of new course * @param int copy id * */ public function cloneDependencies($a_target_id, $a_copy_id) { parent::cloneDependencies($a_target_id, $a_copy_id); include_once 'Services/Object/classes/class.ilObjectActivation.php'; ilObjectActivation::cloneDependencies($this->getRefId(), $a_target_id, $a_copy_id); include_once 'Services/Tracking/classes/class.ilLPCollections.php'; $lp_collection = new ilLPCollections($this->getId()); $lp_collection->cloneCollections($a_target_id, $a_copy_id); return true; }
/** * Returns a description of the available certificate parameters. The description will be shown at * the bottom of the certificate editor text area. * * @return string The certificate parameters description */ public function getCertificateVariablesDescription() { global $lng; $vars = $this->getBaseVariablesDescription(); $vars["SCORM_TITLE"] = $lng->txt("certificate_ph_scormtitle"); $vars["SCORM_POINTS"] = $lng->txt("certificate_ph_scormpoints"); $vars["SCORM_POINTS_MAX"] = $lng->txt("certificate_ph_scormmaxpoints"); $template = new ilTemplate("tpl.certificate_edit.html", TRUE, TRUE, "Modules/ScormAicc"); $template->setCurrentBlock("items"); foreach ($vars as $id => $caption) { $template->setVariable("ID", $id); $template->setVariable("TXT", $caption); $template->parseCurrentBlock(); } $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction")); include_once 'Services/Tracking/classes/class.ilLPCollections.php'; $lp_collections = new ilLPCollections($this->object->getId()); if (!($items = ilLPCollections::_getPossibleSAHSItems($this->object->getId()))) { $template->setCurrentBlock('NO_SCO'); $template->setVariable('PH_NO_SCO', $lng->txt('certificate_ph_no_sco')); $template->parseCurrentBlock(); } else { $template->setCurrentBlock('SCOS'); $template->setVariable('PH_SCOS', $lng->txt('certificate_ph_scos')); $template->parseCurrentBlock(); $template->setCurrentBlock('SCO_HEADER'); $template->setVariable('PH_TITLE_SCO', $lng->txt('certificate_ph_title_sco')); //$template->setVariable('PH_PH',$lng->txt('certificate_ph_ph')); $template->setVariable('PH_SCO_TITLE', $lng->txt('certificate_ph_sco_title')); $template->setVariable('PH_SCO_POINTS_RAW', $lng->txt('certificate_ph_sco_points_raw')); $template->setVariable('PH_SCO_POINTS_MAX', $lng->txt('certificate_ph_sco_points_max')); $template->setVariable('PH_SCO_POINTS_SCALED', $lng->txt('certificate_ph_sco_points_scaled')); $template->parseCurrentBlock(); } $counter = 0; foreach (ilLPCollections::_getPossibleSAHSItems($this->object->getId()) as $item_id => $sahs_item) { if ($lp_collections->isAssigned($item_id)) { $template->setCurrentBlock("SCO"); $template->setVariable('SCO_TITLE', $sahs_item['title']); $template->setVariable('PH_SCO_TITLE', '[SCO_T_' . $counter . ']'); $template->setVariable('PH_SCO_POINTS_RAW', '[SCO_P_' . $counter . ']'); $template->setVariable('PH_SCO_POINTS_MAX', '[SCO_PM_' . $counter . ']'); $template->setVariable('PH_SCO_POINTS_SCALED', '[SCO_PP_' . $counter . ']'); $template->parseCurrentBlock(); $counter++; } } return $template->get(); }
/** * delete object or referenced object * (in the case of a referenced object, object data is only deleted * if last reference is deleted) * This function removes an object entirely from system!! * * @access public * @return boolean true if object was removed completely; false if only a references was removed */ function delete() { global $rbacadmin, $log, $ilDB; $remove = false; // delete object_data entry if (!$this->referenced || $this->countReferences() == 1) { // check type match $db_type = ilObject::_lookupType($this->getId()); if ($this->type != $db_type) { $message = "ilObject::delete(): Type mismatch. Object with obj_id: " . $this->id . " " . "was instantiated by type '" . $this->type . "'. DB type is: " . $db_type; // write log entry $log->write($message); // raise error $this->ilias->raiseError("ilObject::delete(): Type mismatch. (" . $this->type . "/" . $this->id . ")", $this->ilias->error_obj->WARNING); } // delete entry in object_data $q = "DELETE FROM object_data " . "WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($q); // delete long description $query = "DELETE FROM object_description WHERE obj_id = " . $ilDB->quote($this->getId(), "integer"); $ilDB->manipulate($query); // write log entry $log->write("ilObject::delete(), deleted object, obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle()); // remove news include_once "./Services/News/classes/class.ilNewsItem.php"; $news_item = new ilNewsItem(); $news_item->deleteNewsOfContext($this->getId(), $this->getType()); include_once "./Services/Block/classes/class.ilBlockSetting.php"; ilBlockSetting::_deleteSettingsOfBlock($this->getId(), "news"); include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; ilDidacticTemplateObjSettings::deleteByObjId($this->getId()); /* remove notes (see infoscreen gui) as they can be seen as personal data we are keeping them for now include_once("Services/Notes/classes/class.ilNote.php"); foreach(array(IL_NOTE_PRIVATE, IL_NOTE_PUBLIC) as $note_type) { foreach(ilNote::_getNotesOfObject($this->id, 0, $this->type, $note_type) as $note) { $note->delete(); } } */ // BEGIN WebDAV: Delete WebDAV properties $query = "DELETE FROM dav_property " . "WHERE obj_id = " . $ilDB->quote($this->getId(), 'integer'); $res = $ilDB->manipulate($query); // END WebDAV: Delete WebDAV properties include_once './Services/Tracking/classes/class.ilChangeEvent.php'; ilChangeEvent::_delete($this->getId()); include_once './Services/Tracking/classes/class.ilLPCollections.php'; ilLPCollections::_deleteAll($this->getId()); include_once './Services/WebServices/ECS/classes/class.ilECSImport.php'; ilECSImport::_deleteByObjId($this->getId()); $remove = true; } else { // write log entry $log->write("ilObject::delete(), object not deleted, number of references: " . $this->countReferences() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle()); } // delete object_reference entry if ($this->referenced) { include_once "Services/Object/classes/class.ilObjectActivation.php"; ilObjectActivation::deleteAllEntries($this->getRefId()); // delete entry in object_reference $query = "DELETE FROM object_reference " . "WHERE ref_id = " . $ilDB->quote($this->getRefId(), 'integer'); $res = $ilDB->manipulate($query); // write log entry $log->write("ilObject::delete(), reference deleted, ref_id: " . $this->getRefId() . ", obj_id: " . $this->getId() . ", type: " . $this->getType() . ", title: " . $this->getTitle()); // DELETE PERMISSION ENTRIES IN RBAC_PA // DONE: method overwritten in ilObjRole & ilObjUser. // this call only applies for objects in rbac (not usr,role,rolt) // TODO: Do this for role templates too $rbacadmin->revokePermission($this->getRefId(), 0, false); include_once "Services/AccessControl/classes/class.ilRbacLog.php"; ilRbacLog::delete($this->getRefId()); // Remove applied didactic template setting include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; ilDidacticTemplateObjSettings::deleteByRefId($this->getRefId()); // Remove desktop items ilUtil::removeItemFromDesktops($this->getRefId()); } // remove conditions if ($this->referenced) { $ch =& new ilConditionHandler(); $ch->delete($this->getRefId()); unset($ch); } return $remove; }
function __read() { global $ilObjDataCache, $ilDB; $this->items = array(); if ($ilObjDataCache->lookupType($this->getObjId()) != 'sahs') { $course_ref_ids = ilObject::_getAllReferences($this->getObjId()); $course_ref_id = end($course_ref_ids); $query = "SELECT * FROM ut_lp_collections utc " . "JOIN object_reference obr ON item_id = ref_id " . "JOIN object_data obd ON obr.obj_id = obd.obj_id " . "WHERE utc.obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer') . " " . "ORDER BY title"; } else { $query = "SELECT * FROM ut_lp_collections WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer'); } $res = $this->db->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { if ($ilObjDataCache->lookupType($this->getObjId()) != 'sahs') { if (!in_array($row->item_id, ilLPCollections::_getPossibleItems($course_ref_id))) { $this->__deleteEntry($this->getObjId(), $row->item_id); continue; } } // Check anonymized if ($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId($row->item_id)) == 'tst') { include_once './Modules/Test/classes/class.ilObjTest.php'; if (ilObjTest::_lookupAnonymity($item_obj_id)) { $this->__deleteEntry($this->getObjId(), $row->item_id); continue; } } $this->items[] = $row->item_id; } }
/** * Clone object dependencies (start objects, preconditions) * * @access public * @param int target ref id of new course * @param int copy id * */ public function cloneDependencies($a_target_id, $a_copy_id) { parent::cloneDependencies($a_target_id, $a_copy_id); // Clone course start objects include_once 'Modules/Course/classes/class.ilCourseStart.php'; $start = new ilCourseStart($this->getRefId(), $this->getId()); $start->cloneDependencies($a_target_id, $a_copy_id); // Clone course item settings include_once 'Services/Object/classes/class.ilObjectActivation.php'; ilObjectActivation::cloneDependencies($this->getRefId(), $a_target_id, $a_copy_id); // Clone course learning objectives include_once 'Modules/Course/classes/class.ilCourseObjective.php'; $crs_objective = new ilCourseObjective($this); $crs_objective->ilClone($a_target_id, $a_copy_id); include_once 'Services/Tracking/classes/class.ilLPCollections.php'; $lp_collection = new ilLPCollections($this->getId()); $lp_collection->cloneCollections($a_target_id, $a_copy_id); return true; }
function getValidModes() { global $lng; switch ($this->obj_type) { case 'crs': if (ilLPObjSettings::_checkObjectives($this->getObjId())) { return array(LP_MODE_OBJECTIVES => $lng->txt('trac_mode_objectives')); } return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_MANUAL_BY_TUTOR => $lng->txt('trac_mode_manual_by_tutor'), LP_MODE_COLLECTION => $lng->txt('trac_mode_collection')); break; case 'dbk': return array(LP_MODE_MANUAL => $lng->txt('trac_mode_manual'), LP_MODE_DEACTIVATE => $lng->txt('trac_mode_deactivated')); case 'lm': return array(LP_MODE_MANUAL => $lng->txt('trac_mode_manual'), LP_MODE_VISITS => $lng->txt('trac_mode_visits'), LP_MODE_TLT => $lng->txt('trac_mode_tlt'), LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated')); case 'htlm': return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_MANUAL => $lng->txt('trac_mode_manual')); case 'sahs': include_once './Services/Tracking/classes/class.ilLPCollections.php'; include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; $subtype = ilObjSAHSLearningModule::_lookupSubType($this->getObjId()); if ($subtype != "scorm2004") { if (ilLPObjSettings::_checkSCORMPreconditions($this->getObjId())) { return array(LP_MODE_SCORM => $lng->txt('trac_mode_scorm_aicc')); } if (ilLPCollections::_getCountPossibleSAHSItems($this->getObjId())) { return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_SCORM => $lng->txt('trac_mode_scorm_aicc')); } return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated')); } else { if (ilLPObjSettings::_checkSCORMPreconditions($this->getObjId())) { return array(LP_MODE_SCORM => $lng->txt('trac_mode_scorm_aicc'), LP_MODE_SCORM_PACKAGE => $lng->txt('trac_mode_scorm_package')); } if (ilLPCollections::_getCountPossibleSAHSItems($this->getObjId())) { return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_SCORM_PACKAGE => $lng->txt('trac_mode_scorm_package'), LP_MODE_SCORM => $lng->txt('trac_mode_scorm_aicc')); } return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_SCORM_PACKAGE => $lng->txt('trac_mode_scorm_package')); } break; case 'tst': return array(LP_MODE_TEST_FINISHED => $lng->txt('trac_mode_test_finished'), LP_MODE_TEST_PASSED => $lng->txt('trac_mode_test_passed'), LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated')); case 'exc': return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_EXERCISE_RETURNED => $lng->txt('trac_mode_exercise_returned')); case 'grp': return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_MANUAL_BY_TUTOR => $lng->txt('trac_mode_manual_by_tutor'), LP_MODE_COLLECTION => $lng->txt('trac_mode_collection')); case 'fold': return array(LP_MODE_DEACTIVATED => $lng->txt('trac_mode_deactivated'), LP_MODE_COLLECTION => $lng->txt('trac_mode_collection')); case 'sess': return array(LP_MODE_EVENT => $this->lng->txt('trac_mode_event')); default: return array(); } }
/** * Init table */ protected function initTable() { global $ilCtrl; $this->setFormAction($ilCtrl->getFormAction($this->getParentObject())); switch ($this->getMode()) { case LP_MODE_COLLECTION: $this->setRowTemplate('tpl.lp_collection_row.html', 'Services/Tracking'); $this->setTitle($this->lng->txt('trac_lp_determination')); $this->setDescription($this->lng->txt('trac_lp_determination_info_crs')); break; case LP_MODE_MANUAL_BY_TUTOR: $this->setRowTemplate('tpl.lp_collection_row.html', 'Services/Tracking'); $this->setTitle($this->lng->txt('trac_lp_determination_tutor')); $this->setDescription($this->lng->txt('trac_lp_determination_info_crs_tutor')); break; case LP_MODE_SCORM: $this->setRowTemplate('tpl.lp_collection_scorm_row.html', 'Services/Tracking'); $this->setTitle($this->lng->txt('trac_lp_determination')); $this->setDescription($this->lng->txt('trac_lp_determination_info_sco')); break; } $this->addColumn('', '', '1px'); $this->addColumn($this->lng->txt('item'), 'title', '50%'); if ($this->getMode() != LP_MODE_SCORM) { $this->addColumn($this->lng->txt('trac_mode'), 'mode'); } if ($this->getMode() != LP_MODE_MANUAL_BY_TUTOR) { $this->addMultiCommand('assign', $this->lng->txt('trac_collection_assign')); $this->addMultiCommand('deassign', $this->lng->txt('trac_collection_deassign')); $this->addColumn($this->lng->txt('trac_determines_learning_progress'), 'status'); } else { $this->addMultiCommand('assign', $this->lng->txt('trac_manual_display')); $this->addMultiCommand('deassign', $this->lng->txt('trac_manual_no_display')); $this->addColumn($this->lng->txt('trac_manual_is_displayed'), 'status'); } $this->enable('select_all'); $this->setSelectAllCheckbox('item_ids'); if ($this->getMode() == LP_MODE_COLLECTION) { $this->addMultiCommand('groupMaterials', $this->lng->txt('trac_group_materials')); if (ilLPCollections::hasGroupedItems(ilObject::_lookupObjId($this->getNode()))) { $this->addMultiCommand('releaseMaterials', $this->lng->txt('trac_release_materials')); } } }
/** * Init form for condition table * * @access private * @param * */ private function initFormCondition($a_source_id, $a_condition_id = 0, $a_mode = 'add') { $trigger_obj_id = ilObject::_lookupObjId($a_source_id); $trigger_type = ilObject::_lookupType($trigger_obj_id); $condition = ilConditionHandler::_getCondition($a_condition_id); if (is_object($this->form)) { return true; } include_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $this->form = new ilPropertyFormGUI(); $this->ctrl->setParameter($this, 'source_id', $a_source_id); $this->form->setFormAction($this->ctrl->getFormAction($this)); $info_source = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_source")); $info_source->setValue(ilObject::_lookupTitle(ilObject::_lookupObjId($a_source_id))); $this->form->addItem($info_source); $info_target = new ilNonEditableValueGUI($this->lng->txt("rbac_precondition_target")); $info_target->setValue($this->getTargetTitle()); $this->form->addItem($info_target); /* moved to list $obl = new ilCheckboxInputGUI($this->lng->txt('precondition_obligatory'), 'obligatory'); $obl->setInfo($this->lng->txt('precondition_obligatory_info')); $obl->setValue(1); if($a_condition_id) { $obl->setChecked($condition['obligatory']); } else { $obl->setChecked(true); } $this->form->addItem($obl); */ $obl = new ilHiddenInputGUI('obligatory'); if ($a_condition_id) { $obl->setValue($condition['obligatory']); } else { $obl->setValue(1); } $this->form->addItem($obl); $sel = new ilSelectInputGUI($this->lng->txt('condition'), 'operator'); include_once "./Services/AccessControl/classes/class.ilConditionHandler.php"; $ch_obj = new ilConditionHandler(); if ($a_mode == 'add') { $operators[0] = $this->lng->txt('select_one'); } foreach ($ch_obj->getOperatorsByTargetType($trigger_type) as $operator) { $operators[$operator] = $this->lng->txt('condition_' . $operator); } $sel->setValue(isset($condition['operator']) ? $condition['operator'] : 0); $sel->setOptions($operators); $sel->setRequired(true); $this->form->addItem($sel); if (ilConditionHandler::_isReferenceHandlingOptional($this->getTargetType())) { $rad_opt = new ilRadioGroupInputGUI($this->lng->txt('cond_ref_handling'), 'ref_handling'); $rad_opt->setValue(isset($condition['ref_handling']) ? $condition['ref_handling'] : ilConditionHandler::SHARED_CONDITIONS); $opt2 = new ilRadioOption($this->lng->txt('cond_ref_shared'), ilConditionHandler::SHARED_CONDITIONS); $rad_opt->addOption($opt2); $opt1 = new ilRadioOption($this->lng->txt('cond_ref_unique'), ilConditionHandler::UNIQUE_CONDITIONS); $rad_opt->addOption($opt1); $this->form->addItem($rad_opt); } // Additional settings for SCO's if ($trigger_type == 'sahs') { $this->lng->loadLanguageModule('trac'); include_once 'Services/Tracking/classes/class.ilLPCollections.php'; $lp_collections = new ilLPCollections($trigger_obj_id); $cus = new ilCustomInputGUI($this->lng->txt('trac_sahs_relevant_items'), 'item_ids[]'); $cus->setRequired(true); $tpl = new ilTemplate('tpl.condition_handler_sco_row.html', true, true, "Services/AccessControl"); $counter = 0; foreach (ilLPCollections::_getPossibleSAHSItems($trigger_obj_id) as $item_id => $sahs_item) { $tpl->setCurrentBlock("sco_row"); $tpl->setVariable('SCO_ID', $item_id); $tpl->setVariable('SCO_TITLE', $sahs_item['title']); $tpl->setVariable('CHECKED', $lp_collections->isAssigned($item_id) ? 'checked="checked"' : ''); $tpl->parseCurrentBlock(); $counter++; } $tpl->setVariable('INFO_SEL', $this->lng->txt('trac_lp_determination_info_sco')); $cus->setHTML($tpl->get()); $this->form->addItem($cus); } switch ($a_mode) { case 'edit': $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.png')); $this->form->setTitle($this->lng->txt('rbac_edit_condition')); $this->form->addCommandButton('updateCondition', $this->lng->txt('save')); $this->form->addCommandButton('listConditions', $this->lng->txt('cancel')); break; case 'add': $this->form->setTitleIcon(ilUtil::getImagePath('icon_' . $this->getTargetType() . '.png')); $this->form->setTitle($this->lng->txt('add_condition')); $this->form->addCommandButton('assign', $this->lng->txt('save')); $this->form->addCommandButton('selector', $this->lng->txt('back')); break; } return true; }
/** * Save obligatory state per grouped materials */ protected function saveObligatoryMaterials() { if (!is_array((array) $_POST['grp'])) { ilUtil::sendFailure($this->lng->txt('select_one'), true); $this->ctrl->redirect($this, 'show'); } try { include_once './Services/Tracking/classes/class.ilLPCollections.php'; ilLPCollections::saveObligatoryMaterials($this->getObjId(), (array) $_POST['grp']); // refresh learning progress include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php"; ilLPStatusWrapper::_refreshStatus($this->getObjId()); ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); $this->ctrl->redirect($this, 'show'); } catch (UnexpectedValueException $e) { ilUtil::sendFailure($this->lng->txt('trac_grouped_material_obligatory_err'), true); ilUtil::sendInfo($this->lng->txt('err_check_input'), true); $this->ctrl->redirect($this, 'show'); } }
/** * Test LP collections * @return */ public function testLPCollections() { include_once './Services/Tracking/classes/class.ilLPCollections.php'; $coll = new ilLPCollections(999); $coll->add(888); $coll->delete(888); $coll->add(777); ilLPCollections::_deleteAll(999); }