ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLPCronObjectStatistics Class Reference

Cron for lp object statistics. More...

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

Public Member Functions

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

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

ilLPCronObjectStatistics::gatherCourseLPData ( )
protected

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

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

Referenced by run().

{
global $tree, $ilDB;
$count = 0;
// process all courses
$all_courses = array_keys(ilObject::_getObjectsByType("crs"));
if($all_courses)
{
// gather objects in trash
$trashed_objects = $tree->getSavedNodeObjIds($all_courses);
include_once 'Services/Object/classes/class.ilObjectLP.php';
include_once "Modules/Course/classes/class.ilCourseParticipants.php";
include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
foreach($all_courses as $crs_id)
{
// trashed objects will not change
if(!in_array($crs_id, $trashed_objects))
{
// only if LP is active
$olp = ilObjectLP::getInstance($crs_id);
if(!$olp->isActive())
{
continue;
}
// only save once per day
$ilDB->manipulate("DELETE FROM obj_lp_stat WHERE".
" obj_id = ".$ilDB->quote($crs_id, "integer").
" AND fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer"));
$members = new ilCourseParticipants($crs_id);
$members = $members->getMembers();
$in_progress = count(ilLPStatusWrapper::_lookupInProgressForObject($crs_id, $members));
$completed = count(ilLPStatusWrapper::_lookupCompletedForObject($crs_id, $members));
// calculate with other values - there is not direct method
$not_attempted = count($members) - $in_progress - $completed - $failed;
$set = array(
"type" => array("text", "crs"),
"obj_id" => array("integer", $crs_id),
"yyyy" => array("integer", date("Y", $this->date)),
"mm" => array("integer", date("m", $this->date)),
"dd" => array("integer", date("d", $this->date)),
"fulldate" => array("integer", date("Ymd", $this->date)),
"mem_cnt" => array("integer", count($members)),
"in_progress" => array("integer", $in_progress),
"completed" => array("integer", $completed),
"failed" => array("integer", $failed),
"not_attempted" => array("integer", $not_attempted)
);
$ilDB->insert("obj_lp_stat", $set);
$count++;
// #17928
}
}
}
return $count;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCronObjectStatistics::gatherTypesData ( )
protected

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

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

Referenced by run().

{
global $ilDB;
$count = 0;
include_once "Services/Tracking/classes/class.ilTrQuery.php";
foreach($data as $type => $item)
{
// only save once per day
$ilDB->manipulate("DELETE FROM obj_type_stat WHERE".
" type = ".$ilDB->quote($type, "text").
" AND fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer"));
$set = array(
"type" => array("text", $type),
"yyyy" => array("integer", date("Y", $this->date)),
"mm" => array("integer", date("m", $this->date)),
"dd" => array("integer", date("d", $this->date)),
"fulldate" => array("integer", date("Ymd", $this->date)),
"cnt_references" => array("integer", (int)$item["references"]),
"cnt_objects" => array("integer", (int)$item["objects"]),
"cnt_deleted" => array("integer", (int)$item["deleted"])
);
$ilDB->insert("obj_type_stat", $set);
$count++;
// #17928
}
return $count;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCronObjectStatistics::gatherUserData ( )
protected

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

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

Referenced by run().

{
global $ilDB;
$count = 0;
$to = mktime(23, 59, 59, date("m", $this->date), date("d", $this->date), date("Y", $this->date));
$sql = "SELECT COUNT(DISTINCT(usr_id)) counter,obj_id FROM read_event".
" WHERE last_access >= ".$ilDB->quote($this->date, "integer").
" AND last_access <= ".$ilDB->quote($to, "integer").
" GROUP BY obj_id";
$set = $ilDB->query($sql);
while($row = $ilDB->fetchAssoc($set))
{
// only save once per day
$ilDB->manipulate("DELETE FROM obj_user_stat".
" WHERE fulldate = ".$ilDB->quote(date("Ymd", $this->date), "integer").
" AND obj_id = ".$ilDB->quote($row["obj_id"], "integer"));
$iset = array(
"obj_id" => array("integer", $row["obj_id"]),
"yyyy" => array("integer", date("Y", $this->date)),
"mm" => array("integer", date("m", $this->date)),
"dd" => array("integer", date("d", $this->date)),
"fulldate" => array("integer", date("Ymd", $this->date)),
"counter" => array("integer", $row["counter"])
);
$ilDB->insert("obj_user_stat", $iset);
$count++;
// #17928
}
return $count;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLPCronObjectStatistics::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

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

References ilCronJob\SCHEDULE_TYPE_DAILY.

ilLPCronObjectStatistics::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

{
return;
}
ilLPCronObjectStatistics::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

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

References $lng.

{
global $lng;
$lng->loadLanguageModule("trac");
return $lng->txt("trac_object_statistics_info");
}
ilLPCronObjectStatistics::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

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

{
return "lp_object_statistics";
}

+ Here is the caller graph for this function:

ilLPCronObjectStatistics::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

References $lng.

{
global $lng;
$lng->loadLanguageModule("trac");
return $lng->txt("trac_object_statistics");
}
ilLPCronObjectStatistics::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

{
return true;
}
ilLPCronObjectStatistics::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

{
return false;
}
ilLPCronObjectStatistics::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

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

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

{
// all date related operations are based on this timestamp
// should be midnight of yesterday (see gatherUserData()) to always have full day
$this->date = strtotime("yesterday");
$message = array();
$count = 0;
$count += $this->gatherCourseLPData();
$count += $this->gatherTypesData();
$count += $this->gatherUserData();
if($count)
{
}
$result->setStatus($status);
return $result;
}

+ Here is the call graph for this function:

Field Documentation

ilLPCronObjectStatistics::$date
protected

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


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