ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCourseObjectiveResult Class Reference

class ilcourseobjective More...

+ Collaboration diagram for ilCourseObjectiveResult:

Public Member Functions

 __construct ($a_usr_id)
 Constructor. More...
 
 getUserId ()
 
 getAccomplished ($a_crs_id)
 
 getSuggested ($a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)
 
 reset ($a_course_id)
 
 getStatus ($a_course_id)
 
 hasAccomplishedObjective ($a_objective_id)
 
 readStatus ($a_crs_id)
 
 __deleteEntries ($a_objective_ids)
 

Static Public Member Functions

static _getAccomplished ($a_user_id, $a_crs_id)
 
static _getSuggested ($a_user_id, $a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)
 
static getSuggestedQuestions ($a_usr_id, $a_crs_id)
 get suggested questions ids More...
 
static _deleteUser ($user_id)
 
static _updateObjectiveResult ($a_user_id, $a_active_id, $a_question_id)
 
static _readAssignedObjectivesOfQuestion ($a_question_id)
 
static _readAssignedObjectives ($a_all_objectives)
 
static _updateObjectiveStatus ($a_user_id, $objectives)
 
static __isFullfilled ($question_points, $objective_data)
 
static __updatePassed ($a_user_id, $objective_ids)
 can be protected? More...
 

Data Fields

 $db = null
 
 $user_id = null
 

Protected Member Functions

 resetTestForUser (ilObjTest $a_test, $a_user_id)
 

Detailed Description

class ilcourseobjective

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 19 of file class.ilCourseObjectiveResult.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseObjectiveResult::__construct (   $a_usr_id)

Constructor.

Parameters
int$a_usr_id

Definition at line 29 of file class.ilCourseObjectiveResult.php.

30 {
31 global $DIC;
32
33 $ilDB = $DIC['ilDB'];
34
35 $this->db = $ilDB;
36
37 $this->user_id = $a_usr_id;
38 }
global $DIC
Definition: goto.php:24
global $ilDB

References $DIC, and $ilDB.

Member Function Documentation

◆ __deleteEntries()

ilCourseObjectiveResult::__deleteEntries (   $a_objective_ids)

Definition at line 298 of file class.ilCourseObjectiveResult.php.

299 {
300 global $DIC;
301
302 $ilLog = $DIC['ilLog'];
303
304 $ilLog->logStack();
305 #$ilLog(__METHOD__.': Call of deprecated method.');
306
307 return true;
308 }

References $DIC.

◆ __isFullfilled()

static ilCourseObjectiveResult::__isFullfilled (   $question_points,
  $objective_data 
)
static

Definition at line 469 of file class.ilCourseObjectiveResult.php.

470 {
471 if (!is_array($objective_data['questions'])) {
472 return false;
473 }
474 $max_points = 0;
475 $reached_points = 0;
476 foreach ($objective_data['questions'] as $question_id) {
477 $max_points += $question_points[$question_id]['max_points'];
478 $reached_points += $question_points[$question_id]['reached_points'];
479 }
480 if (!$max_points) {
481 return false;
482 }
483
484 return $reached_points >= $objective_data['tst_limit'] ? true : false;
485
486 return (($reached_points / $max_points * 100) >= $objective_data['tst_limit']) ? true : false;
487 }
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.

References true.

Referenced by _updateObjectiveStatus().

+ Here is the caller graph for this function:

◆ __updatePassed()

static ilCourseObjectiveResult::__updatePassed (   $a_user_id,
  $objective_ids 
)
static

can be protected?

@global type $ilDB

Parameters
type$a_user_id
type$objective_ids

Definition at line 496 of file class.ilCourseObjectiveResult.php.

