/** * execute the connection to source **/ function connect() { $this->lang = DoceboLanguage::createInstance('rg_report'); // perform the query for data retriving $course_man = new Man_Course(); $this->acl_man = new DoceboACLManager(); $p_dr = new PeopleDataRetriever($GLOBALS['dbConn'], $GLOBALS['prefix_fw']); $re_people = $p_dr->getAllRowsIdst(); $this->_readed_end = false; $this->row_index = 0; $user_selected = array(); if (!$re_people) { $this->_readed_end = true; return TRUE; } while (list($idst) = sql_fetch_row($re_people)) { $user_selected[$idst] = $idst; } $this->users_info = $this->acl_man->getUsers($user_selected); $this->id_courses = $course_man->getAllCourses(); $this->num_iscr = array(); $this->num_nobegin = array(); $this->num_itinere = array(); $this->num_end = array(); $this->time_in_course = array(); $effective_user = array(); $query_course_user = "******" . $GLOBALS['prefix_lms'] . "_courseuser AS cu \r\n\t\tWHERE idUser IN ( " . implode(',', $user_selected) . " ) "; $re_course_user = sql_query($query_course_user); while (list($id_u, $id_c, $fisrt_access, $date_complete) = sql_fetch_row($re_course_user)) { if (isset($this->num_iscr[$id_c])) { ++$this->num_iscr[$id_c]; } else { $this->num_iscr[$id_c] = 1; } if ($fisrt_access === NULL) { //never enter if (isset($this->num_nobegin[$id_c])) { ++$this->num_nobegin[$id_c]; } else { $this->num_nobegin[$id_c] = 1; } } elseif ($date_complete === NULL) { //enter if (isset($this->num_itinere[$id_c])) { ++$this->num_itinere[$id_c]; } else { $this->num_itinere[$id_c] = 1; } } else { //complete if (isset($this->num_end[$id_c])) { ++$this->num_end[$id_c]; } else { $this->num_end[$id_c] = 1; } } $effective_user[] = $id_u; } if (!empty($effective_user)) { $query_time = "\r\n\t\t\tSELECT idCourse, SUM(UNIX_TIMESTAMP(lastTime) - UNIX_TIMESTAMP(enterTime)) \r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession \r\n\t\t\tWHERE idUser IN ( " . implode(',', $effective_user) . " )\r\n\t\t\tGROUP BY idCourse "; $re_time = sql_query($query_time); while (list($id_c, $time_num) = sql_fetch_row($re_time)) { $this->time_in_course[$id_c] = $time_num; } } return TRUE; }
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; }
/** * Return the output in the selected format for the report with the filters given * @param string $type output type * @param array $report_data a properly formatted list of rule to follow * @param string $other * @return string the properly formated report */ function _get_courses_query($type = 'html', $report_data = NULL, $other = '') { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; $output = ''; $jump_url = ''; $org_chart_subdivision = 0; // not implemented $elem_selected = array(); $lang =& DoceboLanguage::createInstance('report', 'framework'); $acl_man = new DoceboACLManager(); $acl_man->include_suspended = TRUE; $course_man = new Man_Course(); // read form _SESSION (XXX: change this) the report setting $filter_userselection = !$report_data && isset($_SESSION['report_tempdata']['rows_filter']['users']) ? $_SESSION['report_tempdata']['rows_filter']['users'] : $report_data['rows_filter']['users']; $filter_columns = !$report_data && $_SESSION['report_tempdata']['columns_filter'] ? $_SESSION['report_tempdata']['columns_filter'] : $report_data['columns_filter']; if (!$report_data && isset($_SESSION['report_tempdata']['rows_filter']['all_users'])) { $alluser = $_SESSION['report_tempdata']['rows_filter']['all_users'] ? 1 : 0; } else { $alluser = $report_data['rows_filter']['all_users'] ? 1 : 0; } // break filters into a more usable format $filter_allcourses = $filter_columns['all_courses']; $filter_courseselection =& $filter_columns['selected_courses']; $order_by = isset($filter_columns['order_by']) ? $filter_columns['order_by'] : "userid"; $order_dir = isset($filter_columns['order_dir']) ? $filter_columns['order_dir'] : "asc"; $show_suspended = 'active_only'; if (isset($filter_columns['show_suspended']) && $filter_columns['show_suspended']) { $show_suspended = 'all'; } // retrive the user selected if ($alluser > 0) { // all the user selected (we can avoid this ? no we need to hide the suspended users) $user_selected =& $acl_man->getAllUsersIdst(); } else { // resolve the user selection $user_selected =& $acl_man->getAllUsersFromSelection($filter_userselection); } //apply sub admin filters, if needed $userlevelid = Docebo::user()->getUserLevelId(); if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) { //filter users $alluser = false; require_once _base_ . '/lib/lib.preference.php'; $adminManager = new AdminPreference(); $admin_users = $adminManager->getAdminUsers(Docebo::user()->getIdST()); $admin_users = $acl_man->getAllUsersFromSelection($admin_users); $user_selected = array_intersect($user_selected, $admin_users); unset($admin_users); //filter courses $admin_allcourses = false; $admin_courses = $adminManager->getAdminCourse(Docebo::user()->getIdST()); if (!$filter_allcourses) { $rs = sql_query("SELECT idCourse FROM %lms_course"); $course_selected = array(); while (list($id_course) = sql_fetch_row($rs)) { $course_selected[] = $id_course; } } if (isset($admin_courses['course'][0])) { //No filter $admin_allcourses = true; } elseif (isset($admin_courses['course'][-1])) { require_once _lms_ . '/lib/lib.catalogue.php'; $cat_man = new Catalogue_Manager(); $user_catalogue = $cat_man->getUserAllCatalogueId(Docebo::user()->getIdSt()); if (count($user_catalogue) > 0) { $courses = array(0); foreach ($user_catalogue as $id_cat) { $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true); $courses = array_merge($courses, $catalogue_course); } foreach ($courses as $id_course) { if ($id_course != 0) { $admin_courses['course'][$id_course] = $id_course; } } } elseif (Get::sett('on_catalogue_empty', 'off') == 'on') { //No filter } if (!empty($admin_courses['course'])) { $rs = sql_query("SELECT idCourse FROM %lms_course"); $course_selected = array(); while (list($id_course) = sql_fetch_row($rs)) { $course_selected[] = $id_course; } $_clist = array_values($admin_courses['course']); $course_selected = array_intersect($course_selected, $_clist); } else { $course_selected = array(); } } else { $array_courses = array(); $array_courses = array_merge($array_courses, $admin_courses['course']); if (!empty($admin_courses['coursepath'])) { require_once _lms_ . '/lib/lib.coursepath.php'; $path_man = new Catalogue_Manager(); $coursepath_course =& $path_man->getAllCourses($admin_courses['coursepath']); $array_courses = array_merge($array_courses, $coursepath_course); } if (!empty($admin_courses['catalogue'])) { require_once _lms_ . '/lib/lib.catalogue.php'; $cat_man = new Catalogue_Manager(); foreach ($admin_courses['catalogue'] as $id_cat) { $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true); $array_courses = array_merge($array_courses, $catalogue_course); } } $admin_courses['course'] = array_merge($admin_courses['course'], $array_courses); if (!empty($admin_courses['course'])) { $rs = sql_query("SELECT idCourse FROM %lms_course"); $course_selected = array(); while (list($id_course) = sql_fetch_row($rs)) { $course_selected[] = $id_course; } $_clist = array_values($admin_courses['course']); $course_selected = array_intersect($course_selected, $_clist); } else { $course_selected = array(); } } unset($admin_courses); if (!$filter_allcourses) { $filter_courseselection = array_intersect($filter_courseselection, $course_selected); } else { $filter_courseselection = $course_selected; } if ($filter_allcourses && $admin_allcourses) { $filter_allcourses = true; } else { $filter_allcourses = false; } } $show_classrooms_editions = isset($filter_columns['show_classrooms_editions']) ? (bool) $filter_columns['show_classrooms_editions'] : false; $classrooms_editions_info = array(); if ($show_classrooms_editions) { //retrieve classrooms info $query = "SELECT d.*, MIN(dd.date_begin) AS date_1, MAX(dd.date_end) AS date_2 " . " FROM %lms_course_date AS d JOIN %lms_course_date_day AS dd ON (d.id_date = dd.id_date) " . (!$filter_allcourses ? " AND d.id_course IN (" . implode(',', $filter_courseselection) . ") " : "") . " GROUP BY dd.id_date"; $res = sql_query($query); while ($obj = sql_fetch_object($res)) { $classrooms_editions_info['classrooms'][$obj->id_date] = $obj; } //retrieve editions info //TO DO ... } // if we must subdived the users into the org_chart folders we must retrive some extra info if ($org_chart_subdivision == 1) { require_once $GLOBALS['where_framework'] . '/lib/lib.orgchart.php'; $org_man = new OrgChartManager(); if ($alluser == 1) { $elem_selected = $org_man->getAllGroupIdFolder(); } else { $elem_selected = $user_selected; } $org_name = $org_man->getFolderFormIdst($elem_selected); if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) { require_once _base_ . '/lib/lib.preference.php'; $adminManager = new AdminPreference(); $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST()); $org_name_temp = $org_name; $org_name = array(); foreach ($org_name_temp as $id => $value) { if (isset($admin_tree[$id])) { $org_name[$id] = $value; } } } } if (empty($user_selected)) { cout($lang->def('_NULL_SELECTION'), 'content'); return; } // Retrive all the course $id_courses = $course_man->getAllCourses(); if (empty($id_courses)) { return $lang->def('_NULL_COURSE_SELECTION'); } $re_category = sql_query("\r\n\t\tSELECT idCategory, path\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_category"); $category_list = array(0 => $lang->def('_NONE')); $category_path_list = array(0 => '/'); while (list($id_cat, $name_cat) = sql_fetch_row($re_category)) { $category_list[$id_cat] = substr($name_cat, strrpos($name_cat, '/') + 1); $category_path_list[$id_cat] = substr($name_cat, 5, strlen($name_cat) - 5); //eliminates "/root" } $time_list = array(); $session_list = array(); $lastaccess_list = array(); $query = "\r\n\t\tSELECT idUser, idCourse, COUNT(*), SUM(UNIX_TIMESTAMP(lastTime) - UNIX_TIMESTAMP(enterTime)), MAX(lastTime)\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_tracksession\r\n\t\tWHERE 1 " . ($alluser > 0 ? "" : "AND idUser IN ( " . implode(',', $user_selected) . " ) ") . ($filter_allcourses ? "" : "AND idCourse IN (" . implode(',', $filter_courseselection) . ") "); //if($start_time != '') $query .= " AND enterTime >= '".$start_time."' "; //if($end_time != '') $query .= " AND lastTime <= '".$end_time."' "; $query .= "GROUP BY idUser, idCourse "; $re_time = sql_query($query); while (list($id_u, $id_c, $session_num, $time_num, $last_num) = sql_fetch_row($re_time)) { $session_list[$id_u . '_' . $id_c] = $session_num; $time_list[$id_u . '_' . $id_c] = $time_num; $lastaccess_list[$id_u . '_' . $id_c] = $last_num; } //recover start and final score require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $org_man = new OrganizationManagement(false); $score_start = $org_man->getStartObjectScore($user_selected, array_keys($id_courses)); $score_final = $org_man->getFinalObjectScore($user_selected, array_keys($id_courses)); require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; $rep_man = new CourseReportManager(); $score_course = $rep_man->getUserFinalScore($user_selected, array_keys($id_courses)); //set query suspended users condition $query_show_suspended = "u.valid = 1"; //default condition switch ($show_suspended) { case "all": $query_show_suspended = "1"; break; case "suspended_only": $query_show_suspended = "u.valid = 0"; break; case "active_only": $query_show_suspended = "u.valid = 1"; break; } //set query order by param $_dir = "ASC"; switch ($order_dir) { case "desc": $_dir = "DESC"; break; } $query_order_by = "u.userid, c.code"; switch ($order_by) { case 'firstname': $query_order_by = "u.firstname " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'lastname': $query_order_by = "u.lastname " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'email': $query_order_by = "u.email " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'course_code': $query_order_by = "c.code " . $_dir . ", u.userid " . $_dir . ""; break; case 'course_name': $query_order_by = "c.name " . $_dir . ", c.code " . $_dir . ", u.userid " . $_dir . ""; break; case 'status': $query_order_by = "cu.status " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'level': $query_order_by = "cu.level " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'date_subscription': $query_order_by = "cu.date_inscr " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'date_first_access': $query_order_by = "cu.date_first_access " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'date_last_access': $query_order_by = "cu.date_last_access " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; case 'date_complete': $query_order_by = "cu.date_complete " . $_dir . ", u.userid " . $_dir . ", c.code " . $_dir . ""; break; } if ($org_chart_subdivision == 0) { // find some information if ($show_classrooms_editions) { $query_course_user = "******" . " cu.status, cu.date_inscr, cu.date_first_access, cu.date_complete, c.mediumTime, c.course_type, c.credits, " . " u.userid, u.firstname, u.lastname, u.email, u.register_date, u.valid, " . " d.id_date, du.date_subscription AS classroom_date_subscription, du.date_complete AS classroom_date_complete " . " FROM ( %lms_courseuser AS cu JOIN %lms_course AS c JOIN %adm_user as u " . " ON (cu.idCourse = c.idCourse AND cu.idUser = u.idst) ) " . " LEFT JOIN (%lms_course_date AS d JOIN %lms_course_date_user AS du ON (d.id_date = du.id_date)) " . " ON (d.id_course = cu.idCourse AND du.id_user = cu.idUser) " . " WHERE " . $query_show_suspended . " " . ($alluser > 0 ? "" : "AND cu.idUser IN ( " . implode(',', $user_selected) . " ) ") . ($filter_allcourses ? "" : "AND c.idCourse IN (" . implode(',', $filter_courseselection) . ") ") . " ORDER BY " . $query_order_by; } else { $query_course_user = "******" . " cu.status, cu.date_inscr, cu.date_first_access, cu.date_complete, c.mediumTime, c.course_type, c.credits, " . " u.userid, u.firstname, u.lastname, u.email, u.register_date, u.valid " . " FROM %lms_courseuser AS cu JOIN %lms_course AS c JOIN %adm_user as u " . " ON (cu.idCourse = c.idCourse AND cu.idUser = u.idst) " . " WHERE " . $query_show_suspended . " = 1 " . ($alluser > 0 ? "" : "AND cu.idUser IN ( " . implode(',', $user_selected) . " ) ") . ($filter_allcourses ? "" : "AND c.idCourse IN (" . implode(',', $filter_courseselection) . ") ") . " ORDER BY " . $query_order_by; } $output .= $this->_printTable_courses($type, $query_course_user, $category_list, $category_path_list, $session_list, $lastaccess_list, $time_list, $score_start, $score_final, $score_course, $user_selected, $filter_columns, $show_classrooms_editions, $classrooms_editions_info); } else { $date_now = Format::date(date("Y-m-d H:i:s")); reset($org_name); while (list($idst_group, $folder_name) = each($org_name)) { if ($type == 'html') { cout('<div class="datasummary">' . '<b>' . $lang->def('_FOLDER_NAME') . ' :</b> ' . $folder_name['name'] . ($folder_name['type_of_folder'] == ORG_CHART_WITH_DESCENDANTS ? ' (' . $lang->def('_WITH_DESCENDANTS') . ')' : '') . '<br />', 'content'); cout('<b>' . $lang->def('_CREATION_DATE') . ' :</b> ' . $date_now . '<br /></div>', 'content'); } $group_user = $acl_man->getGroupAllUser($idst_group); // find some information if ($show_classrooms_editions) { $query_course_user = "******" . " cu.status, cu.date_inscr, cu.date_first_access, cu.date_complete, c.mediumTime, c.course_type, c.credits, " . " u.userid, u.firstname, u.lastname, u.email, u.register_date, u.valid, " . " d.id_date, du.date_subscription AS classroom_date_subscription, du.date_complete AS classroom_date_complete " . " FROM ( %lms_courseuser AS cu JOIN %lms_course AS c JOIN %adm_user as u " . " ON (cu.idCourse = c.idCourse AND cu.idUser = u.idst) ) " . " LEFT JOIN (%lms_course_date AS d JOIN %lms_course_date_user AS du ON (d.id_date = du.id_date)) " . " ON (d.id_course = cu.idCourse AND du.id_user = cu.idUser) " . " WHERE " . $query_show_suspended . " " . (!empty($group_user) ? " AND cu.idUser IN ( " . implode(',', $group_user) . " ) " : " AND 0 ") . ($filter_allcourses ? "" : "AND c.idCourse IN (" . implode(',', $filter_courseselection) . ") ") . " ORDER BY " . $query_order_by; } else { $query_course_user = "******" . " cu.status, cu.date_inscr, cu.date_first_access, cu.date_complete, c.mediumTime, c.course_type, c.credits, " . " u.userid, u.firstname, u.lastname, u.email, u.register_date, u.valid " . " FROM %lms_courseuser AS cu JOIN %lms_course AS c JOIN %adm_user as u " . " ON (cu.idCourse = c.idCourse AND cu.idUser = u.idst) " . " WHERE " . $query_show_suspended . " = 1 " . (!empty($group_user) ? " AND cu.idUser IN ( " . implode(',', $group_user) . " ) " : " AND 0 ") . ($filter_allcourses ? "" : "AND c.idCourse IN (" . implode(',', $filter_courseselection) . ") ") . " ORDER BY " . $query_order_by; } $output .= $this->_printTable_courses($type, $query_course_user, $category_list, $category_path_list, $session_list, $lastaccess_list, $time_list, $score_start, $score_final, $score_course, $filter_userselection, $filter_columns, $show_classrooms_editions, $classrooms_editions_info); } } return $output; }
function _get_courses_query($type = 'html', $report_data = NULL, $other = '') { require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once dirname(__FILE__) . '/report_tableprinter.php'; if ($report_data == NULL) { $ref =& $_SESSION['report_tempdata']; } else { $ref =& $report_data; } $fw = $GLOBALS['prefix_fw']; $lms = $GLOBALS['prefix_lms']; $sel_all = $ref['rows_filter']['select_all']; $sel_type = $ref['rows_filter']['selection_type']; $selection = $ref['rows_filter']['selection']; $all_courses = $ref['columns_filter']['all_courses']; $courses = $ref['columns_filter']['selected_courses']; $cols =& $ref['columns_filter']['showed_columns']; $acl = new DoceboACLManager(); $html = ''; $man = new Man_Course(); $courses_codes = $man->getAllCourses(); if ($all_courses) { $courses = array(); foreach ($courses_codes as $key => $val) { $courses[] = $key; } } /* if(Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN) { // if the usre is a subadmin with only few course assigned require_once(_base_.'/lib/lib.preference.php'); $adminManager = new AdminPreference(); $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST()); $courses = array_intersect($courses, $admin_tree['courses']); } */ $increment = 0; if ($cols['completed']) { $increment++; } if ($cols['initinere']) { $increment++; } if ($cols['notstarted']) { $increment++; } if ($cols['show_percentages']) { $increment = $increment * 2; } /* //admin users filter $acl_man = Docebo::user()->getACLManager(); $userlevelid = Docebo::user()->getUserLevelId(); if ( $userlevelid != ADMIN_GROUP_GODADMIN ) { require_once(_base_.'/lib/lib.preference.php'); $adminManager = new AdminPreference(); $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST()); $admin_users = $acl_man->getAllUsersFromSelection($admin_tree); $admin_users = array_unique($admin_users); }*/ $userlevelid = Docebo::user()->getUserLevelId(); if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) { //filter users $alluser = false; require_once _base_ . '/lib/lib.preference.php'; $adminManager = new AdminPreference(); $admin_users = $adminManager->getAdminUsers(Docebo::user()->getIdST()); //$user_selected = array_intersect($user_selected, $admin_users); //unset($admin_users); //filter courses $admin_courses = $adminManager->getAdminCourse(Docebo::user()->getIdST()); if ($all_courses) { $all_courses = false; $rs = sql_query("SELECT idCourse FROM %lms_course"); $course_selected = array(); while (list($id_course) = sql_fetch_row($rs)) { $course_selected[] = $id_course; } } if (isset($admin_courses['course'][0])) { //No filter } elseif (isset($admin_courses['course'][-1])) { require_once _lms_ . '/lib/lib.catalogue.php'; $cat_man = new Catalogue_Manager(); $user_catalogue = $cat_man->getUserAllCatalogueId(Docebo::user()->getIdSt()); if (count($user_catalogue) > 0) { $courses = array(0); foreach ($user_catalogue as $id_cat) { $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true); $courses = array_merge($courses, $catalogue_course); } foreach ($courses as $id_course) { if ($id_course != 0) { $admin_courses['course'][$id_course] = $id_course; } } } elseif (Get::sett('on_catalogue_empty', 'off') == 'on') { //No filter } if (!empty($admin_courses['course'])) { $_clist = array_values($admin_courses['course']); $course_selected = array_intersect($course_selected, $_clist); } else { $course_selected = array(); } } else { $array_courses = array(); $array_courses = array_merge($array_courses, $admin_courses['course']); if (!empty($admin_courses['coursepath'])) { require_once _lms_ . '/lib/lib.coursepath.php'; $path_man = new Catalogue_Manager(); $coursepath_course =& $path_man->getAllCourses($admin_courses['coursepath']); $array_courses = array_merge($array_courses, $coursepath_course); } if (!empty($admin_courses['catalogue'])) { require_once _lms_ . '/lib/lib.catalogue.php'; $cat_man = new Catalogue_Manager(); foreach ($admin_courses['catalogue'] as $id_cat) { $catalogue_course =& $cat_man->getCatalogueCourse($id_cat, true); $array_courses = array_merge($array_courses, $catalogue_course); } } $admin_courses['course'] = array_merge($admin_courses['course'], $array_courses); if (!empty($admin_courses['course'])) { $_clist = array_values($admin_courses['course']); $course_selected = array_intersect($course_selected, $_clist); } else { $course_selected = array(); } } unset($admin_courses); } switch ($sel_type) { case 'groups': //retrieve all labels $orgchart_labels = array(); $query = "SELECT * FROM " . $fw . "_org_chart WHERE lang_code='" . getLanguage() . "'"; $res = sql_query($query); while ($row = mysql_fetch_assoc($res)) { $orgchart_labels[$row['id_dir']] = $row['translation']; } $labels = array(); $query = "SELECT * FROM " . $fw . "_group WHERE (hidden='false' OR groupid LIKE '/oc_%' OR groupid LIKE '/ocd_%') AND type='free'"; $res = sql_query($query); while ($row = mysql_fetch_assoc($res)) { if ($row['hidden'] == 'false') { $labels[$row['idst']] = $acl->relativeId($row['groupid']); } else { $temp = explode("_", $row['groupid']); //echo '<div>'.print_r($temp,true).'</div>'; if ($temp[0] == '/oc') { $labels[$row['idst']] = $temp[1] != 0 ? $orgchart_labels[$temp[1]] : ''; } elseif ($temp[0] == '/ocd') { $labels[$row['idst']] = $temp[1] != 0 ? $orgchart_labels[$temp[1]] : ''; } } } $tot_size = 2; $head1 = array(array('colspan' => 2, 'value' => $this->lang->def('_GROUPS'))); $head2 = array($this->lang->def('_NAME'), $this->lang->def('_TOTAL')); foreach ($courses as $course) { $head1[] = array('value' => ($courses_codes[$course]['code'] ? '[' . $courses_codes[$course]['code'] . '] ' : '') . $courses_codes[$course]['name'], 'colspan' => $increment); if ($cols['completed']) { $head2[] = $this->lang->def('_USER_STATUS_END'); } if ($cols['completed'] && $cols['show_percentages']) { $head2[] = _PERCENT_SIMBOL; } if ($cols['initinere']) { $head2[] = $this->lang->def('_USER_STATUS_BEGIN'); } if ($cols['initinere'] && $cols['show_percentages']) { $head2[] = _PERCENT_SIMBOL; } if ($cols['notstarted']) { $head2[] = $this->lang->def('_USER_STATUS_SUBS'); } if ($cols['notstarted'] && $cols['show_percentages']) { $head2[] = _PERCENT_SIMBOL; } $tot_size += $increment; } $buffer = new ReportTablePrinter($type, true); $buffer->openTable('', ''); $buffer->openHeader(); $buffer->addHeader($head1); $buffer->addHeader($head2); $buffer->closeHeader(); $tot_users = 0; $course_stats = array(); //for each group, retrieve label and user statistics foreach ($selection as $dir_id => $group_id) { $group_users = $acl->getGroupAllUser($group_id); if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) { $group_users = array_intersect($group_users, $admin_users); } $users_num = count($group_users); $line = array(); $line[] = $labels[$group_id]; $line[] = $users_num; $tot_users += $users_num; if (count($group_users) > 0) { $query = "SELECT cu.idUser, cu.idCourse, cu.status " . " FROM " . $lms . "_courseuser as cu, " . $lms . "_course as c, " . $fw . "_user as u " . " WHERE cu.idUser=u.idst AND cu.idCourse=c.idCourse " . " AND u.idst IN (" . implode(",", $group_users) . ") " . (!$all_courses ? " AND c.idCourse IN (" . implode(",", $courses) . " )" : ""); $res = sql_query($query); //$tot_completed = 0; while ($row = mysql_fetch_assoc($res)) { if (!isset($course_stats[$row['idCourse']][$group_id])) { $course_stats[$row['idCourse']][$group_id] = array('completed' => 0, 'initinere' => 0, 'notstarted' => 0, 'total' => 0); } switch ((int) $row['status']) { case 2: $course_stats[$row['idCourse']][$group_id]['completed']++; break; case 1: $course_stats[$row['idCourse']][$group_id]['initinere']++; break; case 0: $course_stats[$row['idCourse']][$group_id]['notstarted']++; break; } $course_stats[$row['idCourse']][$group_id]['total']++; } foreach ($courses as $course) { if (isset($course_stats[$course][$group_id])) { if ($course_stats[$course][$group_id]['total'] == 0) { $dividend = 1; } else { $dividend = $course_stats[$course][$group_id]['total']; } if ($cols['completed']) { $line[] = $course_stats[$course][$group_id]['completed']; } if ($cols['completed'] && $cols['show_percentages']) { $line[] = number_format(100.0 * $course_stats[$course][$group_id]['completed'] / $dividend, 2, ',', '') . _PERCENT_SIMBOL; } if ($cols['initinere']) { $line[] = $course_stats[$course][$group_id]['initinere']; } if ($cols['initinere'] && $cols['show_percentages']) { $line[] = number_format(100.0 * $course_stats[$course][$group_id]['initinere'] / $dividend, 2, ',', '') . _PERCENT_SIMBOL; } if ($cols['notstarted']) { $line[] = $course_stats[$course][$group_id]['notstarted']; } if ($cols['notstarted'] && $cols['show_percentages']) { $line[] = number_format(100.0 * $course_stats[$course][$group_id]['notstarted'] / $dividend, 2, ',', '') . _PERCENT_SIMBOL; } } else { if ($cols['completed']) { $line[] = '0'; } if ($cols['completed'] && $cols['show_percentages']) { $line[] = '0,00%'; } if ($cols['initinere']) { $line[] = '0'; } if ($cols['initinere'] && $cols['show_percentages']) { $line[] = '0,00%'; } if ($cols['notstarted']) { $line[] = '0'; } if ($cols['notstarted'] && $cols['show_percentages']) { $line[] = '0,00%'; } } } //$line[] = $tot_completed; } else { foreach ($courses as $course) { if ($cols['completed']) { $line[] = '0'; } if ($cols['completed'] && $cols['show_percentages']) { $line[] = '0,00%'; } if ($cols['initinere']) { $line[] = '0'; } if ($cols['initinere'] && $cols['show_percentages']) { $line[] = '0,00%'; } if ($cols['notstarted']) { $line[] = '0'; } if ($cols['notstarted'] && $cols['show_percentages']) { $line[] = '0,00%'; } } } $buffer->addLine($line); } $buffer->closeBody(); //echo '<pre>'.print_r($course_stats,true).'</pre>'; //calc totals $foot = array('', $tot_users); foreach ($courses as $course) { $completed_total = 0; $initinere_total = 0; $notstarted_total = 0; $total_total = 0; foreach ($selection as $dir_id => $group_id) { $completed_total += isset($course_stats[$course][$group_id]['completed']) ? $course_stats[$course][$group_id]['completed'] : 0; $initinere_total += isset($course_stats[$course][$group_id]['initinere']) ? $course_stats[$course][$group_id]['initinere'] : 0; $notstarted_total += isset($course_stats[$course][$group_id]['notstarted']) ? $course_stats[$course][$group_id]['notstarted'] : 0; $total_total += isset($course_stats[$course][$group_id]['total']) ? $course_stats[$course][$group_id]['total'] : 0; } if ($cols['completed']) { $foot[] = $completed_total; } if ($cols['completed'] && $cols['show_percentages']) { $foot[] = $total_total != 0 ? number_format(100.0 * $completed_total / $total_total, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL; } if ($cols['initinere']) { $foot[] = $initinere_total; } if ($cols['initinere'] && $cols['show_percentages']) { $foot[] = $total_total != 0 ? number_format(100.0 * $initinere_total / $total_total, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL; } if ($cols['notstarted']) { $foot[] = $notstarted_total; } if ($cols['notstarted'] && $cols['show_percentages']) { $foot[] = $total_total != 0 ? number_format(100.0 * $notstarted_total / $total_total, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL; } } $buffer->setFoot($foot); $buffer->closeTable(); $html .= $buffer->get(); break; case 'users': $temp = array(); // resolve the user selection $users =& $acl->getAllUsersFromIdst($selection); if ($userlevelid != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) { $users = array_intersect($users, $admin_users); } if (count($users) <= 0) { $html .= '<p>' . $this->lang->def('_EMPTY_SELECTION') . '</p>'; break; } $query = "SELECT cu.idUser, cu.idCourse, cu.status, u.userId, c.code, u.firstname, u.lastname " . " FROM ( " . $lms . "_courseuser as cu " . " JOIN " . $lms . "_course as c ON ( cu.idCourse = c.idCourse) ) " . " JOIN " . $fw . "_user as u ON (cu.idUser = u.idst) " . " WHERE 1 " . " AND cu.idCourse IN (" . implode(",", $courses) . ") " . ($sel_all ? "" : " AND idUser IN (" . implode(",", $users) . ")") . ""; $res = sql_query($query); while ($row = mysql_fetch_array($res)) { if (!isset($temp[$row['idUser']])) { $temp[$row['idUser']] = array('username' => $acl->relativeId($row['userId']), 'fullname' => $row['lastname'] . ' ' . $row['firstname'], 'courses' => array()); } $temp[$row['idUser']]['courses'][$row['idCourse']] = $row['status']; } //echo '<pre>'; //print_r($temp); //draw table $tot_size = 1; $head2 = array($this->lang->def('_USERNAME'), $this->lang->def('_FULLNAME')); $head1 = array(array('colspan' => 2, 'value' => $this->lang->def('_USER'))); foreach ($courses as $course) { $head1[] = array('value' => ($courses_codes[$course]['code'] ? '[' . $courses_codes[$course]['code'] . '] ' : '') . $courses_codes[$course]['name'], 'colspan' => $increment); if ($cols['completed']) { $head2[] = $this->lang->def('_USER_STATUS_END'); } if ($cols['completed'] && $cols['show_percentages']) { $head2[] = _PERCENT_SIMBOL; } if ($cols['initinere']) { $head2[] = $this->lang->def('_USER_STATUS_BEGIN'); } if ($cols['initinere'] && $cols['show_percentages']) { $head2[] = _PERCENT_SIMBOL; } if ($cols['notstarted']) { $head2[] = $this->lang->def('_USER_STATUS_SUBS'); } if ($cols['notstarted'] && $cols['show_percentages']) { $head2[] = _PERCENT_SIMBOL; } $tot_size += $increment; } $buffer = new ReportTablePrinter($type, true); $buffer->openTable('', ''); $buffer->openHeader(); $buffer->addHeader($head1); $buffer->addHeader($head2); $buffer->closeHeader(); $completed_total = array(); $initinere_total = array(); $notstarted_total = array(); $courses_total = array(); foreach ($courses as $course) { $completed_total[$course] = 0; $initinere_total[$course] = 0; $notstarted_total[$course] = 0; $courses_total[$course] = 0; } $buffer->openBody(); foreach ($temp as $id_user => $table_row) { $line = array(); $line[] = $table_row['username']; $line[] = $table_row['fullname']; foreach ($courses as $course) { if (isset($table_row['courses'][$course])) { if ($cols['completed']) { $line[] = $table_row['courses'][$course] == 2 ? 1 : 0; } if ($cols['completed'] && $cols['show_percentages']) { $line[] = $table_row['courses'][$course] == 2 ? '100' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL : '0' . _PERCENT_SIMBOL; } if ($cols['initinere']) { $line[] = $table_row['courses'][$course] == 1 ? 1 : 0; } if ($cols['initinere'] && $cols['show_percentages']) { $line[] = $table_row['courses'][$course] == 1 ? '100' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL : '0' . _PERCENT_SIMBOL; } if ($cols['notstarted']) { $line[] = $table_row['courses'][$course] == 0 ? 1 : 0; } if ($cols['notstarted'] && $cols['show_percentages']) { $line[] = $table_row['courses'][$course] == 0 ? '100' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL : '0' . _PERCENT_SIMBOL; } switch ((int) $table_row['courses'][$course]) { case 2: if (isset($completed_total[$course])) { $completed_total[$course] += 1; } else { $completed_course[$course] = 1; } break; case 1: if (isset($initinere_total[$course])) { $initinere_total[$course] += 1; } else { $initinere_course[$course] = 1; } break; case 0: if (isset($notstarted_total[$course])) { $notstarted_total[$course] += 1; } else { $notstarted_course[$course] = 1; } break; } if (isset($courses_total[$course])) { $courses_total[$course] += 1; } else { $courses_total[$course] = 1; } } else { if ($cols['completed']) { $line[] = '0'; } if ($cols['completed'] && $cols['show_percentages']) { $line[] = '0' . _PERCENT_SIMBOL; } if ($cols['initinere']) { $line[] = '0'; } if ($cols['initinere'] && $cols['show_percentages']) { $line[] = '0' . _PERCENT_SIMBOL; } if ($cols['notstarted']) { $line[] = '0'; } if ($cols['notstarted'] && $cols['show_percentages']) { $line[] = '0' . _PERCENT_SIMBOL; } if (isset($courses_total[$course])) { $courses_total[$course] += 1; } else { $courses_total[$course] = 1; } } } $buffer->addLine($line); } $buffer->closeBody(); $totals_line = array('', ''); foreach ($courses as $course) { $completed_num = isset($completed_total[$course]) ? $completed_total[$course] : '0'; $initinere_num = isset($initinere_total[$course]) ? $initinere_total[$course] : '0'; $notstarted_num = isset($notstarted_total[$course]) ? $notstarted_total[$course] : '0'; $total_num = isset($courses_total[$course]) ? $courses_total[$course] : '0'; if ($cols['completed']) { $totals_line[] = $completed_num; } if ($cols['completed'] && $cols['show_percentages']) { $totals_line[] = $total_num != 0 ? number_format(100.0 * $completed_num / $total_num, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL; } if ($cols['initinere']) { $totals_line[] = $initinere_num; } if ($cols['initinere'] && $cols['show_percentages']) { $totals_line[] = $total_num != 0 ? number_format(100.0 * $initinere_num / $total_num, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL; } if ($cols['notstarted']) { $totals_line[] = $notstarted_num; } if ($cols['notstarted'] && $cols['show_percentages']) { $totals_line[] = $total_num != 0 ? number_format(100.0 * $notstarted_num / $total_num, 2, _DECIMAL_SEPARATOR, '') . _PERCENT_SIMBOL : '0' . _DECIMAL_SEPARATOR . '00' . _PERCENT_SIMBOL; } } $buffer->setFoot($totals_line); $buffer->closeTable(); $html .= $buffer->get(); break; } return $html; }
function addEvent() { checkPerm('view'); require_once _base_ . '/lib/lib.form.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; $lang =& DoceboLanguage::createInstance('reservation'); $out = $GLOBALS['page']; $out->setWorkingZone('content'); $man_res = new Man_Reservation(); $man_course = new Man_Course(); if (isset($_GET['confirm'])) { $confirm = importVar('confirm', true, 0); $id_course = importVar('id_course', true, 0); $id_laboratory = importVar('id_laboratory', true, 0); $id_category = importVar('id_category', true, 0); $title = importVar('title', false, ''); $description = importVar('description', false, ''); $date = importVar('date', false, ''); $max_user = importVar('max_user', true, 0); $deadline = importVar('deadline', false, ''); $from_time_h = importVar('from_time_h', false, ''); $from_time_m = importVar('from_time_m', false, ''); $to_time_h = importVar('to_time_h', false, ''); $to_time_m = importVar('to_time_m', false, ''); $date = Format::dateDb($date, 'date'); $deadline = Format::dateDb($deadline, 'date'); $from_time = $from_time_h . ':' . $from_time_m . ':00'; $to_time = $to_time_h . ':' . $to_time_m . ':00'; if ($date < date('Y-m-d') || $date < $deadline) { Util::jump_to('index.php?modname=reservation&op=add_event&error=date'); } if ($from_time >= $to_time) { Util::jump_to('index.php?modname=reservation&op=add_event&error=time'); } if ($confirm) { $result = $man_res->addEvents($id_course, $id_laboratory, $id_category, $title, $description, $date, $max_user, $deadline, $from_time, $to_time); } if ($result) { Util::jump_to('index.php?modname=reservation&op=view_event'); } Util::jump_to('index.php?modname=reservation&op=add_event&error=laboratory'); } $out->add(getTitleArea($lang->def('_NEW_EVENT'), '', $lang->def('_EVENT')) . '<div class="std_block">'); $error = importVar('error', false, ''); if ($error !== '') { switch ($error) { case 'date': $out->add(getErrorUi($lang->def('_WRONG_DATE'))); break; case 'time': $out->add(getErrorUi($lang->def('_WRONG_TIME'))); break; case 'laboratory': $out->add(getErrorUi($lang->def('_LOCATION_BUSY'))); break; } } $course = array(); $course = $man_course->getAllCourses(); $course_id = array(); foreach ($course as $sources) { $course_id[$sources['id_course']] = $sources['name']; } $out->add(Form::openForm('form_event', 'index.php?modname=reservation&op=add_event&confirm=1') . Form::openElementSpace() . Form::getTextfield($lang->def('_TITLE'), 'title', 'title', 255) . Form::getTextarea($lang->def('_DESCRIPTION'), 'description', 'description') . Form::getDropdown($lang->def('_COURSE'), 'id_course', 'id_course', $course_id) . Form::getDropdown($lang->def('_LOCATION'), 'id_laboratory', 'id_laboratory', $man_res->getLaboratories()) . Form::getDropdown($lang->def('_CATEGORY'), 'id_category', 'id_category', $man_res->getCategory()) . Form::getDateField($lang->def('_DATE'), 'date', 'date') . Form::getDateField($lang->def('_DEADLINE'), 'deadline', 'deadline') . Form::getTextfield($lang->def('_MAX_USER'), 'max_user', 'max_user', 255) . Form::getLineBox($lang->def('_FROM_TIME'), Form::getInputDropdown('', 'from_time_h', 'from_time_h', $man_res->getHours(), false, false) . ' : ' . Form::getInputDropdown('', 'from_time_m', 'from_time_m', $man_res->getMinutes(), false, false)) . Form::getLineBox($lang->def('_TO_TIME'), Form::getInputDropdown('', 'to_time_h', 'to_time_h', $man_res->getHours(), false, false) . ' : ' . Form::getInputDropdown('', 'to_time_m', 'to_time_m', $man_res->getMinutes(), false, false)) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('send_event', 'send_event', $lang->def('_NEW_EVENT')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm()); $out->add('</div>', 'content'); }
public function sel_users_coursepath_actionTask() { $id_path = Get::Req('id_path', DOTY_INT, 0); if ($id_path <= 0) { //... return; } $selection = Get::req('userselector_input', DOTY_MIXED, true); $new_selection = $selection['coursepath_subscriptions']; $old_selection = $this->model->getCoursePathSubscriptionsList($id_path); $new_selection = explode(",", $new_selection); $new_selection = $this->acl_man->getAllUsersFromSelection($new_selection); $_common = array_intersect($new_selection, $old_selection); $_to_add = array_diff($new_selection, $_common); $_to_del = array_diff($old_selection, $_common); $res = true; if (!$res) { $result = 'err_subscribe'; } else { $result = 'ok_subcribe'; } require_once _lms_ . '/lib/lib.coursepath.php'; $path_man = new CoursePath_Manager(); //1 - get list of the courses of the coursepath $base_url = 'index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path; $courses = $path_man->getAllCourses(array($id_path)); if (empty($courses)) { Util::jump_to($base_url); } //2 - check if there are any editions or classrooms require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; $course_man = new Man_Course(); $classroom = $course_man->getAllCourses(false, 'classroom', $courses); $edition = $course_man->getAllCourses(false, 'edition', $courses); //3 - if yes, then make a second step in order to choose editions and classrooms if (!empty($classroom) || !empty($edition)) { $classroom_list = array(); if (!empty($classroom)) { require_once _lms_ . '/lib/lib.date.php'; $date_man = new DateManager(); foreach ($classroom as $id_course => $info) { $classrooms = $date_man->getCourseDate($id_course, true); $classrooms_for_dropdown = array(); $classrooms_for_dropdown[0] = Lang::t('_NO_CLASSROOM_SUBSCRIPTION', 'coursepath'); foreach ($classrooms as $classroom_info) { $classrooms_for_dropdown[$classroom_info['id_date']] = $classroom_info['code'] . ' - ' . $classroom_info['name'] . ' - ' . Format::date($classroom_info['date_begin'], 'date') . ' - ' . Format::date($classroom_info['date_end'], 'date'); } $classroom_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $classrooms_for_dropdown); //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'classroom_'.$id_course, 'classroom_'.$id_course, $edition_for_dropdown)); } } $edition_list = array(); if (!empty($edition)) { require_once _lms_ . '/lib/lib.edition.php'; $edition_man = new EditionManager(); foreach ($edition as $id_course => $info) { $editions = $edition_man->getEditionsInfoByCourses($id_course); $editions_for_dropdown = array(); $editions_for_dropdown[0] = Lang::t('_NONE', 'coursepath'); foreach ($editions[$id_course] as $edition_info) { $editions_for_dropdown[$edition_info['id_edition']] = $edition_info['code'] . ' - ' . $edition_info['name'] . ' - ' . Format::date($edition_info['date_begin'], 'date') . ' - ' . Format::date($edition_info['date_end'], 'date'); } $edition_list[] = array('id_course' => $id_course, 'label' => $info['name'], 'list' => $edition_for_dropdown); //cout(Form::getDropdown(Lang::t('_EDITION_SELECTION', 'coursepath').' : '.$info['code'].' - '.$info['name'], 'edition_'.$id_course, 'edition_'.$id_course, $edition_for_dropdown)); } } $this->render('choose_editions_coursepath', array('id_path' => $id_path, 'courses_list' => $courses, 'editions_list' => $edition_list, 'classrooms_list' => $classroom_list, 'users_to_add' => $_to_add, 'users_to_del' => $_to_del, 'path_name' => $this->model->getCoursepathNameForSubscription($id_path))); } else { $path_man->subscribeUserToCoursePath($id_path, $_to_add); require_once _lms_ . '/lib/lib.course.php'; foreach ($courses as $id_course) { $docebo_course = new DoceboCourse($id_course); $level_idst =& $docebo_course->getCourseLevel($id_course); if (count($level_idst) == 0 || $level_idst[1] == '') { $level_idst =& $docebo_course->createCourseLevel($id_course); } foreach ($_to_add as $id_user) { $level = 3; //student $waiting = false; //$this->acl_man->addToGroup($level_idst[$level], $id_user); $this->_addToCourseGroup($level_idst[$level], $id_user); $this->model->id_course = $id_course; $this->model->subscribeUser($id_user, $level, $waiting); } } Util::jump_to('index.php?r=' . $this->link . '/show_coursepath&id_path=' . (int) $id_path . '&res=' . $result); } }
function addsubscriptionedition() { require_once _lms_ . '/lib/lib.subscribe.php'; require_once _lms_ . '/lib/lib.coursepath.php'; $cpath_man = new CoursePath_Manager(); $subs_man = new CourseSubscribe_Management(); $id_path = Get::req('id_path', DOTY_INT, 0); $user_selected = unserialize(urldecode(Get::req('users', DOTY_MIXED, array()))); $courses = $cpath_man->getAllCourses(array($id_path)); if (isset($_POST['undo']) || !isset($_POST['save'])) { Util::jump_to('index.php?modname=coursepath&op=addsubscription&id_path=' . $id_path); } $re = true; $query_pathlist = "\r\n\tSELECT path_name, subscribe_method\r\n\tFROM " . $GLOBALS['prefix_lms'] . "_coursepath\r\n\tWHERE id_path = '" . $id_path . "'\r\n\tORDER BY path_name "; list($path_name, $subscribe_method) = sql_fetch_row(sql_query($query_pathlist)); if ($subscribe_method != 1 && !checkPerm('moderate', true)) { $waiting = 1; } else { $waiting = 0; } $users_subsc = array(); $course_man = new Man_Course(); $assessment = $course_man->getAllCourses(false, 'assessment', $courses); $classroom = $course_man->getAllCourses(false, 'classroom', $courses); $edition = $course_man->getAllCourses(false, 'edition', $courses); $array_id_date = array(); $array_id_edition = array(); if (!empty($classroom)) { foreach ($classroom as $id_course => $info) { if (Get::req('classroom_' . $id_course, DOTY_INT, 0) != 0) { $array_id_date[Get::req('classroom_' . $id_course, DOTY_INT, 0)] = Get::req('classroom_' . $id_course, DOTY_INT, 0); } } } if (!empty($edition)) { foreach ($edition as $id_course => $info) { if (Get::req('edition_' . $id_course, DOTY_INT, 0) != 0) { $array_id_edition[Get::req('edition_' . $id_course, DOTY_INT, 0)] = Get::req('edition_' . $id_course, DOTY_INT, 0); } } } require_once _lms_ . '/lib/lib.date.php'; $date_man = new DateManager(); require_once _lms_ . '/lib/lib.edition.php'; $edition_man = new EditionManager(); while (list(, $id_user) = each($user_selected)) { $text_query = "\r\n\t\tINSERT INTO " . $GLOBALS['prefix_lms'] . "_coursepath_user\r\n\t\t( id_path, idUser, waiting, subscribed_by ) VALUES\r\n\t\t( '" . $id_path . "', '" . $id_user . "', '" . $waiting . "', '" . getLogUserId() . "' )"; $re_s = sql_query($text_query); if ($re_s == true) { $users_subsc[] = $id_user; } $re &= $re_s; if (!empty($assessment)) { foreach ($assessment as $id_assessment => $assessment_info) { sql_query("INSERT INTO %lms_assessment_user (id_assessment, id_user, type_of) VALUES ('" . $id_assessment . "', '" . $id_user . "', 'user')"); } reset($assessment); } if (!empty($array_id_date)) { foreach ($array_id_date as $id_date) { $date_man->addUserToDate($id_date, $id_user, Docebo::user()->getIdSt()); } reset($array_id_date); } if (!empty($array_id_edition)) { foreach ($array_id_edition as $id_edition) { $edition_man->addUserToEdition($id_edition, $id_user, Docebo::user()->getIdSt()); } reset($array_id_edition); } } // now subscribe user to all the course if ($waiting == 0) { $re &= $subs_man->multipleSubscribe($users_subsc, $courses, 3); } Util::jump_to('index.php?modname=coursepath&op=pathlist&result=' . ($re ? 'ok' : 'err')); }
function displayCoursePathList(&$url, $selected_tab) { 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.coursepath.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.preassessment.php'; require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; $lang =& DoceboLanguage::createInstance('catalogue'); $lang_c =& DoceboLanguage::createInstance('course'); $nav_bar = new NavBar('ini', Get::sett('visuItem'), 0); $nav_bar->setLink($url->getUrl()); $ini = $nav_bar->getSelectedElement(); $course_man = new Man_Course(); $path_man = new CoursePath_Manager(); $cat_man = new Catalogue_Manager(); $man_courseuser = new Man_CourseUser(); $profile = new UserProfile(getLogUserId()); $profile->init('profile', 'framework', '', 'ap'); $profile->addStyleSheet('lms'); $catalogues =& $cat_man->getUserAllCatalogueId(getLogUserId()); if (!empty($catalogues)) { // at least one catalogue is assigned to this user $cat_path =& $cat_man->getAllCoursepathOfUser(getLogUserId()); if (!empty($cat_path)) { $path_man->filterInPath($cat_path); } } elseif (Get::sett('on_catalogue_empty') == 'off') { $path_man->filterInPath(array(0)); } if (!Docebo::user()->isAnonymous()) { if (!isset($_SESSION['cp_assessment_effect'])) { $pa_man = new AssessmentList(); $arr_assessment = $pa_man->getUserAssessmentSubsription(Docebo::user()->getArrSt()); $report = new CourseReportManager(); $user_result = $report->getAllUserFinalScore(getLogUserId(), $arr_assessment['course_list']); $rule_man = new AssessmentRule(); $ass_elem = $rule_man->getCompleteEffectListForAssessmentWithUserResult($arr_assessment['course_list'], $user_result); $_SESSION['cp_assessment_effect'] = urlencode(serialize($ass_elem)); } else { $ass_elem = unserialize(urldecode($_SESSION['cp_assessment_effect'])); } if (!empty($ass_elem['parsed']['coursepath'])) { $path_man->filterOrInPath($ass_elem['parsed']['coursepath']); } } // retrive all the classroorm // search for the coursepath ------------------------------------------------------ $coursepath = $path_man->getCoursepathList($ini, Get::sett('visuItem')); if (empty($coursepath)) { // no path found for the criteria --------------------------------------------- $GLOBALS['page']->add('<p class="no_course_found">' . $lang->def('_NO_COURSE_FOUND') . '</p></div>', 'content'); return; } // find structures of the course path --------------------------------------------- $courses = $path_man->getPathStructure(array_keys($coursepath)); $path_slot = $path_man->getPathSlot(array_keys($coursepath)); // fin user subscription needed --------------------------------------------------- $user_paths =& $path_man->getUserSubscriptionsInfo(getLogUserId(), false); $usercourses =& $man_courseuser->getUserSubscriptionsInfo(getLogUserId(), false); // find course basilar information ------------------------------------------------ $course_info = $course_man->getAllCourses(false, false, $courses['all_items'], true); $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content'); while (list($id_path, $path) = each($coursepath)) { $html = '<div class="coursepath_container">'; $in_h = ' <span class="coursepath_subscribe">'; $can_subs = true; if (isset($ass_elem['parsed']['coursepath'])) { if (isset($ass_elem['not_done']['coursepath']) && in_array($id_path, $ass_elem['not_done']['coursepath'])) { // the assosiacted preassessment is not done $in_h .= ''; //$lang->def('_MUST_DO_PREASSESSMENT'); $can_subs = false; } elseif (isset($ass_elem['to_apply']['coursepath']) && in_array($id_path, $ass_elem['to_apply']['coursepath'])) { // the assosiacted preassessment suggest this coursepath $in_h .= $lang->def('_PREASSESSMENT_SUGGESTION'); } } else { switch ($path[COURSEPATH_METHOD]) { case METHOD_WAIT: $in_h .= $lang->def('_METHOD_WAIT'); break; case METHOD_AUTO: $in_h .= $lang->def('_METHOD_AUTO'); break; case METHOD_MANUAL: default: $in_h .= $lang->def('_METHOD_MANUAL'); $can_subs = false; break; } } $in_h .= '</span>'; $in_h .= ' <span class="coursepath_status">'; if (isset($usercourses[$id_path])) { // user is alredy subscribed to this coursepath if ($usercourses[$id_path]['waiting']) { $in_h .= $lang->def('_COURSEPATH_WAITING'); } else { $in_h .= $lang->def('_USER_STATUS_SUBS'); } } $in_h .= '</span>'; // ------------------------------------------------------------- $html .= '<div class="coursepath_info_container">'; $html .= '<h2 class="pathtitle">' . $in_h . ($path[COURSEPATH_CODE] != '' ? '[' . $path[COURSEPATH_CODE] . '] ' : '') . $path[COURSEPATH_NAME] . '</h2>' . '<p class="course_support_info">' . str_replace('[enrolled]', $path[CP_ENROLLED], $lang->def('_COURSEPATH_INTRO')) . '</p>'; if (!isset($courses[$id_path]) || empty($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 .= '<h4>' . $lang->def('_MANDATORY') . '</h4>'; if (!empty($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 .= '<h4>' . $title . '</h4>'; if (!empty($courses[$id_path][$id_slot])) { $html .= '<ul class="coursepath_otherslot">'; } } $i = 0; while (list($id) = each($courses[$id_path][$id_slot])) { $html .= '<li class="path_course ' . ($i % 2 ? 'path_odd' : '') . '">' . '<a class="show_details_more" href="javascript:;" onclick="course_dash(this, \'' . $id . '\',\'info_' . $id_path . '_' . $id . '\', \'' . $can_subs . '\');">' . $lang->def('_DETAILS') . '</a>' . ($course_info[$id]['code'] != '' ? ' [' . $course_info[$id]['code'] . '] ' : '') . $course_info[$id]['name'] . '<div id="info_' . $id_path . '_' . $id . '"></div>' . '</li>'; $i++; } if (!empty($courses[$id_path][$id_slot])) { $html .= '</ul>'; } } } $html .= '</div>'; $html .= '</div>'; $GLOBALS['page']->add($html, 'content'); } $GLOBALS['page']->add($nav_bar->getNavBar($ini), 'content'); }