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 ".
77 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
78 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
82 $accomplished[] =
$row->objective_id;
84 return $accomplished ? $accomplished : array();
96 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
104 $query =
"SELECT objective_id FROM crs_objective_status ".
105 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
" ".
106 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
110 $finished[] =
$row->objective_id;
116 $query =
"SELECT objective_id FROM crs_objective_status_p ".
117 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
118 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer');
122 $finished[] =
$row->objective_id;
125 foreach($objectives as $objective_id)
127 if(!in_array($objective_id,$finished))
129 $suggested[] = $objective_id;
132 return $suggested ? $suggested : array();
143 foreach(self::_getSuggested($a_usr_id,$a_crs_id) as $objective_id)
145 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
147 foreach($obj->getFinalTestQuestions() as $qst)
149 $qsts[] = $qst[
'question_id'];
152 return $qsts ? $qsts : array();
159 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
160 include_once
'./Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
167 foreach($tmp_obj_question->getTests() as $test_data)
169 #$this->__deleteEntries($tmp_obj_question->getQuestionsByTest($test_data['ref_id']));
173 $tmp_test->removeTestResultsForUser($this->
getUserId());
179 if(count($objectives))
181 $query =
"DELETE FROM crs_objective_status ".
182 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
183 "AND user_id = ".$ilDB->quote($this->
getUserId() ,
'integer').
" ";
186 $query =
"DELETE FROM crs_objective_status_p ".
187 "WHERE ".$ilDB->in(
'objective_id',$objectives,
false,
'integer').
' '.
188 "AND user_id = ".$ilDB->quote($this->
getUserId()).
"";
197 include_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
198 include_once
'Modules/Course/classes/class.ilCourseObjective.php';
204 if(!count($objective_ids))
209 if(count($accomplished) == count($objective_ids))
214 $all_pretest_answered =
false;
215 $all_final_answered =
false;
216 foreach($objectives as
$data)
220 if($data[
'tst_status'])
222 $all_final_answered =
true;
226 $all_pretest_answered =
true;
230 if($all_final_answered)
234 if($all_pretest_answered and
239 elseif($all_pretest_answered)
250 $query =
"SELECT status FROM crs_objective_status ".
251 "WHERE objective_id = ".$ilDB->quote($a_objective_id ,
'integer').
" ".
252 "AND user_id = ".$ilDB->quote($this->
getUserId() ,
'integer').
"";
264 include_once
'./Modules/Course/classes/class.ilCourseObjective.php';
281 #$ilLog(__METHOD__.': Call of deprecated method.');
290 $query =
"DELETE FROM crs_objective_status ".
291 "WHERE user_id = ".$ilDB->quote(
$user_id ,
'integer').
" ";
294 $query =
"DELETE FROM crs_objective_status_p ".
295 "WHERE user_id = ".$ilDB->quote(
$user_id ,
'integer').
" ";
319 $query =
"SELECT q2.question_id qid,q2.objective_id ob FROM crs_objective_qst q1, ".
320 "crs_objective_qst q2 ".
321 "WHERE q1.question_id = ".$ilDB->quote($a_question_id ,
'integer').
" ".
322 "AND q1.objective_id = q2.objective_id ";
327 $objectives[
'all_objectives'][
$row->ob] =
$row->ob;
328 $objectives[
'all_questions'][
$row->qid] =
$row->qid;
330 if(!is_array($objectives))
335 return $objectives ? $objectives : array();
344 $query =
"SELECT t.objective_id obj,t.ref_id ref, question_id,tst_status,tst_limit ".
345 "FROM crs_objective_tst t JOIN crs_objective_qst q ".
346 "ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) ".
347 "WHERE ".$ilDB->in(
't.objective_id',$a_all_objectives,
false,
'integer');
359 $objectives[
$row->obj.
"_".
$row->tst_status][
'questions'][
$row->question_id] =
$row->question_id;
360 $objectives[
$row->obj.
"_".
$row->tst_status][
'tst_status'] =
$row->tst_status;
361 $objectives[
$row->obj.
"_".
$row->tst_status][
'tst_limit'] =
$row->tst_limit;
362 $objectives[
$row->obj.
"_".
$row->tst_status][
'objective_id'] =
$row->obj;
366 return $objectives ? $objectives : array();
371 global
$ilDB,$ilUser;
373 if(!count($objectives[
'all_questions']) or
374 !count($objectives[
'all_objectives']))
387 $query =
"SELECT question_id,points FROM qpl_questions ".
388 "WHERE ".$ilDB->in(
'question_id',(array) $objectives[
'all_questions'],
false,
'integer');
390 while(
$row = $ilDB->fetchAssoc(
$res))
392 $objectives[
'all_question_points'][
$row[
'question_id']][
'max_points'] = $row[
'points'];
395 $query =
"SELECT question_fi, MAX(points) as reached FROM tst_test_result ".
396 "JOIN tst_active ON (active_id = active_fi) ".
397 "WHERE user_fi = ".$ilDB->quote($a_user_id,
'integer').
" ".
398 "AND ".$ilDB->in(
'question_fi',(array) $objectives[
'all_questions'],
false,
'integer').
" ".
399 #"AND question_fi IN (".implode(",",ilUtil::quoteArray($objectives['all_questions'])).") ".
400 "GROUP BY question_fi,user_fi";
404 $objectives[
'all_question_points'][
$row->question_fi][
'reached_points'] =
$row->reached;
408 $fullfilled = array();
410 foreach($objectives[
'objectives'] as $kind =>
$data)
416 if(
$data[
'tst_status'])
418 $fullfilled[] = array(
$data[
'objective_id'],$ilUser->getId(),
$data[
'tst_status']);
422 $pretest[] = array(
$data[
'objective_id'],$ilUser->getId());
426 if(count($fullfilled))
428 $ilDB->executeMultiple($ilDB->prepare(
"REPLACE INTO crs_objective_status VALUES(?,?,?)"),
434 $ilDB->executeMultiple($ilDB->prepare(
"REPLACE INTO crs_objective_status_p VALUES(?,?)"),
443 if(!is_array($objective_data[
'questions']))
449 foreach($objective_data[
'questions'] as $question_id)
451 $max_points += $question_points[$question_id][
'max_points'];
452 $reached_points += $question_points[$question_id][
'reached_points'];
459 return $reached_points >= $objective_data[
'tst_limit'] ?
true :
false;
461 return (($reached_points / $max_points * 100) >= $objective_data[
'tst_limit']) ?
true :
false;
470 $query =
"SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 ".
471 "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and ".
472 $ilDB->in(
't1.objective_id',$objective_ids,
false,
'integer').
" ".
473 "GROUP BY t1.crs_id";
477 $query =
"SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs ".
478 "JOIN crs_objectives co ON cs.objective_id = co.objective_id ".
479 "WHERE crs_id = ".$ilDB->quote(
$row->crs_id ,
'integer').
" ".
480 "AND user_id = ".$ilDB->quote($a_user_id ,
'integer').
" ";
482 $user_res = $ilDB->query(
$query);
485 if($user_row->num_passed ==
$row->num)
487 $passed[] =
$row->crs_id;
493 foreach($passed as $crs_id)
495 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
497 $members->updatePassed($a_user_id,
true);