From 99fb4cd59bacfd2775c180f19211d0d2e6c760fc Mon Sep 17 00:00:00 2001 From: smeyer-ilias Date: Fri, 21 Aug 2015 10:02:07 +0200 Subject: [PATCH] lok3 #20 --- .../Objectives/class.ilLOEditorGUI.php | 26 +++++++++++++++++++ .../Objectives/class.ilLOTestAssignments.php | 2 +- .../class.ilLOTestQuestionAdapter.php | 9 ++++--- .../Objectives/class.ilLOUserResults.php | 18 +++++++++++-- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php b/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php index dba9fe5942c5..8707d20fc263 100644 --- a/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php +++ b/Modules/Course/classes/Objectives/class.ilLOEditorGUI.php @@ -213,6 +213,22 @@ protected function settings(ilPropertyFormGUI $form = NULL) $this->showStatus(ilLOEditorStatus::SECTION_SETTINGS); } + /** + * Delete assignments + * @param type $a_type + */ + protected function deleteAssignments($a_type) + { + include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; + $assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId()); + foreach($assignments->getAssignmentsByType($a_type) as $assignment) + { + $assignment->delete(); + } + return; + } + + /** * */ @@ -227,22 +243,28 @@ protected function saveSettings() { case ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL: $settings->setInitialTestAsStart($form->getInput('start_ip')); + $this->deleteAssignments(ilLOSettings::TYPE_TEST_INITIAL); break; case ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED: $settings->setInitialTestAsStart(FALSE); + $settings->setInitialTest(0); break; case ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL: $settings->setInitialTestAsStart($form->getInput('start_iq')); + $this->deleteAssignments(ilLOSettings::TYPE_TEST_INITIAL); break; case ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED: $settings->setInitialTestAsStart(FALSE); + $settings->setInitialTest(0); break; case ilLOSettings::TYPE_INITIAL_NONE: $settings->setInitialTestAsStart(FALSE); + $settings->setInitialTest(0); + $this->deleteAssignments(ilLOSettings::TYPE_TEST_INITIAL); break; } @@ -254,6 +276,10 @@ protected function saveSettings() { $settings->setQualifyingTestAsStart($form->getInput('start_q')); } + if($form->getInput('qttype') == ilLOSettings::TYPE_QUALIFYING_SELECTED) + { + $settings->setQualifiedTest(0); + } if( ($settings->getInitialTestType() != ilLOSettings::TYPE_INITIAL_NONE) && diff --git a/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php b/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php index c95467d90a27..fc4b0bd449eb 100644 --- a/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php +++ b/Modules/Course/classes/Objectives/class.ilLOTestAssignments.php @@ -146,7 +146,7 @@ public function isSeparateTest($a_test_ref_id) return FALSE; } } - if($this->getSettings()->hasSeparateQualifiedTests()) + if(!$this->getSettings()->hasSeparateQualifiedTests()) { if($this->getSettings()->getQualifiedTest() == $a_test_ref_id) { diff --git a/Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php b/Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php index 65cee8484fcb..ef826fc8b0bd 100644 --- a/Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php +++ b/Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php @@ -89,8 +89,8 @@ protected function lookupRelevantObjectiveIdsForTest($a_container_id, $a_tst_ref $passed_objectives = array(); include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; $results = new ilLOUserResults($a_container_id,$a_user_id); - $passed = $results->getCompletedObjectiveIdsByType($test_type); + $passed = $results->getCompletedObjectiveIds(); $GLOBALS['ilLog']->write(__METHOD__.': Passed objectives are '.print_r($passed,TRUE).' test_type = '.$test_type); @@ -161,11 +161,11 @@ public function prepareTestPass(ilTestSession $a_test_session, ilTestSequence $a if($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::MARK_PASSED_OBJECTIVE_QST) { - #$this->setQuestionsOptional($a_test_sequence); + $this->setQuestionsOptional($a_test_sequence); } elseif($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::HIDE_PASSED_OBJECTIVE_QST) { - #$this->hideQuestions($a_test_sequence); + $this->hideQuestions($a_test_sequence); } $this->storeTestRun(); @@ -463,14 +463,17 @@ protected function updateQuestions(ilTestSession $session, ilTestSequence $seq) { if($this->getAssignments()->isSeparateTest($session->getRefId())) { + $GLOBALS['ilLog']->write(__METHOD__.': separate run'); return $this->updateSeparateTestQuestions($session, $seq); } if($seq instanceof ilTestSequenceFixedQuestionSet) { + $GLOBALS['ilLog']->write(__METHOD__.': fixed run'); return $this->updateFixedQuestions($session, $seq); } if($seq instanceof ilTestSequenceRandomQuestionSet) { + $GLOBALS['ilLog']->write(__METHOD__.': random run'); return $this->updateRandomQuestions($session, $seq); } diff --git a/Modules/Course/classes/Objectives/class.ilLOUserResults.php b/Modules/Course/classes/Objectives/class.ilLOUserResults.php index e4d0e40cb44a..220f59ed18dc 100644 --- a/Modules/Course/classes/Objectives/class.ilLOUserResults.php +++ b/Modules/Course/classes/Objectives/class.ilLOUserResults.php @@ -295,8 +295,22 @@ public function getSuggestedObjectiveIds() * @return array objective-ids */ public function getCompletedObjectiveIds() - { - return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED); + { + include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php'; + $settings = ilLOSettings::getInstanceByObjId($this->course_obj_id); + + if(!$settings->isInitialTestQualifying() or !$settings->worksWithInitialTest()) + { + return $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED); + } + + // qualifying initial + return array_unique( + array_merge( + $this->findObjectiveIds(self::TYPE_INITIAL, self::STATUS_COMPLETED), + $this->findObjectiveIds(self::TYPE_QUALIFIED, self::STATUS_COMPLETED) + ) + ); } /**