/**
  * 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);
 }
 protected function addItemDetails(ilObjectListGUI $a_item_list_gui, array $a_item)
 {
     global $lng, $ilCtrl;
     $item_ref_id = $a_item["ref_id"];
     if (is_array($this->objective_map)) {
         $details = array();
         if (isset($this->objective_map["material"][$item_ref_id])) {
             // #12965
             foreach ($this->objective_map["material"][$item_ref_id] as $objective_id) {
                 $ilCtrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $objective_id);
                 $url = $ilCtrl->getLinkTargetByClass(array('illoeditorgui', 'ilcourseobjectivesgui'), 'edit');
                 $ilCtrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', '');
                 $details[] = array('desc' => $lng->txt('crs_loc_tab_materials') . ': ', 'target' => '_top', 'link' => $url, 'name' => $this->objective_map["names"][$objective_id]);
             }
         }
         if ($this->objective_map["test_i"] == $item_ref_id) {
             $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 1);
             $details[] = array('desc' => '', 'target' => '_top', 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testOverview'), 'name' => $lng->txt('crs_loc_tab_itest'));
             $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0);
         }
         if ($this->objective_map["test_q"] == $item_ref_id) {
             $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 2);
             $details[] = array('desc' => '', 'target' => '_top', 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testOverview'), 'name' => $lng->txt('crs_loc_tab_qtest'));
             $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0);
         }
         // #15367 - patch LOK
         if (is_array($this->objective_map["test_ass"][$item_ref_id])) {
             foreach ($this->objective_map["test_ass"][$item_ref_id] as $type => $items) {
                 if ($type == ilLOSettings::TYPE_TEST_INITIAL) {
                     $caption = $lng->txt('crs_loc_tab_itest');
                     $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 1);
                 } else {
                     $caption = $lng->txt('crs_loc_tab_qtest');
                     $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 2);
                 }
                 foreach ($items as $objtv_title) {
                     $details[] = array('desc' => '', 'target' => '_top', 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testsOverview'), 'name' => $caption . " (" . $this->lng->txt("crs_loc_learning_objective") . ": " . $objtv_title . ")");
                 }
                 $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0);
             }
         }
         if (sizeof($details)) {
             $a_item_list_gui->enableItemDetailLinks(true);
             $a_item_list_gui->setItemDetailLinks($details, $lng->txt('crs_loc_settings_tbl') . ': ');
         } else {
             $a_item_list_gui->enableItemDetailLinks(false);
         }
     }
     // order
     if ($this->getContainerGUI()->isActiveOrdering()) {
         $a_item_list_gui->enableCommands(true, true);
         $a_item_list_gui->enableProperties(false);
     } else {
         if (!$this->getContainerGUI()->isActiveAdministrationPanel()) {
             $a_item_list_gui->enableCommands(true, true);
             $a_item_list_gui->enableProperties(false);
         }
     }
     if ($a_item['objective_id']) {
         $a_item_list_gui->setDefaultCommandParameters(array('objective_id' => $a_item['objective_id']));
         if ($this->loc_settings->getQualifiedTest() == $a_item['ref_id']) {
             $a_item_list_gui->setConditionTarget($this->getContainerObject()->getRefId(), $a_item['objective_id'], 'lobj');
             // check conditions of target
             include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
             $fullfilled = ilConditionHandler::_checkAllConditionsOfTarget($this->getContainerObject()->getRefId(), $a_item['objective_id'], 'lobj');
             if (!$fullfilled || $a_item['objective_status']) {
                 $a_item_list_gui->disableTitleLink(true);
             }
         }
         include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
         $res = ilLOUserResults::lookupResult($this->getContainerObject()->getId(), $GLOBALS['ilUser']->getId(), $a_item['objective_id'], ilLOUserResults::TYPE_QUALIFIED);
         $res = $this->updateResult($res, $a_item['ref_id'], $a_item['objective_id'], $GLOBALS['ilUser']->getId());
         if ($res['is_final']) {
             $a_item_list_gui->disableTitleLink(true);
             $a_item_list_gui->enableProperties(true);
             $a_item_list_gui->addCustomProperty($this->lng->txt('crs_loc_passes_reached'), '', true);
         } elseif ($this->loc_settings->getQualifiedTest() == $a_item['ref_id']) {
             include_once './Modules/Course/classes/class.ilCourseObjective.php';
             $poss_pass = ilCourseObjective::lookupMaxPasses($a_item['objective_id']);
             if ($poss_pass) {
                 $a_item_list_gui->enableProperties(true);
                 $a_item_list_gui->addCustomProperty($this->lng->txt('crs_loc_passes_left'), $poss_pass - $res['tries'] > 0 ? $poss_pass - $res['tries'] : 1, false);
             }
         }
     }
 }
 /**
  * update question result of run
  * @param ilTestSession $session
  * @param assQuestion $qst
  */
 protected function updateQuestionResult(ilTestSession $session, assQuestion $qst)
 {
     foreach ($this->run as $run) {
         if ($run->questionExists($qst->getId())) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': reached points are ' . $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
             $run->setQuestionResult($qst->getId(), $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
             $run->update();
             $res = $run->getResult();
             include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
             include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
             $old_result = ilLOUserResults::lookupResult($this->container_id, $this->user_id, $run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL);
             $ur = new ilLOUserResults($this->container_id, $this->user_id);
             $ur->saveObjectiveResult($run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOUserResults::TYPE_QUALIFIED : ilLOUserResults::TYPE_INITIAL, ilLOUtils::isCompleted($this->container_id, $session->getRefId(), $run->getObjectiveId(), $res['max'], $res['reached'], $old_result['limit_perc']) ? ilLOUserResults::STATUS_COMPLETED : ilLOUserResults::STATUS_FAILED, (int) $res['percentage'], $old_result['limit_perc'], $old_result['tries'], $old_result['is_final']);
             $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($run->getResult(), true));
             include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
             ilLPStatusWrapper::_updateStatus($this->container_id, $this->user_id);
         }
     }
     return false;
 }