/** * * @param type $a_container_id * @param type $a_objective_id * @param type $a_test_type */ public static function lookupObjectiveRequiredPercentage($a_container_id, $a_objective_id, $a_test_ref_id, $a_max_points) { include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php'; $settings = ilLOSettings::getInstanceByObjId($a_container_id); include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php'; $assignments = ilLOTestAssignments::getInstance($a_container_id); $a_test_type = $assignments->getTypeByTest($a_test_ref_id); if ($assignments->isSeparateTest($a_test_ref_id)) { include_once './Services/Object/classes/class.ilObjectFactory.php'; $factory = new ilObjectFactory(); $tst = $factory->getInstanceByRefId($a_test_ref_id, FALSE); if ($tst instanceof ilObjTest) { $schema = $tst->getMarkSchema(); foreach ($schema->getMarkSteps() as $mark) { if ($mark->getPassed()) { return (int) $mark->getMinimumLevel(); } } } } $tst_ref_id = $a_test_ref_id; if (self::lookupRandomTest(ilObject::_lookupObjId($tst_ref_id))) { include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php'; return (int) ilLORandomTestQuestionPools::lookupLimit($a_container_id, $a_objective_id, $a_test_type); } else { include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; $limit = ilCourseObjectiveQuestion::loookupTestLimit(ilObject::_lookupObjId($tst_ref_id), $a_objective_id); return $limit; } }
/** * * @param type $a_container_id * @param type $a_objective_id * @param type $a_test_type */ public static function lookupObjectiveRequiredPercentage($a_container_id, $a_objective_id, $a_test_type, $a_max_points) { include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php'; $settings = ilLOSettings::getInstanceByObjId($a_container_id); if ($a_test_type == ilLOSettings::TYPE_TEST_QUALIFIED) { $tst_ref_id = $settings->getQualifiedTest(); } else { $tst_ref_id = $settings->getInitialTest(); } if (self::lookupRandomTest(ilObject::_lookupObjId($tst_ref_id))) { include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php'; return (int) ilLORandomTestQuestionPools::lookupLimit($a_container_id, $a_objective_id, $a_test_type); } else { include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; $limit = ilCourseObjectiveQuestion::loookupTestLimit(ilObject::_lookupObjId($tst_ref_id), $a_objective_id); return $limit; } }
/** * 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; }
/** * 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()); }
protected function updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq) { include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php'; include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; foreach ($this->run as $tst_run) { // Clear questions of previous run $tst_run->clearQuestions(); $rnd = new ilLORandomTestQuestionPools($this->container_id, $tst_run->getObjectiveId(), $this->getSettings()->getQualifiedTest() == $session->getRefId() ? ilLOSettings::TYPE_TEST_QUALIFIED : ilLOSettings::TYPE_TEST_INITIAL); $stored_sequence_id = $rnd->getQplSequence(); $points = 0; foreach ($seq->getQuestionIds() as $qst) { if ($stored_sequence_id == $seq->getResponsibleSourcePoolDefinitionId($qst)) { $tst_run->addQuestion($qst); $points += ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion($qst); } } $tst_run->setMaxPoints($points); } }
/** * Save random test settings */ protected function saveRandom() { $this->ctrl->saveParameter($this, 'objective_id'); $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']); $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']); $this->test_type = (int) $_REQUEST['tt']; $form = $this->initFormRandom(); if ($form->checkInput()) { $qst = $this->__initQuestionObject((int) $_GET['objective_id']); $qst->deleteByTestType($this->test_type == ilLOSettings::TYPE_TEST_INITIAL ? ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT : ilCourseObjectiveQuestion::TYPE_FINAL_TEST); $ref_id = $this->getSettings()->getTestByType($this->test_type); include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php'; $rnd = new ilLORandomTestQuestionPools($this->course_obj->getId(), (int) $_REQUEST['objective_id'], $this->test_type); $rnd->delete(); $rnd->setLimit($form->getInput('per')); $rnd->setQplSequence($form->getInput('qpl')); $rnd->setTestId(ilObject::_lookupObjId($ref_id)); $rnd->create(); } else { $form->setValuesByPost(); ilUtil::sendFailure($this->lng->txt('err_check_input')); return $this->showRandomTestAssignment(); } ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); if ($this->test_type == ilLOSettings::TYPE_TEST_QUALIFIED) { $this->ctrl->returnToParent($this); } else { $this->ctrl->redirect($this, 'finalTestAssignment'); } }