/**
  * 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;
 }
Exemplo n.º 2
0
 protected function getObjectivesStatus($a_set_errors = true)
 {
     if (!$this->getObjectivesAvailableStatus($a_set_errors)) {
         return false;
     }
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $num_active = ilCourseObjective::_getCountObjectives($this->getParentObject()->getId(), true);
     if (!$num_active) {
         if ($a_set_errors) {
             $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_lo');
         }
         return false;
     }
     foreach (ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(), true) as $objective_id) {
         include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
         $obj = new ilCourseObjectiveMaterials($objective_id);
         if (!count($obj->getMaterials())) {
             if ($a_set_errors) {
                 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_mat');
             }
             return false;
         }
     }
     // check for assigned initial test questions
     if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
         // check for assigned questions
         if (!$this->lookupQuestionsAssigned($this->getSettings()->getInitialTest())) {
             if ($a_set_errors) {
                 $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_qst');
             }
             return false;
         }
     }
     // check for assigned questions
     if (!$this->getSettings()->hasSeparateQualifiedTests() and !$this->lookupQuestionsAssigned($this->getSettings()->getQualifiedTest())) {
         if ($a_set_errors) {
             $this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_no_active_qst');
         }
         return false;
     }
     // @deprecated
     /*
     if(!$this->checkNumberOfTries())
     {
     	if($a_set_errors)
     	{
     		$this->appendFailure(self::SECTION_OBJECTIVES, 'crs_loc_err_nr_tries_exceeded');
     	}
     	return false;
     }
     */
     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', '');
 }
