3 declare(strict_types=0);
42 $this->
logger = $DIC->logger()->trac();
43 $this->
lng = $DIC->language();
44 $this->
lng->loadLanguageModule(
"trac");
45 $this->db = $DIC->database();
46 $this->tree = $DIC->repositoryTree();
47 $this->cron_manager = $DIC->cron()->manager();
52 return "lp_object_statistics";
57 return $this->
lng->txt(
"trac_object_statistics");
62 return $this->
lng->txt(
"trac_object_statistics_info");
67 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
89 $this->date = strtotime(
"yesterday");
104 $result->setStatus($status);
120 $trashed_objects = $this->tree->getSavedNodeObjIds($all_courses);
122 foreach ($all_courses as $crs_id) {
124 if (!in_array($crs_id, $trashed_objects)) {
128 'Found course without reference: obj_id = ' . $crs_id
135 if (!$olp->isActive()) {
140 $this->db->manipulate(
141 "DELETE FROM obj_lp_stat WHERE" .
142 " obj_id = " . $this->db->quote($crs_id,
"integer") .
143 " AND fulldate = " . $this->db->quote(
144 date(
"Ymd", $this->date),
150 $members = $members->getMembers();
152 $in_progress = count(
172 $not_attempted = count(
174 ) - $in_progress - $completed - $failed;
177 "type" => array(
"text",
"crs"),
178 "obj_id" => array(
"integer", $crs_id),
179 "yyyy" => array(
"integer", date(
"Y", $this->date)),
180 "mm" => array(
"integer", date(
"m", $this->date)),
181 "dd" => array(
"integer", date(
"d", $this->date)),
182 "fulldate" => array(
"integer",
183 date(
"Ymd", $this->date)
185 "mem_cnt" => array(
"integer", count($members)),
186 "in_progress" => array(
"integer", $in_progress),
187 "completed" => array(
"integer", $completed),
188 "failed" => array(
"integer", $failed),
189 "not_attempted" => array(
"integer", $not_attempted)
192 $this->db->insert(
"obj_lp_stat", $set);
194 $this->cron_manager->ping($this->
getId());
205 foreach (
$data as $type => $item) {
207 $this->db->manipulate(
208 "DELETE FROM obj_type_stat WHERE" .
209 " type = " . $this->db->quote($type,
"text") .
210 " AND fulldate = " . $this->db->quote(
211 date(
"Ymd", $this->date),
217 "type" => array(
"text", $type),
218 "yyyy" => array(
"integer", date(
"Y", $this->date)),
219 "mm" => array(
"integer", date(
"m", $this->date)),
220 "dd" => array(
"integer", date(
"d", $this->date)),
221 "fulldate" => array(
"integer", date(
"Ymd", $this->date)),
222 "cnt_references" => array(
"integer", (
int) $item[
"references"]),
223 "cnt_objects" => array(
"integer", (
int) $item[
"objects"]),
224 "cnt_deleted" => array(
"integer", isset($item[
"deleted"]) ? (
int) $item[
"deleted"] : 0)
227 $this->db->insert(
"obj_type_stat", $set);
230 $this->cron_manager->ping($this->
getId());
242 date(
"m", $this->date),
243 date(
"d", $this->date),
244 date(
"Y", $this->date)
247 $sql =
"SELECT COUNT(DISTINCT(usr_id)) counter,obj_id FROM read_event" .
248 " WHERE last_access >= " . $this->db->quote(
252 " AND last_access <= " . $this->db->quote($to,
"integer") .
254 $set = $this->db->query($sql);
255 while ($row = $this->db->fetchAssoc($set)) {
257 $this->db->manipulate(
258 "DELETE FROM obj_user_stat" .
259 " WHERE fulldate = " . $this->db->quote(
260 date(
"Ymd", $this->date),
263 " AND obj_id = " . $this->db->quote($row[
"obj_id"],
"integer")
267 "obj_id" => array(
"integer", $row[
"obj_id"]),
268 "yyyy" => array(
"integer", date(
"Y", $this->date)),
269 "mm" => array(
"integer", date(
"m", $this->date)),
270 "dd" => array(
"integer", date(
"d", $this->date)),
271 "fulldate" => array(
"integer", date(
"Ymd", $this->date)),
272 "counter" => array(
"integer", $row[
"counter"])
275 $this->db->insert(
"obj_user_stat", $iset);
278 $this->cron_manager->ping($this->
getId());
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
static _getAllReferences(int $id)
get all reference ids for object ID
static _getObjectsByType(string $obj_type="", int $owner=null)
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
Cron for lp object statistics.
final const STATUS_NO_ACTION
ilCronManager $cron_manager
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
static getObjectTypeStatistics()
getDefaultScheduleValue()
static getInstance(int $obj_id)
gatherCourseLPData()
gather course data