From 10a82d1a44a91c7dc4a69ce92e7e7dd2d7ea5da7 Mon Sep 17 00:00:00 2001 From: bheyser Date: Fri, 21 Aug 2015 09:54:56 +0200 Subject: [PATCH] lok3 #17 --- .../classes/class.ilTestEvaluationGUI.php | 10 ++++++---- .../Test/classes/class.ilTestOutputGUI.php | 3 +-- ...ss.ilTestQuestionRelatedObjectivesList.php | 19 ++++++++++++++++++- .../classes/class.ilTestSequenceFactory.php | 16 ++++++++-------- .../Test/classes/class.ilTestServiceGUI.php | 9 +++++++-- .../class.ilTestPassOverviewTableGUI.php | 2 +- 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Modules/Test/classes/class.ilTestEvaluationGUI.php b/Modules/Test/classes/class.ilTestEvaluationGUI.php index 0ca1382f06b2..703657d4adee 100644 --- a/Modules/Test/classes/class.ilTestEvaluationGUI.php +++ b/Modules/Test/classes/class.ilTestEvaluationGUI.php @@ -1086,9 +1086,7 @@ function outUserPassDetails() require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession); - $objectivesList = $this->buildQuestionRelatedObjectivesList( - $objectivesAdapter, $testSequence->getQuestionIds() - ); + $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); $objectivesList->loadObjectivesTitles(); $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($testSession->getObjectiveOrientedContainerId()); @@ -1458,9 +1456,13 @@ function outCorrectSolution() if( $this->objectiveOrientedPresentationRequired() ) { + $testSequence = $this->testSequenceFactory->getSequenceByPass($testSession, $pass); + $testSequence->loadFromDb(); + $testSequence->loadQuestions(); + require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php'; $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession); - $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, array($questionId)); + $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); $objectivesList->loadObjectivesTitles(); } else diff --git a/Modules/Test/classes/class.ilTestOutputGUI.php b/Modules/Test/classes/class.ilTestOutputGUI.php index e0b66cb38b08..2438328c5bd1 100755 --- a/Modules/Test/classes/class.ilTestOutputGUI.php +++ b/Modules/Test/classes/class.ilTestOutputGUI.php @@ -64,7 +64,6 @@ public function executeCommand() require_once 'Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php'; $this->questionRelatedObjectivesList = new ilTestQuestionRelatedObjectivesList(); - $this->questionRelatedObjectivesList->setQuestionIds($this->testSequence->getQuestionIds()); include_once 'Services/jQuery/classes/class.iljQueryUtil.php'; iljQueryUtil::initjQuery(); @@ -324,7 +323,7 @@ protected function redirectQuestionCmd() $objectivesAdapter->notifyTestStart($this->testSession, $this->object->getId()); $objectivesAdapter->prepareTestPass($this->testSession, $this->testSequence); - $objectivesAdapter->buildQuestionRelatedObjectiveList($this->questionRelatedObjectivesList); + $objectivesAdapter->buildQuestionRelatedObjectiveList($this->testSequence, $this->questionRelatedObjectivesList); if( $this->testSequence->hasOptionalQuestions() ) { diff --git a/Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php b/Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php index cc9daf671b84..136dfd887ee8 100644 --- a/Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php +++ b/Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php @@ -81,4 +81,21 @@ public function getUniqueObjectivesString() { return implode(', ', $this->objectivesTitles); } -} \ No newline at end of file + + public function getUniqueObjectivesStringForQuestions($questionIds) + { + $objectiveTitles = array(); + + foreach( $this->objectivesByQuestion as $questionId => $objectiveId ) + { + if( !in_array($questionId, $questionIds) ) + { + continue; + } + + $objectiveTitles[$objectiveId] = $this->objectivesTitles[$objectiveId]; + } + + return implode(', ', $objectiveTitles); + } +} \ No newline at end of file diff --git a/Modules/Test/classes/class.ilTestSequenceFactory.php b/Modules/Test/classes/class.ilTestSequenceFactory.php index 8092477a2378..76a92780aa0c 100644 --- a/Modules/Test/classes/class.ilTestSequenceFactory.php +++ b/Modules/Test/classes/class.ilTestSequenceFactory.php @@ -12,11 +12,11 @@ class ilTestSequenceFactory { /** - * singleton instance of test sequence + * singleton instances of test sequences * - * @var ilTestSequence|ilTestSequenceDynamicQuestionSet + * @var array */ - private $testSequence = null; + private $testSequences = array(); /** * global ilDB object instance @@ -81,14 +81,14 @@ public function getSequence($testSession) */ public function getSequenceByPass($testSession, $pass) { - if($this->testSequence === null) + if($this->testSequences[$pass] === null) { switch( $this->testOBJ->getQuestionSetType() ) { case ilObjTest::QUESTION_SET_TYPE_FIXED: require_once 'Modules/Test/classes/class.ilTestSequenceFixedQuestionSet.php'; - $this->testSequence = new ilTestSequenceFixedQuestionSet( + $this->testSequences[$pass] = new ilTestSequenceFixedQuestionSet( $testSession->getActiveId(), $pass, $this->testOBJ->isRandomTest() ); break; @@ -96,7 +96,7 @@ public function getSequenceByPass($testSession, $pass) case ilObjTest::QUESTION_SET_TYPE_RANDOM: require_once 'Modules/Test/classes/class.ilTestSequenceRandomQuestionSet.php'; - $this->testSequence = new ilTestSequenceRandomQuestionSet( + $this->testSequences[$pass] = new ilTestSequenceRandomQuestionSet( $testSession->getActiveId(), $pass, $this->testOBJ->isRandomTest() ); break; @@ -108,7 +108,7 @@ public function getSequenceByPass($testSession, $pass) $questionSet = new ilTestDynamicQuestionSet( $this->db, $this->lng, $this->pluginAdmin, $this->testOBJ ); - $this->testSequence = new ilTestSequenceDynamicQuestionSet( + $this->testSequences[$pass] = new ilTestSequenceDynamicQuestionSet( $this->db, $questionSet, $testSession->getActiveId() ); @@ -120,6 +120,6 @@ public function getSequenceByPass($testSession, $pass) } } - return $this->testSequence; + return $this->testSequences[$pass]; } } diff --git a/Modules/Test/classes/class.ilTestServiceGUI.php b/Modules/Test/classes/class.ilTestServiceGUI.php index 6c585385b056..8c0e0f46ee1b 100755 --- a/Modules/Test/classes/class.ilTestServiceGUI.php +++ b/Modules/Test/classes/class.ilTestServiceGUI.php @@ -230,8 +230,13 @@ public function getPassOverview(ilTestSession $testSession, $targetclass = "", $ $testSequence = $this->testSequenceFactory->getSequenceByPass($testSession, $pass); $testSequence->loadFromDb(); $testSequence->loadQuestions(); - $row['objectivesList'] = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); - $row['objectivesList']->loadObjectivesTitles(); + $testSequence->setConsiderHiddenQuestionsEnabled($considerHiddenQuestions); + $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence); + $objectivesList->loadObjectivesTitles(); + + $row['objectives'] = $objectivesList->getUniqueObjectivesStringForQuestions( + $testSequence->getUserSequenceQuestions() + ); } if(!$short) diff --git a/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php b/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php index a8bdb252c0b6..c52e10f936c8 100644 --- a/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php +++ b/Modules/Test/classes/tables/class.ilTestPassOverviewTableGUI.php @@ -106,7 +106,7 @@ public function fillRow(array $row) if( $this->isObjectiveOrientedPresentationEnabled() ) { - $this->tpl->setVariable('VAL_LO_OBJECTIVES', $row['objectivesList']->getUniqueObjectivesString()); + $this->tpl->setVariable('VAL_LO_OBJECTIVES', $row['objectives']); $this->tpl->setVariable('VAL_LO_TRY', sprintf( $this->lng->txt('tst_res_lo_try_n'), $row['pass']