/** * update question overview * * @access protected * @return */ protected function saveQuestionOverview() { include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; global $ilAccess, $ilErr; if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) { $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING); } $error = false; $_POST['self'] = $_POST['self'] ? $_POST['self'] : array(); $_POST['final'] = $_POST['final'] ? $_POST['final'] : array(); foreach ($_POST['self'] as $objective_id => $limit) { $qst = new ilCourseObjectiveQuestion($objective_id); $max_points = $qst->getSelfAssessmentPoints(); if ($limit < 0 or $limit > $max_points) { ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err')); $this->questionOverview(); return false; } } foreach ($_POST['final'] as $objective_id => $limit) { $qst = new ilCourseObjectiveQuestion($objective_id); $max_points = $qst->getFinalTestPoints(); if ($limit < 0 or $limit > $max_points) { ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err')); $this->questionOverview(); return false; } } foreach ($_POST['self'] as $objective_id => $limit) { ilCourseObjectiveQuestion::_updateTestLimits($objective_id, ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT, $limit); } foreach ($_POST['final'] as $objective_id => $limit) { ilCourseObjectiveQuestion::_updateTestLimits($objective_id, ilCourseObjectiveQuestion::TYPE_FINAL_TEST, $limit); } ilUtil::sendSuccess($this->lng->txt('settings_saved')); $this->questionOverview(); return true; }
/** * parse * * @access public * @param array array of objective id's */ public function parse($a_objective_ids) { include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php'; $objectives = array(); foreach ($a_objective_ids as $objective_id) { $objective = new ilCourseObjective($this->course_obj, $objective_id); // Self assessment tests $question_obj = new ilCourseObjectiveQuestion($objective_id); $tests = array(); foreach ($question_obj->getSelfAssessmentTests() as $tmp_test) { if (isset($_POST['self'][$objective_id])) { $objective_data['self_limit'] = $_POST['self'][$objective_id]; } else { $objective_data['self_limit'] = $tmp_test['limit']; } $questions = array(); foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) { $qst['title'] = $tmp_question['title']; $qst['description'] = $tmp_question['description']; $qst['points'] = $tmp_question['points']; $questions[] = $qst; } $tst['questions'] = $questions; $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']); $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']); $tests[] = $tst; } $objective_data['self_tests'] = $tests; $objective_data['self_max_points'] = $question_obj->getSelfAssessmentPoints(); // Final tests $tests = array(); foreach ($question_obj->getFinalTests() as $tmp_test) { if (isset($_POST['final'][$objective_id])) { $objective_data['final_limit'] = $_POST['final'][$objective_id]; } else { $objective_data['final_limit'] = $tmp_test['limit']; } $questions = array(); foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) { $qst['title'] = $tmp_question['title']; $qst['description'] = $tmp_question['description']; $qst['points'] = $tmp_question['points']; $questions[] = $qst; } $tst['questions'] = $questions; $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']); $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']); $tests[] = $tst; } $objective_data['final_tests'] = $tests; $objective_data['final_max_points'] = $question_obj->getFinalTestPoints(); $objective_data['id'] = $objective_id; $objective_data['title'] = $objective->getTitle(); $objective_data['description'] = $objective->getDescription(); $objectives[] = $objective_data; } $this->setData($objectives ? $objectives : array()); }