497 {
498 global $DIC;
499
500 $ilDB = $DIC['ilDB'];
501
502 $passed = array();
503
504 $query = "SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 " .
505 "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and " .
506 $ilDB->in('t1.objective_id', $objective_ids, false, 'integer') . " " .
507 "GROUP BY t1.crs_id";
508 $res = $ilDB->query($query);
509 $crs_ids = array();
510 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
511 $query = "SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs " .
512 "JOIN crs_objectives co ON cs.objective_id = co.objective_id " .
513 "WHERE crs_id = " . $ilDB->quote($row->crs_id, 'integer') . " " .
514 "AND user_id = " . $ilDB->quote($a_user_id, 'integer') . " ";
515
516 $user_res = $ilDB->query($query);
517 while ($user_row = $user_res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
518 if ($user_row->num_passed == $row->num) {
519 $passed[] = $row->crs_id;
520 }
521 }
522 $crs_ids[$row->crs_id] = $row->crs_id;
523 }
524 if (count($passed)) {
525 foreach ($passed as $crs_id) {
526 include_once('Modules/Course/classes/class.ilCourseParticipants.php');
528 $members->updatePassed($a_user_id, true);
529 }
530 }
531
532 // update tracking status
533 foreach ($crs_ids as $cid) {
534 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
535 ilLPStatusWrapper::_updateStatus($cid, $a_user_id);
536 }
537 }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, ilCourseParticipants\_getInstanceByObjId(), ilLPStatusWrapper\_updateStatus(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _updateObjectiveStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteUser()

static ilCourseObjectiveResult::_deleteUser (   $user_id)
static

Definition at line 310 of file class.ilCourseObjectiveResult.php.

311 {
312 global $DIC;
313
314 $ilDB = $DIC['ilDB'];
315
316 $query = "DELETE FROM crs_objective_status " .
317 "WHERE user_id = " . $ilDB->quote($user_id, 'integer') . " ";
318 $res = $ilDB->manipulate($query);
319
320 $query = "DELETE FROM crs_objective_status_p " .
321 "WHERE user_id = " . $ilDB->quote($user_id, 'integer') . " ";
322 $res = $ilDB->manipulate($query);
323 return true;
324 }

References $DIC, $ilDB, $query, $res, and $user_id.

◆ _getAccomplished()

static ilCourseObjectiveResult::_getAccomplished (   $a_user_id,
  $a_crs_id 
)
static

Definition at line 48 of file class.ilCourseObjectiveResult.php.

49 {
50 global $DIC;
51
52 $ilDB = $DIC['ilDB'];
53
54 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
55 // begin-patch lok
56 $objectives = ilCourseObjective::_getObjectiveIds($a_crs_id, true);
57 // end-patch lok
58
59 if (!is_array($objectives)) {
60 return array();
61 }
62 $query = "SELECT objective_id FROM crs_objective_status " .
63 "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . ' ' .
64 "AND user_id = " . $ilDB->quote($a_user_id, 'integer') . " ";
65 $res = $ilDB->query($query);
66 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
67 $accomplished[] = $row->objective_id;
68 }
69 return $accomplished ? $accomplished : array();
70 }
static _getObjectiveIds($course_id, $a_activated_only=false)

References $DIC, $ilDB, $query, $res, ilCourseObjective\_getObjectiveIds(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by getAccomplished().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSuggested()

static ilCourseObjectiveResult::_getSuggested (   $a_user_id,
  $a_crs_id,
  $a_status = IL_OBJECTIVE_STATUS_FINAL 
)
static

Definition at line 77 of file class.ilCourseObjectiveResult.php.

78 {
79 global $DIC;
80
81 $ilDB = $DIC['ilDB'];
82
83 include_once './Modules/Course/classes/class.ilCourseObjective.php';
84 // begin-patch lok
85 $objectives = ilCourseObjective::_getObjectiveIds($a_crs_id, true);
86 // end-patch lok
87
88 $finished = array();
89 if ($a_status == IL_OBJECTIVE_STATUS_FINAL or
90 $a_status == IL_OBJECTIVE_STATUS_FINISHED) {
91 // check finished
92 $query = "SELECT objective_id FROM crs_objective_status " .
93 "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . " " .
94 "AND user_id = " . $ilDB->quote($a_user_id, 'integer') . " ";
95 $res = $ilDB->query($query);
96 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
97 $finished[] = $row->objective_id;
98 }
99 } else {
100 // Pretest
101 $query = "SELECT objective_id FROM crs_objective_status_p " .
102 "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . ' ' .
103 "AND user_id = " . $ilDB->quote($a_user_id, 'integer');
104 $res = $ilDB->query($query);
105 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
106 $finished[] = $row->objective_id;
107 }
108 }
109 foreach ($objectives as $objective_id) {
110 if (!in_array($objective_id, $finished)) {
111 $suggested[] = $objective_id;
112 }
113 }
114 return $suggested ? $suggested : array();
115 }
const IL_OBJECTIVE_STATUS_FINISHED
const IL_OBJECTIVE_STATUS_FINAL

References $DIC, $ilDB, $query, $res, ilCourseObjective\_getObjectiveIds(), ilDBConstants\FETCHMODE_OBJECT, IL_OBJECTIVE_STATUS_FINAL, and IL_OBJECTIVE_STATUS_FINISHED.

Referenced by getSuggested(), and ilCourseObjectiveResultCache\readSuggested().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _readAssignedObjectives()

static ilCourseObjectiveResult::_readAssignedObjectives (   $a_all_objectives)
static

Definition at line 365 of file class.ilCourseObjectiveResult.php.

366 {
367 global $DIC;
368
369 $ilDB = $DIC['ilDB'];
370
371 // Read necessary points
372 $query = "SELECT t.objective_id obj,t.ref_id ref, question_id,tst_status,tst_limit " .
373 "FROM crs_objective_tst t JOIN crs_objective_qst q " .
374 "ON (t.objective_id = q.objective_id AND t.ref_id = q.ref_id) " .
375 "WHERE " . $ilDB->in('t.objective_id', $a_all_objectives, false, 'integer');
376
377 $res = $ilDB->query($query);
378 $objectives = array();
379 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
380 /*
381 $objectives[$row->obj."_".$row->ref]['questions'][$row->question_id] = $row->question_id;
382 $objectives[$row->obj."_".$row->ref]['tst_status'] = $row->tst_status;
383 $objectives[$row->obj."_".$row->ref]['tst_limit'] = $row->tst_limit;
384 $objectives[$row->obj."_".$row->ref]['objective_id'] = $row->obj;
385 */
386
387 $objectives[$row->obj . "_" . $row->tst_status]['questions'][$row->question_id] = $row->question_id;
388 $objectives[$row->obj . "_" . $row->tst_status]['tst_status'] = $row->tst_status;
389 $objectives[$row->obj . "_" . $row->tst_status]['tst_limit'] = $row->tst_limit;
390 $objectives[$row->obj . "_" . $row->tst_status]['objective_id'] = $row->obj;
391 }
392 return $objectives;
393 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by _readAssignedObjectivesOfQuestion(), getStatus(), and readStatus().

+ Here is the caller graph for this function:

◆ _readAssignedObjectivesOfQuestion()

static ilCourseObjectiveResult::_readAssignedObjectivesOfQuestion (   $a_question_id)
static

Definition at line 339 of file class.ilCourseObjectiveResult.php.

340 {
341 global $DIC;
342
343 $ilDB = $DIC['ilDB'];
344
345 // get all objtives and questions this current question is assigned to
346 $query = "SELECT q2.question_id qid,q2.objective_id ob FROM crs_objective_qst q1, " .
347 "crs_objective_qst q2 " .
348 "WHERE q1.question_id = " . $ilDB->quote($a_question_id, 'integer') . " " .
349 "AND q1.objective_id = q2.objective_id ";
350
351 $res = $ilDB->query($query);
352 $objectives = array();
353 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
354 $objectives['all_objectives'][$row->ob] = $row->ob;
355 $objectives['all_questions'][$row->qid] = $row->qid;
356 }
357 if (empty($objectives)) {
358 return false;
359 }
360 $objectives['objectives'] = self::_readAssignedObjectives($objectives['all_objectives']);
361 return $objectives;
362 }
static _readAssignedObjectives($a_all_objectives)

