5 define(
'IL_OBJECTIVE_STATUS_EMPTY',
'empty');
6 define(
'IL_OBJECTIVE_STATUS_PRETEST',
'pretest');
7 define(
'IL_OBJECTIVE_STATUS_FINAL',
'final');
8 define(
'IL_OBJECTIVE_STATUS_NONE',
'none');
9 define(
'IL_OBJECTIVE_STATUS_FINISHED',
'finished');
10 define(
'IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST',
'pretest_non_suggest');
31 $this->user_id = $a_usr_id;
46 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
49 if(!is_array($objectives))
53 $query =
"SELECT objective_id FROM crs_objective_status ".
54 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
55 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
59 $accomplished[] =
$row->objective_id;
61 return $accomplished ? $accomplished : array();
73 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
81 $query =
"SELECT objective_id FROM crs_objective_status ".
82 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
" ".
83 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
87 $finished[] =
$row->objective_id;
93 $query =
"SELECT objective_id FROM crs_objective_status_p ".
94 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
95 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer');
99 $finished[] =
$row->objective_id;
102 foreach($objectives as $objective_id)
104 if(!in_array($objective_id,$finished))
106 $suggested[] = $objective_id;
109 return $suggested ? $suggested : array();
120 foreach(self::_getSuggested($a_usr_id,$a_crs_id) as $objective_id)
122 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
124 foreach($obj->getFinalTestQuestions() as $qst)
126 $qsts[] = $qst[
'question_id'];
129 return $qsts ? $qsts : array();
136 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
137 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
144 foreach($tmp_obj_question->getTests() as $test_data)
146 #$this->__deleteEntries($tmp_obj_question->getQuestionsByTest($test_data['ref_id']));
150 $tmp_test->removeTestResultsForUser($this->
getUserId());
156 if(count($objectives))
158 $query =
"DELETE FROM crs_objective_status ".
159 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
160 "AND user_id = ".$ilDB->quote($this->
getUserId() ,
'integer').
" ";
163 $query =
"DELETE FROM crs_objective_status_p ".
164 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
165 "AND user_id = ".$ilDB->quote($this->
getUserId()).
"";
169 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
177 include_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
178 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
184 if(!count($objective_ids))
189 if(count($accomplished) == count($objective_ids))
194 $all_pretest_answered =
false;
195 $all_final_answered =
false;
196 foreach($objectives as
$data)
200 if($data[
'tst_status'])
202 $all_final_answered =
true;
206 $all_pretest_answered =
true;
210 if($all_final_answered)
214 if($all_pretest_answered and
219 elseif($all_pretest_answered)
230 $query =
"SELECT status FROM crs_objective_status ".
231 "WHERE objective_id = ".$ilDB->quote($a_objective_id ,
'integer').
" ".
232 "AND user_id = ".$ilDB->quote($this->
getUserId() ,
'integer').
"";
244 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
261 #$ilLog(__METHOD__.': Call of deprecated method.');
270 $query =
"DELETE FROM crs_objective_status ".
271 "WHERE user_id = ".$ilDB->quote(
$user_id ,
'integer').
" ";
274 $query =
"DELETE FROM crs_objective_status_p ".
275 "WHERE user_id = ".$ilDB->quote(
$user_id ,
'integer').
" ";
299 $query =
"SELECT q2.question_id qid,q2.objective_id ob FROM crs_objective_qst q1, ".
300 "crs_objective_qst q2 ".
301 "WHERE q1.question_id = ".$ilDB->quote($a_question_id ,
'integer').
" ".
302 "AND q1.objective_id = q2.objective_id ";
307 $objectives[
'all_objectives'][
$row->ob] =
$row->ob;
308 $objectives[
'all_questions'][
$row->qid] =
$row->qid;
310 if(!is_array($objectives))
315 return $objectives ? $objectives : array();
324 $query =
"SELECT t.objective_id obj,t.ref_id ref, question_id,tst_status,tst_limit ".
325 "FROM crs_objective_tst t JOIN crs_objective_qst q ".
326 "ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) ".
327 "WHERE ".$ilDB->in(
't.objective_id',$a_all_objectives,
false,
'integer');
339 $objectives[
$row->obj.
"_".
$row->tst_status][
'questions'][
$row->question_id] =
$row->question_id;
340 $objectives[
$row->obj.
"_".
$row->tst_status][
'tst_status'] =
$row->tst_status;
341 $objectives[
$row->obj.
"_".
$row->tst_status][
'tst_limit'] =
$row->tst_limit;
342 $objectives[
$row->obj.
"_".
$row->tst_status][
'objective_id'] =
$row->obj;
346 return $objectives ? $objectives : array();
353 if(!count($objectives[
'all_questions']) or
354 !count($objectives[
'all_objectives']))
359 $query =
"SELECT question_id,points FROM qpl_questions ".
360 "WHERE ".$ilDB->in(
'question_id',(array) $objectives[
'all_questions'],
false,
'integer');
362 while(
$row = $ilDB->fetchAssoc(
$res))
364 $objectives[
'all_question_points'][
$row[
'question_id']][
'max_points'] = $row[
'points'];
367 $query =
"SELECT question_fi, MAX(points) as reached FROM tst_test_result ".
368 "JOIN tst_active ON (active_id = active_fi) ".
369 "WHERE user_fi = ".$ilDB->quote($a_user_id,
'integer').
" ".
370 "AND ".$ilDB->in(
'question_fi',(array) $objectives[
'all_questions'],
false,
'integer').
" ".
371 #"AND question_fi IN (".implode(",",ilUtil::quoteArray($objectives['all_questions'])).") ".
372 "GROUP BY question_fi,user_fi";
376 $objectives[
'all_question_points'][
$row->question_fi][
'reached_points'] =
$row->reached;
380 $fullfilled = array();
382 foreach($objectives[
'objectives'] as $kind =>
$data)
388 if(
$data[
'tst_status'])
390 $fullfilled[] = array(
$data[
'objective_id'],$ilUser->getId(),
$data[
'tst_status']);
394 $pretest[] = array(
$data[
'objective_id'],$ilUser->getId());
398 if(count($fullfilled))
400 foreach($fullfilled as $fullfilled_arr)
403 'crs_objective_status',
405 'objective_id' => array(
'integer',$fullfilled_arr[0]),
406 'user_id' => array(
'integer',$fullfilled_arr[1])
409 'status' => array(
'integer',$fullfilled_arr[2])
417 foreach($pretest as $pretest_arr)
420 'crs_objective_status_p',
422 'objective_id' => array(
'integer',$pretest_arr[0]),
423 'user_id' => array(
'integer',$pretest_arr[1])
434 if(!is_array($objective_data[
'questions']))
440 foreach($objective_data[
'questions'] as $question_id)
442 $max_points += $question_points[$question_id][
'max_points'];
443 $reached_points += $question_points[$question_id][
'reached_points'];
450 return $reached_points >= $objective_data[
'tst_limit'] ?
true :
false;
452 return (($reached_points / $max_points * 100) >= $objective_data[
'tst_limit']) ?
true :
false;
461 $query =
"SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 ".
462 "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and ".
463 $ilDB->in(
't1.objective_id',$objective_ids,
false,
'integer').
" ".
464 "GROUP BY t1.crs_id";
469 $query =
"SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs ".
470 "JOIN crs_objectives co ON cs.objective_id = co.objective_id ".
471 "WHERE crs_id = ".$ilDB->quote(
$row->crs_id ,
'integer').
" ".
472 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
474 $user_res = $ilDB->query(
$query);
477 if($user_row->num_passed ==
$row->num)
479 $passed[] =
$row->crs_id;
482 $crs_ids[
$row->crs_id] =
$row->crs_id;
486 foreach($passed as $crs_id)
488 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
490 $members->updatePassed($a_user_id,
true);
495 foreach ($crs_ids as $cid)
497 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");