public function loadObjectivesTitles()
 {
     require_once 'Modules/Course/classes/class.ilCourseObjective.php';
     foreach ($this->objectivesByQuestion as $objectiveId) {
         if (!isset($this->objectivesTitles[$objectiveId])) {
             $objectiveTitle = ilCourseObjective::lookupObjectiveTitle($objectiveId);
             $this->objectivesTitles[$objectiveId] = $objectiveTitle;
         }
     }
 }
Esempio n. 2
0
 /**
  * 
  * @param type $a_container_id
  * @param type $a_objective_id
  * @param type $a_passes
  * @return boolean
  */
 public static function lookupMaxAttempts($a_container_id, $a_objective_id)
 {
     include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
     $settings = ilLOSettings::getInstanceByObjId($a_container_id);
     if ($settings->isGeneralQualifiedTestVisible()) {
         return 0;
     }
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $max_passes = ilCourseObjective::lookupMaxPasses($a_objective_id);
     return (int) $max_passes;
 }
 /**
  * Lookup all relevant objective ids for a specific test
  * @return array
  */
 protected function lookupRelevantObjectiveIdsForTest($a_container_id, $a_tst_ref_id, $a_user_id)
 {
     include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
     $assignments = ilLOTestAssignments::getInstance($a_container_id);
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $objective_ids = ilCourseObjective::_getObjectiveIds($a_container_id);
     $relevant_objective_ids = array();
     if (!$this->getSettings()->hasSeparateInitialTests()) {
         if ($a_tst_ref_id == $this->getSettings()->getInitialTest()) {
             $relevant_objective_ids = $objective_ids;
         }
     } elseif (!$this->getSettings()->hasSeparateQualifiedTests()) {
         if ($a_tst_ref_id == $this->getSettings()->getQualifiedTest()) {
             $relevant_objective_ids = $objective_ids;
         }
     }
     foreach ((array) $objective_ids as $objective_id) {
         $assigned_itest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);
         if ($assigned_itest == $a_tst_ref_id) {
             $relevant_objective_ids[] = $objective_id;
         }
         $assigned_qtest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
         if ($assigned_qtest == $a_tst_ref_id) {
             $relevant_objective_ids[] = $objective_id;
         }
     }
     $relevant_objective_ids = array_unique($relevant_objective_ids);
     if (count($relevant_objective_ids) <= 1) {
         return $relevant_objective_ids;
     }
     // filter passed objectives
     $test_type = $assignments->getTypeByTest($a_tst_ref_id);
     $passed_objectives = array();
     include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
     $results = new ilLOUserResults($a_container_id, $a_user_id);
     $passed = $results->getCompletedObjectiveIds();
     $GLOBALS['ilLog']->write(__METHOD__ . ': Passed objectives are ' . print_r($passed, TRUE) . ' test_type = ' . $test_type);
     // all completed => show all objectives
     if (count($passed) >= count($relevant_objective_ids)) {
         return $relevant_objective_ids;
     }
     $unpassed = array();
     foreach ($relevant_objective_ids as $objective_id) {
         if (!in_array($objective_id, $passed)) {
             $unpassed[] = $objective_id;
         }
     }
     return $unpassed;
 }
 /**
  * parse
  *
  * @access public
  * @param array array of objective id's
  */
 public function parse($a_objective_ids)
 {
     $position = 1;
     foreach ($a_objective_ids as $objective_id) {
         $objective = new ilCourseObjective($this->course_obj, $objective_id);
         $objective_data['id'] = $objective_id;
         $objective_data['position'] = sprintf("%.1f", $position++) * 10;
         $objective_data['title'] = $objective->getTitle();
         $objective_data['description'] = $objective->getDescription();
         // begin-patch lok
         $objective_data['online'] = $objective->isActive();
         $objective_data['passes'] = $objective->getPasses();
         // end-patch lok
         // assigned materials
         $materials = array();
         $ass_materials = new ilCourseObjectiveMaterials($objective_id);
         foreach ($ass_materials->getMaterials() as $material) {
             $materials[$material['ref_id']]['obj_id'] = $obj_id = ilObject::_lookupObjId($material['ref_id']);
             $materials[$material['ref_id']]['type'] = ilObject::_lookupType($obj_id);
             switch ($material['type']) {
                 case 'pg':
                 case 'st':
                     $materials[$material['ref_id']]['items'][] = $material;
                     break;
                 default:
             }
         }
         $objective_data['materials'] = $materials;
         $question_obj = new ilCourseObjectiveQuestion($objective_id);
         // self assessment questions
         // begin-patch lok
         if ($this->getSettings()->worksWithInitialTest()) {
             if (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest()))) {
                 $test = array();
                 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
                 $rnd = new ilLORandomTestQuestionPools($this->course_obj->getId(), $objective_id, ilLOSettings::TYPE_TEST_INITIAL);
                 $test['obj_id'] = ilObject::_lookupObjId($this->getSettings()->getInitialTest());
                 $qst = ilLOUtils::lookupQplBySequence($this->getSettings()->getInitialTest(), $rnd->getQplSequence());
                 if ($qst) {
                     $test['questions'][] = array('title' => $qst);
                 }
                 $objective_data['self'] = array($test);
             } else {
                 $tests = array();
                 foreach ($question_obj->getSelfAssessmentTests() as $test) {
                     $questions = array();
                     foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
                         $questions[] = $qst;
                     }
                     $tmp_test = $test;
                     $tmp_test['questions'] = $questions;
                     $tests[] = $tmp_test;
                 }
                 $objective_data['self'] = $tests;
             }
         }
         // end-patch lok
         // final test questions
         // begin-patch lok
         if ($this->getSettings()->getQualifiedTest()) {
             if (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getQualifiedTest()))) {
                 $test = array();
                 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
                 $rnd = new ilLORandomTestQuestionPools($this->course_obj->getId(), $objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
                 $test['obj_id'] = ilObject::_lookupObjId($this->getSettings()->getQualifiedTest());
                 $qst = ilLOUtils::lookupQplBySequence($this->getSettings()->getQualifiedTest(), $rnd->getQplSequence());
                 if ($qst) {
                     $test['questions'][] = array('title' => $qst);
                 }
                 $objective_data['final'] = array($test);
             } else {
                 $tests = array();
                 foreach ($question_obj->getFinalTests() as $test) {
                     $questions = array();
                     foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
                         $questions[] = $qst;
                     }
                     $tmp_test = $test;
                     $tmp_test['questions'] = $questions;
                     $tests[] = $tmp_test;
                 }
                 $objective_data['final'] = $tests;
             }
         }
         // end-patch lok
         $objectives[] = (array) $objective_data;
     }
     $this->setData($objectives ? $objectives : array());
 }
 /**
  * Parse user results for table
  * @return type
  */
 public function parse()
 {
     include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $objective_ids = ilCourseObjective::_getObjectiveIds($this->getParentContainer()->getId(), TRUE);
     foreach ((array) $objective_ids as $objective_id) {
         $objective = array();
         $objective['id'] = $objective_id;
         $objective['title'] = ilCourseObjective::lookupObjectiveTitle($objective_id);
         if ($this->getSettings()->worksWithInitialTest()) {
             $results_it = ilLOUserResults::lookupResult($this->getParentContainer()->getId(), $this->getUserId(), $objective_id, ilLOSettings::TYPE_TEST_INITIAL);
             $objective['tries_it'] = $results_it['tries'];
             $objective['res_it'] = $results_it['result_perc'];
             $objective['link_it'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_INITIAL, $objective_id);
         }
         $results_qt = ilLOUserResults::lookupResult($this->getParentContainer()->getId(), $this->getUserId(), $objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
         $objective['tries_qt'] = $results_qt['tries'];
         $objective['res_qt'] = $results_qt['result_perc'];
         $objective['link_qt'] = $this->createTestResultLink(ilLOSettings::TYPE_TEST_QUALIFIED, $objective_id);
         $tbl_data[] = $objective;
     }
     return $this->setData($tbl_data);
 }
 function __read()
 {
     global $tree, $ilDB;
     include_once 'Modules/Course/classes/class.ilCourseObjective.php';
     $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
     $container_ref_id = current($container_ref_ids);
     // begin-patch lok
     $this->lms = array();
     $query = "SELECT position,lm_ass_id,lm.ref_id,lm.obj_id,lm.type FROM crs_objective_lm lm " . "JOIN object_reference obr ON lm.ref_id = obr.ref_id " . "JOIN object_data obd ON obr.obj_id = obd.obj_id " . "LEFT JOIN lm_data lmd ON lmd.obj_id = lm.obj_id " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " . "ORDER BY position,obd.title,lmd.title";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id, $row->ref_id)) {
             $this->delete($row->lm_ass_id);
             continue;
         }
         $lm['ref_id'] = $row->ref_id;
         $lm['obj_id'] = $row->obj_id;
         $lm['type'] = $row->type;
         $lm['lm_ass_id'] = $row->lm_ass_id;
         $lm['position'] = $row->position;
         $this->lms[$row->lm_ass_id] = $lm;
     }
     // end-patch lok
     return true;
 }
 /**
  * question overiew
  *
  * @access protected
  * @return
  */
 protected function questionOverview()
 {
     global $ilAccess, $ilErr, $ilTabs;
     $ilTabs->setSubTabActive('crs_objective_overview_question_assignment');
     if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
         $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
     }
     include_once './Modules/Course/classes/class.ilCourseObjectiveQuestionsTableGUI.php';
     $table = new ilCourseObjectiveQuestionsTableGUI($this, $this->course_obj);
     $table->setTitle($this->lng->txt('crs_objectives_edit_question_assignments'), 'icon_lobj.png', $this->lng->txt('crs_objectives'));
     $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId()));
     $this->tpl->setContent($table->getHTML());
 }
