ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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: saml.php:7
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, and $ilLog.

◆ __isFullfilled()

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

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

468 {
469 if (!is_array($objective_data['questions'])) {
470 return false;
471 }
472 $max_points = 0;
473 $reached_points = 0;
474 foreach ($objective_data['questions'] as $question_id) {
475 $max_points += $question_points[$question_id]['max_points'];
476 $reached_points += $question_points[$question_id]['reached_points'];
477 }
478 if (!$max_points) {
479 return false;
480 }
481
482 return $reached_points >= $objective_data['tst_limit'] ? true : false;
483
484 return (($reached_points / $max_points * 100) >= $objective_data['tst_limit']) ? true : false;
485 }

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 494 of file class.ilCourseObjectiveResult.php.

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

References $DIC, $ilDB, $query, $res, $row, 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, $row, 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, $row, 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 364 of file class.ilCourseObjectiveResult.php.

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

References $DIC, $ilDB, $query, $res, $row, 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 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
353 $objectives['all_objectives'][$row->ob] = $row->ob;
354 $objectives['all_questions'][$row->qid] = $row->qid;
355 }
356 if (!is_array($objectives)) {
357 return false;
358 }
359 $objectives['objectives'] = self::_readAssignedObjectives($objectives['all_objectives']);
360 return $objectives ? $objectives : array();
361 }
static _readAssignedObjectives($a_all_objectives)

References $DIC, $ilDB, $query, $res, $row, _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 393 of file class.ilCourseObjectiveResult.php.

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

References $data, $DIC, $ilDB, $ilUser, $query, $res, $row, __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, $row, 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 }
$factory
Definition: metadata.php:43
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.
$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: