ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilLPCronObjectStatistics Class Reference

Cron for lp object statistics. More...

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

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 run ()
 
- 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 ()
 
 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

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

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

Referenced by run().

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

◆ gatherTypesData()

ilLPCronObjectStatistics::gatherTypesData ( )
protected

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

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

Referenced by run().

154  {
155  global $ilDB;
156 
157  $count = 0;
158 
159  include_once "Services/Tracking/classes/class.ilTrQuery.php";
161  foreach($data as $type => $item)
162  {
163  // only save once per day
164  $ilDB->manipulate("DELETE FROM obj_type_stat WHERE".
165  " type = ".$ilDB->quote($type, "text").
166  " AND fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer"));
167 
168  $set = array(
169  "type" => array("text", $type),
170  "yyyy" => array("integer", date("Y", $this->date)),
171  "mm" => array("integer", date("m", $this->date)),
172  "dd" => array("integer", date("d", $this->date)),
173  "fulldate" => array("integer", date("Ymd", $this->date)),
174  "cnt_references" => array("integer", (int)$item["references"]),
175  "cnt_objects" => array("integer", (int)$item["objects"]),
176  "cnt_deleted" => array("integer", (int)$item["deleted"])
177  );
178 
179  $ilDB->insert("obj_type_stat", $set);
180 
181  $count++;
182 
183  // #17928
184  ilCronManager::ping($this->getId());
185  }
186 
187  return $count;
188  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
static ping($a_job_id)
Keep cron job alive.
global $ilDB
static getObjectTypeStatistics()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherUserData()

ilLPCronObjectStatistics::gatherUserData ( )
protected

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

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

Referenced by run().

191  {
192  global $ilDB;
193 
194  $count = 0;
195 
196  $to = mktime(23, 59, 59, date("m", $this->date), date("d", $this->date), date("Y", $this->date));
197 
198  $sql = "SELECT COUNT(DISTINCT(usr_id)) counter,obj_id FROM read_event".
199  " WHERE last_access >= ".$ilDB->quote($this->date, "integer").
200  " AND last_access <= ".$ilDB->quote($to, "integer").
201  " GROUP BY obj_id";
202  $set = $ilDB->query($sql);
203  while($row = $ilDB->fetchAssoc($set))
204  {
205  // only save once per day
206  $ilDB->manipulate("DELETE FROM obj_user_stat".
207  " WHERE fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer").
208  " AND obj_id = ".$ilDB->quote($row["obj_id"], "integer"));
209 
210  $iset = array(
211  "obj_id" => array("integer", $row["obj_id"]),
212  "yyyy" => array("integer", date("Y", $this->date)),
213  "mm" => array("integer", date("m", $this->date)),
214  "dd" => array("integer", date("d", $this->date)),
215  "fulldate" => array("integer", date("Ymd", $this->date)),
216  "counter" => array("integer", $row["counter"])
217  );
218 
219  $ilDB->insert("obj_user_stat", $iset);
220 
221  $count++;
222 
223  // #17928
224  ilCronManager::ping($this->getId());
225  }
226 
227  return $count;
228  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
static ping($a_job_id)
Keep cron job alive.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLPCronObjectStatistics::getDefaultScheduleType ( )

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

39  {
40  return self::SCHEDULE_TYPE_DAILY;
41  }

◆ getDefaultScheduleValue()

ilLPCronObjectStatistics::getDefaultScheduleValue ( )

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

44  {
45  return;
46  }

◆ getDescription()

ilLPCronObjectStatistics::getDescription ( )

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

References $lng.

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

◆ getId()

ilLPCronObjectStatistics::getId ( )

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

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

18  {
19  return "lp_object_statistics";
20  }
+ Here is the caller graph for this function:

◆ getTitle()

ilLPCronObjectStatistics::getTitle ( )

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

References $lng.

23  {
24  global $lng;
25 
26  $lng->loadLanguageModule("trac");
27  return $lng->txt("trac_object_statistics");
28  }
global $lng
Definition: privfeed.php:17

◆ hasAutoActivation()

ilLPCronObjectStatistics::hasAutoActivation ( )

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

49  {
50  return true;
51  }

◆ hasFlexibleSchedule()

ilLPCronObjectStatistics::hasFlexibleSchedule ( )

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

54  {
55  return false;
56  }

◆ run()

ilLPCronObjectStatistics::run ( )

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

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

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)
73  {
75  }
76 
77  $result = new ilCronJobResult();
78  $result->setStatus($status);
79 
80  return $result;
81  }
$result
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
Cron job result data container.
+ 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: