/**
  * 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());
 }
Esempio 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;
 }
 /**
  * render objective
  *
  * @access protected
  * @param int objective id
  * @param bool co page status
  * @param ilAccordionGUI $a_accordion 
  * @param array $a_lo_result 
  * @return string html
  */
 protected function renderObjective($a_objective_id, &$a_has_lo_page, ilAccordionGUI $a_accordion = null, array $a_lo_result = null)
 {
     global $ilUser, $lng;
     include_once './Modules/Course/classes/class.ilCourseObjective.php';
     $objective = new ilCourseObjective($this->getContainerObject(), $a_objective_id);
     include_once './Services/Container/classes/class.ilContainerSorting.php';
     include_once './Services/Object/classes/class.ilObjectActivation.php';
     $items = ilObjectActivation::getItemsByObjective($a_objective_id);
     // sorting is handled by ilCourseObjectiveMaterials
     // $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('lobj',$a_objective_id,$items);
     include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
     $objectives_lm_obj = new ilCourseObjectiveMaterials($a_objective_id);
     // #13381 - map material assignment to position
     $sort_map = array();
     foreach ($objectives_lm_obj->getMaterials() as $item) {
         $sort_map[$item["lm_ass_id"]] = $item["position"];
     }
     $is_manage = $this->getContainerGUI()->isActiveAdministrationPanel();
     $is_order = $this->getContainerGUI()->isActiveOrdering();
     $sort_content = array();
     foreach ($items as $item) {
         if ($this->getDetailsLevel($a_objective_id) < self::DETAILS_ALL) {
             continue;
         }
         $item_list_gui2 = $this->getItemGUI($item);
         $item_list_gui2->enableIcon(true);
         if ($is_order || $a_accordion) {
             $item_list_gui2->enableCommands(true, true);
             $item_list_gui2->enableProperties(false);
         }
         $chapters = $objectives_lm_obj->getChapters();
         if (count($chapters)) {
             $has_sections = false;
             foreach ($chapters as $chapter) {
                 if ($chapter['ref_id'] != $item['child']) {
                     continue;
                 }
                 $has_sections = true;
                 include_once './Modules/LearningModule/classes/class.ilLMObject.php';
                 $title = $item['title'] . " &rsaquo; " . ilLMObject::_lookupTitle($chapter['obj_id']) . " (" . $lng->txt('obj_' . $chapter['type']) . ")";
                 $item_list_gui2->setDefaultCommandParameters(array("obj_id" => $chapter['obj_id'], "focus_id" => $chapter['obj_id'], "focus_return" => $this->container_obj->getRefId()));
                 if ($is_order) {
                     $item_list_gui2->setPositionInputField("[lobj][" . $a_objective_id . "][" . $chapter['lm_ass_id'] . "]", sprintf('%d', $chapter['position'] * 10));
                 }
                 $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'], $item['obj_id'], $title, $item['description']);
                 // #13381 - use materials order
                 $sort_key = str_pad($chapter['position'], 5, 0, STR_PAD_LEFT) . "_" . strtolower($title) . "_" . $chapter['lm_ass_id'];
                 $sort_content[$sort_key] = $sub_item_html;
             }
         }
         $this->rendered_items[$item['child']] = true;
         if ($lm_ass_id = $objectives_lm_obj->isAssigned($item['ref_id'], true)) {
             if ($is_order) {
                 $item_list_gui2->setPositionInputField("[lobj][" . $a_objective_id . "][" . $lm_ass_id . "]", sprintf('%d', $sort_map[$lm_ass_id] * 10));
             }
             $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description']);
             // #13381 - use materials order
             $sort_key = str_pad($sort_map[$lm_ass_id], 5, 0, STR_PAD_LEFT) . "_" . strtolower($item['title']) . "_" . $lm_ass_id;
             $sort_content[$sort_key] = $sub_item_html;
         }
     }
     if ($this->getDetailsLevel($a_objective_id) == self::DETAILS_ALL) {
         $this->objective_list_gui->enableCommands(false);
     } else {
         $this->objective_list_gui->enableCommands(true);
     }
     if ($is_order) {
         $this->objective_list_gui->setPositionInputField("[lobj][" . $a_objective_id . "][0]", $objective->__getPosition() * 10);
     }
     ksort($sort_content);
     if (!$a_accordion) {
         foreach ($sort_content as $sub_item_html) {
             $this->objective_list_gui->addSubItemHTML($sub_item_html);
         }
         return $this->objective_list_gui->getListItemHTML(0, $a_objective_id, $objective->getTitle(), $objective->getDescription(), $is_manage || $is_order);
     } else {
         $acc_content = $sort_content;
         $initial_shown = false;
         if ($this->getSettings()->hasSeparateInitialTests() and !$a_lo_result['initial_status']) {
             $acc_content[] = $this->renderTest($this->getTestAssignments()->getTestByObjective($a_objective_id, ilLOSettings::TYPE_TEST_INITIAL), $a_objective_id, true, false, $a_lo_result);
             $initial_shown = TRUE;
         } elseif ($this->getSettings()->hasSeparateQualifiedTests()) {
             $acc_content[] = $this->renderTest($this->getTestAssignments()->getTestByObjective($a_objective_id, ilLOSettings::TYPE_TEST_QUALIFIED), $a_objective_id, false, false, $a_lo_result);
         }
         /*
         if($this->loc_settings->getInitialTest() &&
         	$this->loc_settings->getType() == ilLOSettings::LOC_INITIAL_SEL &&
         	!$a_lo_result["initial_status"])
         {
         	$acc_content[] = $this->renderTest($this->loc_settings->getInitialTest(), $a_objective_id, true, false, $a_lo_result);
         	$initial_shown = true;
         }	
         if(!$initial_shown &&
         	$this->loc_settings->getQualifiedTest() && 
         	$this->loc_settings->isQualifiedTestPerObjectiveVisible())
         {
         	$acc_content[] = $this->renderTest($this->loc_settings->getQualifiedTest(), $a_objective_id, false, false, $a_lo_result);
         }
         */
         $co_page = null;
         include_once "./Services/COPage/classes/class.ilPageUtil.php";
         if (ilPageUtil::_existsAndNotEmpty("lobj", $objective->getObjectiveId())) {
             $a_has_lo_page = true;
             include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
             $page_gui = new ilLOPageGUI($objective->getObjectiveId());
             include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
             $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
             $page_gui->setPresentationTitle("");
             $page_gui->setTemplateOutput(false);
             $page_gui->setHeader("");
             $co_page = "<div class='ilContObjectiveIntro'>" . $page_gui->showPage() . "</div>";
         }
         // patch optes start
         $a_accordion->addItem($this->buildAccordionTitle($objective, $a_lo_result), $co_page . $this->buildAccordionContent($acc_content), isset($_GET["oobj"]) && (int) $_GET["oobj"] == $objective->getObjectiveId());
         // patch optes end
     }
 }
 /**
  * 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());
 }