ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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, ilObject\_getObjectsByType(), ilLPStatusWrapper\_lookupCompletedForObject(), ilLPStatusWrapper\_lookupFailedForObject(), ilLPStatusWrapper\_lookupInProgressForObject(), and ilObjectLP\getInstance().

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  }
145  }
146 
147  return $count;
148  }
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.
$failed
Definition: Utf8Test.php:86
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
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 150 of file class.ilLPCronObjectStatistics.php.

References $data, and ilTrQuery\getObjectTypeStatistics().

Referenced by run().

151  {
152  global $ilDB;
153 
154  $count = 0;
155 
156  include_once "Services/Tracking/classes/class.ilTrQuery.php";
158  foreach($data as $type => $item)
159  {
160  // only save once per day
161  $ilDB->manipulate("DELETE FROM obj_type_stat WHERE".
162  " type = ".$ilDB->quote($type, "text").
163  " AND fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer"));
164 
165  $set = array(
166  "type" => array("text", $type),
167  "yyyy" => array("integer", date("Y", $this->date)),
168  "mm" => array("integer", date("m", $this->date)),
169  "dd" => array("integer", date("d", $this->date)),
170  "fulldate" => array("integer", date("Ymd", $this->date)),
171  "cnt_references" => array("integer", (int)$item["references"]),
172  "cnt_objects" => array("integer", (int)$item["objects"]),
173  "cnt_deleted" => array("integer", (int)$item["deleted"])
174  );
175 
176  $ilDB->insert("obj_type_stat", $set);
177 
178  $count++;
179  }
180 
181  return $count;
182  }
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherUserData()

ilLPCronObjectStatistics::gatherUserData ( )
protected

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

References $row.

Referenced by run().

185  {
186  global $ilDB;
187 
188  $count = 0;
189 
190  $to = mktime(23, 59, 59, date("m", $this->date), date("d", $this->date), date("Y", $this->date));
191 
192  $sql = "SELECT COUNT(DISTINCT(usr_id)) counter,obj_id FROM read_event".
193  " WHERE last_access >= ".$ilDB->quote($this->date, "integer").
194  " AND last_access <= ".$ilDB->quote($to, "integer").
195  " GROUP BY obj_id";
196  $set = $ilDB->query($sql);
197  while($row = $ilDB->fetchAssoc($set))
198  {
199  // only save once per day
200  $ilDB->manipulate("DELETE FROM obj_user_stat".
201  " WHERE fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer").
202  " AND obj_id = ".$ilDB->quote($row["obj_id"], "integer"));
203 
204  $iset = array(
205  "obj_id" => array("integer", $row["obj_id"]),
206  "yyyy" => array("integer", date("Y", $this->date)),
207  "mm" => array("integer", date("m", $this->date)),
208  "dd" => array("integer", date("d", $this->date)),
209  "fulldate" => array("integer", date("Ymd", $this->date)),
210  "counter" => array("integer", $row["counter"])
211  );
212 
213  $ilDB->insert("obj_user_stat", $iset);
214 
215  $count++;
216  }
217 
218  return $count;
219  }
+ 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:40

◆ getId()

ilLPCronObjectStatistics::getId ( )

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

18  {
19  return "lp_object_statistics";
20  }

◆ 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:40

◆ 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, 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
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: