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; }
private function getActiveUserTimeInLesson($lesson) { //$timeReport = new EfrontTimes(); $userTimes = EfrontLesson::getUserActiveTimeInLesson($this->user['login'], $lesson->lesson['id']); $userTimes = EfrontTimes::formatTimeForReporting($userTimes); return $userTimes; }
$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) {
$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) {
$workSheet->setColumn(1, 3, 30); $workSheet->write(2, 1, _ACCESSNUMBER, $fieldLeftFormat); $workSheet->write(2, 2, $totalUserAccesses, $fieldRightFormat); $workSheet->write(3, 1, _TOTALACCESSTIME, $fieldLeftFormat); $time = EfrontTimes::formatTimeForReporting($totalUserTime); $workSheet->write(3, 2, $time['time_string'], $fieldRightFormat); $workSheet->write(5, 1, _USERSINFO . " (" . formatTimestamp($from) . " - " . formatTimestamp($to) . ")", $headerFormat); $workSheet->mergeCells(5, 1, 5, 3); $workSheet->write(6, 1, _LOGIN, $titleLeftFormat); $workSheet->write(6, 2, _ACCESSNUMBER, $titleLeftFormat); $workSheet->write(6, 3, _TOTALTIME, $titleLeftFormat); $row = 7; foreach ($users as $login => $value) { $workSheet->write($row, 1, formatLogin($login), $fieldLeftFormat); $workSheet->write($row, 2, $value['accesses'], $fieldCenterFormat); $time = EfrontTimes::formatTimeForReporting($value['seconds']); $workSheet->write($row++, 3, $time['time_string'], $fieldCenterFormat); } $workSheet =& $workBook->addWorkSheet("Analytic log"); $workSheet->setInputEncoding('utf-8'); $workSheet->setColumn(0, 0, 5); $workSheet->write(1, 1, _ANALYTICLOG, $headerFormat); $workSheet->mergeCells(1, 1, 1, 7); $workSheet->setColumn(1, 6, 30); $workSheet->write(2, 1, _LOGIN, $fieldLeftFormat); $workSheet->write(2, 2, _LESSON, $fieldLeftFormat); $workSheet->write(2, 3, _UNIT, $fieldLeftFormat); $workSheet->write(2, 4, _ACTION, $fieldLeftFormat); $workSheet->write(2, 5, _TIME, $fieldLeftFormat); $workSheet->write(2, 6, _IPADDRESS, $fieldLeftFormat); $row = 3;
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']; } $result = eF_getTableData("logs", "count(*)", "action = 'login' and users_LOGIN='******'login'] . "' order by timestamp"); $traffic['total_logins'] = $result[0]['count(*)']; $result = eF_getTableData("users_to_lessons", "lessons_ID, completed, to_timestamp", "archive=0 and users_LOGIN='******'login'] . "'"); $completionData = array(); foreach ($result as $value) { $completionData[$value['lessons_ID']] = $value; } //$completionData = array_combine($result["lessons_ID"], $result['completed']); foreach ($traffic['lessons'] as $lessonId => $value) { $traffic['lessons'][$lessonId]['completed'] = $completionData[$lessonId]['completed']; $traffic['lessons'][$lessonId]['to_timestamp'] = $completionData[$lessonId]['to_timestamp']; }
* lesson traffic */ try { $actions = array('login' => _LOGIN, 'logout' => _LOGOUT, 'lesson' => _ACCESSEDLESSON, 'content' => _ACCESSEDCONTENT, 'tests' => _ACCESSEDTEST, 'test_begin' => _BEGUNTEST, 'lastmove' => _NAVIGATEDSYSTEM); $smarty->assign("T_ACTIONS", $actions); $constraints = array('archive' => false, 'return_objects' => false, 'table_filters' => $stats_filters); $filteredUsers = $infoLesson->getLessonUsers($constraints); $users = array(); foreach ($filteredUsers as $user) { $users[$user['login']] = $user['active']; } // if ($GLOBALS['configuration']['time_reports']) { $traffic['users'] = $infoLesson->getUsersActiveTimeInLesson(); foreach ($traffic['users'] as $key => $value) { $traffic['users'][$key] = EfrontTimes::formatTimeForReporting($value); } } else { $traffic['users'] = $infoLesson->getLessonTimesForUsers(); } foreach ($traffic['users'] as $key => $user) { if (isset($statsFiltersUsers) && !in_array($key, array_keys($statsFiltersUsers))) { unset($traffic['users'][$key]); } } foreach ($traffic['users'] as $value) { $traffic['total_seconds'] += $value['total_seconds']; } $traffic['total_time'] = eF_convertIntervalToTime($traffic['total_seconds']); try { /*
$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) { if ($moduleFieldset = $module->getFieldsetSmartyTpl('lesson_progress')) { $moduleFieldsets[] = $moduleFieldset;
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);