$result = eF_getTableData("users_to_content", "visits, attempt_identifier", "content_ID={$unit['id']} and users_LOGIN='******'login']}'"); if (!empty($result)) { // vd($_SESSION['attempt_identifier']); // vd($result[0]['attempt_identifier']); $visits = $result[0]['visits']; if ($_SESSION['attempt_identifier'] != $result[0]['attempt_identifier']) { eF_updateTableData("users_to_content", array("visits" => $result[0]['visits'] + 1, "attempt_identifier" => $_SESSION['attempt_identifier']), "content_ID={$unit['id']} and users_LOGIN='******'login']}'"); $visits = $result[0]['visits'] + 1; } } else { eF_insertTableData("users_to_content", array("attempt_identifier" => $_SESSION['attempt_identifier'], "visits" => 1, "content_ID" => $unit['id'], "lessons_ID" => $unit['lessons_ID'], "users_LOGIN" => $scoUser->user['login'])); $visits = 1; } $remaining_times = $unit['options']['scorm_times'] - $visits; } } $newUserProgress = EfrontStats::getUsersLessonStatus($scoLesson, $scoUser->user['login']); $newPercentage = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['overall_progress']; $newConditionsPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['conditions_passed']; $newLessonPassed = $newUserProgress[$scoLesson->lesson['id']][$scoUser->user['login']]['lesson_passed']; if ($scoLesson->lesson['course_only'] && $_SESSION['s_courses_ID']) { $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'"); if ($res[0]['issued_certificate'] != "") { $courseCertified = true; } } echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, $scormState, $redirectTo, $trackActivityInfo, $courseCertified, $remaining_times)); } catch (Exception $e) { echo json_encode(array('error' => $e->getMessage())); } exit;
$nextLesson = $currentUser->getNextLesson($currentLesson, $_SESSION['s_courses_ID']); if ($currentLesson->lesson['course_only'] && isset($_SESSION['s_courses_ID'])) { $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'"); if ($res[0]['issued_certificate'] != "") { $courseCertified = true; } } echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, false, false, false, $courseCertified)); } catch (Exception $e) { handleAjaxExceptions($e); } exit; } if (isset($_GET['ajax']) && isset($_GET['check_conditions'])) { try { $newUserProgress = EfrontStats::getUsersLessonStatus($currentLesson, $currentUser->user['login']); $newPercentage = $newUserProgress[$currentLesson->lesson['id']][$currentUser->user['login']]['overall_progress']; $newConditionsPassed = $newUserProgress[$currentLesson->lesson['id']][$currentUser->user['login']]['conditions_passed']; $newLessonPassed = $newUserProgress[$currentLesson->lesson['id']][$currentUser->user['login']]['lesson_passed']; $nextLesson = $currentUser->getNextLesson($currentLesson, $_SESSION['s_courses_ID']); if ($currentLesson->lesson['course_only'] && isset($_SESSION['s_courses_ID'])) { $res = eF_getTableData("users_to_courses", "issued_certificate", "courses_ID=" . $_SESSION['s_courses_ID'] . " and users_LOGIN='******'s_login'] . "'"); if ($res[0]['issued_certificate'] != "") { $courseCertified = true; } } echo json_encode(array($newPercentage, $newConditionsPassed, $newLessonPassed, false, false, false, $courseCertified)); } catch (Exception $e) { handleAjaxExceptions($e); } exit;
/** * Mark seen nodes * * This function gets the units that the user has seen * and sets the 'seen' property either to 1 or to 0. * <br/>Example: * <code> * $currentContent = new EfrontContentTree(5); //Initialize content for lesson with id 5 * $currentContent -> markSeenNodes($currentUser); //Mark the seen content for user in object $currentUser * </cod> * * @param mixed $user Either a user login or an EfrontUser object * @since 3.5.0 * @access public */ public function markSeenNodes($user) { $user instanceof EfrontUser ? $login = $user->user['login'] : ($login = $user); $seenContent = EfrontStats::getStudentsSeenContent($this->lessonId, $login); $seenNodes = array_keys($seenContent[$this->lessonId][$login]); $resultScorm = eF_getTabledataFlat("scorm_data", "content_ID, lesson_status", "users_LOGIN='******'"); $resultScorm = array_combine($resultScorm['content_ID'], $resultScorm['lesson_status']); $result = eF_getTableData("content c, completed_tests ct, tests t", "t.content_ID, ct.status, ct.timestamp, ct.archive, t.keep_best", "ct.status != 'deleted' and c.id = t.content_ID and c.lessons_ID = " . $this->lessonId . " and ct.tests_ID = t.id and ct.users_LOGIN='******'"); foreach ($result as $value) { if ($value['keep_best'] && $value['status'] == 'passed') { $resultTests[$value['content_ID']] = $value['status']; } else { if (!$value['archive'] && !isset($resultTests[$value['content_ID']])) { $resultTests[$value['content_ID']] = $value['status']; } } if (!$value['archive']) { $resultTestsTimes[$value['content_ID']] = $value['timestamp']; } } $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($this->tree), RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { in_array($key, $seenNodes) || $resultScorm[$key] == 'completed' || $resultScorm[$key] == 'passed' ? $value['seen'] = 1 : ($value['seen'] = 0); if ($resultScorm[$key]) { $resultScorm[$key] == 'incomplete' ? $value['incomplete'] = 1 : ($value['incomplete'] = 0); $resultScorm[$key] == 'failed' ? $value['failed'] = 1 : ($value['failed'] = 0); } else { if ($resultTests[$key]) { $resultTests[$key] == 'incomplete' ? $value['incomplete'] = $resultTestsTimes[$key] : ($value['incomplete'] = 0); $resultTests[$key] == 'failed' ? $value['failed'] = 1 : ($value['failed'] = 0); } } } //Empty top level unit should be marked as complete if all sub units are marked as complete foreach ($iterator as $key => $value) { if (!$value['has_data'] && $value['ctg_type'] == 'theory') { $childIterator = new EfrontVisitableFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($value), RecursiveIteratorIterator::SELF_FIRST)); $seenChildNodes = true; $has_child = false; foreach ($childIterator as $key2 => $value2) { $has_child = true; if (!$value2['seen'] && $value2['has_data']) { $seenChildNodes = false; } } $seenChildNodes && $has_child ? $value['seen'] = 1 : ($value['seen'] = 0); } } }
private function doSynchronizeCourseLessons() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $courses = array(); foreach (EfrontCourse::getCourses() as $value) { $courses[$value['id']] = $value['name']; } $form = new HTML_QuickForm("file_encodings_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=sync_course_lessons&do=learning", "", null, true); $form->addElement('static', '', _MODULE_ADMINISTRATOR_TOOLS_THISWILLPROPAGATECOMPLETIONSTATUSFROMACOURSETOITSLESSONSFORALLUSERS); $form->addElement('select', 'course', _COURSE, $courses); $form->addElement('advcheckbox', 'set_completed', _MODULE_ADMINISTRATOR_TOOLS_UPDATECOMPLETEDLESSONS . '</span>'); $form->addElement('static', '', _MODULE_ADMINISTRATOR_TOOLS_SETCOMPLETEDLESSONSTOTHESAMEDATE); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { try { $updates = 0; $stats = EfrontStats::getUsersCourseStatus($form->exportValue('course')); foreach ($stats[$form->exportValue('course')] as $value) { if ($value['completed']) { foreach ($value['lesson_status'] as $lesson_id => $lesson_status) { if (!$lesson_status['completed'] || $form->exportValue('set_completed')) { eF_updateTableData("users_to_lessons", array('completed' => 1, 'to_timestamp' => $value['completion_date'], 'score' => $value['score']), "lessons_ID={$lesson_id} and users_LOGIN='******'login'] . "'"); $updates++; } } } } $message = str_replace("%x", $updates, _MODULE_ADMINISTRATOR_TOOLS_PERFORMEDXUPDATES); $message_type = 'success'; } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } $this->setMessageVar($message, $message_type); } $smarty->assign("T_SYNC_COURSE_LESSONS_FORM", $form->toArray()); }
foreach ($userCourses as $courseId => $value) { $coursesTotalSec = 0; //$coursesAvgScore += $value['score']; if ($value['completed']) { $completedScores[] = $value['score']; } $data[$courseId] = array(_NAME => $value['name'], _CATEGORY => str_replace(" → ", " -> ", $directionsTreePaths[$value['directions_ID']]), _REGISTRATIONDATE => formatTimestamp($value['active_in_course']), _COMPLETED => $value['completed'] ? _YES . ($value['to_timestamp'] ? ', ' . _ON . ' ' . formatTimestamp($value['to_timestamp']) : '') : '-', _SCORE => formatScore($value['score']) . '%', 'active' => $value['active']); $courseLessons = $infoUser->getUserStatusInCourseLessons(new EfrontCourse($value)); if (!empty($courseLessons)) { $subsectionFormatting = array(_NAME => array('width' => '68%', 'fill' => true), _COMPLETED => array('width' => '13%', 'fill' => true, 'align' => 'C'), _SCORE => array('width' => '9%', 'fill' => true, 'align' => 'R')); if ($GLOBALS['configuration']['time_reports']) { $subsectionFormatting[_ACTIVETIMEINLESSON] = array('width' => '10%', 'fill' => true, 'align' => 'R'); } else { $subsectionFormatting[_TIME] = array('width' => '10%', 'fill' => true, 'align' => 'R'); } $result = EfrontStats::getStudentsDoneTests($courseLessons, $infoUser->user['login']); $userDoneTests = array(); foreach ($result[$infoUser->user['login']] as $test) { $userDoneTests[$test['lessons_ID']][] = $test; } $subSectionData = array(); foreach ($courseLessons as $lessonId => $courseLesson) { $courseLesson = $courseLesson->lesson; if ($GLOBALS['configuration']['time_reports']) { $coursesTotalSec += $courseLesson['active_time_in_lesson']['total_seconds']; } else { $coursesTotalSec += $courseLesson['time_in_lesson']['total_seconds']; } $subSectionData[$lessonId] = array(_NAME => $courseLesson['name'], _COMPLETED => $courseLesson['completed'] ? _YES . ($courseLesson['timestamp_completed'] ? ', ' . _ON . ' ' . formatTimestamp($courseLesson['timestamp_completed']) : '') : '-', _SCORE => formatScore($courseLesson['score']) . '%'); if ($GLOBALS['configuration']['time_reports']) { $subSectionData[$lessonId][_ACTIVETIMEINLESSON] = $courseLesson['active_time_in_lesson']['time_string'];
//strip object, we don't need it if ($course->course['completed']) { $coursesScores[] = $course->course['score']; $coursesCEUS[] = $course->course['ceu']; } else { unset($userCourses[$key]['ceu']); } } $smarty->assign("T_USER_COURSES", $userCourses); $userLessons = $editedUser->getUserStatusInLessons(); foreach ($userLessons as $key => $value) { if (!in_array($value->lesson['user_type'], array_keys($studentRoles))) { unset($userLessons[$key]); } } $result = EfrontStats::getStudentsDoneTests($userLessons, $editedUser->user['login']); $feedbacks = eF_getTableDataFlat("tests t, content c", "t.id, t.content_ID", "c.id=t.content_ID and c.ctg_type='feedback'"); $labels = array('completed' => _COMPLETED, 'passed' => _PASSED, 'failed' => _FAILED, 'incomplete' => _PENDING); foreach ($result[$editedUser->user['login']] as $contentId => $value) { if (!in_array($contentId, $feedbacks['content_ID'])) { $value['status'] = $labels[$value['status']]; $userDoneTests[$value['lessons_ID']][] = $value; } } $smarty->assign("T_USER_TESTS", $userDoneTests); foreach ($userLessons as $key => $lesson) { if ($lesson->lesson['course_only']) { foreach ($courseLessons as $courseId => $foo) { if (isset($courseLessons[$courseId][$key])) { $courseLessons[$courseId][$key] = $lesson->lesson; } elseif ($foo->lesson) {
$column = 1; foreach ($lessonProjects as $id => $project) { $row = 1; $workSheet->setColumn($column, $column, 20); $workSheet->write($row++, $column, $project->project['title'], $fieldCenterFormat); foreach ($projectsInfo[$id]['done'] as $results) { if (in_array($results['users_LOGIN'], array_keys($rows))) { $workSheet->write($rows[$results['users_LOGIN']], $column, formatScore(round($results['grade'], 2)) . "%", $fieldCenterFormat); } } $column++; } } //add a separate sheet for each distinct student of that lesson //$doneTests = EfrontStats :: getStudentsDoneTests($infoLesson -> lesson['id']); $assignedProjects = EfrontStats::getStudentsAssignedProjects($infoLesson->lesson['id']); //Changed adding a worksheet for each user in lesson reports because it could crash file with more than 2000 users (#854) $workSheet =& $workBook->addWorksheet('Students'); $workSheet->setInputEncoding('utf-8'); $row = 0; $workSheet->write($row, 0, $infoLesson->lesson['name'], $headerBigFormat); foreach ($students as $user) { $workSheet->mergeCells($row, 0, $row++, 9); $workSheet->write($row, 0, formatLogin($user['login']), $fieldCenterFormat); $workSheet->mergeCells($row, 0, $row++, 9); $workSheet->setColumn(0, 0, 40); $workSheet->write(++$row, 0, _LESSONROLE, $headerFormat); $workSheet->mergeCells($row, 0, $row, 1); $workSheet->write(++$row, 0, $roles[$user['role']], $fieldCenterFormat); $workSheet->mergeCells($row, 0, $row, 1); if ($GLOBALS['configuration']['time_reports']) {
isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $recentTests = array_slice($recentTests, $offset, $limit, true); } $smarty->assign("T_PENDING_TESTS", $recentTests); !$skillgap_tests ? $smarty->display('professor.tpl') : $smarty->display('administrator.tpl'); exit; } } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } try { if ($_student_ && !$skillgap_tests) { $seenContent = EfrontStats::getStudentsSeenContent($currentLesson->lesson['id'], $currentUser->user['login']); $seenContent = $seenContent[$currentLesson->lesson['id']][$currentUser->user['login']]; if ($currentLesson->options['rules']) { $ruleCheck = $currentContent->checkRules($currentUnit['id'], $seenContent); } if (isset($_GET['view_unit']) && eF_checkParameter($_GET['view_unit'], 'id') && (!$GLOBALS['currentLesson']->options['rules'] || $ruleCheck === true)) { $visitableIterator = new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST))); $smarty->assign("T_CONTENT_TREE", $currentContent->toHTML(false, 'dhtmlContentTree', array('truncateNames' => 25, 'selectedNode' => $currentUnit['id']))); $smarty->assign("T_UNIT", $currentUnit); $smarty->assign("T_NEXT_UNIT", $currentContent->getNextNode($currentUnit, $visitableIterator)); $smarty->assign("T_PREVIOUS_UNIT", $currentContent->getPreviousNode($currentUnit, $visitableIterator)); //Next and previous units are needed for navigation buttons $smarty->assign("T_PARENT_LIST", $currentContent->getNodeAncestors($currentUnit)); //Parents are needed for printing the titles $test = new EfrontTest($currentUnit['id'], true); $status = $test->getStatus($currentUser, $_GET['show_solved_test']);
public static function lightGetUserStatusInLesson($login, $currentLesson, $seenContent, $visitableIterator) { $visitableTestIds = $visitableUnits = array(); foreach ($visitableIterator as $key => $value) { if ($value['active']) { $visitableUnits[$key] = $key; if ($value['ctg_type'] == 'tests' || $value['ctg_type'] == 'scorm_test') { $visitableTestIds[$key] = $key; } } } $overallProgress = 0; if (sizeof($visitableUnits) > 0) { $overallProgress = round(100 * sizeof(array_intersect(array_keys($visitableUnits), array_keys($seenContent))) / sizeof($visitableUnits), 2); } $conditions = $currentLesson->getConditions(); foreach ($conditions as $condition) { if ($condition['time_in_lesson']) { $time_condition = true; } } if ($time_condition) { $usersTimesInLessonContent = EfrontLesson::getUserActiveTimeInLesson($login, $currentLesson->lesson['id']); } else { $usersTimesInLessonContent = null; } list($conditionsMet, $lessonPassed) = EfrontStats::checkConditions($seenContent, $conditions, $visitableUnits, $visitableTestIds, $usersTimesInLessonContent); $status = eF_getTableData("users_to_lessons", "*", "users_LOGIN='******' and lessons_ID={$currentLesson->lesson['id']}"); $userProgress = array('completed' => $status[0]['completed'], 'score' => $status[0]['score'], 'overall_progress' => $overallProgress, 'lesson_passed' => $lessonPassed, 'total_conditions' => sizeof($conditions), 'conditions_passed' => array_sum($conditionsMet)); return $userProgress; }
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; } } $smarty->assign("T_MODULE_FIELDSETS", $moduleFieldsets);
/** * Analyse completed test * * This function is used to analyse completed test. Scores are calculated for * each unit and subunit, based on the corresponding questions performance. * <br/>Example: * <code> * list($parentScores, $analysisCode) = $completedTest -> analyseTest(); * </code> * The function returns an array with 2 separate elements: The first element is the array * of scores per unit, which is needed in order to display the chart. The second element * is the content tree, where the scores per unit are depicted. * * @return array A results array. * @since 3.5.2 * @access public */ public function analyseTest() { $parentScores = array(); foreach ($this->questions as $question) { $questionIds[$question->question['content_ID']]['score'] += $question->score; $questionIds[$question->question['content_ID']]['total']++; $question->score > 0 ? $questionIds[$question->question['content_ID']]['correct'] += $question->score / 100 : null; } $questionsStats = EfrontStats::getQuestionsUnitStatistics($this->questions); //Get unit names and ids $content = new EfrontContentTree(key($this->getLesson())); if (isset($_GET['entity']) && $_GET['entity']) { $temp = $content->seekNode($_GET['entity']); $tree[0] = new EfrontUnit(array('id' => 0, 'name' => _NOUNIT, 'active' => 1, $temp['id'] => $temp)); //Add a bogus unit to hold questions which do not belong to a unit $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($tree), RecursiveIteratorIterator::SELF_FIRST)); } else { $tree = $content->tree; $tree[0] = new EfrontUnit(array('id' => 0, 'name' => _NOUNIT, 'active' => 1)); //Add a bogus unit to hold questions which do not belong to a unit $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST)); } foreach ($iterator as $key => $value) { if ($key != 0) { foreach ($content->getNodeAncestors($key) as $id => $foo) { $parentScores[$foo['id']]['score'] += $questionIds[$key]['score']; $parentScores[$foo['id']]['total'] += $questionIds[$key]['total']; $parentScores[$foo['id']]['correct'] += $questionIds[$key]['correct']; } $parentScores[$key]['this_score'] += $questionIds[$key]['score']; $parentScores[$key]['this_total'] += $questionIds[$key]['total']; $parentScores[$key]['this_correct'] += $questionIds[$key]['correct']; $parentScores[$key]['name'] = $value['name']; // Check if this chapter is a parent one. if (isset($content->tree[$key])) { $parentScores[$key]['top_level'] = 1; } else { $parentScores[$key]['top_level'] = 0; } } } foreach ($parentScores as $id => $value) { if ($value['total']) { $parentScores[$id]['percentage'] = round($value['score'] / $value['total'], 2); } if ($value['this_total']) { $parentScores[$id]['this_percentage'] = round($value['this_score'] / $value['this_total'], 2); } if ($value['total']) { $options['custom'][$id] = ' <span style = "margin-left:20px;color:gray">' . $parentScores[$id]['percentage'] . '% [' . $value['correct'] . '/' . $value['total'] . ']</span> <img src = "images/16x16/information.png" style = "vertical-align:middle" alt = "" title = "' . _THISLEVEL . ': ' . $parentScores[$id]['this_percentage'] . '% [' . $value['this_correct'] . '/' . $value['this_total'] . ']'; if ($value['total'] - $value['this_total'] > 0) { $options['custom'][$id] .= '/ ' . _BELOWLEVELS . ': ' . round(($value['score'] - $value['this_score']) / ($value['total'] - $value['this_total']), 2) . '% [' . ($value['correct'] - $value['this_correct']) . '/' . ($value['total'] - $value['this_total']) . '] '; } $options['custom'][$id] .= '">'; } else { unset($parentScores[$id]); } } $iterator = new analyseTestFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST)), array_keys($parentScores)); $options['show_hide'] = false; $options['noclick'] = true; //$options['tree_root'] = array('name' => _BACKTOTOP, 'class' => 'examples', 'onclick' => "$('analysis_frame').src = $('analysis_frame').src.replace(/selected_unit=(\d*)/, 'selected_unit='+Element.extend(this).up().id.replace(/node/, ''));"); //$options['onclick'] = "re = new RegExp(this.up().id.replace(/node/, ''), 'g');if(treeObj.getNodeOrders().match(re).length > 1) $('analysis_frame').src = $('analysis_frame').src.replace(/selected_unit=(\d*)/, 'selected_unit='+Element.extend(this).up().id.replace(/node/, ''));"; $options['onclick'] = "showGraph(\$('proto_chart'), 'graph_test_analysis', Element.extend(this).up().id.replace(/node/, ''));"; return array($parentScores, $content->toHTML($iterator, false, $options)); }
//$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"); }
/** * Prepare certificate for user * * This function is used to prepare the certificate that * will be issued to the specified user. It returns an array with the certificate data * <br/>Example: * <code> * $certificate = $course -> prepareCertificate('jdoe'); * </code> * * @param string $login The user to prepare a certificate for * @return string The certificate data * @since 3.5.0 * @access public */ public function prepareCertificate($login, $time = '') { $login = EfrontUser::convertArgumentToUserLogin($login); $courseUser = EfrontUserFactory::factory($login); $userStats = EfrontStats::getUsersCourseStatus($this, $login); $data = array('organization' => $GLOBALS['configuration']['site_name'], 'course_name' => $this->course['name'], 'user_surname' => $courseUser->user['surname'], 'user_name' => $courseUser->user['name'], 'serial_number' => md5(uniqid(mt_rand(), true)), 'grade' => $userStats[$this->course['id']][$login]['score'], 'date' => $time != '' ? $time : time()); $data = serialize($data); $modules = eF_loadAllModules(); foreach ($modules as $module) { $module->onPrepareCourseCertificate($login, $this->course['id'], $data); } return $data; }
} } $smarty->assign("T_LESSON_INFO", $lessonInformation); if (!$_admin_) { $seenContent = EfrontStats::getStudentsSeenContent($currentLesson->lesson['id'], $currentUser->user['login']); //Get the passing score for each "specific_test" rule $allTestsScore = eF_getTableDataFlat("tests", "content_ID,mastery_score"); if (sizeof($allTestsScore) > 0) { $allTestsScore = array_combine($allTestsScore['content_ID'], $allTestsScore['mastery_score']); } else { $allTestsScore = array(); } foreach ($conditions as $key => $condition) { if ($condition['type'] == 'specific_test') { $conditions[$key]['test_passing_score'] = $allTestsScore[$condition['options'][0]]; } } $times = new EfrontTimes(); list($conditionsStatus, $lessonPassed) = EfrontStats::checkConditions($seenContent[$currentLesson->lesson['id']][$currentUser->user['login']], $conditions, $visitableContentIds, $testsIds, EfrontLesson::getUserActiveTimeInLesson($currentUser->user['login'], $currentLesson->lesson['id'])); $smarty->assign("T_CONDITIONS", $conditions); $smarty->assign("T_CONDITIONS_STATUS", $conditionsStatus); //$smarty -> assign("T_LESSON_PASSED", $lessonPassed); foreach ($iterator = new EfrontAttributeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree)), array('id', 'name')) as $key => $value) { $key == 'id' ? $ids[] = $value : ($names[] = $value); } $smarty->assign("T_TREE_NAMES", array_combine($ids, $names)); $smarty->assign("T_BASE_URL", "ctg=lesson_information"); } else { $smarty->assign("T_BASE_URL", "ctg=lessons&lesson_info=" . $currentLesson->lesson['id']); } }
/** * Set seen unit * * This function is used to set the designated unit as seen or not seen, * according to $seen parameter. It also sets current unit to be the seen * unit, if we are setting a unit as seen. Otherwise, the current unit is * either leaved unchanged, or, if it matches the unset unit, it points * to another seen unit. * <br/>Example: * <code> * $user -> setSeenUnit(32, 2, true); //Set the unit with id 32 in lesson 2 as seen * $user -> setSeenUnit(32, 2, false); //Set the unit with id 32 in lesson 2 as not seen * </code> * From version 3.5.2 and above, this function also sets the lesson as completed, if the conditions are met * * @param mixed $unit The unit to set status for, can be an id or an EfrontUnit object * @param mixed $lesson The lesson that the unit belongs to, can be an id or an EfrontLesson object * @param boolean $seen Whether to set the unit as seen or not * @return boolean true if the lesson was completed as well * @since 3.5.0 * @access public */ public function setSeenUnit($unit, $lesson, $seen) { if (isset($this->coreAccess['content']) && $this->coreAccess['content'] != 'change') { //If user type is not plain 'student' and is not set to 'change' mode, do nothing return true; } if ($unit instanceof EfrontUnit) { //Check validity of $unit $unit = $unit['id']; } elseif (!eF_checkParameter($unit, 'id')) { throw new EfrontContentException(_INVALIDID . ": {$unit}", EfrontContentException::INVALID_ID); } if ($lesson instanceof EfrontLesson) { //Check validity of $lesson $lesson = $lesson->lesson['id']; } elseif (!eF_checkParameter($lesson, 'id')) { throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID); } $lessons = $this->getLessons(); if (!in_array($lesson, array_keys($lessons))) { //Check if the user is actually registered in this lesson throw new EfrontUserException(_USERDOESNOTHAVETHISLESSON . ": " . $lesson, EfrontUserException::USER_NOT_HAVE_LESSON); } $result = eF_getTableData("users_to_lessons", "done_content, current_unit", "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson); sizeof($result) > 0 ? $doneContent = unserialize($result[0]['done_content']) : ($doneContent = array()); $current_unit = 0; if ($seen) { $doneContent[$unit] = $unit; $current_unit = $unit; } else { if (isset($doneContent[$unit])) { //Because of Fatal error: Cannot unset string offsets error unset($doneContent[$unit]); } if ($unit == $result[0]['current_unit']) { sizeof($doneContent) ? $current_unit = end($doneContent) : ($current_unit = 0); } } sizeof($doneContent) ? $doneContent = serialize($doneContent) : ($doneContent = null); eF_updateTableData("users_to_lessons", array('done_content' => $doneContent, 'current_unit' => $current_unit), "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson); // $cacheKey = "user_lesson_status:lesson:".$lesson."user:"******"type" => EfrontEvent::CONTENT_COMPLETION, "users_LOGIN" => $this->user['login'], "lessons_ID" => $lesson, "entity_ID" => $current_unit)); } //Set the lesson as complete, if it can be. $completedLesson = false; $userProgress = EfrontStats::getUsersLessonStatus($lesson, $this->user['login']); $userProgress = $userProgress[$lesson][$this->user['login']]; //eF_updateTableData("users_to_lessons", array('progress' => $userProgress['overall_progress']), "users_LOGIN='******'login']."' and lessons_ID=".$lesson); if ($seen) { if ($userProgress['lesson_passed'] && !$userProgress['completed']) { $lesson = new EfrontLesson($lesson); if ($lesson->options['auto_complete']) { $userProgress['tests_avg_score'] ? $avgScore = $userProgress['tests_avg_score'] : ($avgScore = 100); $timestamp = _AUTOCOMPLETEDAT . ': ' . date("Y/m/d, H:i:s"); $this->completeLesson($lesson, $avgScore, $timestamp); $completedLesson = true; } } if (!self::$cached_modules) { self::$cached_modules = eF_loadAllModules(); } // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen foreach (self::$cached_modules as $module) { $module->onCompleteUnit($unit, $this->user['login']); } } return $completedLesson; }
$modulesToRemove[] = 'course_reports'; $modulesToRemove[] = 'fuze_meetings'; $modulesToRemove[] = 'training_reports'; } #cpp#endif if (G_VERSIONTYPE != 'enterprise') { #cpp#ifndef ENTERPRISE $modulesToRemove[] = 'branch_reports'; $modulesToRemove[] = 'jobs_manager'; } #cpp#endif if (is_file('post_install.php')) { include 'post_install.php'; runPostInstallationFunctions(); } EfrontStats::createViews(); if (!isset($_GET['unattended'])) { header("location:" . $_SERVER['PHP_SELF'] . "?finish=1"); exit; } } } catch (Exception $e) { Installation::handleInstallationExceptions($e); } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $form->setJsWarnings('The following errors occured:', 'Please correct the above errors'); $form->setRequiredNote('* Denotes mandatory fields');