function beforeLoad() { switch ($GLOBALS['op']) { case "mycourses": case "unregistercourse": if (isset($_SESSION['idCourse'])) { TrackUser::closeSessionCourseTrack(); unset($_SESSION['idCourse']); unset($_SESSION['idEdition']); } if (isset($_SESSION['cp_assessment_effect'])) { unset($_SESSION['cp_assessment_effect']); } } }
function play($idResource, $idParams, $back_url) { //if(!checkPerm('view', true, 'organization') && !checkPerm('view', true, 'storage')) die("You can't access"); //echo ("idResource = ".$idResource."; idParams = ".$idParams."; back_url = ".$back_url); list($file) = sql_fetch_row(sql_query("SELECT path" . " FROM " . $GLOBALS['prefix_lms'] . "_materials_lesson" . " WHERE idLesson = '" . $idResource . "'")); //recognize mime type $expFileName = explode('.', $file); $totPart = count($expFileName) - 1; require_once $GLOBALS['where_lms'] . '/lib/lib.param.php'; $idReference = getLOParam($idParams, 'idReference'); // NOTE: Track only if $idReference is present if ($idReference !== FALSE) { require_once $GLOBALS['where_lms'] . '/class.module/track.item.php'; list($exist, $idTrack) = Track_Item::getIdTrack($idReference, getLogUserId(), $idResource, TRUE); if ($exist) { $ti = new Track_Item($idTrack); $ti->setDate(date('Y-m-d H:i:s')); $ti->status = 'completed'; $ti->update(); } else { $ti = new Track_Item(false); $ti->createTrack($idReference, $idTrack, getLogUserId(), date('Y-m-d H:i:s'), 'completed', 'item'); } } if ($_SESSION['direct_play'] == 1) { if (isset($_SESSION['idCourse'])) { TrackUser::closeSessionCourseTrack(); unset($_SESSION['idCourse']); unset($_SESSION['idEdition']); } if (isset($_SESSION['test_assessment'])) { unset($_SESSION['test_assessment']); } if (isset($_SESSION['cp_assessment_effect'])) { unset($_SESSION['cp_assessment_effect']); } $_SESSION['current_main_menu'] = '1'; $_SESSION['sel_module_id'] = '1'; $_SESSION['is_ghost'] = false; } //send file sendFile('/appLms/' . Get::sett('pathlesson'), $file, $expFileName[$totPart]); }
require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; logIntoCourse($id_c, false); } elseif (!isset($_SESSION['idCourse'])) { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; logIntoCourse($id_c, false); } if (isset($_SESSION['cp_assessment_effect'])) { unset($_SESSION['cp_assessment_effect']); } break; case "resetselmodule": unset($_SESSION['sel_module_id']); break; case "unregistercourse": if (isset($_SESSION['idCourse'])) { TrackUser::closeSessionCourseTrack(); unset($_SESSION['idCourse']); unset($_SESSION['idEdition']); } if (isset($_SESSION['cp_assessment_effect'])) { unset($_SESSION['cp_assessment_effect']); } break; case "changelang": Lang::set(Get::req('new_lang', DOTY_MIXED)); $_SESSION['changed_lang'] = true; break; } } // istance the course description class if (isset($_SESSION['idCourse']) && !isset($GLOBALS['course_descriptor'])) {
function logoutSessionCourseTrack() { if (isset($_SESSION['idCourse'])) { TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], '_LOGOUT', 'view'); } }
function userCourseList(&$url, $use_tab = true, $page_add = true) { YuiLib::load(array('animation' => 'animation-min.js', 'dragdrop' => 'dragdrop-min.js', 'button' => 'button-min.js', 'container' => 'container-min.js', 'my_window' => 'windows.js'), array('container/assets/skins/sam' => 'container.css', 'button/assets/skins/sam' => 'button.css')); if ($page_add) { addJs($GLOBALS['where_lms_relative'] . '/modules/coursecatalogue/', 'ajax.coursecatalogue.js'); } require_once _base_ . '/lib/lib.form.php'; require_once _base_ . '/lib/lib.user_profile.php'; require_once _base_ . '/lib/lib.navbar.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.catalogue.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursepath.php'; require_once $GLOBALS["where_framework"] . "/lib/lib.ajax_comment.php"; require_once $GLOBALS['where_lms'] . '/lib/lib.classroom.php'; // pre-loading coursepath ------------------------------------------------------------------ $path_man = new CoursePath_Manager(); // search for the coursepath ---------------------------------------------------------- $user_coursepath = $path_man->getUserSubscriptionsInfo(getLogUserId(), true); $coursepath = $path_man->getCoursepathAllInfo(array_keys($user_coursepath)); if (!empty($coursepath)) { // find structures of the course path --------------------------------------------- $path_courses = $path_man->getPathStructure(array_keys($coursepath)); $cp_info = $path_man->getAllCoursesInfo($path_courses['all_paths']); /*echo "<pre>\n\n"; print_r($cp_info); echo "\n\n</pre>";*/ } // ------------------------------------------------------------------------ $course_stats = array('total' => 0, 'u_can_enter' => 0, 'with_status' => array(CST_AVAILABLE => 0, CST_EFFECTIVE => 0, CST_CONCLUDED => 0, CST_CANCELLED => 0), 'with_ustatus' => array(_CUS_SUBSCRIBED => 0, _CUS_BEGIN => 0, _CUS_END => 0, _CUS_SUSPEND => 0), 'with_wstatus' => array(_CUS_RESERVED => 0, _CUS_WAITING_LIST => 0), 'with_ulevel' => array(), 'expiring' => 0, 'cert_relesable' => 0); // ------------------------------------------------------------------------ $filter = importVar('filter', false, 'total'); if ($filter == 'level') { $filter_level = importVar('filter_on', true, 0); } $current_tab = importVar('current_tab', false, 'lo_plan'); if ($use_tab && $page_add) { addCss('style_tab'); $lo_plan = importVar('lo_plan', false, 0); $lo_history = importVar('lo_history', false, 0); if ($lo_plan != 0) { $current_tab = 'lo_plan'; } if ($lo_history != 0) { $current_tab = 'lo_history'; } } if ($use_tab && $page_add) { addCss('style_tab'); $lo_plan = importVar('lo_plan', false, 0); $lo_history = importVar('lo_history', false, 0); if ($lo_plan != 0) { $current_tab = 'lo_plan'; } if ($lo_history != 0) { $current_tab = 'lo_history'; } } require_once $GLOBALS['where_lms'] . '/lib/lib.certificate.php'; $cert = new Certificate(); $released = $cert->certificateReleased(getLogUserId()); $available_cert = $cert->certificateForCourses(false, false); // cahce classroom ----------------------------------------------------------------- $classroom_man = new ClassroomManager(); $classrooms = $classroom_man->getClassroomNameList(); $lang =& DoceboLanguage::createInstance('catalogue'); $lang_c =& DoceboLanguage::createInstance('course'); $man_course = new Man_Course(); $subcourse_list = sql_query("" . " SELECT u.idCourse, u.edition_id, level, u.date_inscr, u.date_first_access, " . "\t\tu.date_complete, u.status AS user_status, u.waiting, u.edition_id " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser AS u" . " WHERE idUser = '******'"); $subscription = array(); while ($cinfo = mysql_fetch_assoc($subcourse_list)) { $subscription['course'][$cinfo['idCourse']] = $cinfo; if ($cinfo['edition_id'] != 0) { $subscription['edition'][$cinfo['idCourse']][$cinfo['edition_id']] = $cinfo; } } // searching courses --------------------------------------------------------------- $select_course = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_othermaterial, c.course_demo, c.course_vote, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.valid_time, c.userStatusOp, c.show_result, u.status AS user_status, u.level " . ", c.use_logo_in_courselist, c.img_course, c.direct_play "; $from_course = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\t JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u "; $where_course = " c.idCourse = u.idCourse " . " AND u.idUser = '******' " . " AND ( c.status <> '" . CST_PREPARATION . "' OR u.level > 3 )" . " AND c.course_type <> 'assessment' "; $selected_year = 0; $selected_search = ''; if (isset($_POST['apply_filter'])) { if ($_POST['year']) { $where_course .= " AND c.create_date BETWEEN '" . $_POST['year'] . "-01-01 00:00:00' AND '" . $_POST['year'] . "-12-31 23:59:59'"; $selected_year = $_POST['year']; } if ($_POST['search'] !== '') { $where_course .= " AND c.name LIKE '%" . $_POST['search'] . "%'"; $selected_search = $_POST['search']; } } $group_by_course = " GROUP BY c.idCourse "; $order_course = " ORDER BY "; $tablist = Get::sett('tablist_mycourses', ''); if ($tablist != '') { $arr_order_course = explode(',', $tablist); $arr_temp = array(); foreach ($arr_order_course as $key => $value) { switch ($value) { case 'status': $arr_temp[] = ' u.status '; break; case 'code': $arr_temp[] = ' c.code '; break; case 'name': $arr_temp[] = ' c.name '; break; } } $order_course = $order_course . implode(', ', $arr_temp); } if ($order_course == " ORDER BY ") { //default without parameter $order_course .= " u.status, c.name "; } // apply search filter -------------------------------------------------------------- $all_lang = Docebo::langManager()->getAllLangCode(); $re_course = sql_query($select_course . $from_course . " WHERE " . $where_course . $group_by_course . $order_course); // retrive editions ---------------------------------------------------------------- $select_edition = " SELECT e.* "; $from_edition = " FROM " . $GLOBALS["prefix_lms"] . "_course_editions AS e " . " JOIN " . $GLOBALS["prefix_lms"] . "_courseuser AS u "; $where_edition = " WHERE e.status <> '" . CST_PREPARATION . "' AND e.id_edition = u.edition_id "; $re_edition = sql_query($select_edition . $from_edition . $where_edition); // -------------------------------------------------------------------------------- $editions = array(); if ($re_edition) { while ($edition_elem = mysql_fetch_assoc($re_edition)) { $edition_elem['classrooms'] = isset($classrooms[$edition_elem['classrooms']]) ? $classrooms[$edition_elem['classrooms']] : ''; $editions[$edition_elem["id_course"]][$edition_elem["id_course"]] = $edition_elem; } } $man_courseuser = new Man_CourseUser(); $ax_comm = new AjaxComment('course', 'lms'); $comment_count = $ax_comm->getResourceCommentCount(); $user_score = $man_courseuser->getUserCourseScored(getLogUserId()); // ----------------------------------------------------------------------------- $needed_info_for = array(); if (!empty($subscription['course'])) { $id_course_list = array_keys($subscription['course']); // find last access to the courses --------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; $last_access_courses = TrackUser::getLastAccessToCourse(getLogUserId()); // retrive unreaded advice ----------------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.advice.php'; $advices = Man_Advice::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses); // retrive unreaded forum messages --------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.forum.php'; $forums = Man_Forum::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses); // retrive new lesson ---------------------------------------------------------------------------------- require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $org_chart = OrganizationManagement::getCountUnreaded(getLogUserId(), $id_course_list, $last_access_courses); if (!empty($path_courses['all_items'])) { $needed_info_for = array_diff($path_courses['all_items'], $id_course_list); } $first_is_scorm = OrganizationManagement::objectFilter($id_course_list, 'scormorg'); $enroll_list = sql_query("" . " SELECT u.idCourse, u.edition_id, COUNT(*) as number " . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser AS u" . " WHERE u.idCourse IN (" . implode($id_course_list, ',') . ") " . " AND u.level = '3'" . " AND u.status IN ('" . _CUS_CONFIRMED . "', '" . _CUS_SUBSCRIBED . "', '" . _CUS_BEGIN . "', '" . _CUS_END . "', '" . _CUS_SUSPEND . "', '" . _CUS_WAITING_LIST . "')" . " AND u.absent = '0'" . " GROUP BY u.idCourse, u.edition_id "); $enrolled = array(); while ($cinfo = mysql_fetch_assoc($enroll_list)) { $enrolled[$cinfo['idCourse']][$cinfo['edition_id']] = $cinfo['number']; } } // search pre-assessment ----------------------------------------------------------- $select_assess = "" . " SELECT c.idCourse, c.course_type, c.idCategory, c.code, c.name, c.description, c.lang_code, c.difficult, " . "\tc.subscribe_method, c.date_begin, c.date_end, c.max_num_subscribe, " . "\tc.selling, c.prize, c.create_date, c.status AS course_status, c.course_edition, " . "\tc.classrooms, c.img_othermaterial, c.course_demo, c.course_vote, " . "\tc.can_subscribe, c.sub_start_date, c.sub_end_date, c.valid_time, c.userStatusOp, " . "\tu.level, u.date_inscr, u.date_first_access, u.date_complete, u.status AS user_status, u.waiting, c.advance, u.waiting "; $from_assess = " FROM " . $GLOBALS['prefix_lms'] . "_course AS c " . "\t JOIN " . $GLOBALS['prefix_lms'] . "_courseuser AS u "; $where_assess = " c.idCourse = u.idCourse " . " AND u.idUser = '******' " . " AND c.course_type = 'assessment' " . " AND ( c.status <> '" . CST_PREPARATION . "' OR u.level > 3 ) " . ($filter == 'level' ? " AND level = '" . $filter_level . "'" : ""); //." AND ( u.status <> '"._CUS_END."' OR u.level > 3 ) "; $preass_list = sql_query($select_assess . $from_assess . " WHERE " . $where_assess . " ORDER BY c.name "); // pre assessment list --------------------------------------------------------------------------------------- $i = 0; if (mysql_num_rows($preass_list) && $current_tab == 'lo_plan') { if ($page_add) { $GLOBALS['page']->add('<div id="mycourse_asses">' . '<h1>' . $lang_c->def('_ASSESSMENT_LIST') . '</h1>', 'content'); } while ($cinfo = mysql_fetch_assoc($preass_list)) { $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL; if (isset($comment_count[$cinfo['idCourse']])) { $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']]; } if ($page_add) { $GLOBALS['page']->add(dashmyassess($url, $lang_c, $cinfo, $i++), 'content'); } } if ($page_add) { $GLOBALS['page']->add('</div>', 'content'); } } // page intest ------------------------------------------------------------ require_once $GLOBALS['where_lms'] . '/lib/lib.levels.php'; $lvl = CourseLevel::getLevels(); $title = $lang->def('_COURSE_LIST'); switch ($filter) { case "access": $title = $lang->def('_COURSE_YOU_CAN_ACCESS'); break; case "expiring": $title = $lang->def('_COURSE_EXPIRING'); break; case "subscribed": $title = $lang->def('_COURSE_SUBSCRIBED'); break; case "begin": $title = $lang->def('_COURSE_BEGIN'); break; case "end": $title = $lang->def('_COURSE_END'); break; case "level": $title = str_replace('[level]', $lvl[$_GET['filter_on']], $lang->def('_COURSE_AS')); break; } if ($page_add) { $GLOBALS['page']->add('<div id="mycourse_list">' . '<h1>' . $title . '</h1>', 'content'); } $i = 0; $direct_play = false; while ($cinfo = mysql_fetch_assoc($re_course)) { $access = Man_Course::canEnterCourse($cinfo); if ($cinfo['direct_play'] == 1) { $direct_play = true; } $course_stats['total']++; if ($cinfo['user_status'] == _CUS_RESERVED || $cinfo['user_status'] == _CUS_WAITING_LIST) { $course_stats['with_wstatus'][$cinfo['user_status']]++; } elseif ($access['can']) { $course_stats['u_can_enter']++; } if (isset($course_stats['with_ustatus'][$cinfo['user_status']])) { $course_stats['with_ustatus'][$cinfo['user_status']]++; } else { $course_stats['with_ustatus'][$cinfo['user_status']] = 1; } if (!isset($course_stats['with_ulevel'][$cinfo['level']])) { $course_stats['with_ulevel'][$cinfo['level']] = 1; } else { $course_stats['with_ulevel'][$cinfo['level']]++; } if (isset($available_cert[$cinfo['idCourse']])) { while (list($id_cert, $certificate) = each($available_cert[$cinfo['idCourse']])) { if (!isset($released[$id_cert]) && $cert->canRelease($certificate[CERT_AV_STATUS], $cinfo['user_status'])) { $course_stats['cert_relesable']++; } } } } if (mysql_num_rows($re_course)) { mysql_data_seek($re_course, 0); } while ($cinfo = mysql_fetch_assoc($re_course)) { $cinfo['edition_list'] = isset($editions[$cinfo['idCourse']]) ? $editions[$cinfo['idCourse']] : array(); $cinfo['user_score'] = isset($user_score[$cinfo['idCourse']]) ? $user_score[$cinfo['idCourse']] : NULL; $cinfo['enrolled'] = isset($enrolled[$cinfo['idCourse']]) ? $enrolled[$cinfo['idCourse']] : false; if (isset($comment_count[$cinfo['idCourse']])) { $cinfo['comment_count'] = $comment_count[$cinfo['idCourse']]; } $cinfo['classrooms'] = isset($classrooms[$cinfo['classrooms']]) ? $classrooms[$cinfo['classrooms']] : ''; // advertising -------------------------------------------------------------------------------------------- $cinfo['to_read']['advice'] = isset($advices[$cinfo['idCourse']]) ? $advices[$cinfo['idCourse']] : 0; $cinfo['to_read']['forum'] = isset($forums[$cinfo['idCourse']]) ? $forums[$cinfo['idCourse']] : 0; $cinfo['to_read']['lobj'] = isset($org_chart[$cinfo['idCourse']]) ? $org_chart[$cinfo['idCourse']] : 0; // 10 days in the future $range = time() + 10 * 24 * 60 * 60; $expiring = false; if ($cinfo['date_end'] != '0000-00-00') { $time_end = fromDatetimeToTimestamp($cinfo['date_end']); if ($range > $time_end) { $expiring = true; $course_stats['expiring']++; } } if ($cinfo['valid_time'] != '0' && $cinfo['valid_time'] != '' && $cinfo['date_first_access'] != '') { $time_first_access = fromDatetimeToTimestamp($cinfo['date_first_access']); if ($range > $time_first_access + $cinfo['valid_time'] * 24 * 3600) { $expiring = true; $course_stats['expiring']++; } } if (isset($first_is_scorm[$cinfo['idCourse']])) { $cinfo['first_is_scorm'] = $first_is_scorm[$cinfo['idCourse']]; } else { $cinfo['first_is_scorm'] = false; } $access = Man_Course::canEnterCourse($cinfo); // -------------------------------------------------------------------- if (!isset($path_courses['all_items'][$cinfo['idCourse']])) { // the course is not related with a coursepath, so i can print it -------------- if ($filter == 'level') { if ($subscription['course'][$cinfo['idCourse']]['level'] == $filter_level) { $dash = dashmycourse($url, $lang_c, $subscription, $cinfo, $i++); } else { $dash = ''; } } else { $dash = dashmycourse($url, $lang_c, $subscription, $cinfo, $i++); } if ($use_tab == true) { if ($course_stats['with_ustatus'][_CUS_END] == $course_stats['total']) { $current_tab = 'lo_history'; } if ($current_tab == 'lo_history') { if ($cinfo['user_status'] == _CUS_END && $page_add) { $GLOBALS['page']->add($dash, 'content'); } } else { if (($cinfo['user_status'] != _CUS_END || $cinfo['level'] >= 4) && $page_add) { $GLOBALS['page']->add($dash, 'content'); } } } else { switch ($filter) { case "access": if ($access['can'] && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "expiring": if ($expiring && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "subscribed": if ($cinfo['user_status'] == _CUS_SUBSCRIBED && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "begin": if ($cinfo['user_status'] == _CUS_BEGIN && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "end": if ($cinfo['user_status'] == _CUS_END && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; case "level": if ($_GET['filter_on'] == $cinfo['level'] && $page_add) { $GLOBALS['page']->add($dash, 'content'); } break; default: if ($page_add) { $GLOBALS['page']->add($dash, 'content'); } } } } else { // the course is related with a coursepath, so i must wait to print it ---------- //$cinfo['prerequisites'] = $path_courses['all_items'][$cinfo['idCourse']]; // <- useless? //$courses =array($cinfo['idCourse']=>$cinfo); $prere = $cp_info[$cinfo['idCourse']]["prerequisites"]; if ($path_man->checkPrerequisites($prere, $subscription)) { $cinfo['prerequisites_satisfied'] = true; } else { $cinfo['prerequisites_satisfied'] = false; } if ($filter == 'level') { if ($subscription['course'][$cinfo['idCourse']]['level'] == $filter_level) { $course_cache[$cinfo['idCourse']] = dashmycourse($url, $lang_c, $subscription, $cinfo, 1, true, 4); } else { $course_cache[$cinfo['idCourse']] = ''; } } else { $course_cache[$cinfo['idCourse']] = dashmycourse($url, $lang_c, $subscription, $cinfo, 1, true, 4); } } // end else-if ------------------------------------------------------- } // end while ------------------------------------------------------------ if ($direct_play && $page_add) { $GLOBALS['page']->add('' . ' <link href="' . getPathTemplate() . '/style/shadowbox.css" rel="stylesheet" type="text/css" />' . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox-yui.js"></script>' . "\n" . '<script type="text/javascript" src="' . $GLOBALS['where_framework_relative'] . '/addons/shadowbox/shadowbox.js"></script>' . "\n", 'page_head'); $GLOBALS['page']->add('<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function() { var options = { listenOverlay:false, overlayOpacity:"0.8", loadingImage:"' . getPathImage('lms') . 'standard/loading.gif", overlayBgImage:"' . getPathImage('lms') . 'standard/overlay-85.png", text: {close: "' . Lang::t('_CLOSE') . '", cancel: "' . Lang::t('_UNDO') . '", loading:"' . Lang::t('_LOADING') . '" }, onOpen: function (gallery) { window.onbeforeunload = function() { return "' . Lang::t('_CONFIRM_EXIT', 'organization', 'lms') . '"; } } }; Shadowbox.init(options); Shadowbox.close = function() { window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window); } }); </script>'); } if ($course_stats['total'] == 0 && $page_add) { $GLOBALS['page']->add('' . '<b>' . $lang->def('_NO_COURSE') . '</b> ' . '<br />', 'content'); } if ($page_add) { $GLOBALS['page']->add('</div>', 'content'); } // Coursepath -------------------------------------------------------------- if (!empty($coursepath)) { // find structures of the course path ---------------------------------- $path_slot = $path_man->getPathSlot(array_keys($coursepath)); // coursepath list ----------------------------------------------------- if ($page_add) { $GLOBALS['page']->add('<div id="mycoursepath_list">' . '<h1>' . $lang->def('_COURSEPATH_LIST') . '</h1>', 'content'); } $i = 0; // find course basilar information ------------------------------------- if (!empty($needed_info_for)) { $course_info = $man_course->getAllCourses(false, false, $needed_info_for); } else { $course_info = array(); } while (list($id_path, $path) = each($coursepath)) { $html = '<div class="coursepath_container coursepath_container_simple">'; $html .= '<h2>' . ($path[COURSEPATH_CODE] != '' ? '[' . $path[COURSEPATH_CODE] . '] ' : '') . $path[COURSEPATH_NAME] . '</h2>'; if (!isset($path_courses[$id_path]) || empty($path_courses[$id_path])) { $html .= $lang->def('_NO_COURSE_ASSIGNED_TO_COURSEPATH') . '<br />'; } else { // display the slots foreach ($path_slot[$id_path] as $id_slot => $slot_info) { if ($id_slot == 0) { $html .= '<h3>' . $lang->def('_MANDATORY') . '</h3>'; if (!empty($path_courses[$id_path][$id_slot])) { $html .= '<ul class="coursepath_mainslot">'; } } else { if ($slot_info['min_selection'] > 0 && $slot_info['max_selection'] > 0) { $title = str_replace(array('[min_selection]', '[max_selection]'), array($slot_info['min_selection'], $slot_info['max_selection']), $lang->def('_COURSE_PATH_SLOT_MIN_MAX')); } elseif ($slot_info['max_selection'] > 0) { $title = str_replace('[max_selection]', $slot_info['max_selection'], $lang->def('_COURSE_PATH_SLOT_MAX')); } else { $title = $lang->def('_COURSE_PATH_SLOT'); } $html .= '<h3>' . $title . '</h3>'; if (!empty($path_courses[$id_path][$id_slot])) { $html .= '<ul class="coursepath_otherslot">'; } } while (list($id) = each($path_courses[$id_path][$id_slot])) { if (isset($course_cache[$id])) { $html .= '<li>' . $course_cache[$id] . '</li>'; } else { $html .= '<li>' . dashAcourse($id, 4) . '</li>'; } } if (!empty($path_courses[$id_path][$id_slot])) { $html .= '</ul>'; } } } $html .= '</div>'; if ($page_add) { $GLOBALS['page']->add($html, 'content'); } } if ($page_add) { $GLOBALS['page']->add('</div>', 'content'); } } if ($course_stats['cert_relesable'] < 0) { $course_stats['cert_relesable'] = 0; } return $course_stats; }
function getOnlineUsers() { global $acl_man; $whoIsOnlineList = TrackUser::getListWhoIsOnline($_SESSION['idCourse']); $first = true; $list = '"list":['; $emptylist = true; for ($i = 0; $i < count($whoIsOnlineList); $i++) { $idSt = $whoIsOnlineList[$i]; //if (Docebo::user()->getIdSt()<>$idSt) { $emptylist = false; $userInfo = $acl_man->getUser($idSt, ''); $ids = split("/", $userInfo[1]); $idUser = $ids[1]; $userName = substr($userInfo[2], 0, 1) . "." . $userInfo[3]; $list .= '{"idSt":"' . $idSt . '","idUser":"******","userName":"******"},'; //}; } if (!$emptylist) { $list = substr($list, 0, strlen($list) - 1); } $list .= ']'; return $list; }
function logIntoCourse($id_course, $gotofirst_page = true) { // Reset previous opened track session if any if (!Docebo::user()->isAnonymous() && isset($_SESSION['idCourse'])) { require_once _lms_ . '/lib/lib.track_user.php'; TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], '', ''); } // Unset possibile previous session setting if (isset($_SESSION['direct_play'])) { unset($_SESSION['direct_play']); } $re_course = sql_query("\r\n\tSELECT level, status, waiting\r\n\tFROM %lms_courseuser\r\n\tWHERE idCourse = " . (int) $id_course . " AND idUser = "******""); list($level_c, $status_user, $waiting_user) = sql_fetch_row($re_course); Docebo::setCourse($id_course); $course_info = Docebo::course()->getAllInfo(); $course_info['course_status'] = $course_info['status']; $course_info['user_status'] = $status_user; $course_info['waiting'] = $waiting_user; $course_info['level'] = $level_c; // Can the user enter into the course ? if (!Man_Course::canEnterCourse($course_info)) { return false; } // Disable tracking for ghost level $_SESSION['is_ghost'] = $course_info['level'] == 2 ? true : false; // If it's the first time we need to change the course status if ($course_info['user_status'] == _CUS_SUBSCRIBED) { require_once _lms_ . '/lib/lib.stats.php'; saveTrackStatusChange(getLogUserId(), $id_course, _CUS_BEGIN); } // Setup some session data $_SESSION['timeEnter'] = date("Y-m-d H:i:s"); $_SESSION['idCourse'] = $id_course; $_SESSION['levelCourse'] = $course_info['level']; //we need to redo this //$_SESSION['idEdition'] = $id_e; Docebo::user()->loadUserSectionST('/lms/course/private/' . $course_info['level'] . '/'); Docebo::user()->SaveInSession(); // Initialize the session into the course TrackUser::createSessionCourseTrack(); $first_page = firstPage(); $_SESSION['current_main_menu'] = $first_page['idMain']; $_SESSION['sel_module_id'] = $first_page['idModule']; $jumpurl = 'index.php?modname=' . $first_page['modulename'] . '&op=' . $first_page['op'] . '&id_module_sel=' . $first_page['idModule']; // course in direct play or assessment if ($course_info['direct_play'] == 1 || $course_info['course_type'] == 'assessment') { if ($_SESSION['levelCourse'] >= 4) { // direct play with a teacher, basically it's not ok // check if we are managing the LOs from admin: if yes, jump into the test management if ($course_info['course_type'] == 'assessment' && Get::req('from_admin', DOTY_INT, 0) > 0) { // enter the assessment course and go to test editing if there is a test with no question in it $query = "SELECT idOrg, idResource " . " FROM %lms_organization " . " WHERE idCourse = " . (int) $_SESSION['idCourse'] . " AND objectType = 'test' " . " ORDER BY path ASC, title ASC " . " LIMIT 0,1"; $res = sql_query($query); if ($res && sql_num_rows($res) > 0) { list($id_org, $id_test) = sql_fetch_row($res); if ($id_test > 0) { require_once _lms_ . '/lib/lib.test.php'; $tman = new TestManagement($id_test); if ($tman->getNumberOfQuestion() <= 0) { Util::jump_to('index.php?modname=test&op=modtestgui&idTest=' . $id_test . '&back_url=' . urlencode($jumpurl)); } } } } } else { // direct play with a student // i need to play directly the course if it's not completed and is the only object of the course require_once _lms_ . '/lib/lib.orgchart.php'; $orgman = new OrganizationManagement($_SESSION['idCourse']); $first_lo =& $orgman->getInfoWhereType(false, $_SESSION['idCourse']); if (count($first_lo) == 1) { $_SESSION['direct_play'] = 1; $obj = array_shift($first_lo); Util::jump_to('index.php?modname=organization&op=custom_playitem&id_item=' . $obj['id_org'] . ''); } elseif (count($first_lo) >= 2) { $obj = array_shift($first_lo); // if we have more than an object we need to play the first one until it's completed $query = "SELECT status FROM %lms_commontrack WHERE idReference = " . (int) $obj['id_org'] . " AND idUser = "******"assessment") { //check if we are managing the LOs from admin: if yes, jump into the test management if (Get::req('from_admin', DOTY_INT, 0) > 0) { //enter the assessment course and go to test editing $query = "SELECT idOrg, idResource FROM %lms_organization WHERE idCourse=".(int)$_SESSION['idCourse']." AND objectType='test' " ." ORDER BY path ASC, title ASC LIMIT 0,1"; $res = sql_query($query); if ($res && sql_num_rows($res)>0) { list($id_org, $id_test) = sql_fetch_row($res); if ($id_test > 0) { require_once(_lms_.'/lib/lib.test.php'); $tman = new TestManagement($id_test); if ($tman->getNumberOfQuestion() <= 0) { Util::jump_to('index.php?modname=test&op=modtestgui&idTest='.$id_test.'&back_url='.urlencode($jumpurl)); } } } } } if($gotofirst_page) Util::jump_to($jumpurl); else return true; } switch($course_info['course_type']) { case "assessment" : { if($_SESSION['levelCourse'] <= 3) { // i need to play directly the test require_once($GLOBALS['where_lms'].'/lib/lib.orgchart.php'); $orgman = new OrganizationManagement($_SESSION['idCourse']); $test =& $orgman->getInfoWhereType('test', $_SESSION['idCourse']); if(count($test) == 1) { $obj = array_shift($test); $_SESSION['test_assessment'] = 1; Util::jump_to('index.php?modname=organization&op=custom_playitem&id_item='.$obj['id_org'].''); } if($gotofirst_page) Util::jump_to($jumpurl); else return true; } else { if($gotofirst_page) { //... Util::jump_to($jumpurl); } else return true; } };break; default: { if($gotofirst_page) Util::jump_to($jumpurl); else return true; } } /* not used in // now analyze the course type and select the acton to perform if(isset($_GET['showresult'])) { require_once(_lms_.'/lib/lib.orgchart.php'); $orgman = new OrganizationManagement($_SESSION['idCourse']); $scorm =& $orgman->getInfoWhereType('scormorg', $_SESSION['idCourse']); if(count($scorm) == '1') { $obj = array_shift($scorm); Util::jump_to('index.php?modname=organization&op=scorm_track&id_user='******'&id_org='.$obj['id_resource'].'&back='.$GLOBALS['course_descriptor']->getValue('direct_play')); } Util::jump_to('index.php?modname=course&op=showresults&id_course='.$_SESSION['idCourse']); } */ }
function organization_display(&$treeView) { // print conainer div and form require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], 'organization', 'view'); global $modname, $op; $GLOBALS['page']->setWorkingZone('content'); $GLOBALS['page']->add('<div class="std_block">'); $GLOBALS['page']->add('<form id="orgshow" method="post"' . ' action="index.php?modname=' . $modname . '&op=' . $op . '"' . ' >' . "\n" . '<input type="hidden" id="authentic_request_org" name="authentic_request" value="' . Util::getSignature() . '" />'); if (funAccess('moditem', 'MOD', TRUE, 'organization')) { $treeView->withActions = TRUE; } else { $tdb = $treeView->getTreeDb(); } $GLOBALS['page']->add($treeView->load()); if (funAccess('moditem', 'MOD', TRUE, 'organization')) { $GLOBALS['page']->add($treeView->loadActions()); } $GLOBALS['page']->add('</form>'); // print form for import action $GLOBALS['page']->add('</div>'); YuiLib::load(array(), array()); /* addCss('shadowbox'); Util::get_js(Get::rel_path('base').'/addons/shadowbox/shadowbox-yui.js', true, true); Util::get_js(Get::rel_path('base').'/addons/shadowbox/shadowbox.js', true, true); $GLOBALS['page']->add( '' .'<script type="text/javascript"> YAHOO.util.Event.onDOMReady(function() { var options = { listenOverlay:false, overlayOpacity:"0.8", loadingImage:"'.getPathImage('lms').'standard/loading.gif", overlayBgImage:"'.getPathImage('lms').'standard/overlay-85.png", text: {close: "'. Lang::t('_CLOSE').'", cancel: "'. Lang::t('_UNDO').'", loading:"'. Lang::t('_LOADING').'" }, onOpen: function (gallery) { window.onbeforeunload = function() { return "'. Lang::t('_CONFIRM').'"; } } }; Shadowbox.init(options); Shadowbox.close = function() { window.onbeforeunload = null; window.frames[\'shadowbox_content\'].uiPlayer.closePlayer(true, window); } }); </script>' ); */ $GLOBALS['page']->add('<script type="text/javascript">' . "var lb = new LightBox();\r\n var Config = {};\r\n Config.langs = {_CLOSE: '" . Lang::t('_CLOSE', 'standard') . "'};\r\n lb.init(Config);" . '</script>'); }
function checkPermForCourse($mode, $id_course, $return_value = false, $use_mod_name = false) { if ($use_mod_name != false) { $mod_name = $use_mod_name; } else { $mod_name = $GLOBALS['modname']; } switch ($mode) { case "OP": case "view": $suff = 'view'; break; case "NEW": case "add": $suff = 'add'; break; case "MOD": case "mod": $suff = 'mod'; break; case "REM": case "del": $suff = 'del'; break; default: $suff = $mode; } $role = '/' . Get::cur_plat() . '/course/private/' . $id_course . '/' . $mod_name . '/' . $suff; if (!$return_value && isset($_SESSION['idCourse'])) { TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], $mod_name, $suff); } if (Docebo::user()->matchUserRole($role)) { return true; } else { if ($return_value) { return false; } else { die("You can't access"); } } }
function getSubstitution() { $subs = array(); $lang =& DoceboLanguage::createInstance('course', 'lms'); $lang =& DoceboLanguage::createInstance('certificate', 'lms'); if ($this->id_meta != 0) { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; $acl_man =& $GLOBALS['current_user']->getAclManager(); $courses = array(); $array_coursetype = array('elearning' => $lang->def('_COURSE_TYPE_ELEARNING', 'course', 'lms'), 'classroom' => $lang->def('_CLASSROOM', 'course', 'lms'), 'web_seminar' => $lang->def('Web seminar')); $course_time = 0; $blended_time = 0; $query = "SELECT DISTINCT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idMetaCertificate = '" . $this->id_meta . "'" . " AND idUser = '******'"; $result = sql_query($query); $table_course = '<table width="100%" cellspacing="1" cellpadding="1" border="1" align="" summary="Corsi frequentati">' . '<thead>' . '<tr>' . '<td>' . $lang->def('_COURSE_NAME') . '</td>' . '<td>' . $lang->def('_COURSE_TYPE') . '</td>' . '<td align="right">' . $lang->def('_COURSE_TIME') . '</td>' . '</tr>' . '</thead>' . '</tbody>'; $table_blended = '<table width="100%" cellspacing="1" cellpadding="1" border="1" align="" summary="Corsi frequentati">' . '<thead>' . '<tr>' . '<td>' . $lang->def('_COURSE_NAME') . '</td>' . '<td>' . $lang->def('_COURSE_PROF') . '</td>' . '<td>' . $lang->def('_COURSE_TYPE') . '</td>' . '<td align="right">' . $lang->def('_COURSE_TIME') . '</td>' . '</thead>' . '</tbody>'; $course_count = 0; $blended_count = 0; $array_meta_complete = array(); $array_meta_inscr = array(); $array_meta_access = array(); while (list($id_course) = sql_fetch_row($result)) { $query = "SELECT date_complete, date_inscr, date_first_access" . " FROM " . $GLOBALS['prefix_lms'] . "_courseuser" . " WHERE idCourse = '" . $id_course . "'" . " AND idUser = '******'"; list($date_complete_meta, $date_inscr_meta, $date_access_meta) = sql_fetch_row(sql_query($query)); $array_meta_complete[] = $date_complete_meta; $array_meta_inscr[] = $date_inscr_meta; $array_meta_access[] = $date_access_meta; $man_course = new Man_Course(); $course_info = $man_course->getCourseInfo($id_course); $rep_man = new CourseReportManager(); $score_course = $rep_man->getUserFinalScore(array($this->id_user), array($this->id_course)); if ($course_info['course_type'] === 'blended') { $teacher_array = getSubscribed($id_course, false, 6, true); $first = true; if (is_array($teacher_array) && !empty($teacher_array)) { while (list(, $id_teach) = each($teacher_array)) { $teacher_info = $acl_man->getUser($id_teach); if ($first) { $teacher = $teacher_info[ACL_INFO_FIRSTNAME] . ' ' . $teacher_info[ACL_INFO_LASTNAME]; $first = false; } else { $teacher = '<br/>' . $teacher_info[ACL_INFO_FIRSTNAME] . ' ' . $teacher_info[ACL_INFO_LASTNAME]; } } } else { $teacher = ' '; } $table_blended .= '<tr>' . '<td>' . $course_info['name'] . '</td>' . '<td>' . $teacher . '</td>' . '<td>' . $array_coursetype[$course_info['course_type']] . '</td>' . '<td align="right">' . $course_info['mediumTime'] . '</td>' . '</tr>'; $blended_time += $course_info['mediumTime']; $blended_count++; } else { $table_course .= '<tr>' . '<td>' . $course_info['name'] . '</td>' . '<td>' . $array_coursetype[$course_info['course_type']] . '</td>' . '<td align="right">' . $course_info['mediumTime'] . '</td>' . '</tr>'; $course_time += $course_info['mediumTime']; $course_count++; } } $table_course .= '<tr>' . '<td align="right" colspan="2">' . $lang->def('_TOTAL_HOURS') . '</td>' . '<td align="right">' . $course_time . '</td>' . '</tr>' . '</tbody>' . '</table>'; $table_blended .= '<tr>' . '<td align="right" colspan="2">' . $lang->def('_TOTAL_HOURS') . '</td>' . '<td align="right">' . $blended_time . '</td>' . '</tr>' . '</tbody>' . '</table>'; rsort($array_meta_complete); sort($array_meta_inscr); sort($array_meta_access); $subs['[meta_complete]'] = $array_meta_complete[0]; $subs['[meta_inscr]'] = $array_meta_inscr[0]; $subs['[meta_access]'] = $array_meta_access[0]; $subs['[table_course]'] = $course_count ? $table_course : ''; $subs['[table_blended]'] = $blended_count ? $table_blended : ''; } else { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; $courseuser = new Man_CourseUser(); $course_stat =& $courseuser->getUserCourses($this->id_user, false, false, false, array($this->id_course)); if (isset($course_stat[$this->id_course])) { $subs['[date_enroll]'] = Format::date($course_stat[$this->id_course]['date_inscr'], 'date'); $subs['[date_first_access]'] = Format::date($course_stat[$this->id_course]['date_first_access'], 'date'); $subs['[date_complete]'] = Format::date($course_stat[$this->id_course]['date_complete'], 'date'); $subs['[date_complete_year]'] = substr($course_stat[$this->id_course]['date_complete'], 0, 4); } else { $subs['[date_enroll]'] = ''; $subs['[date_first_access]'] = ''; $subs['[date_complete]'] = ''; $subs['[date_complete_year]'] = ''; } require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $org_man = new OrganizationManagement($this->id_course); $score_start = $org_man->getStartObjectScore(array($this->id_user), array($this->id_course)); $score_final = $org_man->getFinalObjectScore(array($this->id_user), array($this->id_course)); require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; $rep_man = new CourseReportManager(); $score_course = $rep_man->getUserFinalScore(array($this->id_user), array($this->id_course)); $subs['[test_score_start]'] = isset($score_start[$this->id_course][$this->id_user]) ? $score_start[$this->id_course][$this->id_user]['score'] : ''; $subs['[test_score_start_max]'] = isset($score_start[$this->id_course][$this->id_user]) ? $score_start[$this->id_course][$this->id_user]['max_score'] : ''; $subs['[test_score_final]'] = isset($score_final[$this->id_course][$this->id_user]) ? $score_final[$this->id_course][$this->id_user]['score'] : ''; $subs['[test_score_final_max]'] = !empty($score_final[$this->id_course][$this->id_user]['max_score']) ? $score_final[$this->id_course][$this->id_user]['max_score'] : '100'; $subs['[course_score_final]'] = isset($score_course[$this->id_user][$this->id_course]) ? $score_course[$this->id_user][$this->id_course]['score'] : ''; $subs['[course_score_final_max]'] = isset($score_course[$this->id_user][$this->id_course]) ? $score_course[$this->id_user][$this->id_course]['max_score'] : ''; require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; $time_in = TrackUser::getUserTotalCourseTime($this->id_user, $this->id_course); $hours = (int) ($time_in / 3600); $minutes = (int) ($time_in % 3600 / 60); $seconds = (int) ($time_in % 60); if ($minutes < 10) { $minutes = '0' . $minutes; } if ($seconds < 10) { $seconds = '0' . $seconds; } $subs['[total_time]'] = $hours . 'h ' . $minutes . 'm ' . $seconds . 's'; $subs['[total_time_hour]'] = $hours; $subs['[total_time_minute]'] = $minutes; $subs['[total_time_second]'] = $seconds; } return $subs; }
define("LMS", true); define("IN_FORMA", true); define("_deeppath_", '../../../'); require dirname(__FILE__) . '/' . _deeppath_ . 'base.php'; // start buffer ob_start(); // initialize require _base_ . '/lib/lib.bootstrap.php'; Boot::init(BOOT_DATETIME); // not a pagewriter but something similar $GLOBALS['operation_result'] = ''; if (!function_exists("aout")) { function aout($string) { $GLOBALS['operation_result'] .= $string; } } // here all the specific code ========================================================== require_once $GLOBALS['where_lms'] . '/lib/lib.track_user.php'; TrackUser::setActionTrack(getLogUserId(), $_SESSION['idCourse'], 'scorm', 'close'); // update the tracking // ===================================================================================== // close database connection // finalize Boot::finalize(); // remove all the echo ob_clean(); // Print out the page echo $GLOBALS['operation_result']; // flush buffer ob_end_flush();
$user_stats['head'][0] = Lang::t('_PARTIAL_TIME', 'course'); $user_stats['body'][0] = '<span id="partial_time">' . $partial_time . '</span>'; $user_stats['head'][1] = Lang::t('_TOTAL_TIME', 'course'); $user_stats['body'][1] = '<span id="total_time">' . $tot_time . '</span>'; } } if (Docebo::course()->getValue('show_who_online') == _SHOW_INSTMSG) { addCss('instmsg'); addJs('addons/yui/my_window/', 'windows.js'); addJs($GLOBALS['where_lms_relative'] . '/modules/instmsg/', 'instmsg.js'); $GLOBALS['page']->add('<script type="text/javascript">' . " setup_instmsg( '" . Docebo::user()->getIdSt() . "', " . "'" . $userid . "', " . "'" . getPathImage('fw') . "' ); " . '</script>' . "\n", 'page_head'); $user_stats['head'][2] = Lang::t('_WHOIS_ONLINE', 'course'); $user_stats['body'][2] = '<b id="user_online_n">' . '<a id="open_users_list" href="javascript:void(0)">' . TrackUser::getWhoIsOnline($_SESSION['idCourse']) . '</a></b>'; } elseif (Docebo::course()->getValue('show_who_online') == _SHOW_COUNT) { $user_stats['head'][2] = Lang::t('_WHOIS_ONLINE', 'course'); $user_stats['body'][2] = '<b id="user_online_n">' . TrackUser::getWhoIsOnline($_SESSION['idCourse']) . '</b>'; } $all_stats = '<div id="accordion"><h3>'; $all_stats .= '<span class="tempo">' . Lang::t('_TOTAL_TIME', 'course') . ': ' . $tot_time . ' '; // get status count value if (Docebo::course()->getValue('show_progress') == 1) { require_once $GLOBALS['where_lms'] . '/lib/lib.stats.php'; $total = getNumCourseItems($_SESSION['idCourse'], FALSE, getLogUserId(), FALSE); $tot_complete = getStatStatusCount(getLogUserId(), $_SESSION['idCourse'], array('completed', 'passed')); $tot_incomplete = $total - $tot_complete; $tot_passed = getStatStatusCount(getLogUserId(), $_SESSION['idCourse'], array('passed')); $tot_failed = getStatStatusCount(getLogUserId(), $_SESSION['idCourse'], array('failed')); } // print progress bar ------------------------------------------------- $user_stats_table = ""; if (Docebo::course()->getValue('show_progress') == 1 && true) {
public function stop() { $track_id = Request::get('trackid'); $username = TrackId::where('track_id', $track_id)->first(); $trackers = TrackAssign::where('username', $username->username)->get(array('tracker_id')); foreach ($trackers as $tracker) { $values = array($tracker->tracker_id, $username->username); RestApi::sendNotification('ST', $values); } $username->status = 0; $username->save(); $query = "INSERT INTO track_user_backup (track_id, latitude, longitude, created_at, updated_at) SELECT track_id, latitude, longitude, created_at, updated_at FROM track_user WHERE track_id = '{$track_id}'"; DB::insert(DB::raw($query)); TrackUser::where('track_id', $track_id)->delete(); }