Esempio n. 8
0
 protected function checkNumberOfTries()
 {
     $qt = $this->getSettings()->getQualifiedTest();
     if (!$qt) {
         return true;
     }
     include_once './Services/Object/classes/class.ilObjectFactory.php';
     $factory = new ilObjectFactory();
     $tst = $factory->getInstanceByRefId($qt, false);
     if (!$tst instanceof ilObjTest) {
         return true;
     }
     $tries = $tst->getNrOfTries();
     if (!$tries) {
         return true;
     }
     $obj_tries = 0;
     foreach ($this->getObjectives() as $objective) {
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         $obj_tries += ilCourseObjective::lookupMaxPasses($objective);
     }
     $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $obj_tries);
     return $obj_tries <= $tries;
 }
 protected function buildAccordionTitle(ilCourseObjective $a_objective, array $a_lo_result = null)
 {
     $tpl = new ilTemplate("tpl.objective_accordion_title.html", true, true, "Services/Container");
     if ($a_lo_result) {
         $tpl->setVariable("PROGRESS_BAR", self::buildObjectiveProgressBar((bool) $this->loc_settings->getInitialTest(), $a_objective->getObjectiveId(), $a_lo_result));
     }
     // $tpl->setVariable("ICON_SRC", ilObject::_getIcon($a_objective->getObjectiveId(), "small", "lobj"));
     // $tpl->setVariable("ICON_TXT", $this->lng->txt("icon")." ".$this->lng->txt("crs_objectives"));
     $tpl->setVariable("TITLE", $this->lng->txt("crs_loc_learning_objective") . ": " . trim($a_objective->getTitle()));
     $tpl->setVariable("DESCRIPTION", nl2br(trim($a_objective->getDescription())));
     // #15510
     $tpl->setVariable("ANCHOR_ID", "objtv_acc_" . $a_objective->getObjectiveId());
     return $tpl->get();
 }
 function getItems(array $a_user_fields, array $a_privary_fields = null)
 {
     include_once "./Services/Tracking/classes/class.ilTrQuery.php";
     $collection = ilTrQuery::getObjectIds($this->obj_id, $this->ref_id, true);
     if ($collection["object_ids"]) {
         // we need these for the timing warnings
         $this->ref_ids = $collection["ref_ids"];
         // only if object is [part of] course/group
         $check_agreement = false;
         if ($this->in_course) {
             // privacy (if course agreement is activated)
             include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
             $privacy = ilPrivacySettings::_getInstance();
             if ($privacy->courseConfirmationRequired()) {
                 $check_agreement = $this->in_course;
             }
         } else {
             if ($this->in_group) {
                 // privacy (if group agreement is activated)
                 include_once "Services/PrivacySecurity/classes/class.ilPrivacySettings.php";
                 $privacy = ilPrivacySettings::_getInstance();
                 if ($privacy->groupConfirmationRequired()) {
                     $check_agreement = $this->in_group;
                 }
             }
         }
         $data = ilTrQuery::getUserObjectMatrix($this->ref_id, $collection["object_ids"], $this->filter["name"], $a_user_fields, $a_privary_fields, $check_agreement);
         if ($collection["objectives_parent_id"] && $data["users"]) {
             // sub-items: learning objectives
             $objectives = ilTrQuery::getUserObjectiveMatrix($collection["objectives_parent_id"], $data["users"]);
             $this->objective_ids = array();
             foreach ($objectives as $user_id => $objectives) {
                 if (isset($data["set"][$user_id])) {
                     foreach ($objectives as $objective_id => $status) {
                         $obj_id = "objtv_" . $objective_id;
                         $data["set"][$user_id][$obj_id] = $status;
                         if (!in_array($obj_id, $this->objective_ids)) {
                             $this->objective_ids[$objective_id] = ilCourseObjective::lookupObjectiveTitle($objective_id);
                         }
                     }
                 }
             }
         }
         // sub-items: SCOs
         if ($collection["scorm"] && $data["set"]) {
             $this->sco_ids = array();
             foreach (array_keys($data["set"]) as $user_id) {
                 foreach ($collection["scorm"]["scos"] as $sco) {
                     if (!in_array($sco, $this->sco_ids)) {
                         $this->sco_ids[$sco] = $collection["scorm"]["scos_title"][$sco];
                     }
                     // alex, 5 Nov 2011: we got users being in failed and in
                     // completed status, I changed the setting in: first check failed
                     // then check completed since failed should superseed completed
                     // (before completed has been checked before failed)
                     $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
                     if (in_array($user_id, $collection["scorm"]["failed"][$sco])) {
                         $status = ilLPStatus::LP_STATUS_FAILED_NUM;
                     } else {
                         if (in_array($user_id, $collection["scorm"]["completed"][$sco])) {
                             $status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
                         } else {
                             if (in_array($user_id, $collection["scorm"]["in_progress"][$sco])) {
                                 $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
                             }
                         }
                     }
                     $obj_id = "objsco_" . $sco;
                     $data["set"][$user_id][$obj_id] = $status;
                 }
             }
         }
         // sub-items: generic, e.g. lm chapter
         if ($collection["subitems"] && $data["set"]) {
             foreach (array_keys($data["set"]) as $user_id) {
                 foreach ($collection["subitems"]["items"] as $item_id) {
                     $this->subitem_ids[$item_id] = $collection["subitems"]["item_titles"][$item_id];
                     $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
                     if (in_array($user_id, $collection["subitems"]["completed"][$item_id])) {
                         $status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
                     } else {
                         if (is_array($collection["subitems"]["in_progress"]) && in_array($user_id, $collection["subitems"]["in_progress"][$item_id])) {
                             $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
                         }
                     }
                     $obj_id = "objsub_" . $item_id;
                     $data["set"][$user_id][$obj_id] = $status;
                 }
             }
         }
         // percentage export
         if ($data["set"]) {
             $this->perc_map = array();
             foreach ($data["set"] as $row) {
                 foreach ($row as $column => $value) {
                     if (substr($column, -5) == "_perc") {
                         if ((int) $value > 0) {
                             $obj_id = explode("_", $column);
                             $obj_id = (int) $obj_id[1];
                             $this->perc_map[$obj_id] = true;
                         }
                     }
                 }
             }
         }
         $this->setMaxCount($data["cnt"]);
         $this->setData($data["set"]);
         return $collection["object_ids"];
     }
     return false;
 }
Esempio n. 11
0
 function _deleteAll($course_id)
 {
     global $ilDB;
     // begin-patch lok
     $ids = ilCourseObjective::_getObjectiveIds($course_id, false);
     // end-patch lok
     if (!count($ids)) {
         return true;
     }
     $in = $ilDB->in('objective_id', $ids, false, 'integer');
     $query = "DELETE FROM crs_objective_lm WHERE  " . $in;
     $res = $ilDB->manipulate($query);
     $query = "DELETE FROM crs_objective_tst WHERE " . $in;
     $res = $ilDB->manipulate($query);
     $query = "DELETE FROM crs_objective_qst WHERE " . $in;
     $res = $ilDB->manipulate($query);
     $query = "DELETE FROM crs_objectives WHERE crs_id = " . $ilDB->quote($course_id, 'integer');
     $res = $ilDB->manipulate($query);
     // refresh learning progress status after deleting objectives
     include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
     ilLPStatusWrapper::_refreshStatus($course_id);
     return true;
 }
 /**
  * init details
  *
  * @access protected
  * @param
  * @return
  */
 protected function initDetails()
 {
     global $ilUser;
     if (isset($_GET['details_level'])) {
         $this->details_level = (int) $_GET['details_level'];
         ilObjUser::_writePref($ilUser->getId(), 'crs_objectives_details', $this->details_level);
     } else {
         $this->details_level = $ilUser->getPref('crs_objectives_details') ? $ilUser->getPref('crs_objectives_details') : self::DETAILS_TITLE;
     }
     if (isset($_GET['objective_details'])) {
         $this->force_details = (int) $_GET['objective_details'];
         ilObjUser::_writePref($ilUser->getId(), 'crs_objectives_force_details_' . $this->getContainerObject()->getId(), $this->force_details);
     } elseif ($details_id = $ilUser->getPref('crs_objectives_force_details_' . $this->getContainerObject()->getId())) {
         $this->force_details = $details_id;
     } else {
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         include_once './Modules/Course/classes/class.ilCourseObjectiveResultCache.php';
         foreach (ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId()) as $objective_id) {
             if (ilCourseObjectiveResultCache::isSuggested($ilUser->getId(), $this->getContainerObject()->getId(), $objective_id)) {
                 $this->force_details = $objective_id;
                 break;
             }
         }
     }
     return true;
 }
 /**
  * Parse test
  * throws ilLOInvalidConfigurationException in case assigned test cannot be found.
  */
 protected function doParse($a_tst_ref_id, $a_objective_id = 0)
 {
     include_once './Modules/Test/classes/class.ilObjTest.php';
     $tst = ilObjectFactory::getInstanceByRefId($a_tst_ref_id, false);
     if (!$tst instanceof ilObjTest) {
         throw new ilLOInvalidConfigurationException('No valid test given');
     }
     $tst_data['ref_id'] = $tst->getRefId();
     $tst_data['title'] = $tst->getTitle();
     $tst_data['description'] = $tst->getLongDescription();
     $tst_data['ttype'] = $tst->getQuestionSetType();
     if ($this->getAssignmentType() == self::TYPE_MULTIPLE_ASSIGNMENTS) {
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         $tst_data['objective'] = ilCourseObjective::lookupObjectiveTitle($a_objective_id);
     }
     switch ($tst->getQuestionSetType()) {
         case ilObjTest::QUESTION_SET_TYPE_FIXED:
             $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_num_qst');
             $tst_data['qst_info'] .= ' ' . count($tst->getAllQuestions());
             break;
         default:
             // get available assiged question pools
             include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
             include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
             $list = new ilTestRandomQuestionSetSourcePoolDefinitionList($GLOBALS['ilDB'], $tst, new ilTestRandomQuestionSetSourcePoolDefinitionFactory($GLOBALS['ilDB'], $tst));
             $list->loadDefinitions();
             // tax translations
             include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
             $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']);
             $translater->loadLabels($list);
             $tst_data['qst_info'] = $this->lng->txt('crs_loc_tst_qpls');
             $num = 0;
             foreach ($list as $definition) {
                 /** @var ilTestRandomQuestionSetSourcePoolDefinition[] $definition */
                 $title = $definition->getPoolTitle();
                 $tax_id = $definition->getMappedFilterTaxId();
                 if ($tax_id) {
                     $title .= ' -> ' . $translater->getTaxonomyTreeLabel($tax_id);
                 }
                 $tax_node = $definition->getMappedFilterTaxNodeId();
                 if ($tax_node) {
                     $title .= ' -> ' . $translater->getTaxonomyNodeLabel($tax_node);
                 }
                 $tst_data['qpls'][] = $title;
                 ++$num;
             }
             if (!$num) {
                 $tst_data['qst_info'] .= ' ' . (int) 0;
             }
             break;
     }
     return $tst_data;
 }
Esempio n. 14
0
 /**
  * Delete objectives
  * @global type $rbacsystem
  * @return boolean
  */
 protected function deleteObjectives()
 {
     global $rbacsystem;
     foreach ($_POST['objective_ids'] as $objective_id) {
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         $objective_obj = new ilCourseObjective($this->getParentObject(), $objective_id);
         $objective_obj->delete();
     }
     include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
     ilLPStatusWrapper::_refreshStatus($this->getParentObject()->getId());
     ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'), true);
     $this->ctrl->redirect($this, 'listObjectives');
     return true;
 }
 private function checkAccessLearningObjectivePage($obj_id, $page_id)
 {
     include_once "Modules/Course/classes/class.ilCourseObjective.php";
     $crs_obj_id = ilCourseObjective::_lookupContainerIdByObjectiveId($page_id);
     return $this->checkAccessObject($crs_obj_id, 'crs');
 }
 /**
  * Get tabs
  */
 function getTabs(&$tabs_gui)
 {
     global $rbacsystem, $ilAccess, $ilUser, $lng, $ilHelp;
     $ilHelp->setScreenIdComponent("crs");
     $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
     if ($ilAccess->checkAccess('read', '', $this->ref_id)) {
         $tabs_gui->addTab('view_content', $lng->txt("content"), $this->ctrl->getLinkTarget($this, ''));
     }
     if ($ilAccess->checkAccess('visible', '', $this->ref_id)) {
         //$next_class = $this->ctrl->getNextClass($this);
         // this is not nice. tabs should be displayed in ilcoursegui
         // not via ilrepositorygui, then next_class == ilinfoscreengui
         // could be checked
         $force_active = strtolower($_GET["cmdClass"]) == "ilinfoscreengui" || strtolower($_GET["cmdClass"]) == "ilnotegui" ? true : false;
         $tabs_gui->addTarget("info_short", $this->ctrl->getLinkTargetByClass(array("ilobjcoursegui", "ilinfoscreengui"), "showSummary"), "infoScreen", "", "", $force_active);
     }
     if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
         $force_active = strtolower($_GET["cmdClass"]) == "ilconditionhandlerinterface" && $_GET["item_id"] == "" ? true : false;
         $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "edit"), array("edit", "editMapSettings", "editCourseIcons", "listStructure"), "", "", $force_active);
     }
     $is_participant = ilCourseParticipants::_isParticipant($this->ref_id, $ilUser->getId());
     // member list
     if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
         $tabs_gui->addTarget("members", $this->ctrl->getLinkTarget($this, "members"), "members", get_class($this));
     } elseif ($this->object->getShowMembers() == $this->object->SHOW_MEMBERS_ENABLED && $is_participant) {
         $tabs_gui->addTarget("members", $this->ctrl->getLinkTarget($this, "membersGallery"), "members", get_class($this));
     }
     // learning progress
     include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
     if (ilLearningProgressAccess::checkAccess($this->object->getRefId(), $is_participant)) {
         $tabs_gui->addTarget('learning_progress', $this->ctrl->getLinkTargetByClass(array('ilobjcoursegui', 'illearningprogressgui'), ''), '', array('illplistofobjectsgui', 'illplistofsettingsgui', 'illearningprogressgui', 'illplistofprogressgui'));
     }
     // learning objectives
     if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         if ($this->object->getViewMode() == IL_CRS_VIEW_OBJECTIVE or ilCourseObjective::_getCountObjectives($this->object->getId())) {
             $force_active = strtolower($_GET["cmdClass"]) == "ilcourseobjectivesgui" ? true : false;
             $tabs_gui->addTarget("crs_objectives", $this->ctrl->getLinkTarget($this, "listObjectives"), "listObjectives", get_class($this), "", $force_active);
         }
     }
     // license overview
     include_once "Services/License/classes/class.ilLicenseAccess.php";
     if ($ilAccess->checkAccess('edit_permission', '', $this->ref_id) and ilLicenseAccess::_isEnabled()) {
         $tabs_gui->addTarget("licenses", $this->ctrl->getLinkTargetByClass('illicenseoverviewgui', ''), "", "illicenseoverviewgui");
     }
     // lom meta data
     if ($ilAccess->checkAccess('write', '', $this->ref_id)) {
         $tabs_gui->addTarget("meta_data", $this->ctrl->getLinkTargetByClass(array('ilobjcoursegui', 'ilmdeditorgui'), 'listSection'), "", "ilmdeditorgui");
     }
     if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $tabs_gui->addTarget('export', $this->ctrl->getLinkTargetByClass('ilexportgui', ''), 'export', 'ilexportgui');
     }
     if ($ilAccess->checkAccess('edit_permission', '', $this->ref_id)) {
         $tabs_gui->addTarget("perm_settings", $this->ctrl->getLinkTargetByClass(array(get_class($this), 'ilpermissiongui'), "perm"), array("perm", "info", "owner"), 'ilpermissiongui');
     }
     if ($this->ctrl->getTargetScript() == "adm_object.php") {
         $tabs_gui->addTarget("show_owner", $this->ctrl->getLinkTarget($this, "owner"), "owner", get_class($this));
         if ($this->tree->getSavedNodeData($this->ref_id)) {
             $tabs_gui->addTarget("trash", $this->ctrl->getLinkTarget($this, "trash"), "trash", get_class($this));
         }
     }
     // Join/Leave
     if ($ilAccess->checkAccess('join', '', $this->ref_id) and !$this->object->getMemberObject()->isAssigned()) {
         include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
         if (ilCourseWaitingList::_isOnList($ilUser->getId(), $this->object->getId())) {
             $tabs_gui->addTab('leave', $this->lng->txt('membership_leave'), $this->ctrl->getLinkTargetByClass('ilcourseregistrationgui', 'show', ''));
         } else {
             $tabs_gui->addTarget("join", $this->ctrl->getLinkTargetByClass('ilcourseregistrationgui', "show"), 'show', "");
         }
     }
     if ($ilAccess->checkAccess('leave', '', $this->object->getRefId()) and $this->object->getMemberObject()->isMember()) {
         $tabs_gui->addTarget("crs_unsubscribe", $this->ctrl->getLinkTarget($this, "unsubscribe"), 'leave', "");
     }
 }
 function __read()
 {
     global $ilDB, $tree;
     include_once './Modules/Test/classes/class.ilObjTest.php';
     include_once 'Modules/Course/classes/class.ilCourseObjective.php';
     $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
     $container_ref_id = current($container_ref_ids);
     // Read test data
     $query = "SELECT * FROM crs_objective_tst " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
         $this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
         $this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
         $this->tests[$row->ref_id]['status'] = $row->tst_status;
         $this->tests[$row->ref_id]['limit'] = $row->tst_limit_p;
     }
     $this->questions = array();
     $query = "SELECT * FROM crs_objective_qst coq " . "JOIN qpl_questions qq ON coq.question_id = qq.question_id " . "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " . "ORDER BY title";
     $res = $this->db->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if (!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id, $row->ref_id)) {
             $this->__deleteTest($row->ref_id);
             continue;
         }
         if (!($question = ilObjTest::_instanciateQuestion($row->question_id))) {
             $this->delete($row->question_id);
             continue;
         }
         $qst['ref_id'] = $row->ref_id;
         $qst['obj_id'] = $row->obj_id;
         $qst['question_id'] = $row->question_id;
         $qst['qst_ass_id'] = $row->qst_ass_id;
         $qst['title'] = $question->getTitle();
         $qst['description'] = $question->getComment();
         $qst['test_type'] = $this->tests[$row->ref_id]['status'];
         $qst['points'] = $question->getPoints();
         $this->questions[$row->qst_ass_id] = $qst;
     }
     return true;
 }
 protected function getCoursesOfUser($a_user_id)
 {
     global $tree;
     // see ilPDSelectedItemsBlockGUI
     include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
     include_once 'Services/Membership/classes/class.ilParticipants.php';
     $items = ilParticipants::_getMembershipByType($a_user_id, 'crs');
     $references = $lp_obj_refs = array();
     foreach ($items as $obj_id) {
         $ref_id = ilObject::_getAllReferences($obj_id);
         if (is_array($ref_id) && count($ref_id)) {
             $ref_id = array_pop($ref_id);
             if (!$tree->isDeleted($ref_id)) {
                 $visible = false;
                 $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false);
                 if ($active && $visible) {
                     $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id));
                     $lp_obj_refs[$obj_id] = $ref_id;
                 }
             }
         }
     }
     // get lp data for valid courses
     if (sizeof($lp_obj_refs)) {
         // lp must be active, personal and not anonymized
         include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
         if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) {
             // see ilLPProgressTableGUI
             include_once "Services/Tracking/classes/class.ilTrQuery.php";
             include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs);
             foreach ($lp_data as $item) {
                 $ref_id = $item["ref_ids"];
                 $references[$ref_id]["lp_status"] = $item["status"];
                 // add objectives
                 if ($item["u_mode"] == ilLPObjSettings::LP_MODE_OBJECTIVES) {
                     // we need the collection for the correct order
                     include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
                     $coll_objtv = new ilLPCollectionOfObjectives($item["obj_id"], $item["u_mode"]);
                     $coll_objtv = $coll_objtv->getItems();
                     if ($coll_objtv) {
                         // #13373
                         $lo_results = $this->parseLOUserResults($item["obj_id"], $a_user_id);
                         $tmp = array();
                         include_once "Modules/Course/classes/class.ilCourseObjective.php";
                         foreach ($coll_objtv as $objective_id) {
                             $tmp[$objective_id] = array("id" => $objective_id, "title" => ilCourseObjective::lookupObjectiveTitle($objective_id));
                             if (array_key_exists($objective_id, $lo_results)) {
                                 $lo_result = $lo_results[$objective_id];
                                 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
                                 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
                                 $tmp[$objective_id]["status"] = $lo_result["status"];
                                 $tmp[$objective_id]["type"] = $lo_result["type"];
                             }
                         }
                         // order
                         foreach ($coll_objtv as $objtv_id) {
                             $references[$ref_id]["objectives"][] = $tmp[$objtv_id];
                         }
                     }
                 }
             }
         }
     }
     $references = ilUtil::sortArray($references, "title", "ASC");
     return $references;
 }
 /**
  * Determine status
  *
  * @param	integer		object id
  * @param	integer		user id
  * @param	object		object (optional depends on object type)
  * @return	integer		status
  */
 function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
 {
     global $ilObjDataCache, $ilDB;
     // the status completed depends on:
     // $status_info['num_objectives'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
     // - ilCourseObjective::_getObjectiveIds($a_obj_id);
     // - table crs_objectives manipulated in
     // - ilCourseObjective
     // $status_info['objective_result']  (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
     // table crs_objective_status (must not contain a dataset)
     // ilCourseObjectiveResult -> added ilLPStatusWrapper::_updateStatus()
     $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
     switch ($ilObjDataCache->lookupType($a_obj_id)) {
         case "crs":
             include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
             if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
                 $status = self::LP_STATUS_IN_PROGRESS_NUM;
                 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
                 $objectives = ilCourseObjective::_getObjectiveIds($a_obj_id);
                 if ($objectives) {
                     $set = $ilDB->query("SELECT count(objective_id) cnt FROM crs_objective_status " . "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
                     if ($rec = $ilDB->fetchAssoc($set)) {
                         if ($rec["cnt"] == count($objectives)) {
                             $status = self::LP_STATUS_COMPLETED_NUM;
                         }
                     }
                 }
             }
             break;
     }
     return $status;
 }
Esempio n. 20
0
 /**
  * Test redirection will be moved lo adapter
  */
 protected function redirectLocToTestObject($a_force_new_run = NULL)
 {
     $objective_id = (int) $_REQUEST['objective_id'];
     $test_id = (int) $_REQUEST['tid'];
     include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
     include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
     include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
     $res = new ilLOUserResults($this->object->getId(), $GLOBALS['ilUser']->getId());
     $passed = $res->getCompletedObjectiveIds();
     $has_completed = FALSE;
     if ($objective_id) {
         $objective_ids = array($objective_id);
         if (in_array($objective_id, $passed)) {
             $has_completed = TRUE;
             $passed = array();
         }
     } else {
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         $objective_ids = ilCourseObjective::_getObjectiveIds($this->object->getId(), true);
         // do not disable objective question if all are passed
         if (count($objective_ids) == count($passed)) {
             $has_completed = TRUE;
             $passed = array();
         }
     }
     if ($has_completed) {
         // show confirmation
         $this->redirectLocToTestConfirmation($objective_id, $test_id);
         return TRUE;
     }
     include_once './Services/Link/classes/class.ilLink.php';
     ilUtil::redirect(ilLink::_getLink($test_id));
     return TRUE;
 }
 function __showObjectives()
 {
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     if (!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->course_obj->getId()))) {
         return false;
     }
     if ($_GET['details']) {
         $_SESSION['crs_details_id'] = $_GET['details'];
     }
     $this->details_id = $_SESSION['crs_details_id'] ? $_SESSION['crs_details_id'] : $objective_ids[0];
     // TODO get status for table header
     switch ($this->status) {
         case 'none':
             $status = $this->lng->txt('crs_objective_accomplished');
             break;
         case 'pretest':
         case 'pretest_non_suggest':
             $status = $this->lng->txt('crs_objective_pretest');
             break;
         default:
             $status = $this->lng->txt('crs_objective_result');
     }
     // show table
     $this->tpl->addBlockfile('OBJECTIVE_BLOCK', 'objective_block', 'tpl.crs_objectives_view_table.html', 'Modules/Course');
     $this->tpl->setVariable("TBL_TITLE_OBJECTIVES", $this->lng->txt('crs_objectives'));
     $this->__showHideLinks('objectives');
     if (isset($_SESSION['crs_hide_objectives'])) {
         return true;
     }
     $this->tpl->setVariable('TBL_HEADER_NAME_OBJECTIVES_A', $this->lng->txt('type'));
     $this->tpl->setVariable('TBL_HEADER_NAME_OBJECTIVES_B', $this->lng->txt('description'));
     $this->tpl->setVariable('TBL_HEADER_NAME_OBJECTIVES_C', $status);
     //$max = count($objective_ids) % 2 ? count($objective_ids) + 1 : count($objective_ids);
     $max = count($objective_ids);
     for ($i = 0; $i < $max; ++$i) {
         $tmp_objective =& new ilCourseObjective($this->course_obj, $objective_ids[$i]);
         $this->tpl->setCurrentBlock("objective_row");
         if ($this->details_id == $objective_ids[$i]) {
             $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES", 'option_value_details');
             $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES", 'option_value_center_details');
         } else {
             $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES", 'option_value');
             $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES", 'option_value_center');
         }
         $this->tpl->setVariable("OBJ_NR_1_OBJECTIVES", $i + 1 . '.');
         $this->ctrl->setParameter($this, 'details', $objective_ids[$i]);
         $this->tpl->setVariable("OBJ_LINK_1_OBJECTIVES", $this->ctrl->getLinkTarget($this, 'view'));
         $this->tpl->setVariable("OBJ_TITLE_1_OBJECTIVES", $tmp_objective->getTitle());
         $img = !in_array($objective_ids[$i], $this->suggested) ? ilUtil::getImagePath('icon_ok.png') : ilUtil::getImagePath('icon_not_ok.png');
         $txt = !in_array($objective_ids[$i], $this->suggested) ? $this->lng->txt('crs_objective_accomplished') : $this->lng->txt('crs_objective_not_accomplished');
         $this->tpl->setVariable("OBJ_STATUS_IMG_1_OBJECTIVES", $img);
         $this->tpl->setVariable("OBJ_STATUS_ALT_1_OBJECTIVES", $txt);
         if (isset($objective_ids[$i + $max / 2])) {
             $tmp_objective =& new ilCourseObjective($this->course_obj, $objective_ids[$i + $max / 2]);
             $this->tpl->setCurrentBlock("objective_row");
             if ($this->details_id == $objective_ids[$i + $max / 2]) {
                 $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES", 'option_value_details');
                 $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES", 'option_value_center_details');
             } else {
                 $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES", 'option_value');
                 $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES", 'option_value_center');
             }
             $this->tpl->setVariable("OBJ_NR_2_OBJECTIVES", $i + $max / 2 + 1 . '.');
             $this->ctrl->setParameter($this, 'details', $objective_ids[$i + $max / 2]);
             $this->tpl->setVariable("OBJ_LINK_2_OBJECTIVES", $this->ctrl->getLinkTarget($this, 'view'));
             $this->tpl->setVariable("OBJ_TITLE_2_OBJECTIVES", $tmp_objective->getTitle());
             $objective_id = $objective_ids[$i + $max / 2];
             $img = !in_array($objective_id, $this->suggested) ? ilUtil::getImagePath('icon_ok.png') : ilUtil::getImagePath('icon_not_ok.png');
             $txt = !in_array($objective_id, $this->suggested) ? $this->lng->txt('crs_objective_accomplished') : $this->lng->txt('crs_objective_not_accomplished');
             $this->tpl->setVariable("OBJ_STATUS_IMG_2_OBJECTIVES", $img);
             $this->tpl->setVariable("OBJ_STATUS_ALT_2_OBJECTIVES", $txt);
         }
         $this->tpl->parseCurrentBlock();
         unset($tmp_objective);
     }
     $this->ctrl->setParameter($this, 'details', '');
 }
 function &_getItems($a_obj_id, $a_use_subtree_by_id = false)
 {
     global $ilObjDataCache;
     global $ilDB, $tree;
     include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
     $mode = ilLPObjSettings::_lookupMode($a_obj_id);
     if ($mode == LP_MODE_OBJECTIVES) {
         include_once 'Modules/Course/classes/class.ilCourseObjective.php';
         return ilCourseObjective::_getObjectiveIds($a_obj_id);
     }
     if ($mode != LP_MODE_SCORM and $mode != LP_MODE_COLLECTION and $mode != LP_MODE_MANUAL_BY_TUTOR) {
         return array();
     }
     if ($ilObjDataCache->lookupType($a_obj_id) != 'sahs') {
         $course_ref_ids = ilObject::_getAllReferences($a_obj_id);
         $course_ref_id = end($course_ref_ids);
         if (!$a_use_subtree_by_id) {
             $possible_items = ilLPCollections::_getPossibleItems($course_ref_id);
         } else {
             $possible_items = $tree->getSubTreeIds($course_ref_id);
         }
         $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 = " . $ilDB->quote($a_obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer') . " " . "ORDER BY title";
     } else {
         // SAHS
         $query = "SELECT * FROM ut_lp_collections WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer');
     }
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         if ($ilObjDataCache->lookupType($a_obj_id) != 'sahs') {
             if (!in_array($row->item_id, $possible_items)) {
                 ilLPCollections::__deleteEntry($a_obj_id, $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)) {
                 ilLPCollections::__deleteEntry($a_obj_id, $row->item_id);
                 continue;
             }
         }
         $items[] = $row->item_id;
     }
     return $items ? $items : array();
 }
 protected function read($a_obj_id)
 {
     include_once 'Modules/Course/classes/class.ilCourseObjective.php';
     $this->items = ilCourseObjective::_getObjectiveIds($a_obj_id);
 }
 /**
  * parse
  *
  * @access public
  * @param array array of objective id's
  */
 public function parse($a_objective_ids)
 {
     $position = 1;
     foreach ($a_objective_ids as $objective_id) {
         $objective = new ilCourseObjective($this->course_obj, $objective_id);
         $objective_data['id'] = $objective_id;
         $objective_data['position'] = sprintf("%.1f", $position++);
         $objective_data['title'] = $objective->getTitle();
         $objective_data['description'] = $objective->getDescription();
         // assigned materials
         $materials = array();
         $ass_materials = new ilCourseObjectiveMaterials($objective_id);
         foreach ($ass_materials->getMaterials() as $material) {
             $materials[$material['ref_id']]['obj_id'] = $obj_id = ilObject::_lookupObjId($material['ref_id']);
             $materials[$material['ref_id']]['type'] = ilObject::_lookupType($obj_id);
             switch ($material['type']) {
                 case 'pg':
                 case 'st':
                     $materials[$material['ref_id']]['items'][] = $material;
                     break;
                 default:
             }
         }
         $objective_data['materials'] = $materials;
         $question_obj = new ilCourseObjectiveQuestion($objective_id);
         // self assessment questions
         $tests = array();
         foreach ($question_obj->getSelfAssessmentTests() as $test) {
             $questions = array();
             foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
                 $questions[] = $qst;
             }
             $tmp_test = $test;
             $tmp_test['questions'] = $questions;
             $tests[] = $tmp_test;
         }
         $objective_data['self'] = $tests;
         // final test questions
         $tests = array();
         foreach ($question_obj->getFinalTests() as $test) {
             $questions = array();
             foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
                 $questions[] = $qst;
             }
             $tmp_test = $test;
             $tmp_test['questions'] = $questions;
             $tests[] = $tmp_test;
         }
         $objective_data['final'] = $tests;
         $objectives[] = $objective_data;
     }
     $this->setData($objectives ? $objectives : array());
 }
 function readStatus($a_crs_id)
 {
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     // begin-patch lok
     $objective_ids = ilCourseObjective::_getObjectiveIds($a_crs_id, true);
     // end-patch lok
     $objectives = ilCourseObjectiveResult::_readAssignedObjectives($objective_ids);
     ilCourseObjectiveResult::_updateObjectiveStatus($this->getUserId(), $objectives);
     return true;
 }
Esempio n. 26
0
 protected function parseObjectives($a_obj_id, $a_user_id)
 {
     $res = array();
     // we need the collection for the correct order
     include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
     include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php";
     $coll_objtv = new ilLPCollectionOfObjectives($a_obj_id, ilLPObjSettings::LP_MODE_OBJECTIVES);
     $coll_objtv = $coll_objtv->getItems();
     if ($coll_objtv) {
         // #13373
         $lo_results = $this->parseLOUserResults($a_obj_id, $a_user_id);
         include_once "Modules/Course/classes/Objectives/class.ilLOTestAssignments.php";
         $lo_ass = ilLOTestAssignments::getInstance($a_obj_id);
         $tmp = array();
         include_once "Modules/Course/classes/class.ilCourseObjective.php";
         foreach ($coll_objtv as $objective_id) {
             // patch optes start
             $title = ilCourseObjective::lookupObjectiveTitle($objective_id, true);
             $tmp[$objective_id] = array("id" => $objective_id, "title" => $title["title"], "desc" => $title["description"], "itest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL), "qtest" => $lo_ass->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED));
             // patch optes end
             if (array_key_exists($objective_id, $lo_results)) {
                 $lo_result = $lo_results[$objective_id];
                 $tmp[$objective_id]["user_id"] = $lo_result["user_id"];
                 $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"];
                 $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"];
                 $tmp[$objective_id]["status"] = $lo_result["status"];
                 $tmp[$objective_id]["type"] = $lo_result["type"];
                 $tmp[$objective_id]["initial"] = $lo_result["initial"];
             }
         }
         // order
         foreach ($coll_objtv as $objtv_id) {
             $res[] = $tmp[$objtv_id];
         }
     }
     return $res;
 }
 public function initForm($a_as_multi_assignment = FALSE)
 {
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setTitle($this->lng->txt('crs_loc_tst_assignment'));
     $form->setFormAction($this->ctrl->getFormAction($this->getGUI()));
     if ($a_as_multi_assignment) {
         $form->addCommandButton('saveMultiTestAssignment', $this->lng->txt('save'));
     } else {
         $form->addCommandButton('saveTest', $this->lng->txt('save'));
     }
     switch ($this->getTestType()) {
         case ilLOSettings::TYPE_TEST_INITIAL:
             $form->setTitle($this->lng->txt('crs_loc_settings_itest_tbl'));
             break;
         case ilLOSettings::TYPE_TEST_QUALIFIED:
             $form->setTitle($this->lng->txt('crs_loc_settings_qtest_tbl'));
             break;
     }
     $assignable = $this->getAssignableTests();
     $cr_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_form_assign_it'), 'mode');
     $cr_mode->setRequired(true);
     $cr_mode->setValue(self::TEST_NEW);
     $new = new ilRadioOption($this->lng->txt('crs_loc_form_tst_new'), self::TEST_NEW);
     switch ($this->getTestType()) {
         case ilLOSettings::TYPE_TEST_INITIAL:
             $new->setInfo($this->lng->txt("crs_loc_form_tst_new_initial_info"));
             break;
         case ilLOSettings::TYPE_TEST_QUALIFIED:
             $new->setInfo($this->lng->txt("crs_loc_form_tst_new_qualified_info"));
             break;
     }
     // title
     $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
     $ti->setMaxLength(128);
     $ti->setSize(40);
     $ti->setRequired(true);
     $new->addSubItem($ti);
     // description
     $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
     $ta->setCols(40);
     $ta->setRows(2);
     $new->addSubItem($ta);
     // Question assignment type
     include_once './Modules/Test/classes/class.ilObjTest.php';
     $this->lng->loadLanguageModule('assessment');
     $qst = new ilRadioGroupInputGUI($this->lng->txt('tst_question_set_type'), 'qtype');
     $qst->setRequired(true);
     $random = new ilRadioOption($this->lng->txt('tst_question_set_type_random'), ilObjTest::QUESTION_SET_TYPE_RANDOM);
     $qst->addOption($random);
     $fixed = new ilRadioOption($this->lng->txt('tst_question_set_type_fixed'), ilObjTest::QUESTION_SET_TYPE_FIXED);
     $qst->addOption($fixed);
     $new->addSubItem($qst);
     $cr_mode->addOption($new);
     // assign existing
     $existing = new ilRadioOption($this->lng->txt('crs_loc_form_assign'), self::TEST_ASSIGN);
     switch ($this->getTestType()) {
         case ilLOSettings::TYPE_TEST_INITIAL:
             $existing->setInfo($this->lng->txt("crs_loc_form_assign_initial_info"));
             break;
         case ilLOSettings::TYPE_TEST_QUALIFIED:
             $existing->setInfo($this->lng->txt("crs_loc_form_assign_qualified_info"));
             break;
     }
     if (!$assignable) {
         $existing->setDisabled(true);
     }
     $cr_mode->addOption($existing);
     $options = array();
     $options[''] = $this->lng->txt('select_one');
     foreach ((array) $assignable as $tst_ref_id) {
         $tst_obj_id = ilObject::_lookupObjId($tst_ref_id);
         $options[$tst_ref_id] = ilObject::_lookupTitle($tst_obj_id);
     }
     $selectable = new ilSelectInputGUI($this->lng->txt('crs_loc_form_available_tsts'), 'tst');
     $selectable->setRequired(true);
     $selectable->setOptions($options);
     $existing->addSubItem($selectable);
     $form->addItem($cr_mode);
     if ($a_as_multi_assignment) {
         include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
         $assignments = ilLOTestAssignments::getInstance($this->getContainer()->getId());
         include_once './Modules/Course/classes/class.ilCourseObjective.php';
         $objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainer()->getId(), FALSE);
         $options = array();
         $options[''] = $this->lng->txt('select_one');
         foreach ($objective_ids as $oid) {
             $already_assigned_tst = $assignments->getTestByObjective($oid, $this->getTestType());
             if (!$already_assigned_tst) {
                 $options[$oid] = ilCourseObjective::lookupObjectiveTitle($oid);
             }
         }
         $objective = new ilSelectInputGUI($this->lng->txt('crs_objectives'), 'objective');
         $objective->setRequired(TRUE);
         $objective->setOptions($options);
         $form->addItem($objective);
     }
     return $form;
 }
 /**
  * parse
  *
  * @access public
  * @param array array of objective id's
  */
 public function parse($a_objective_ids)
 {
     include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
     $objectives = array();
     foreach ($a_objective_ids as $objective_id) {
         $objective = new ilCourseObjective($this->course_obj, $objective_id);
         // Self assessment tests
         $question_obj = new ilCourseObjectiveQuestion($objective_id);
         $tests = array();
         foreach ($question_obj->getSelfAssessmentTests() as $tmp_test) {
             if (isset($_POST['self'][$objective_id])) {
                 $objective_data['self_limit'] = $_POST['self'][$objective_id];
             } else {
                 $objective_data['self_limit'] = $tmp_test['limit'];
             }
             $questions = array();
             foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
                 $qst['title'] = $tmp_question['title'];
                 $qst['description'] = $tmp_question['description'];
                 $qst['points'] = $tmp_question['points'];
                 $questions[] = $qst;
             }
             $tst['questions'] = $questions;
             $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
             $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
             $tests[] = $tst;
         }
         $objective_data['self_tests'] = $tests;
         $objective_data['self_max_points'] = $question_obj->getSelfAssessmentPoints();
         // Final tests
         $tests = array();
         foreach ($question_obj->getFinalTests() as $tmp_test) {
             if (isset($_POST['final'][$objective_id])) {
                 $objective_data['final_limit'] = $_POST['final'][$objective_id];
             } else {
                 $objective_data['final_limit'] = $tmp_test['limit'];
             }
             $questions = array();
             foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
                 $qst['title'] = $tmp_question['title'];
                 $qst['description'] = $tmp_question['description'];
                 $qst['points'] = $tmp_question['points'];
                 $questions[] = $qst;
             }
             $tst['questions'] = $questions;
             $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
             $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
             $tests[] = $tst;
         }
         $objective_data['final_tests'] = $tests;
         $objective_data['final_max_points'] = $question_obj->getFinalTestPoints();
         $objective_data['id'] = $objective_id;
         $objective_data['title'] = $objective->getTitle();
         $objective_data['description'] = $objective->getDescription();
         $objectives[] = $objective_data;
     }
     $this->setData($objectives ? $objectives : array());
 }
