ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusVisits.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
26{
27 public static function _getInProgress(int $a_obj_id): array
28 {
29 global $DIC;
30
31 $ilDB = $DIC['ilDB'];
32
33 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
34 $required_visits = $status_info['visits'];
35
36 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
37 $user_ids = [];
38 foreach ($all as $event) {
39 if ($event['read_count'] < $required_visits) {
40 $user_ids[] = (int) $event['usr_id'];
41 }
42 }
43 return $user_ids;
44 }
45
46 public static function _getCompleted(int $a_obj_id): array
47 {
48 global $DIC;
49
50 $ilDB = $DIC['ilDB'];
51
52 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
53 $required_visits = $status_info['visits'];
54
55 $all = ilChangeEvent::_lookupReadEvents($a_obj_id);
56 $user_ids = [];
57 foreach ($all as $event) {
58 if ($event['read_count'] >= $required_visits) {
59 $user_ids[] = (int) $event['usr_id'];
60 }
61 }
62 return $user_ids;
63 }
64
65 public static function _getStatusInfo(int $a_obj_id): array
66 {
67 $status_info['visits'] = ilLPObjSettings::_lookupVisits($a_obj_id);
68 return $status_info;
69 }
70
71 public function determineStatus(
72 int $a_obj_id,
73 int $a_usr_id,
74 ?object $a_obj = null
75 ): int {
76 global $DIC;
77
78 $ilObjDataCache = $DIC['ilObjDataCache'];
79 $ilDB = $DIC['ilDB'];
80
82 switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
83 case 'lm':
84 if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
86
87 // completed?
88 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
89 $required_visits = $status_info['visits'];
90
92 $a_obj_id,
93 $a_usr_id
94 );
95 if (($re[0]['read_count'] ?? 0) >= $required_visits) {
97 }
98 }
99 break;
100 }
101 return $status;
102 }
103
104 public function determinePercentage(
105 int $a_obj_id,
106 int $a_usr_id,
107 ?object $a_obj = null
108 ): int {
109 $reqv = ilLPObjSettings::_lookupVisits($a_obj_id);
110
111 $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_usr_id);
112 $rc = (int) ($re[0]["read_count"] ?? 0);
113
114 if ($reqv > 0 && $rc) {
115 $per = (int) min(100, 100 / $reqv * $rc);
116 } else {
117 $per = 100;
118 }
119 return $per;
120 }
121}
static _lookupReadEvents($obj_id, $usr_id=null)
Reads all read events which occured on the object.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
static _lookupVisits(int $a_obj_id)
static _getCompleted(int $a_obj_id)
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getStatusInfo(int $a_obj_id)
determinePercentage(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
static _getInProgress(int $a_obj_id)
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
ilObjectDataCache $ilObjDataCache
global $DIC
Definition: shib_login.php:26