private function getActiveUserTimeInLesson($lesson)
 {
     //$timeReport = new EfrontTimes();
     $userTimes = EfrontLesson::getUserActiveTimeInLesson($this->user['login'], $lesson->lesson['id']);
     $userTimes = EfrontTimes::formatTimeForReporting($userTimes);
     return $userTimes;
 }
         $message_type = 'failure';
         $smarty->assign("T_RULE_CHECK_FAILED", true);
         $ruleCheck = false;
     }
     $smarty->assign("T_USER_PROGRESS", $userProgress);
 }
 if ($_student_) {
     if (preg_match("#</object>#", $currentUnit['data']) || preg_match("#</applet>#", $currentUnit['data'])) {
         $smarty->assign("T_CONTAINS_FLASH", true);
     }
     //$smarty -> assign("T_NEXT_LESSON", $currentLesson -> getNextLesson());
     //$userTimeInUnit = EfrontTimes::formatTimeForReporting($times->getUserSessionTimeInUnit($currentUser->user['login'], $currentUnit['id']));
     $userTimeInUnit = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInUnit($currentUser->user['login'], $currentUnit['id']));
     $smarty->assign("T_USER_TIME_IN_UNIT", $userTimeInUnit);
     //$smarty -> assign("T_USER_CURRENT_TIME_IN_UNIT", $times->getUserCurrentSessionTimeInUnit($currentUser->user['login'], $currentUnit['id']));
     $userTimeInLesson = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($currentUser->user['login'], $currentLesson->lesson['id']));
     $smarty->assign("T_USER_CURRENT_TIME_IN_LESSON", $userTimeInLesson['total_seconds']);
     $smarty->assign("T_USER_TIME_IN_LESSON", $userTimeInLesson);
     foreach ($currentLesson->getConditions() as $value) {
         if ($value['type'] == 'time_in_lesson') {
             $smarty->assign("T_REQUIRED_TIME_IN_LESSON", $value['options'][0] * 60);
         }
     }
     if ($_change_ && $currentLesson->options['tracking'] && $currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_AUTOCOMPLETE && $ruleCheck && !in_array($currentUnit['id'], array_keys($seenContent))) {
         $smarty->assign("T_AUTO_SET_SEEN_UNIT", true);
     }
     if ($_change_ && $currentLesson->options['tracking'] && $currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_COMPLETEAFTERSECONDS && $ruleCheck && !in_array($currentUnit['id'], array_keys($seenContent)) && $userTimeInUnit['total_seconds'] > $currentUnit['options']['complete_time']) {
         $smarty->assign("T_AUTO_SET_SEEN_UNIT", true);
     }
     /*$hideFeedback = false;
     		foreach (new EfrontNoFeedbackFilterIterator(new EfrontVisitableAndEmptyFilterIterator($visitableIterator)) as $key => $value) {
 public function getLessonTimesForUsers($interval = array())
 {
     $usersTimes = array();
     $timesReport = new EfrontTimes($interval);
     $result = $timesReport->getLessonSessionTimesForUsers($this->lesson['id']);
     foreach ($result as $value) {
         $usersTimes[$value['users_LOGIN']] = $timesReport->formatTimeForReporting($value['time']);
     }
     return $usersTimes;
 }
     $testNames = eF_getTableDataFlat("tests t, content c", "t.id, c.name", "c.id=t.content_ID");
     $testNames = array_combine($testNames['id'], $testNames['name']);
     $result = eF_getTableData("logs", "*", "timestamp between {$from} and {$to} order by timestamp");
     foreach ($result as $key => $value) {
         $value['lessons_ID'] ? $result[$key]['lesson_name'] = $lessonNames[$value['lessons_ID']] : null;
         if ($value['action'] == 'content' || $value['action'] == 'tests' || $value['action'] == 'test_begin') {
             $result[$key]['content_name'] = $contentNames[$value['comments']];
         }
     }
     $analytic_log = $result;
     $smarty->assign("T_SYSTEM_LOG", $analytic_log);
 }
 $users = array();
 $result = eF_getTableData("logs, users", "users.name, users.surname, users.active, users_LOGIN, count(logs.id) as cnt ", "users.login=users_LOGIN and action = 'login' and logs.timestamp between {$from} and {$to} group by users_LOGIN order by count(logs.id) desc");
 //    $userTimes = EfrontUser :: getLoginTime(false, array('from' => $from, 'to' => $to));
 $timesReport = new EfrontTimes(array($from, $to));
 $userTimes = $timesReport->getSystemSessionTimesForUsers();
 foreach ($result as $value) {
     $users[$value['users_LOGIN']]['name'] = $value['name'];
     $users[$value['users_LOGIN']]['surname'] = $value['surname'];
     $users[$value['users_LOGIN']]['active'] = $value['active'];
     $users[$value['users_LOGIN']]['accesses'] = $value['cnt'];
     $users[$value['users_LOGIN']]['seconds'] = $userTimes[$value['users_LOGIN']];
 }
 $lessons = array();
 $result = eF_getTableData("logs", "*", "timestamp between {$from} and {$to}");
 foreach ($result as $value) {
     if ($value['lessons_ID']) {
         $lessons[$value['lessons_ID']] = array();
     }
 }
 $currentTheme = new themes($_SESSION['s_theme']);
 $newTime = '';
 $jsonValues = array();
 if ($_SESSION['s_login']) {
     $entity = getUserTimeTarget($_GET['HTTP_REFERER']);
     //Update times for this entity
     if ($_SESSION['s_lesson_user_type'] == 'student' && isset($_POST['user_total_time_in_unit']) && current($entity) == 'unit' && eF_checkParameter(key($entity), 'id')) {
         $newTime = $_POST['user_total_time_in_unit'];
         $jsonValues['entity'] = current($entity);
         $jsonValues['entity_id'] = current($entity);
         if ($newTime && is_numeric($newTime)) {
             $result = eF_executeNew("insert into users_to_content (users_LOGIN, content_ID, lessons_ID) values('" . $_SESSION['s_login'] . "', " . key($entity) . ", " . $_SESSION['s_lessons_ID'] . ") on duplicate key update total_time={$newTime}");
             $jsonValues['time_in_unit'] = EfrontTimes::formatTimeForReporting($newTime);
         } else {
             $jsonValues['old_time_in_unit'] = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInUnit($_SESSION['s_login'], key($entity)));
             $jsonValues['old_time_in_lesson'] = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($_SESSION['s_login'], $_SESSION['s_lessons_ID']));
         }
     }
     if (empty($_SESSION['last_periodic_check']) || time() - $_SESSION['last_periodic_check'] >= ceil($GLOBALS['configuration']['updater_period'] / 1000)) {
         $result = eF_executeNew("update user_times set time=time+(" . time() . "-timestamp_now),timestamp_now=" . time() . "\r\n\t\t\t\t\t\twhere session_expired = 0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN = '******'s_login'] . "'\r\n\t\t\t\t\t\tand entity = '" . current($entity) . "' and entity_id = '" . key($entity) . "'");
         $_SESSION['last_periodic_check'] = time();
         if ($currentTheme->options['sidebar_interface'] == 0) {
             if (empty($_SESSION['last_periodic_check_users']) || time() - $_SESSION['last_periodic_check_users'] >= 300) {
                 $_SESSION['last_periodic_check_users'] = $_SESSION['last_periodic_check'];
                 $online = EfrontUser::getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60);
                 $_SESSION['online_users'] = $online;
                 if ($currentTheme->options['sidebar_interface'] == 0) {
                     $jsonValues['online'] = $online;
                 }
             } else {
                 if ($currentTheme->options['sidebar_interface'] == 0) {
             		foreach ($traffic['users'] as $key => $value) {
             			$graph -> data[]    = array($count, $value['accesses']);
             			$graph -> xLabels[] = array($count++, formatLogin($key));
             		}
             		//pr($graph);
             		$graph -> xTitle = _USERS;
             		$graph -> yTitle = _ACCESSES;
             		$graph -> title  = _ACCESSESPERUSER;
 
             		echo json_encode($graph);
             		exit;
             	} else
 */
 if (isset($_GET['ajax']) && $_GET['ajax'] == 'graph_user_access') {
     $user = EfrontUserFactory::factory($_GET['entity']);
     $timesReport = new EfrontTimes();
     $cnt = 0;
     $result = $timesReport->getUserSessionTimeInSingleLessonPerDay($user->user['login'], $infoLesson->lesson['id']);
     foreach ($result as $key => $value) {
         $labels[$cnt] = $key;
         $count[$cnt++] = ceil($value / 60);
     }
     $graph = new EfrontGraph();
     $graph->type = 'line';
     for ($i = 0; $i < sizeof($labels); $i++) {
         $graph->data[] = array($i, $count[$i]);
         $graph->xLabels[] = array($i, formatTimestamp($labels[$i]));
     }
     $graph->xTitle = _DAY;
     $graph->yTitle = _MINUTES;
     $graph->title = _MINUTESPERDAY;
         $graph->type = 'line';
         for ($i = 0; $i < sizeof($labels); $i++) {
             $graph->data[] = array($i, $count[$i]);
             $graph->xLabels[] = array($i, '<span style = "white-space:nowrap">' . formatTimestamp($labels[$i]) . '</span>');
         }
         $graph->xTitle = _DAY;
         $graph->yTitle = _MINUTES;
         $graph->title = _MINUTESPERDAY;
         echo json_encode($graph);
         exit;
     }
 } catch (Exception $e) {
     handleAjaxExceptions($e);
 }
 //pr($infoUser -> getUserStatusInLessons());
 $timesReport = new EfrontTimes();
 if ($GLOBALS['configuration']['time_reports']) {
     if ($infoUser instanceof EfrontLessonUser) {
         $userTraffic = $infoUser->getLessonsActiveTimeForUser();
     }
 } else {
     $result = $timesReport->getUserSessionTimeInLessons($infoUser->user['login']);
     foreach ($result as $value) {
         $userTraffic[$value['lessons_ID']] = $value['time'];
     }
 }
 foreach ($userLessons as $id => $lesson) {
     $traffic['lessons'][$id] = $timesReport->formatTimeForReporting($userTraffic[$id]);
     $traffic['lessons'][$id]['name'] = $lesson->lesson['name'];
     $traffic['lessons'][$id]['active'] = $lesson->lesson['active'];
 }
Example #8
0
 foreach ($doneTests[$_GET['edit_user']] as $key => $value) {
     if (in_array($key, array_keys($testNames))) {
         $userStats['done_tests'][$key] = array('name' => $testNames[$key], 'score' => $value['average_score'], 'last_test_id' => $value['last_test_id'], 'active_test_id' => $value['active_test_id'], 'last_score' => $value['scores'][$value['last_test_id']], 'active_score' => $value['active_score'], 'times_done' => $value['times_done'], 'content_ID' => $value[$value['last_test_id']]['content_ID']);
     }
 }
 foreach ($scormDoneTests as $key => $value) {
     $userStats['scorm_done_tests'][$key] = array('name' => $value['name'], 'score' => $value['score'], 'content_ID' => $key);
 }
 unset($userStats['done_tests']['average_score']);
 $smarty->assign("T_USER_LESSONS_INFO", $userStats);
 $notDoneTests = array_diff(array_keys($testNames), array_keys($doneTests[$_GET['edit_user']]));
 $smarty->assign("T_PENDING_TESTS", $notDoneTests);
 if ($GLOBALS['configuration']['time_reports']) {
     $userTime = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($editedUser->user['login'], $currentLesson->lesson['id']));
 } else {
     $timeReport = new EfrontTimes();
     $userTime = $timeReport->getUserSessionTimeInLesson($editedUser->user['login'], $currentLesson->lesson['id']);
     $userTime = $timeReport->formatTimeForReporting($userTime);
 }
 $smarty->assign("T_USER_TIME", $userTime);
 $userProjects = EfrontStats::getStudentsAssignedProjects($currentLesson->lesson['id'], $editedUser->user['login']);
 $smarty->assign("T_USER_PROJECTS", $userProjects[$editedUser->user['login']]);
 if (G_VERSIONTYPE == 'enterprise') {
     #cpp#ifdef ENTERPRISE
     /** Get evaluations **/
     $evaluations = eF_getTableData("users JOIN module_hcd_events ON login = author", "login, name, surname,module_hcd_events.*", "module_hcd_events.users_login = '******'login'] . "' AND event_code = 10");
     $smarty->assign('T_EVALUATIONS', $evaluations);
 }
 #cpp#endif
 $moduleFieldsets = array();
 foreach ($currentUser->getModules() as $module) {
Example #9
0
 /**
  * Get user usage info
  *
  * This returns usage info for a user
  * <br/>Example:
  * <code>
  * $info = EfrontStats :: getUserUsageInfo('jdoe');                   //Get usage information for user jdoe
  * </code>
  * @param mixed $user Either a user login or a EfrontUser object
  * @return array the users' basic info
  * @since 3.5.0
  * @access public
  * @static
  */
 public static function getUserUsageInfo($user)
 {
     if (!$user instanceof EfrontUser) {
         $user = EfrontUserFactory::factory($user);
     }
     $info = array();
     $login_info = eF_getTableData("logs", "*", "users_LOGIN='******' and action = 'login'", "timestamp desc");
     $info['last_ip'] = eF_decodeIP($login_info[0]['session_ip']);
     $logins = array();
     foreach ($login_info as $login) {
         $logins[$login['id']] = $login;
     }
     $month_login_info = eF_getTableData("logs", "*", "users_LOGIN='******' and action = 'login' and timestamp > " . (time() - 2592000) . "");
     $month_logins = array();
     foreach ($month_login_info as $login) {
         $month_logins[$login['id']] = $login;
     }
     $week_login_info = eF_getTableData("logs", "*", "users_LOGIN='******' and action = 'login' and timestamp > " . (time() - 604800) . "");
     $week_logins = array();
     foreach ($week_login_info as $login) {
         $week_logins[$login['id']] = $login;
     }
     $timeReport = new EfrontTimes();
     $mean_duration = round($timeReport->getUserMeanSessionTime($user->login) / 60);
     $timeReport = new EfrontTimes(array(time() - 2592000, time()));
     $month_mean_duration = round($timeReport->getUserMeanSessionTime($user->login) / 60);
     $timeReport = new EfrontTimes(array(time() - 604800, time()));
     $week_mean_duration = round($timeReport->getUserMeanSessionTime($user->login) / 60);
     /*
             $temp = self :: getUserTimes($user -> login);
             sizeof($temp['duration']) > 0 ? $mean_duration = ceil((array_sum($temp['duration']) / sizeof($temp['duration'])) / 60) : $mean_duration = 0;
             $temp = self :: getUserTimes($user -> login, array('from' => time() - 2592000, 'to' => time()));
             sizeof($temp['duration']) > 0 ? $month_mean_duration = ceil((array_sum($temp['duration']) / sizeof($temp['duration']) / 60)) : $month_mean_duration = 0;
             $temp = self :: getUserTimes($user -> login, array('from' => time() - 604800, 'to' => time()));
             sizeof($temp['duration']) > 0 ? $week_mean_duration = ceil((array_sum($temp['duration']) / sizeof($temp['duration']) / 60)) : $week_mean_duration = 0;
     */
     $info['logins'] = $logins;
     if (sizeof($info['logins']) > 0) {
         $info['last_login'] = current($info['logins']);
     }
     $info['month_logins'] = $month_logins;
     $info['week_logins'] = $week_logins;
     $info['mean_duration'] = $mean_duration;
     $info['month_mean_duration'] = $month_mean_duration;
     $info['week_mean_duration'] = $week_mean_duration;
     return $info;
 }
Example #10
0
 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");
 }
 require_once $path . "includes/statistics/stats_filters.php";
 $directionsTree = new EfrontDirectionsTree();
 $directionsPaths = $directionsTree->toPathString();
 $course_id = $_GET['sel_course'];
 $infoCourse = new EfrontCourse($_GET['sel_course']);
 $infoCourse->course['num_lessons'] = $infoCourse->countCourseLessons();
 $constraints = array('table_filters' => $stats_filters);
 //$infoCourse -> course['num_students']   = sizeof($infoCourse -> getStudentUsers(false, $constraints));
 //$infoCourse -> course['num_professors'] = sizeof($infoCourse -> getProfessorUsers(false, $constraints));
 $infoCourse->course['category_path'] = $directionsPaths[$infoCourse->course['directions_ID']];
 $smarty->assign("T_CURRENT_COURSE", $infoCourse);
 $smarty->assign("T_STATS_ENTITY_ID", $_GET['sel_course']);
 try {
     $result = eF_getTableData("user_times ut join users_to_courses uc on ut.users_LOGIN=uc.users_LOGIN and ut.courses_ID=uc.courses_ID", "sum(time) as sum, count(distinct uc.users_LOGIN) as count", "completed=1 and uc.archive=0 and ut.courses_ID=" . $infoCourse->course['id'], "", "");
     if ($result[0]['sum']) {
         $smarty->assign("T_AVERAGE_COMPLETION_TIME", EfrontTimes::formatTimeForReporting($result[0]['sum'] / $result[0]['count']));
     }
     $roles = EfrontLessonUser::getLessonsRoles(true);
     $smarty->assign("T_ROLES_ARRAY", $roles);
     $rolesBasic = EfrontLessonUser::getLessonsRoles();
     $smarty->assign("T_BASIC_ROLES_ARRAY", $rolesBasic);
     foreach ($rolesBasic as $key => $role) {
         $constraints = array('archive' => false, 'table_filters' => $stats_filters, 'condition' => 'u.user_type = "' . $key . '"');
         $numUsers = $infoCourse->countCourseUsersAggregatingResults($constraints);
         if ($numUsers) {
             $usersPerRole[$key] = $numUsers;
         }
         //$role == 'student' ? $studentRoles[] = $key : $professorRoles[] = $key;
     }
     $infoCourse->course['users_per_role'] = $usersPerRole;
     $infoCourse->course['num_users'] = array_sum($usersPerRole);
Example #12
0
                 $db->Execute("drop table install_{$table}");
             } catch (Exception $e) {
             }
         }
     }
 }
 if (version_compare($dbVersion, '3.6.7') == -1) {
     $courses = eF_getTableData("courses", "*");
     foreach ($courses as $key => $value) {
         $options = unserialize($value['options']);
         if (!isset($options['certificate_export_method'])) {
             $options['certificate_export_method'] = 'rtf';
             eF_updateTableData('courses', array('options' => serialize($options)), 'id=' . $value['id']);
         }
     }
     EfrontTimes::upgradeFromUsersOnline();
 }
 if (version_compare($dbVersion, '3.6.10') == -1) {
     $result = eF_getTableData("users_to_projects", "*");
     foreach ($result as $value) {
         if (isset($value['filename']) && $value['filename'] != '') {
             try {
                 $file = new EfrontFile($value['filename']);
                 if ($file['directory'] == G_UPLOADPATH . $value['users_LOGIN'] . '/projects') {
                     $projectDirectory = G_UPLOADPATH . $value['users_LOGIN'] . '/projects/' . $value['projects_ID'] . '/';
                     if (!is_dir($projectDirectory)) {
                         EfrontDirectory::createDirectory($projectDirectory);
                     }
                     $file->rename($projectDirectory . $file['physical_name']);
                 }
             } catch (Exception $e) {