34 define(
'IL_OBJECTIVE_STATUS_EMPTY',
'empty');
35 define(
'IL_OBJECTIVE_STATUS_PRETEST',
'pretest');
36 define(
'IL_OBJECTIVE_STATUS_FINAL',
'final');
37 define(
'IL_OBJECTIVE_STATUS_NONE',
'none');
38 define(
'IL_OBJECTIVE_STATUS_FINISHED',
'finished');
39 define(
'IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST',
'pretest_non_suggest');
54 $this->user_id = $a_usr_id;
69 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
72 if(!is_array($objectives))
76 $query =
"SELECT objective_id FROM crs_objective_status ".
78 "AND user_id = ".$ilDB->quote($a_user_id).
" ";
79 $res = $ilDB->query($query);
82 $accomplished[] = $row->objective_id;
84 return $accomplished ? $accomplished : array();
103 $query =
"SELECT objective_id FROM crs_objective_status ".
105 "AND user_id = ".$ilDB->quote($a_user_id).
" ";
106 $res = $ilDB->query($query);
109 $finished[] = $row->objective_id;
115 $query =
"SELECT objective_id FROM crs_objective_status_pretest ".
117 "AND user_id = ".$ilDB->quote($a_user_id).
"";
118 $res = $ilDB->query($query);
121 $finished[] = $row->objective_id;
124 foreach($objectives as $objective_id)
126 if(!in_array($objective_id,$finished))
128 $suggested[] = $objective_id;
131 return $suggested ? $suggested : array();
138 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
139 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
146 foreach($tmp_obj_question->getTests() as $test_data)
148 $this->
__deleteEntries($tmp_obj_question->getQuestionsByTest($test_data[
'ref_id']));
152 $tmp_test->removeTestResultsForUser($this->
getUserId());
158 if(count($objectives))
160 $query =
"DELETE FROM crs_objective_status ".
162 "AND user_id = ".$ilDB->quote($this->
getUserId()).
" ";
163 $this->db->query($query);
165 $query =
"DELETE FROM crs_objective_status_pretest ".
167 "AND user_id = ".$ilDB->quote($this->
getUserId()).
"";
168 $this->db->query($query);
176 include_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
177 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
183 if(!count($objective_ids))
188 if(count($accomplished) == count($objective_ids))
193 $all_pretest_answered =
false;
194 $all_final_answered =
false;
195 foreach($objectives as
$data)
199 if($data[
'tst_status'])
201 $all_final_answered =
true;
205 $all_pretest_answered =
true;
209 if($all_final_answered)
213 if($all_pretest_answered and
218 elseif($all_pretest_answered)
229 $query =
"SELECT status FROM crs_objective_status ".
230 "WHERE objective_id = ".$ilDB->quote($a_objective_id).
" ".
231 "AND user_id = ".$ilDB->quote($this->
getUserId()).
"";
233 $res = $this->db->query($query);
243 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
259 if(!count($a_objective_ids))
267 $query =
"DELETE FROM crs_objective_results ".
268 "WHERE usr_id = ".$ilDB->quote($this->
getUserId()).
" ".
269 "AND question_id ".$in;
270 $this->db->query($query);
277 $query =
"DELETE FROM crs_objective_results ".
278 "WHERE usr_id = ".$ilDB->quote(
$user_id).
" ";
279 $ilDB->query($query);
281 $query =
"DELETE FROM crs_objective_status ".
282 "WHERE user_id = ".$ilDB->quote(
$user_id).
" ";
283 $ilDB->query($query);
285 $query =
"DELETE FROM crs_objective_status_pretest ".
286 "WHERE user_id = ".$ilDB->quote(
$user_id).
" ";
287 $ilDB->query($query);
310 $query =
"SELECT q2.question_id as qid,q2.objective_id as ob FROM crs_objective_qst as q1, ".
311 "crs_objective_qst as q2 ".
312 "WHERE q1.question_id = ".$ilDB->quote($a_question_id).
" ".
313 "AND q1.objective_id = q2.objective_id ";
315 $res = $ilDB->query($query);
318 $objectives[
'all_objectives'][$row->ob] = $row->ob;
319 $objectives[
'all_questions'][$row->qid] = $row->qid;
321 if(!is_array($objectives))
326 return $objectives ? $objectives : array();
335 $query =
"SELECT t.objective_id as obj,t.ref_id as ref, question_id,tst_status,tst_limit ".
336 "FROM crs_objective_tst as t JOIN crs_objective_qst as q ".
337 "ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) ".
340 $res = $ilDB->query($query);
350 $objectives[$row->obj.
"_".$row->tst_status][
'questions'][$row->question_id] = $row->question_id;
351 $objectives[$row->obj.
"_".$row->tst_status][
'tst_status'] = $row->tst_status;
352 $objectives[$row->obj.
"_".$row->tst_status][
'tst_limit'] = $row->tst_limit;
353 $objectives[$row->obj.
"_".$row->tst_status][
'objective_id'] = $row->obj;
357 return $objectives ? $objectives : array();
362 global $ilDB,$ilUser;
364 if(!count($objectives[
'all_questions']) or
365 !count($objectives[
'all_objectives']))
371 $query =
"SELECT question_id,points FROM qpl_questions ".
372 "WHERE question_id IN(".implode(
",",
ilUtil::quoteArray($objectives[
'all_questions'])).
")";
373 $res = $ilDB->query($query);
376 $objectives[
'all_question_points'][$row->question_id][
'max_points'] = $row->points;
379 $query =
"SELECT question_fi, MAX(points) as reached FROM tst_test_result JOIN tst_active ".
380 "ON (active_id = active_fi) ".
381 "WHERE user_fi = ".$ilDB->quote($a_user_id).
" ".
382 "AND question_fi IN (".implode(
",",
ilUtil::quoteArray($objectives[
'all_questions'])).
") ".
383 "GROUP BY question_fi,user_fi";
384 $res = $ilDB->query($query);
387 $objectives[
'all_question_points'][$row->question_fi][
'reached_points'] = $row->reached;
391 $fullfilled = array();
393 foreach($objectives[
'objectives'] as $kind =>
$data)
399 if(
$data[
'tst_status'])
401 $fullfilled[] = array(
$data[
'objective_id'],$ilUser->getId(),
$data[
'tst_status']);
405 $pretest[] = array(
$data[
'objective_id'],$ilUser->getId());
409 if(count($fullfilled))
411 $ilDB->executeMultiple($ilDB->prepare(
"REPLACE INTO crs_objective_status VALUES(?,?,?)"),
417 $ilDB->executeMultiple($ilDB->prepare(
"REPLACE INTO crs_objective_status_pretest VALUES(?,?)"),
426 if(!is_array($objective_data[
'questions']))
432 foreach($objective_data[
'questions'] as $question_id)
434 $max_points += $question_points[$question_id][
'max_points'];
435 $reached_points += $question_points[$question_id][
'reached_points'];
442 return $reached_points >= $objective_data[
'tst_limit'] ?
true :
false;
444 return (($reached_points / $max_points * 100) >= $objective_data[
'tst_limit']) ?
true :
false;
453 $query =
"SELECT COUNT(t1.crs_id) AS num,t1.crs_id FROM crs_objectives as t1 ".
454 "JOIN crs_objectives as t2 WHERE t1.crs_id = t2.crs_id and t1.objective_id ".
456 "GROUP BY t1.crs_id";
457 $res = $ilDB->query($query);
460 $query =
"SELECT COUNT(cs.objective_id) AS num_passed FROM crs_objective_status AS cs ".
461 "JOIN crs_objectives AS co ON cs.objective_id = co.objective_id ".
462 "WHERE crs_id = ".$ilDB->quote($row->crs_id).
" ".
463 "AND user_id = ".$ilDB->quote($a_user_id).
" ";
465 $user_res = $ilDB->query($query);
468 if($user_row->num_passed == $row->num)
470 $passed[] = $row->crs_id;
476 foreach($passed as $crs_id)
478 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
480 $members->updatePassed($a_user_id,
true);