From f501c1d130efcbc87af92b2018efe387e4f126c3 Mon Sep 17 00:00:00 2001 From: smeyer-ilias Date: Fri, 21 Aug 2015 09:19:48 +0200 Subject: [PATCH] lok3 #7 --- .../Objectives/class.ilLOEditorGUI.php | 5 +- .../classes/Objectives/class.ilLOSettings.php | 8 +++ .../Objectives/class.ilLOTestAssignments.php | 8 ++- .../class.ilCourseObjectivesTableGUI.php | 66 ++++++++++++++----- .../default/tpl.crs_objectives_table_row.html | 3 + 5 files changed, 71 insertions(+), 19 deletions(-) diff --git a/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php b/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php index 3768d38af26d..129b0ad13ff7 100644 --- a/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php +++ b/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php @@ -380,14 +380,15 @@ protected function materials() */ protected function testsOverview() { + $this->setTestType((int) $_REQUEST['tt']); + $this->ctrl->setParameter($this,'tt',$this->getTestType()); + $GLOBALS['ilToolbar']->setFormAction($this->ctrl->getFormAction($this)); $GLOBALS['ilToolbar']->addButton( $this->lng->txt('crs_loc_btn_new_assignment'), $this->ctrl->getLinkTarget($this,'testAssignment') ); - $this->setTestType((int) $_REQUEST['tt']); - $this->ctrl->setParameter($this,'tt',$this->getTestType()); $settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId()); switch($this->getTestType()) diff --git a/Modules/Course/classes/Objectives/class.ilLOSettings.php b/Modules/Course/classes/Objectives/class.ilLOSettings.php index d0a2a3758912..3825421a7e15 100644 --- a/Modules/Course/classes/Objectives/class.ilLOSettings.php +++ b/Modules/Course/classes/Objectives/class.ilLOSettings.php @@ -154,6 +154,14 @@ public function isQualifyingTestStart() return $this->qt_start; } + /** + * Check if separate initial test are configured + */ + public function hasSeparateInitialTests() + { + return $this->getInitialTestType() == self::TYPE_INITIAL_PLACEMENT_SELECTED || $this->getInitialTestType() == self::TYPE_INITIAL_QUALIFYING_SELECTED; + } + /** * Check if test ref_id is used in an objective course * @param int ref_id diff --git a/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php b/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php index fdfa50d44893..47e74838eda8 100644 --- a/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php +++ b/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php @@ -75,13 +75,17 @@ public function getAssignmentsByType($a_type) /** * Get assignment by objective * @param type $a_objective_id + * @param type initial or final * @return ilLOTestAssignment */ - public function getAssignmentByObjective($a_objective_id) + public function getAssignmentByObjective($a_objective_id, $a_type) { foreach($this->assignments as $assignment) { - if($assignment->getObjectiveId() == $a_objective_id) + if( + ($assignment->getObjectiveId() == $a_objective_id) && + ($assignment->getAssignmentType() == $a_type) + ) { return $assignment; } diff --git a/Modules/Course/classes/class.ilCourseObjectivesTableGUI.php b/Modules/Course/classes/class.ilCourseObjectivesTableGUI.php index 9e2824bc6d88..7b1df6489e4b 100644 --- a/Modules/Course/classes/class.ilCourseObjectivesTableGUI.php +++ b/Modules/Course/classes/class.ilCourseObjectivesTableGUI.php @@ -210,26 +210,42 @@ protected function fillRow($a_set) // begin-patch lok if($this->getSettings()->worksWithInitialTest()) { - foreach($a_set['self'] as $test) + if($this->getSettings()->hasSeparateInitialTests()) { - // begin-patch lok - foreach((array) $test['questions'] as $question) + if($a_set['initial']) { - $this->tpl->setCurrentBlock('self_qst_row'); - $this->tpl->setVariable('SELF_QST_TITLE',$question['title']); + $obj_id = ilObject::_lookupObjId($a_set['initial']); + $this->tpl->setCurrentBlock('initial_test_per_objective'); + $this->tpl->setVariable('IT_IMG', ilObject::_getIcon($obj_id, 'tiny')); + $this->tpl->setVariable('IT_ALT', $this->lng->txt('obj_tst')); + $this->tpl->setVariable('IT_TITLE',ilObject::_lookupTitle($obj_id)); $this->tpl->parseCurrentBlock(); } - #$this->tpl->setCurrentBlock('self_test_row'); - #$this->tpl->setVariable('SELF_TST_ALT',$this->lng->txt('obj_tst')); - #$this->tpl->setVariable('SELF_TST_TITLE',ilObject::_lookupTitle($test['obj_id'])); - #$this->tpl->parseCurrentBlock(); - // end-patch lok + else + { + $this->tpl->touchBlock('initial_test_per_objective'); + } } - // begin-patch lok - if(!count($a_set['self'])) + else { - $this->tpl->touchBlock('self_qst_row'); + foreach($a_set['self'] as $test) + { + // begin-patch lok + foreach((array) $test['questions'] as $question) + { + $this->tpl->setCurrentBlock('self_qst_row'); + $this->tpl->setVariable('SELF_QST_TITLE',$question['title']); + $this->tpl->parseCurrentBlock(); + } + // end-patch lok + } + // begin-patch lok + if(!count($a_set['self'])) + { + $this->tpl->touchBlock('self_qst_row'); + } } + // end-patch lok } // end-patch lok @@ -376,7 +392,27 @@ public function parse($a_objective_ids) // begin-patch lok if($this->getSettings()->worksWithInitialTest()) { - if(ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest()))) + if($this->getSettings()->hasSeparateInitialTests()) + { + include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; + $assignments = ilLOTestAssignments::getInstance($this->course_obj->getId()); + $assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL); + + $objective_data['initial'] = 0; + if($assignment instanceof ilLOTestAssignment) + { + $test_id = $assignment->getTestRefId(); + + include_once './Services/Object/classes/class.ilObjectFactory.php'; + $factory = new ilObjectFactory(); + $test_candidate = $factory->getInstanceByRefId($test_id,FALSE); + if($test_candidate instanceof ilObjTest) + { + $objective_data['initial'] = $test_id; + } + } + } + elseif(ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest()))) { $test = array(); include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php'; @@ -420,7 +456,7 @@ public function parse($a_objective_ids) { include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; $assignments = ilLOTestAssignments::getInstance($this->course_obj->getId()); - $assignment = $assignments->getAssignmentByObjective($objective_id); + $assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED); $objective_data['final'] = 0; if($assignment instanceof ilLOTestAssignment) diff --git a/Modules/Course/templates/default/tpl.crs_objectives_table_row.html b/Modules/Course/templates/default/tpl.crs_objectives_table_row.html index 92abeb1728b4..5e0950f55e46 100644 --- a/Modules/Course/templates/default/tpl.crs_objectives_table_row.html +++ b/Modules/Course/templates/default/tpl.crs_objectives_table_row.html @@ -39,6 +39,9 @@

{SELF_QST_TITLE}

+ + {IT_ALT} {IT_TITLE} +