ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLPCronObjectStatistics Class Reference

Cron for lp object statistics. More...

+ Inheritance diagram for ilLPCronObjectStatistics:
+ Collaboration diagram for ilLPCronObjectStatistics:

Public Member Functions

 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 run ()
 Run job. More...
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Member Functions

 gatherCourseLPData ()
 gather course data @global type $tree @global type $ilDB More...
 
 gatherTypesData ()
 
 gatherUserData ()
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $date
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Detailed Description

Cron for lp object statistics.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 13 of file class.ilLPCronObjectStatistics.php.

Member Function Documentation

◆ gatherCourseLPData()

ilLPCronObjectStatistics::gatherCourseLPData ( )
protected

gather course data @global type $tree @global type $ilDB

Returns
int

Definition at line 88 of file class.ilLPCronObjectStatistics.php.

89 {
90 global $tree, $ilDB;
91
92 $logger = $GLOBALS['DIC']->logger()->trac();
93
94 $count = 0;
95
96 // process all courses
97 $all_courses = array_keys(ilObject::_getObjectsByType("crs"));
98 if ($all_courses) {
99 // gather objects in trash
100 $trashed_objects = $tree->getSavedNodeObjIds($all_courses);
101
102 include_once 'Services/Object/classes/class.ilObjectLP.php';
103 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
104 include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
105 foreach ($all_courses as $crs_id) {
106 // trashed objects will not change
107 if (!in_array($crs_id, $trashed_objects)) {
108 $refs = ilObject::_getAllReferences($crs_id);
109 if (!count($refs)) {
110 $logger->warning('Found course without reference: obj_id = ' . $crs_id);
111 continue;
112 }
113
114 // only if LP is active
115 $olp = ilObjectLP::getInstance($crs_id);
116 if (!$olp->isActive()) {
117 continue;
118 }
119
120 // only save once per day
121 $ilDB->manipulate("DELETE FROM obj_lp_stat WHERE" .
122 " obj_id = " . $ilDB->quote($crs_id, "integer") .
123 " AND fulldate = " . $ilDB->quote(date("Ymd", $this->date), "integer"));
124
125 $members = new ilCourseParticipants($crs_id);
126 $members = $members->getMembers();
127
128 $in_progress = count(ilLPStatusWrapper::_lookupInProgressForObject($crs_id, $members));
129 $completed = count(ilLPStatusWrapper::_lookupCompletedForObject($crs_id, $members));
130 $failed = count(ilLPStatusWrapper::_lookupFailedForObject($crs_id, $members));
131
132 // calculate with other values - there is not direct method
133 $not_attempted = count($members) - $in_progress - $completed - $failed;
134
135 $set = array(
136 "type" => array("text", "crs"),
137 "obj_id" => array("integer", $crs_id),
138 "yyyy" => array("integer", date("Y", $this->date)),
139 "mm" => array("integer", date("m", $this->date)),
140 "dd" => array("integer", date("d", $this->date)),
141 "fulldate" => array("integer", date("Ymd", $this->date)),
142 "mem_cnt" => array("integer", count($members)),
143 "in_progress" => array("integer", $in_progress),
144 "completed" => array("integer", $completed),
145 "failed" => array("integer", $failed),
146 "not_attempted" => array("integer", $not_attempted)
147 );
148
149 $ilDB->insert("obj_lp_stat", $set);
150
151 $count++;
152
153 // #17928
154 ilCronManager::ping($this->getId());
155 }
156 }
157 }
158
159 return $count;
160 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$failed
Definition: Utf8Test.php:85
static ping($a_job_id)
Keep cron job alive.
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
static getInstance($a_obj_id)
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilDB

References $failed, $GLOBALS, $ilDB, ilObject\_getAllReferences(), ilObject\_getObjectsByType(), ilLPStatusWrapper\_lookupCompletedForObject(), ilLPStatusWrapper\_lookupFailedForObject(), ilLPStatusWrapper\_lookupInProgressForObject(), date, getId(), ilObjectLP\getInstance(), and ilCronManager\ping().

Referenced by run().

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

◆ gatherTypesData()

ilLPCronObjectStatistics::gatherTypesData ( )
protected

Definition at line 162 of file class.ilLPCronObjectStatistics.php.

163 {
164 global $ilDB;
165
166 $count = 0;
167
168 include_once "Services/Tracking/classes/class.ilTrQuery.php";
170 foreach ($data as $type => $item) {
171 // only save once per day
172 $ilDB->manipulate("DELETE FROM obj_type_stat WHERE" .
173 " type = " . $ilDB->quote($type, "text") .
174 " AND fulldate = " . $ilDB->quote(date("Ymd", $this->date), "integer"));
175
176 $set = array(
177 "type" => array("text", $type),
178 "yyyy" => array("integer", date("Y", $this->date)),
179 "mm" => array("integer", date("m", $this->date)),
180 "dd" => array("integer", date("d", $this->date)),
181 "fulldate" => array("integer", date("Ymd", $this->date)),
182 "cnt_references" => array("integer", (int) $item["references"]),
183 "cnt_objects" => array("integer", (int) $item["objects"]),
184 "cnt_deleted" => array("integer", (int) $item["deleted"])
185 );
186
187 $ilDB->insert("obj_type_stat", $set);
188
189 $count++;
190
191 // #17928
192 ilCronManager::ping($this->getId());
193 }
194
195 return $count;
196 }
static getObjectTypeStatistics()
$type

References $data, $ilDB, $type, date, getId(), ilTrQuery\getObjectTypeStatistics(), and ilCronManager\ping().

Referenced by run().

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

◆ gatherUserData()

ilLPCronObjectStatistics::gatherUserData ( )
protected

Definition at line 198 of file class.ilLPCronObjectStatistics.php.

199 {
200 global $ilDB;
201
202 $count = 0;
203
204 $to = mktime(23, 59, 59, date("m", $this->date), date("d", $this->date), date("Y", $this->date));
205
206 $sql = "SELECT COUNT(DISTINCT(usr_id)) counter,obj_id FROM read_event" .
207 " WHERE last_access >= " . $ilDB->quote($this->date, "integer") .
208 " AND last_access <= " . $ilDB->quote($to, "integer") .
209 " GROUP BY obj_id";
210 $set = $ilDB->query($sql);
211 while ($row = $ilDB->fetchAssoc($set)) {
212 // only save once per day
213 $ilDB->manipulate("DELETE FROM obj_user_stat" .
214 " WHERE fulldate = " . $ilDB->quote(date("Ymd", $this->date), "integer") .
215 " AND obj_id = " . $ilDB->quote($row["obj_id"], "integer"));
216
217 $iset = array(
218 "obj_id" => array("integer", $row["obj_id"]),
219 "yyyy" => array("integer", date("Y", $this->date)),
220 "mm" => array("integer", date("m", $this->date)),
221 "dd" => array("integer", date("d", $this->date)),
222 "fulldate" => array("integer", date("Ymd", $this->date)),
223 "counter" => array("integer", $row["counter"])
224 );
225
226 $ilDB->insert("obj_user_stat", $iset);
227
228 $count++;
229
230 // #17928
231 ilCronManager::ping($this->getId());
232 }
233
234 return $count;
235 }

References $ilDB, $row, date, getId(), and ilCronManager\ping().

Referenced by run().

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

◆ getDefaultScheduleType()

ilLPCronObjectStatistics::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

Definition at line 38 of file class.ilLPCronObjectStatistics.php.

39 {
41 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilLPCronObjectStatistics::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

Definition at line 43 of file class.ilLPCronObjectStatistics.php.

44 {
45 return;
46 }

◆ getDescription()

ilLPCronObjectStatistics::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 30 of file class.ilLPCronObjectStatistics.php.

31 {
32 global $lng;
33
34 $lng->loadLanguageModule("trac");
35 return $lng->txt("trac_object_statistics_info");
36 }
global $lng
Definition: privfeed.php:17

References $lng.

◆ getId()

ilLPCronObjectStatistics::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

Definition at line 17 of file class.ilLPCronObjectStatistics.php.

18 {
19 return "lp_object_statistics";
20 }

Referenced by gatherCourseLPData(), gatherTypesData(), and gatherUserData().

+ Here is the caller graph for this function:

◆ getTitle()

ilLPCronObjectStatistics::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

23 {
24 global $lng;
25
26 $lng->loadLanguageModule("trac");
27 return $lng->txt("trac_object_statistics");
28 }

References $lng.

◆ hasAutoActivation()

ilLPCronObjectStatistics::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

49 {
50 return true;
51 }

◆ hasFlexibleSchedule()

ilLPCronObjectStatistics::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 53 of file class.ilLPCronObjectStatistics.php.

54 {
55 return false;
56 }

◆ run()

ilLPCronObjectStatistics::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

Definition at line 58 of file class.ilLPCronObjectStatistics.php.

59 {
60 // all date related operations are based on this timestamp
61 // should be midnight of yesterday (see gatherUserData()) to always have full day
62 $this->date = strtotime("yesterday");
63
65 $message = array();
66
67 $count = 0;
68 $count += $this->gatherCourseLPData();
69 $count += $this->gatherTypesData();
70 $count += $this->gatherUserData();
71
72 if ($count) {
74 }
75
77 $result->setStatus($status);
78
79 return $result;
80 }
$result
Cron job result data container.
gatherCourseLPData()
gather course data @global type $tree @global type $ilDB
catch(Exception $e) $message

References $message, $result, date, gatherCourseLPData(), gatherTypesData(), gatherUserData(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

Field Documentation

◆ $date

ilLPCronObjectStatistics::$date
protected

Definition at line 15 of file class.ilLPCronObjectStatistics.php.


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