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';
51 if(!is_array($objectives))
55 $query =
"SELECT objective_id FROM crs_objective_status ".
56 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
57 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
61 $accomplished[] =
$row->objective_id;
63 return $accomplished ? $accomplished : array();
75 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
85 $query =
"SELECT objective_id FROM crs_objective_status ".
86 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
" ".
87 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
91 $finished[] =
$row->objective_id;
97 $query =
"SELECT objective_id FROM crs_objective_status_p ".
98 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
99 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer');
103 $finished[] =
$row->objective_id;
106 foreach($objectives as $objective_id)
108 if(!in_array($objective_id,$finished))
110 $suggested[] = $objective_id;
113 return $suggested ? $suggested : array();
124 foreach(self::_getSuggested($a_usr_id,$a_crs_id) as $objective_id)
126 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
128 foreach($obj->getFinalTestQuestions() as $qst)
130 $qsts[] = $qst[
'question_id'];
133 return $qsts ? $qsts : array();
142 include_once
"Modules/Test/classes/class.ilTestLP.php";
144 $test_lp->resetLPDataForUserIds(array($a_user_id));
158 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
159 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
161 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
164 include_once
'./Modules/Course/classes/Objectives/class.ilLOSettings.php';
166 $initial_tst = $factory->getInstanceByRefId($initial, FALSE);
173 $qualified_tst = $factory->getInstanceByRefId($qualified, FALSE);
174 if($qualified_tst instanceof ilObjTest)
181 if(count($objectives))
183 $query =
"DELETE FROM crs_objective_status ".
184 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
185 "AND user_id = ".$ilDB->quote($this->
getUserId() ,
'integer').
" ";
188 $query =
"DELETE FROM crs_objective_status_p ".
189 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
190 "AND user_id = ".$ilDB->quote($this->
getUserId()).
"";
193 $query =
"DELETE FROM ilLOUserResults ".
194 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
195 "AND user_id = ".$ilDB->quote($this->
getUserId()).
"";
199 include_once
'./Services/Tracking/classes/class.ilLPStatusWrapper.php';
207 include_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
208 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
216 if(!count($objective_ids))
221 if(count($accomplished) == count($objective_ids))
226 $all_pretest_answered =
false;
227 $all_final_answered =
false;
228 foreach($objectives as $data)
232 if($data[
'tst_status'])
234 $all_final_answered =
true;
238 $all_pretest_answered =
true;
242 if($all_final_answered)
246 if($all_pretest_answered and
251 elseif($all_pretest_answered)
262 $query =
"SELECT status FROM crs_objective_status ".
263 "WHERE objective_id = ".$ilDB->quote($a_objective_id ,
'integer').
" ".
264 "AND user_id = ".$ilDB->quote($this->
getUserId() ,
'integer').
"";
276 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
295 #$ilLog(__METHOD__.': Call of deprecated method.');
304 $query =
"DELETE FROM crs_objective_status ".
305 "WHERE user_id = ".$ilDB->quote(
$user_id ,
'integer').
" ";
308 $query =
"DELETE FROM crs_objective_status_p ".
309 "WHERE user_id = ".$ilDB->quote(
$user_id ,
'integer').
" ";
333 $query =
"SELECT q2.question_id qid,q2.objective_id ob FROM crs_objective_qst q1, ".
334 "crs_objective_qst q2 ".
335 "WHERE q1.question_id = ".$ilDB->quote($a_question_id ,
'integer').
" ".
336 "AND q1.objective_id = q2.objective_id ";
341 $objectives[
'all_objectives'][
$row->ob] =
$row->ob;
342 $objectives[
'all_questions'][
$row->qid] =
$row->qid;
344 if(!is_array($objectives))
349 return $objectives ? $objectives : array();
358 $query =
"SELECT t.objective_id obj,t.ref_id ref, question_id,tst_status,tst_limit ".
359 "FROM crs_objective_tst t JOIN crs_objective_qst q ".
360 "ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) ".
361 "WHERE ".$ilDB->in(
't.objective_id',$a_all_objectives,
false,
'integer');
373 $objectives[
$row->obj.
"_".
$row->tst_status][
'questions'][
$row->question_id] =
$row->question_id;
374 $objectives[
$row->obj.
"_".
$row->tst_status][
'tst_status'] =
$row->tst_status;
375 $objectives[
$row->obj.
"_".
$row->tst_status][
'tst_limit'] =
$row->tst_limit;
376 $objectives[
$row->obj.
"_".
$row->tst_status][
'objective_id'] =
$row->obj;
380 return $objectives ? $objectives : array();
387 if(!count($objectives[
'all_questions']) or
388 !count($objectives[
'all_objectives']))
393 $query =
"SELECT question_id,points FROM qpl_questions ".
394 "WHERE ".$ilDB->in(
'question_id',(array) $objectives[
'all_questions'],
false,
'integer');
396 while(
$row = $ilDB->fetchAssoc(
$res))
398 $objectives[
'all_question_points'][
$row[
'question_id']][
'max_points'] = $row[
'points'];
401 $query =
"SELECT question_fi, MAX(points) as reached FROM tst_test_result ".
402 "JOIN tst_active ON (active_id = active_fi) ".
403 "WHERE user_fi = ".$ilDB->quote($a_user_id,
'integer').
" ".
404 "AND ".$ilDB->in(
'question_fi',(array) $objectives[
'all_questions'],
false,
'integer').
" ".
405 #"AND question_fi IN (".implode(",",ilUtil::quoteArray($objectives['all_questions'])).") ".
406 "GROUP BY question_fi,user_fi";
410 $objectives[
'all_question_points'][
$row->question_fi][
'reached_points'] =
$row->reached;
414 $fullfilled = array();
416 foreach($objectives[
'objectives'] as $kind => $data)
422 if($data[
'tst_status'])
424 $fullfilled[] = array($data[
'objective_id'],$ilUser->getId(),$data[
'tst_status']);
428 $pretest[] = array($data[
'objective_id'],$ilUser->getId());
432 if(count($fullfilled))
434 foreach($fullfilled as $fullfilled_arr)
437 'crs_objective_status',
439 'objective_id' => array(
'integer',$fullfilled_arr[0]),
440 'user_id' => array(
'integer',$fullfilled_arr[1])
443 'status' => array(
'integer',$fullfilled_arr[2])
451 foreach($pretest as $pretest_arr)
454 'crs_objective_status_p',
456 'objective_id' => array(
'integer',$pretest_arr[0]),
457 'user_id' => array(
'integer',$pretest_arr[1])
468 if(!is_array($objective_data[
'questions']))
474 foreach($objective_data[
'questions'] as $question_id)
476 $max_points += $question_points[$question_id][
'max_points'];
477 $reached_points += $question_points[$question_id][
'reached_points'];
484 return $reached_points >= $objective_data[
'tst_limit'] ?
true :
false;
486 return (($reached_points / $max_points * 100) >= $objective_data[
'tst_limit']) ?
true :
false;
495 $query =
"SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 ".
496 "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and ".
497 $ilDB->in(
't1.objective_id',$objective_ids,
false,
'integer').
" ".
498 "GROUP BY t1.crs_id";
503 $query =
"SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs ".
504 "JOIN crs_objectives co ON cs.objective_id = co.objective_id ".
505 "WHERE crs_id = ".$ilDB->quote(
$row->crs_id ,
'integer').
" ".
506 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
508 $user_res = $ilDB->query(
$query);
511 if($user_row->num_passed ==
$row->num)
513 $passed[] =
$row->crs_id;
516 $crs_ids[
$row->crs_id] =
$row->crs_id;
520 foreach($passed as $crs_id)
522 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
524 $members->updatePassed($a_user_id,
true);
529 foreach ($crs_ids as $cid)
531 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");