ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCronObjectStatisticsCheck Class Reference
+ Collaboration diagram for ilCronObjectStatisticsCheck:

Public Member Functions

 __construct ()
 check ()
 gatherCourseLPData ()
 gatherTypesData ()
 gatherUserData ()

Detailed Description

Definition at line 34 of file class.ilCronObjectStatisticsCheck.php.

Constructor & Destructor Documentation

ilCronObjectStatisticsCheck::__construct ( )

Definition at line 36 of file class.ilCronObjectStatisticsCheck.php.

References $ilLog.

{
global $ilLog,$ilDB;
$this->log =& $ilLog;
$this->db =& $ilDB;
// 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");
}

Member Function Documentation

ilCronObjectStatisticsCheck::check ( )

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

References gatherCourseLPData(), gatherTypesData(), and gatherUserData().

{
$this->gatherTypesData();
$this->gatherUserData();
}

+ Here is the call graph for this function:

ilCronObjectStatisticsCheck::gatherCourseLPData ( )

Definition at line 55 of file class.ilCronObjectStatisticsCheck.php.

References $failed, ilObject\_getObjectsByType(), ilLPStatusWrapper\_lookupCompletedForObject(), ilLPStatusWrapper\_lookupFailedForObject(), ilLPStatusWrapper\_lookupInProgressForObject(), ilLPObjSettings\_lookupMode(), LP_MODE_DEACTIVATED, and LP_MODE_UNDEFINED.

Referenced by check().

{
global $tree, $ilDB;
// 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/Tracking/classes/class.ilLPObjSettings.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
$mode = ilLPObjSettings::_lookupMode($crs_id);
if($mode == LP_MODE_DEACTIVATED || $mode == LP_MODE_UNDEFINED)
{
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);
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronObjectStatisticsCheck::gatherTypesData ( )

Definition at line 116 of file class.ilCronObjectStatisticsCheck.php.

References $data, and ilTrQuery\getObjectTypeStatistics().

Referenced by check().

{
global $ilDB;
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);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronObjectStatisticsCheck::gatherUserData ( )

Definition at line 144 of file class.ilCronObjectStatisticsCheck.php.

References $row.

Referenced by check().

{
global $ilDB;
$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);
}
}

+ Here is the caller graph for this function:


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