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); } }
/** * 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()); }
/** * show random test */ protected function initFormRandom() { include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php'; $rnd = new ilLORandomTestQuestionPools($this->course_obj->getId(), (int) $_REQUEST['objective_id'], $this->test_type); include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $form->setFormAction($this->ctrl->getFormAction($this)); if ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) { $form->setTitle($this->lng->txt('crs_loc_form_random_limits_it')); } else { $form->setTitle($this->lng->txt('crs_loc_form_random_limits_qt')); } $form->addCommandButton('saveRandom', $this->lng->txt('save')); $options = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_rand_assign_qpl'), 'type'); $options->setValue(1); $options->setRequired(true); $ass_qpl = new ilRadioOption($this->lng->txt('crs_loc_rand_assign_qpl'), 1); $options->addOption($ass_qpl); $qpl = new ilSelectInputGUI($this->lng->txt('crs_loc_rand_qpl'), 'qpl'); $qpl->setOptions($this->getRandomTestQplOptions()); $qpl->setValue($rnd->getQplSequence()); $ass_qpl->addSubItem($qpl); #$num = new ilNumberInputGUI($this->lng->txt('crs_loc_num_qst'),'num_qst'); #$num->setSize(3); #$num->setMinValue(1); #$num->setRequired(true); #$ass_qpl->addSubItem($num); // points $per = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'), 'per'); $per->setValue($rnd->getLimit()); $per->setSize(3); $per->setMinValue(1); $per->setMaxValue(100); $per->setRequired(true); $ass_qpl->addSubItem($per); $form->addItem($options); return $form; }