References $DIC, $ilDB, $query, $res, _readAssignedObjectives(), and ilDBConstants\FETCHMODE_OBJECT.

+ Here is the call graph for this function:

◆ _updateObjectiveResult()

static ilCourseObjectiveResult::_updateObjectiveResult (   $a_user_id,
  $a_active_id,
  $a_question_id 
)
static

Definition at line 326 of file class.ilCourseObjectiveResult.php.

327 {
328 // find all objectives this question is assigned to
329 if (!$objectives = self::_readAssignedObjectivesOfQuestion($a_question_id)) {
330 // no objectives found. TODO user has passed a test. After that questions of that test are assigned to an objective.
331 // => User has not passed
332 return true;
333 }
334 self::_updateObjectiveStatus($a_user_id, $objectives);
335
336 return true;
337 }
static _updateObjectiveStatus($a_user_id, $objectives)

References _updateObjectiveStatus().

Referenced by assQuestion\_setReachedPoints(), and assQuestion\calculateResultsFromSolution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _updateObjectiveStatus()

static ilCourseObjectiveResult::_updateObjectiveStatus (   $a_user_id,
  $objectives 
)
static

Definition at line 395 of file class.ilCourseObjectiveResult.php.

396 {
397 global $DIC;
398
399 $ilDB = $DIC['ilDB'];
400 $ilUser = $DIC['ilUser'];
401
402 if (!count($objectives['all_questions']) or
403 !count($objectives['all_objectives'])) {
404 return false;
405 }
406 // Read reachable points
407 $query = "SELECT question_id,points FROM qpl_questions " .
408 "WHERE " . $ilDB->in('question_id', (array) $objectives['all_questions'], false, 'integer');
409 $res = $ilDB->query($query);
410 while ($row = $ilDB->fetchAssoc($res)) {
411 $objectives['all_question_points'][$row['question_id']]['max_points'] = $row['points'];
412 }
413 // Read reached points
414 $query = "SELECT question_fi, MAX(points) as reached FROM tst_test_result " .
415 "JOIN tst_active ON (active_id = active_fi) " .
416 "WHERE user_fi = " . $ilDB->quote($a_user_id, 'integer') . " " .
417 "AND " . $ilDB->in('question_fi', (array) $objectives['all_questions'], false, 'integer') . " " .
418 #"AND question_fi IN (".implode(",",ilUtil::quoteArray($objectives['all_questions'])).") ".
419 "GROUP BY question_fi,user_fi";
420 $res = $ilDB->query($query);
421 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
422 $objectives['all_question_points'][$row->question_fi]['reached_points'] = $row->reached;
423 }
424
425 // Check accomplished
426 $fullfilled = array();
427 $pretest = array();
428 foreach ($objectives['objectives'] as $kind => $data) {
429 // objective does not allow to change status
430 if (ilCourseObjectiveResult::__isFullfilled($objectives['all_question_points'], $data)) {
431 // Status 0 means pretest fullfilled, status 1 means final test fullfilled
432 if ($data['tst_status']) {
433 $fullfilled[] = array($data['objective_id'],$ilUser->getId(),$data['tst_status']);
434 } else {
435 $pretest[] = array($data['objective_id'],$ilUser->getId());
436 }
437 }
438 }
439 if (count($fullfilled)) {
440 foreach ($fullfilled as $fullfilled_arr) {
441 $ilDB->replace(
442 'crs_objective_status',
443 array(
444 'objective_id' => array('integer',$fullfilled_arr[0]),
445 'user_id' => array('integer',$fullfilled_arr[1])
446 ),
447 array(
448 'status' => array('integer',$fullfilled_arr[2])
449 )
450 );
451 }
452 ilCourseObjectiveResult::__updatePassed($a_user_id, $objectives['all_objectives']);
453 }
454 if (count($pretest)) {
455 foreach ($pretest as $pretest_arr) {
456 $ilDB->replace(
457 'crs_objective_status_p',
458 array(
459 'objective_id' => array('integer',$pretest_arr[0]),
460 'user_id' => array('integer',$pretest_arr[1])
461 ),
462 array()
463 );
464 }
465 }
466 return true;
467 }
static __isFullfilled($question_points, $objective_data)
static __updatePassed($a_user_id, $objective_ids)
can be protected?
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
$ilUser
Definition: imgupload.php:18
$data
Definition: storeScorm.php:23