Esempio n. 29
0
 /**
  * delete course and all related data	
  *
  * @access	public
  * @return	boolean	true if all object data were removed; false if only a references were removed
  */
 function delete()
 {
     global $ilAppEventHandler;
     // always call parent delete function first!!
     if (!parent::delete()) {
         return false;
     }
     // delete meta data
     $this->deleteMetaData();
     // put here course specific stuff
     $this->__deleteSettings();
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     ilCourseParticipants::_deleteAllEntries($this->getId());
     $this->initCourseArchiveObject();
     $this->archives_obj->deleteAll();
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     ilCourseObjective::_deleteAll($this->getId());
     include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
     ilObjCourseGrouping::_deleteAll($this->getId());
     include_once './Modules/Course/classes/class.ilCourseFile.php';
     ilCourseFile::_deleteByCourse($this->getId());
     include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php';
     ilCourseDefinedFieldDefinition::_deleteByContainer($this->getId());
     $ilAppEventHandler->raise('Modules/Course', 'delete', array('object' => $this, 'obj_id' => $this->getId(), 'appointments' => $this->prepareAppointments('delete')));
     return true;
 }
 /**
  * Determine status
  *
  * @param	integer		object id
  * @param	integer		user id
  * @param	object		object (optional depends on object type)
  * @return	integer		status
  */
 function determineStatus($a_obj_id, $a_user_id, $a_obj = null)
 {
     global $ilObjDataCache, $ilDB;
     // the status completed depends on:
     // $status_info['num_objectives'] (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
     // - ilCourseObjective::_getObjectiveIds($a_obj_id);
     // - table crs_objectives manipulated in
     // - ilCourseObjective
     // $status_info['objective_result']  (ilLPStatusWrapper::_getStatusInfo($a_obj_id);)
     // table crs_objective_status (must not contain a dataset)
     // ilCourseObjectiveResult -> added ilLPStatusWrapper::_updateStatus()
     $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
     switch ($ilObjDataCache->lookupType($a_obj_id)) {
         case "crs":
             include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
             if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
                 // change_event is of no use when no objective has been tried
                 // $status = self::LP_STATUS_IN_PROGRESS_NUM;
                 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
                 $objectives = ilCourseObjective::_getObjectiveIds($a_obj_id, true);
                 if ($objectives) {
                     // #14051 - getSummarizedObjectiveStatusForLP() might return null
                     include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
                     $status = (int) ilLOUserResults::getSummarizedObjectiveStatusForLP($objectives, $a_user_id);
                 }
             }
             break;
     }
     return $status;
 }