//$result = eF_getTableData("logs", "*", "timestamp between $from and $to and users_LOGIN in ('".implode("','", $user_logins)."') order by timestamp desc"); $result = eF_getTableData("logs", "*", "users_LOGIN in ('" . implode("','", $user_logins) . "') order by timestamp desc"); foreach ($result as $key => $value) { $value['lessons_ID'] ? $result[$key]['lesson_name'] = $lessonNames[$value['lessons_ID']] : null; if ($value['action'] == 'content') { $result[$key]['content_name'] = $contentNames[$value['comments']]; } else { if ($value['action'] == 'tests' || $value['action'] == 'test_begin') { $result[$key]['content_name'] = $testNames[$value['comments']]; } } } $smarty->assign("T_USER_LOG", $result); $traffic = array(); $traffic['lessons'] = array(); $allStats = EfrontStats::getUsersTimeAll(); //$allStats = EfrontStats :: getUsersTimeAll($from, $to); $result = EfrontLesson::getLessons(); $probed_lessons = array(); foreach ($result as $value) { $probed_lessons[$value['id']] = array("lessons_ID" => $value['id'], "lessons_name" => $value['name'], "active" => $value['active']); } foreach ($probed_lessons as $id => $lesson) { $userTraffic = $allStats[$id]; //$userTraffic = EfrontStats :: getUsersTime($id, $user_logins, $from, $to); foreach ($user_logins as $user => $login) { if ($userTraffic[$login]['accesses']) { if (!isset($traffic['lessons'][$id])) { $traffic['lessons'][$id] = $userTraffic[$login]; $traffic['lessons'][$id]['name'] = $lesson['lessons_name']; $traffic['lessons'][$id]['active'] = $lesson['active'];
public static function upgradeFromUsersOnline() { //Check if the users_online table actually exists. If not, then there is no need for upgrade try { $result = $GLOBALS['db']->GetAll("describe users_online"); } catch (Exception $e) { return false; } //Get the first log entry $result = eF_getTableData("logs", "timestamp", "", "timestamp", "", "1"); $dateParts = getdate($result[0]['timestamp']); $firstDay = mktime(0, 0, 0, $dateParts['mon'], $dateParts['mday'], $dateParts['year']); //Delete old upgrade attempts eF_deleteTableData("user_times"); //Get system times for users $timeNow = time(); for ($t = $firstDay; $t <= $timeNow - 86400; $t += 86400) { $userTimes[$t] = EfrontTimes::getDeprecatedUserTimesPerDay(array('from' => $t, 'to' => $t + 86400)); } foreach ($userTimes as $timestamp => $users) { foreach ($users as $login => $times) { $fields = array('session_timestamp' => $timestamp, 'session_id' => 'from 3.6.6 upgrade', 'session_expired' => 1, 'users_LOGIN' => $login, 'timestamp_now' => $timestamp, 'time' => $times['total_seconds'], 'lessons_ID' => NULL, 'courses_ID' => NULL, 'entity' => 'system', 'entity_ID' => 0); eF_insertTableData("user_times", $fields); } } //Get times spent in SCORM $scormTimes = eF_getTableData("scorm_data sd, content c", "sd.total_time, sd.users_LOGIN, c.lessons_ID", "c.id=sd.content_ID"); $scormSeconds = array(); foreach ($scormTimes as $value) { if (!isset($scormSeconds[$value['lessons_ID']][$value['users_LOGIN']])) { $scormSeconds[$value['lessons_ID']][$value['users_LOGIN']] = 0; } $scormSeconds[$value['lessons_ID']][$value['users_LOGIN']] += convertTimeToSeconds($value['total_time']); } //Get times spent in lessons, as reported by system function $userTimes = EfrontStats::getUsersTimeAll(); foreach ($userTimes as $lessonId => $users) { foreach ($users as $login => $user) { if ($user['total_seconds'] || $scormSeconds[$lessonId][$login]) { //If SCO times are bigger than lesson times, then use SCO times if ($user['total_seconds'] < $scormSeconds[$lessonId][$login]) { $user['total_seconds'] = $scormSeconds[$lessonId][$login]; } $fields = array('session_timestamp' => time(), 'session_id' => 'from 3.6.6 upgrade', 'session_expired' => 1, 'users_LOGIN' => $login, 'timestamp_now' => time(), 'time' => $user['total_seconds'], 'lessons_ID' => $lessonId, 'courses_ID' => NULL, 'entity' => 'lesson', 'entity_ID' => $lessonId); eF_insertTableData("user_times", $fields); } } } $GLOBALS['db']->Execute("drop table users_online"); }