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();
351 global
$ilDB,$ilUser;
353 if(!count($objectives[
'all_questions']) or
354 !count($objectives[
'all_objectives']))
367 $query =
"SELECT question_id,points FROM qpl_questions ".
368 "WHERE ".$ilDB->in(
'question_id',(array) $objectives[
'all_questions'],
false,
'integer');
370 while(
$row = $ilDB->fetchAssoc(
$res))
372 $objectives[
'all_question_points'][
$row[
'question_id']][
'max_points'] = $row[
'points'];
375 $query =
"SELECT question_fi, MAX(points) as reached FROM tst_test_result ".
376 "JOIN tst_active ON (active_id = active_fi) ".
377 "WHERE user_fi = ".$ilDB->quote($a_user_id,
'integer').
" ".
378 "AND ".$ilDB->in(
'question_fi',(array) $objectives[
'all_questions'],
false,
'integer').
" ".
379 #"AND question_fi IN (".implode(",",ilUtil::quoteArray($objectives['all_questions'])).") ".
380 "GROUP BY question_fi,user_fi";
384 $objectives[
'all_question_points'][
$row->question_fi][
'reached_points'] =
$row->reached;
388 $fullfilled = array();
390 foreach($objectives[
'objectives'] as $kind =>
$data)
396 if(
$data[
'tst_status'])
398 $fullfilled[] = array(
$data[
'objective_id'],$ilUser->getId(),
$data[
'tst_status']);
402 $pretest[] = array(
$data[
'objective_id'],$ilUser->getId());
406 if(count($fullfilled))
408 $ilDB->executeMultiple($ilDB->prepare(
"REPLACE INTO crs_objective_status VALUES(?,?,?)"),
414 $ilDB->executeMultiple($ilDB->prepare(
"REPLACE INTO crs_objective_status_p VALUES(?,?)"),
423 if(!is_array($objective_data[
'questions']))
429 foreach($objective_data[
'questions'] as $question_id)
431 $max_points += $question_points[$question_id][
'max_points'];
432 $reached_points += $question_points[$question_id][
'reached_points'];
439 return $reached_points >= $objective_data[
'tst_limit'] ?
true :
false;
441 return (($reached_points / $max_points * 100) >= $objective_data[
'tst_limit']) ?
true :
false;
450 $query =
"SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 ".
451 "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and ".
452 $ilDB->in(
't1.objective_id',$objective_ids,
false,
'integer').
" ".
453 "GROUP BY t1.crs_id";
458 $query =
"SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs ".
459 "JOIN crs_objectives co ON cs.objective_id = co.objective_id ".
460 "WHERE crs_id = ".$ilDB->quote(
$row->crs_id ,
'integer').
" ".
461 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
463 $user_res = $ilDB->query(
$query);
466 if($user_row->num_passed ==
$row->num)
468 $passed[] =
$row->crs_id;
471 $crs_ids[
$row->crs_id] =
$row->crs_id;
475 foreach($passed as $crs_id)
477 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
479 $members->updatePassed($a_user_id,
true);
484 foreach ($crs_ids as $cid)
486 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");