Exemplo n.º 4
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;
 }
 /**
  * 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;
 }
 protected function buildObjectiveMap()
 {
     $objective_map = array();
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     // begin-patch lok
     if (count($objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId(), true))) {
         include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
         foreach ($objective_ids as $objective_id) {
             foreach (ilCourseObjectiveMaterials::_getAssignedMaterials($objective_id) as $mat_ref_id) {
                 $objective_map["material"][$mat_ref_id][] = $objective_id;
                 if (!isset($objective_map["names"][$objective_id])) {
                     $objective = new ilCourseObjective($this->getContainerObject(), $objective_id);
                     $objective_map["names"][$objective_id] = $objective->getTitle();
                 }
             }
         }
         // initial/qualifying test
         $tst = $this->loc_settings->getInitialTest();
         if ($tst) {
             $objective_map["test_i"] = $tst;
         }
         $tst = $this->loc_settings->getQualifiedTest();
         if ($tst) {
             $objective_map["test_q"] = $tst;
         }
     }
     return $objective_map;
 }
Exemplo n.º 7
0
 public static function getUserObjectiveMatrix($a_parent_obj_id, $a_users)
 {
     global $ilDB;
     if ($a_parent_obj_id && $a_users) {
         $res = array();
         include_once "Services/Tracking/classes/class.ilLPStatus.php";
         include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
         include_once "Modules/Course/classes/class.ilCourseObjective.php";
         $objective_ids = ilCourseObjective::_getObjectiveIds($a_parent_obj_id, true);
         // there may be missing entries for any user / objective combination
         foreach ($objective_ids as $objective_id) {
             foreach ($a_users as $user_id) {
                 $res[$user_id][$objective_id] = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
             }
         }
         $query = "SELECT * FROM loc_user_results" . " WHERE " . $ilDB->in("objective_id", $objective_ids, "", "integer") . " AND " . $ilDB->in("user_id", $a_users, "", "integer") . " AND type = " . $ilDB->quote(ilLOUserResults::TYPE_QUALIFIED, "integer");
         $set = $ilDB->query($query);
         while ($row = $ilDB->fetchAssoc($set)) {
             $objective_id = $row["objective_id"];
             $user_id = $row["user_id"];
             // see ilLOUserResults::getObjectiveStatusForLP()
             if ($row["status"] == ilLOUserResults::STATUS_COMPLETED) {
                 $res[$user_id][$objective_id] = ilLPStatus::LP_STATUS_COMPLETED_NUM;
             } else {
                 $res[$user_id][$objective_id] = ilLPStatus::LP_STATUS_FAILED_NUM;
             }
         }
         return $res;
     }
 }
 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;
 }
 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();
 }
Exemplo n.º 10
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;
 }
 /**
  * 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;
 }
Exemplo n.º 12
0
 /**
  * activate chosen objectives
  */
 protected function deactivateObjectives()
 {
     $disabled = (array) $_REQUEST['objective'];
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(), false);
     foreach ((array) $objectives as $objective_id) {
         $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
         if (in_array($objective_id, $disabled)) {
             $objective->setActive(false);
             $objective->update();
         }
     }
     include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
     ilLPStatusWrapper::_refreshStatus($this->getParentObject()->getId());
     ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
     $this->ctrl->redirect($this, 'listObjectives');
 }
 /**
  * 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());
 }
Exemplo n.º 14
0
 /**
  * 
  */
 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';
     $res = new ilLOUserResults($this->object->getId(), $GLOBALS['ilUser']->getId());
     $passed = $res->getCompletedObjectiveIdsByType(ilLOSettings::getInstanceByObjId($this->object->getId())->getQualifiedTest() == $test_id ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL);
     if ($objective_id) {
         $objective_ids = array($objective_id);
         if (in_array($objective_id, $passed)) {
             $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)) {
             $passed = array();
         }
     }
     if (is_null($a_force_new_run)) {
         $resume_type = $this->handleActivePass($test_id, $objective_id);
         switch ($resume_type) {
             case 1:
                 return TRUE;
             case 2:
                 $a_force_new_run = TRUE;
                 break;
             case 3:
                 $a_force_new_run = FALSE;
                 break;
         }
     } else {
         include_once './Modules/Test/classes/class.ilObjTest.php';
         ilObjTest::ensureParticipantsLastActivePassFinished($test_id, $GLOBALS['ilUser']->getId(), $a_force_new_run);
     }
     if ($a_force_new_run === TRUE) {
         include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
         ilLOTestRun::deleteRun($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($test_id));
         foreach ((array) $objective_ids as $oid) {
             if (!in_array($oid, $passed)) {
                 $run = new ilLOTestRun($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($test_id), $oid);
                 $run->create();
             }
         }
     }
     // Redirect to test player
     include_once './Services/Object/classes/class.ilObjectFactory.php';
     $test_obj = ilObjectFactory::getInstanceByObjId(ilObject::_lookupObjId($test_id));
     include_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
     $testPlayerFactory = new ilTestPlayerFactory($test_obj);
     $playerGuiClass = get_class($testPlayerFactory->getPlayerGUI());
     $sessionLock = md5($_COOKIE[session_name()] . time());
     // do NOT set this into $_SESSION
     // resume or start new run
     if (ilObjTest::isParticipantsLastPassActive($test_id, $GLOBALS['ilUser']->getId())) {
         $test_cmd = 'resumePlayer';
     } else {
         $test_cmd = 'startPlayer';
     }
     $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'ref_id', $test_id);
     $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'crs_show_result', $this->object->getRefId());
     $GLOBALS['ilCtrl']->setParameterByClass($playerGuiClass, 'lock', $sessionLock);
     $GLOBALS['ilCtrl']->redirectByClass(array('ilObjTestGUI', $playerGuiClass), $test_cmd);
 }
 protected function read($a_obj_id)
 {
     include_once 'Modules/Course/classes/class.ilCourseObjective.php';
     $this->items = ilCourseObjective::_getObjectiveIds($a_obj_id);
 }
 protected function buildObjectiveMap()
 {
     $objective_map = array();
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     // begin-patch lok
     if (count($objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId(), true))) {
         include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
         foreach ($objective_ids as $objective_id) {
             foreach (ilCourseObjectiveMaterials::_getAssignedMaterials($objective_id) as $mat_ref_id) {
                 $objective_map["material"][$mat_ref_id][] = $objective_id;
                 if (!isset($objective_map["names"][$objective_id])) {
                     $objective = new ilCourseObjective($this->getContainerObject(), $objective_id);
                     $objective_map["names"][$objective_id] = $objective->getTitle();
                 }
             }
         }
         // initial/qualifying test
         $tst = $this->loc_settings->getInitialTest();
         if ($tst) {
             $objective_map["test_i"] = $tst;
         }
         $tst = $this->loc_settings->getQualifiedTest();
         if ($tst) {
             $objective_map["test_q"] = $tst;
         }
         // patch LOK
         // objective test assignments
         include_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
         include_once 'Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
         $ass_test = new ilLOTestAssignments($this->getContainerObject()->getId());
         foreach ($ass_test->getAssignmentsByType(ilLOSettings::TYPE_TEST_INITIAL) as $ass) {
             $title = ilCourseObjective::lookupObjectiveTitle($ass->getObjectiveId());
             $objective_map["test_ass"][$ass->getTestRefId()][$ass->getAssignmentType()][] = $title;
         }
         foreach ($ass_test->getAssignmentsByType(ilLOSettings::TYPE_TEST_QUALIFIED) as $ass) {
             $title = ilCourseObjective::lookupObjectiveTitle($ass->getObjectiveId());
             $objective_map["test_ass"][$ass->getTestRefId()][$ass->getAssignmentType()][] = $title;
         }
     }
     return $objective_map;
 }
Exemplo n.º 17
0
 /**
  * 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;
 }
Exemplo n.º 18
0
 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 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);
 }