References $data, $DIC, $ilDB, $ilUser, $query, $res, __isFullfilled(), __updatePassed(), ilDBConstants\FETCHMODE_OBJECT, and ilUtil\quoteArray().

Referenced by _updateObjectiveResult(), and readStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAccomplished()

ilCourseObjectiveResult::getAccomplished (   $a_crs_id)

Definition at line 44 of file class.ilCourseObjectiveResult.php.

References _getAccomplished(), and getUserId().

Referenced by getStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatus()

ilCourseObjectiveResult::getStatus (   $a_course_id)

Definition at line 223 of file class.ilCourseObjectiveResult.php.

224 {
225 include_once './Modules/TestQuestionPool/classes/class.assQuestion.php';
226 include_once 'Modules/Course/classes/class.ilCourseObjective.php';
227 // begin-patch lok
228 $objective_ids = ilCourseObjective::_getObjectiveIds($a_course_id, true);
229 // end-patch lok
230 $objectives = ilCourseObjectiveResult::_readAssignedObjectives($objective_ids);
231 $accomplished = $this->getAccomplished($a_course_id);
232 $suggested = $this->getSuggested($a_course_id);
233
234 if (!count($objective_ids)) {
236 }
237
238 if (count($accomplished) == count($objective_ids)) {
240 }
241
242 $all_pretest_answered = false;
243 $all_final_answered = false;
244 foreach ($objectives as $data) {
245 if (assQuestion::_areAnswered($this->getUserId(), $data['questions'])) {
246 if ($data['tst_status']) {
247 $all_final_answered = true;
248 } else {
249 $all_pretest_answered = true;
250 }
251 }
252 }
253 if ($all_final_answered) {
255 }
256 if ($all_pretest_answered and
257 !count($suggested)) {
259 } elseif ($all_pretest_answered) {
261 }
263 }
const IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST
const IL_OBJECTIVE_STATUS_EMPTY
const IL_OBJECTIVE_STATUS_NONE
const IL_OBJECTIVE_STATUS_PRETEST
static _areAnswered($a_user_id, $a_question_ids)
Checks if an array of question ids is answered by an user or not.
getSuggested($a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)

References $data, assQuestion\_areAnswered(), ilCourseObjective\_getObjectiveIds(), _readAssignedObjectives(), getAccomplished(), getSuggested(), getUserId(), IL_OBJECTIVE_STATUS_EMPTY, IL_OBJECTIVE_STATUS_FINAL, IL_OBJECTIVE_STATUS_FINISHED, IL_OBJECTIVE_STATUS_NONE, IL_OBJECTIVE_STATUS_PRETEST, and IL_OBJECTIVE_STATUS_PRETEST_NON_SUGGEST.

+ Here is the call graph for this function:

◆ getSuggested()

ilCourseObjectiveResult::getSuggested (   $a_crs_id,
  $a_status = IL_OBJECTIVE_STATUS_FINAL 
)

Definition at line 72 of file class.ilCourseObjectiveResult.php.

73 {
74 return ilCourseObjectiveResult::_getSuggested($this->getUserId(), $a_crs_id, $a_status);
75 }
static _getSuggested($a_user_id, $a_crs_id, $a_status=IL_OBJECTIVE_STATUS_FINAL)

References _getSuggested(), and getUserId().

Referenced by getStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSuggestedQuestions()

static ilCourseObjectiveResult::getSuggestedQuestions (   $a_usr_id,
  $a_crs_id 
)
static

get suggested questions ids

Parameters
object$a_usr_id
object$a_crs_id
Returns

Definition at line 123 of file class.ilCourseObjectiveResult.php.

124 {
125 foreach (self::_getSuggested($a_usr_id, $a_crs_id) as $objective_id) {
126 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
127 $obj = new ilCourseObjectiveQuestion($objective_id);
128 foreach ($obj->getFinalTestQuestions() as $qst) {
129 $qsts[] = $qst['question_id'];
130 }
131 }
132 return $qsts ? $qsts : array();
133 }
class ilcourseobjectiveQuestion

◆ getUserId()

ilCourseObjectiveResult::getUserId ( )

Definition at line 39 of file class.ilCourseObjectiveResult.php.

40 {
41 return $this->user_id;
42 }

References $user_id.

Referenced by getAccomplished(), getStatus(), getSuggested(), hasAccomplishedObjective(), readStatus(), and reset().

+ Here is the caller graph for this function:

◆ hasAccomplishedObjective()

ilCourseObjectiveResult::hasAccomplishedObjective (   $a_objective_id)

Definition at line 265 of file class.ilCourseObjectiveResult.php.

266 {
267 global $DIC;
268
269 $ilDB = $DIC['ilDB'];
270
271 $query = "SELECT status FROM crs_objective_status " .
272 "WHERE objective_id = " . $ilDB->quote($a_objective_id, 'integer') . " " .
273 "AND user_id = " . $ilDB->quote($this->getUserId(), 'integer') . "";
274
275 $res = $this->db->query($query);
276 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
277 return true;
278 }
279 return false;
280 }

References $DIC, $ilDB, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and getUserId().

+ Here is the call graph for this function:

◆ readStatus()

ilCourseObjectiveResult::readStatus (   $a_crs_id)

Definition at line 282 of file class.ilCourseObjectiveResult.php.

283 {
284 include_once './Modules/Course/classes/class.ilCourseObjective.php';
285
286 // begin-patch lok
287 $objective_ids = ilCourseObjective::_getObjectiveIds($a_crs_id, true);
288 // end-patch lok
289 $objectives = ilCourseObjectiveResult::_readAssignedObjectives($objective_ids);
291 return true;
292 }

References ilCourseObjective\_getObjectiveIds(), _readAssignedObjectives(), _updateObjectiveStatus(), and getUserId().

+ Here is the call graph for this function:

◆ reset()

ilCourseObjectiveResult::reset (   $a_course_id)

Definition at line 152 of file class.ilCourseObjectiveResult.php.

153 {
154 global $DIC;
155
156 $ilDB = $DIC['ilDB'];
157
158 include_once './Modules/Course/classes/class.ilCourseObjective.php';
159 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
160
161 include_once './Services/Object/classes/class.ilObjectFactory.php';
163
164 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
165 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
166 $assignments = ilLOTestAssignments::getInstance($a_course_id);
167 foreach (array_merge(
168 $assignments->getAssignmentsByType(ilLOSettings::TYPE_TEST_INITIAL),
169 $assignments->getAssignmentsByType(ilLOSettings::TYPE_TEST_QUALIFIED)
170 )
171 as $assignment) {
172 $tst = $factory->getInstanceByRefId($assignment->getTestRefId(), false);
173 if ($tst instanceof ilObjTest) {
174 global $DIC;
175
176 $lng = $DIC['lng'];
177
178 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
179 $participantData = new ilTestParticipantData($ilDB, $lng);
180 $participantData->setUserIdsFilter(array($this->getUserId()));
181 $participantData->load($tst->getTestId());
182 $tst->removeTestResults($participantData);
183 }
184 }
185
186 $initial = ilLOSettings::getInstanceByObjId($a_course_id)->getInitialTest();
187 $initial_tst = $factory->getInstanceByRefId($initial, false);
188 if ($initial_tst instanceof ilObjTest) {
189 $this->resetTestForUser($initial_tst, $this->getUserId());
190 }
191
192 $qualified = ilLOSettings::getInstanceByObjId($a_course_id)->getQualifiedTest();
193 $qualified_tst = $factory->getInstanceByRefId($qualified, false);
194 if ($qualified_tst instanceof ilObjTest) {
195 $this->resetTestForUser($qualified_tst, $this->getUserId());
196 }
197
198 $objectives = ilCourseObjective::_getObjectiveIds($a_course_id, false);
199
200 if (count($objectives)) {
201 $query = "DELETE FROM crs_objective_status " .
202 "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . ' ' .
203 "AND user_id = " . $ilDB->quote($this->getUserId(), 'integer') . " ";
204 $res = $ilDB->manipulate($query);
205
206 $query = "DELETE FROM crs_objective_status_p " .
207 "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . ' ' .
208 "AND user_id = " . $ilDB->quote($this->getUserId()) . "";
209 $res = $ilDB->manipulate($query);
210
211 $query = "DELETE FROM loc_user_results " .
212 "WHERE " . $ilDB->in('objective_id', $objectives, false, 'integer') . ' ' .
213 "AND user_id = " . $ilDB->quote($this->getUserId()) . "";
214 }
215
216 // update/reset LP for course
217 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
218 ilLPStatusWrapper::_updateStatus($a_course_id, $this->getUserId());
219
220 return true;
221 }
resetTestForUser(ilObjTest $a_test, $a_user_id)
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
Class ilObjectFactory This class offers methods to get instances of the type-specific object classes ...
$factory
Definition: metadata.php:58
$lng

References $DIC, $factory, $ilDB, $lng, $query, $res, ilCourseObjective\_getObjectiveIds(), ilLPStatusWrapper\_updateStatus(), ilLOTestAssignments\getInstance(), ilLOSettings\getInstanceByObjId(), getUserId(), resetTestForUser(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

+ Here is the call graph for this function:

◆ resetTestForUser()

ilCourseObjectiveResult::resetTestForUser ( ilObjTest  $a_test,
  $a_user_id 
)
protected

Definition at line 135 of file class.ilCourseObjectiveResult.php.

136 {
137 // this is done in ilTestLP (see below)
138 // $a_test->removeTestResultsForUser($a_user_id);
139
140 // #15038
141 include_once "Modules/Test/classes/class.ilTestLP.php";
142 $test_lp = ilTestLP::getInstance($a_test->getId());
143 $test_lp->resetLPDataForUserIds(array($a_user_id));
144
145 // #15205 - see ilObjTestGUI::confirmDeleteSelectedUserDataObject()
146 $active_id = $a_test->getActiveIdOfUser($a_user_id);
147 if ($active_id) {
148 $a_test->removeTestActives(array($active_id));
149 }
150 }
removeTestActives($activeIds)
getActiveIdOfUser($user_id="", $anonymous_id="")
Gets the active id of a given user.
static getInstance($a_obj_id)
getId()
get object id @access public

References ilObjTest\getActiveIdOfUser(), ilObject\getId(), ilObjectLP\getInstance(), and ilObjTest\removeTestActives().

Referenced by reset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilCourseObjectiveResult::$db = null

Definition at line 21 of file class.ilCourseObjectiveResult.php.

◆ $user_id

ilCourseObjectiveResult::$user_id = null

Definition at line 22 of file class.ilCourseObjectiveResult.php.

Referenced by _deleteUser(), and getUserId().


The documentation for this class was generated from the following file: