コード例 #1
0
 public static function buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode = false, $a_sub = false, $a_tt_suffix = null)
 {
     global $lng, $ilCtrl, $ilUser;
     $tpl = new ilTemplate("tpl.objective_progressbar.html", true, true, "Services/Container");
     $tooltip_id = "crsobjtvusr_" . $a_objective_id . "_" . $a_lo_result["type"] . "_" . (int) $a_sub;
     if ($a_tt_suffix !== null) {
         $tooltip_id .= "_" . $a_tt_suffix;
     }
     $tt_txt = sprintf($lng->txt("crs_loc_tt_info"), $a_lo_result["result_perc"], $a_lo_result["limit_perc"]);
     // #12970
     $perc_resize = (int) $a_lo_result["result_perc"];
     /*
     if($a_lo_result["limit_perc"] && $a_lo_result["result_perc"])
     {
     	$perc_resize = min(round($a_lo_result["result_perc"]*(100/$a_lo_result["limit_perc"])), 100);
     }
     */
     include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
     include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
     $next_step = $progress_txt = $bar_color = $test_url = $initial_sub = null;
     // qualifying test
     if ($a_lo_result["type"] == ilLOUserResults::TYPE_QUALIFIED or $a_lo_result['type'] == ilLOUserResults::TYPE_INITIAL and ilLOSettings::getInstanceByObjId($a_lo_result['course_id'])->isInitialTestQualifying()) {
         $progress_txt = $lng->txt("crs_loc_progress_result_qtest");
         $tt_txt = $lng->txt("crs_loc_tab_qtest") . ": " . $tt_txt;
         // link to test statistics
         if ($a_lo_result["type"] == ilLOUserResults::TYPE_QUALIFIED && $a_lo_result["qtest"]) {
             $test_url = ilLOUtils::getTestResultLinkForUser($a_lo_result["qtest"], $a_lo_result["user_id"]);
         } else {
             if ($a_lo_result["itest"]) {
                 $test_url = ilLOUtils::getTestResultLinkForUser($a_lo_result["itest"], $a_lo_result["user_id"]);
             }
         }
         if ($a_lo_result["status"] == ilLOUserResults::STATUS_COMPLETED) {
             $next_step = $lng->txt("crs_loc_progress_objective_complete");
             $bar_color = "ilCourseObjectiveProgressBarCompleted";
             if ($a_lo_result["type"] == ilLOUserResults::TYPE_QUALIFIED && $a_has_initial_test && is_array($a_lo_result["initial"])) {
                 $a_lo_result["initial"]["itest"] = $a_lo_result["itest"];
                 $initial_sub = self::buildObjectiveProgressBar(true, $a_objective_id, $a_lo_result["initial"], true, true, $a_tt_suffix);
             }
         } else {
             $next_step = $lng->txt("crs_loc_progress_do_qualifying_again");
             $bar_color = "ilCourseObjectiveProgressBarFailed";
         }
     } else {
         if ($a_lo_result["status"]) {
             $progress_txt = $lng->txt("crs_loc_progress_result_itest");
             $tt_txt = $lng->txt("crs_loc_tab_itest") . ": " . $tt_txt;
             // link to test statistics
             if ($a_lo_result["itest"]) {
                 $test_url = ilLOUtils::getTestResultLinkForUser($a_lo_result["itest"], $a_lo_result["user_id"]);
             }
             $bar_color = "ilCourseObjectiveProgressBarNeutral";
             if ($a_lo_result["status"] == ilLOUserResults::STATUS_COMPLETED) {
                 $next_step = $lng->txt("crs_loc_progress_do_qualifying");
             } else {
                 $next_step = $lng->txt("crs_loc_suggested");
             }
         } else {
             if ((bool) $a_has_initial_test) {
                 $next_step = $lng->txt("crs_loc_progress_no_result_do_initial");
             } else {
                 $next_step = $lng->txt("crs_loc_progress_no_result_no_initial");
             }
         }
     }
     if ($progress_txt) {
         if ($test_url) {
             $tpl->setCurrentBlock("statustxt_bl");
             $tpl->setVariable("TXT_PROGRESS_STATUS", $progress_txt);
             $tpl->setVariable("URL_TEST", $test_url);
         } else {
             $tpl->setCurrentBlock("statustxt_no_link_bl");
             $tpl->setVariable("TXT_PROGRESS_STATUS_NO_LINK", $progress_txt);
         }
         $tpl->parseCurrentBlock();
     }
     if ($bar_color) {
         $limit_pos = (99 - (int) $a_lo_result["limit_perc"]) * -1;
         $tpl->setCurrentBlock("statusbar_bl");
         $tpl->setVariable("PERC_STATUS", $a_lo_result["result_perc"]);
         $tpl->setVariable("LIMIT_POS", $limit_pos);
         $tpl->setVariable("PERC_WIDTH", $perc_resize);
         $tpl->setVariable("PERC_COLOR", $bar_color);
         $tpl->setVariable("TT_ID", $tooltip_id);
         $tpl->parseCurrentBlock();
     }
     if ($next_step && !$a_list_mode) {
         $tpl->setCurrentBlock("nstep_bl");
         $tpl->setVariable("TXT_NEXT_STEP", $next_step);
         $tpl->parseCurrentBlock();
     }
     if ($tt_txt) {
         include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
         ilTooltipGUI::addTooltip($tooltip_id, $tt_txt);
     }
     if ($initial_sub) {
         if ($a_list_mode) {
             $tpl->setVariable("SUB_STYLE", ' style="padding-left: 30px;"');
         } else {
             $tpl->setVariable("SUB_STYLE", ' style="padding-left: 10px;"');
         }
         $tpl->setVariable("SUB_INIT", $initial_sub);
     }
     return $tpl->get();
 }
コード例 #2
0
 /**
  * Check if questions are assigned
  * @param type $a_test_ref_id
  */
 protected function lookupQuestionsAssigned($a_test_ref_id)
 {
     include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
     if (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($a_test_ref_id))) {
         foreach ($this->getObjectives() as $objective_id) {
             include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
             $seq = ilLORandomTestQuestionPools::lookupSequence($this->parent_obj->getId(), $objective_id, ilObject::_lookupObjId($a_test_ref_id));
             if (!$seq) {
                 return false;
             }
         }
     } else {
         foreach ($this->getObjectives() as $objective_id) {
             include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
             $qsts = ilCourseObjectiveQuestion::lookupQuestionsByObjective(ilObject::_lookupObjId($a_test_ref_id), $objective_id);
             if (!count($qsts)) {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #3
0
 /**
  * show objectives
  *
  * @access public
  * @param object $tpl template object
  * @return
  */
 public function showObjectives($a_tpl, $a_is_order = false)
 {
     global $lng, $ilSetting;
     $this->clearAdminCommandsDetermination();
     // get embedded blocks
     $has_container_page = false;
     if (!$a_is_order) {
         $output_html = $this->getContainerGUI()->getContainerPageHTML();
         if ($output_html != "") {
             $has_container_page = true;
             $this->output_html .= $this->insertPageEmbeddedBlocks($output_html);
         }
         unset($output_html);
     }
     // All objectives
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     if (!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId(), true))) {
         return false;
     }
     include_once './Modules/Course/classes/class.ilCourseObjectiveListGUI.php';
     $this->objective_list_gui = new ilCourseObjectiveListGUI();
     $this->objective_list_gui->setContainerObject($this->getContainerGUI());
     if ($ilSetting->get("icon_position_in_lists") == "item_rows") {
         $this->objective_list_gui->enableIcon(true);
     }
     $acc = null;
     if (!$a_is_order) {
         include_once "Services/Accordion/classes/class.ilAccordionGUI.php";
         $acc = new ilAccordionGUI();
         $acc->setUseSessionStorage(true);
         $acc->setAllowMultiOpened(true);
         $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
         $acc->setId("crsobjtv_" . $this->container_obj->getId());
     } else {
         $this->renderer->addCustomBlock('lobj', $lng->txt('crs_objectives'));
     }
     $lur_data = $this->parseLOUserResults();
     $has_initial = ilLOSettings::getInstanceByObjId($this->container_obj->getId())->worksWithInitialTest();
     $has_lo_page = false;
     $obj_cnt = 0;
     foreach ($objective_ids as $objective_id) {
         include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
         if ($has_initial && (!isset($lur_data[$objective_id]) or ilLOUtils::hasActiveRun($this->container_obj->getId(), ilLOSettings::getInstanceByObjId($this->container_obj->getId())->getInitialTest(), $objective_id))) {
             $lur_data[$objective_id] = array("type" => ilLOSettings::TYPE_TEST_INITIAL);
         }
         if ($html = $this->renderObjective($objective_id, $has_lo_page, $acc, $lur_data[$objective_id])) {
             $this->renderer->addItemToBlock('lobj', 'lobj', $objective_id, $html);
         }
         $obj_cnt++;
     }
     // buttons for showing/hiding all objectives
     if (!$a_is_order && $obj_cnt > 1) {
         $this->showButton("", $lng->txt("crs_show_all_obj"), "", "crs_show_all_obj_btn");
         $this->showButton("", $lng->txt("crs_hide_all_obj"), "", "crs_hide_all_obj_btn");
         $acc->setShowAllElement("crs_show_all_obj_btn");
         $acc->setHideAllElement("crs_hide_all_obj_btn");
     }
     if (!$has_container_page && $has_lo_page) {
         // add core co page css
         include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $GLOBALS["tpl"]->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
         $GLOBALS["tpl"]->setCurrentBlock("SyntaxStyle");
         $GLOBALS["tpl"]->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
         $GLOBALS["tpl"]->parseCurrentBlock();
     }
     // order/block
     if ($a_is_order) {
         $this->addFooterRow();
         $this->output_html .= $output_html . $this->renderer->getHTML();
         $this->renderer->resetDetails();
     } else {
         $this->output_html .= "<div class='ilCrsObjAcc'>" . $acc->getHTML() . "</div>";
     }
 }
コード例 #4
0
 /**
  * Create test result link
  * @param type $a_type
  * @param type $a_objective_id
  */
 protected function createTestResultLink($a_type, $a_objective_id)
 {
     include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
     $assignments = ilLOTestAssignments::getInstance($this->getParentContainer()->getId());
     $test_ref_id = $assignments->getTestByObjective($a_objective_id, $a_type);
     if (!$test_ref_id) {
         return '';
     }
     include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
     return ilLOUtils::getTestResultLinkForUser($test_ref_id, $this->getUserId());
 }
コード例 #5
0
 /**
  * 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());
 }
コード例 #6
0
 /**
  * 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;
 }