function statuserfilter() { require_once _base_ . '/lib/lib.table.php'; require_once _base_ . '/lib/lib.form.php'; require_once _lms_ . '/lib/lib.subscribe.php'; $lang =& DoceboLanguage::createInstance('stats', 'lms'); $out =& $GLOBALS['page']; $form = new Form(); $aclManager =& Docebo::user()->getACLManager(); $out->setWorkingZone('content'); $GLOBALS['module_assigned_name'][$GLOBALS['modname']] = $lang->def('_STATFORUSER'); $out->add(getTitleArea($lang->def('_STATFORUSER'), 'stats')); $out->add('<div class="std_block">'); $group_filter = Get::req('group_filter', DOTY_INT, STATFILTER_ALL_GROUP); $status_filter = Get::req('status_filter', DOTY_INT, STATFILTER_ALL_STATUS); $editions_filter = Get::req('editions_filter', DOTY_INT, STATFILTER_ALL_EDITION); $date_filter = Get::req('date_filter', DOTY_INT, STATFILTER_ALL_EDITION); $user_filter = Get::req('user_filter', DOTY_MIXED, ''); $cs = new CourseSubscribe_Manager(); /* * Print form for group and status selection */ $out->add($form->openForm("statuserfilter", "index.php?modname=stats&op=statuser")); // ------- Filter on group $arr_idst = $aclManager->getBasePathGroupST('/lms/course/' . (int) $_SESSION['idCourse'] . '/group'); $arr_result_groups = $aclManager->getGroups($arr_idst); $std_content = $aclManager->getContext(); $aclManager->setContext('/lms/course/' . (int) $_SESSION['idCourse'] . '/group'); $arr_groups = array(STATFILTER_ALL_GROUP => $lang->def('_ALL')); foreach ($arr_result_groups as $idst_group => $info_group) { if (!$info_group[ACL_INFO_GROUPHIDDEN]) { $arr_groups[$idst_group] = $aclManager->relativeId($info_group[ACL_INFO_GROUPID]); } } $aclManager->setContext($std_content); $out->add(Form::getTextField(Lang::t('_FULLNAME', 'standard'), 'user_filter', 'user_filter', 255, $user_filter)); $out->add($form->getDropdown($lang->def('_GROUPS'), 'group_filter', 'group_filter', $arr_groups, $group_filter)); // ------ Filter on status $arr_status = array(STATFILTER_ALL_STATUS => $lang->def('_FILTERSTATUSSELECTONEOPTION')); $arr_status = $arr_status + $cs->getUserStatus(); $out->add($form->getDropdown($lang->def('_ORDER_BY'), 'status_filter', 'status_filter', $arr_status, $status_filter)); //--- filter on edition ------------------------------------------------------ //retrieve edition $query = "SELECT * FROM %lms_course_editions WHERE id_course = " . (int) $_SESSION['idCourse']; $res = sql_query($query); //is there more any edition ? if (sql_num_rows($res) > 0) { $arr_editions = array(STATFILTER_ALL_EDITION => $lang->def('_FILTEREDITIONSELECTONEOPTION')); //list of editions for the dropdown, in the format: "[code] name (date_begin - date_end)" while ($einfo = sql_fetch_object($res)) { $_label = ''; if ($einfo->code != '') { $_label .= '[' . $einfo->code . '] '; } if ($einfo->name != '') { $_label .= $einfo->neme; } if (($einfo->date_begin != '' || $einfo->date_begin != '0000-00-00') && ($einfo->date_end != '' || $einfo->date_end != '0000-00-00')) { $_label .= ' (' . Format::date($einfo->date_begin, 'date') . ' - ' . Format::date($einfo->date_end, 'date') . ')'; } if ($_label == '') { //... } $arr_editions[$einfo->id_edition] = $_label; } //draw editions dropdown $out->add($form->getDropdown($lang->def('_FILTEREDITIONSELECTTITLE'), 'editions_filter', 'editions_filter', $arr_editions, $editions_filter)); } //--- filter on class ------------------------------------------------------ //retrieve class (date) //$query = "SELECT * FROM %lms_course_date WHERE id_course = ".(int)$_SESSION['idCourse']; $query = "SELECT dt.id_date, dt.code, dt.name, MIN( dy.date_begin ) AS sub_start_date, MAX( dy.date_end ) AS sub_end_date\r\n\t\tFROM %lms_course_date AS dt\r\n\t\tJOIN %lms_course_date_day AS dy ON dy.id_date = dt.id_date\r\n\t\tWHERE dt.id_course = " . (int) $_SESSION['idCourse'] . "\r\n\t\tGROUP BY dt.id_date\r\n\t\tORDER BY dy.date_begin"; $res = sql_query($query); //is there more any edition ? if (sql_num_rows($res) > 0) { $arr_date = array(STATFILTER_ALL_EDITION => $lang->def('_FILTEREDITIONSELECTONEOPTION')); //list of editions for the dropdown, in the format: "[code] name (date_begin - date_end)" while ($einfo = sql_fetch_object($res)) { $_label = ''; if ($einfo->code != '') { $_label .= '[' . $einfo->code . '] '; } if ($einfo->name != '') { $_label .= $einfo->neme; } if (($einfo->sub_start_date != '' || $einfo->sub_start_date != '0000-00-00') && ($einfo->sub_end_date != '' || $einfo->sub_end_date != '0000-00-00')) { $_label .= ' (' . Format::date($einfo->sub_start_date, 'date') . ' - ' . Format::date($einfo->sub_end_date, 'date') . ')'; } if ($_label == '') { //... } $arr_date[$einfo->id_date] = $_label; } //draw editions dropdown $out->add($form->getDropdown($lang->def('_FILTEREDITIONSELECTTITLE'), 'date_filter', 'date_filter', $arr_date, $date_filter)); } //------------------------------------------------------------------------------ if (isset($_POST['start_filter']) && ($_POST['start_filter'] = 1)) { $out->add($form->getCheckBox($lang->def('_FILTEROBJECTFINISHED'), 'start_filter', 'start_filter', '1', true)); } else { $out->add($form->getCheckBox($lang->def('_FILTEROBJECTFINISHED'), 'start_filter', 'start_filter', '1')); } $out->add('<br/>'); $out->add($form->getButton('gofilter', 'gofilter', $lang->def('_SEARCH'))); /* * Get all students of course that is contained in selected group * For any student compute progress */ $tabStat = new Table(Get::sett('visuItem'), $lang->def('_STATS_USERS'), $lang->def('_STATS_USERS')); $tabStat->initNavBar('ini', 'button'); $limit = $tabStat->getSelectedElement(); // step 2) load all students of course in selected group $lev = false; $group_all_members = false; if ($group_filter != STATFILTER_ALL_GROUP) { $group_all_members = $aclManager->getGroupAllUser($group_filter); } //$students = getSubscribedInfo((int)$_SESSION['idCourse'], FALSE, $lev, TRUE, ( $status_filter != -1 ? $status_filter : false ), false, true); $students = getSubscribedInfo((int) $_SESSION['idCourse'], false, $lev, true, $status_filter != STATFILTER_ALL_STATUS ? $status_filter : false, $editions_filter != STATFILTER_ALL_EDITION ? $editions_filter : false, true, $user_filter, $group_all_members, $limit, $date_filter != STATFILTER_ALL_EDITION ? $date_filter : false); $query = "SELECT COUNT(*)" . " FROM %lms_courseuser AS cu" . ($user_filter !== '' ? " JOIN " . $GLOBALS['prefix_fw'] . "_user AS u ON u.idst = cu.idUser" : '') . " WHERE cu.idCourse = " . (int) $_SESSION['idCourse'] . ($status_filter != STATFILTER_ALL_STATUS ? " AND cu.status = '" . $status_filter . "'" : '') . ($user_filter !== '' ? " AND (u.firstname LIKE '%" . $user_filter . "%' OR u.lastname LIKE '%" . $user_filter . "%' OR u.userid LIKE '%" . $user_filter . "%')" : '') . ($group_all_members !== false ? " AND c.idUser IN (" . implode(',', $group_all_members) . ")" : ''); list($total_user) = sql_fetch_row(sql_query($query)); $content_h = array($lang->def('_USERNAME'), $lang->def('_STATS_FULLNAME'), $lang->def('_STATUS'), $lang->def('_LEARNING_OBJECTS'), $lang->def('_PROGRESS')); $type_h = array('', '', 'image', 'image', 'image'); $tabStat->setColsStyle($type_h); $tabStat->addHead($content_h); $aclManager =& Docebo::user()->getACLManager(); $acl =& Docebo::user()->getACL(); // search memebers of the selected group foreach ($students as $idst => $user_course_info) { if ($group_filter == STATFILTER_ALL_GROUP || in_array($idst, $group_all_members)) { $user_info = $aclManager->getUser($idst, FALSE); if ($user_info != false) { $totItems = getNumCourseItems((int) $_SESSION['idCourse'], FALSE, $idst, FALSE); $totComplete = getStatStatusCount($idst, (int) $_SESSION['idCourse'], array('completed', 'passed')); $totFailed = getStatStatusCount($idst, (int) $_SESSION['idCourse'], array('failed')); $stat_status = $cs->getUserStatusTr($user_course_info['status']); if (isset($_POST['start_filter']) && ($_POST['start_filter'] = 1)) { if ($totComplete) { // now print entry $content = array('<a href="index.php?modname=stats&op=statoneuser&idUser='******'" >' . $aclManager->relativeId($user_info[ACL_INFO_USERID]) . '</a>', $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME], '<a href="index.php?modname=stats&op=modstatus&idUser='******'">' . $stat_status . '</a>'); $content[] = $totComplete . '/' . $totFailed . '/' . $totItems; $content[] = renderProgress($totComplete, $totFailed, $totItems); $tabStat->addBody($content); } } else { // now print entry $content = array('<a href="index.php?modname=stats&op=statoneuser&idUser='******'" >' . $aclManager->relativeId($user_info[ACL_INFO_USERID]) . '</a>', $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME], '<a href="index.php?modname=stats&op=modstatus&idUser='******'">' . $stat_status . '</a>'); $content[] = $totComplete . '/' . $totFailed . '/' . $totItems; $content[] = renderProgress($totComplete, $totFailed, $totItems); $tabStat->addBody($content); } } } } $out->add($tabStat->getTable()); $out->add($tabStat->getNavBar($limit, $total_user)); $out->add($form->closeForm()); $out->add('</div>'); }
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) { $user_stats_table = '<table id="user_stats" class="quick_table">' . '<thead><tr>' . (isset($user_stats['head'][0]) ? '<th scope="col">' . $user_stats['head'][0] . '</th>' : '') . (isset($user_stats['head'][1]) ? '<th scope="col">' . $user_stats['head'][1] . '</th>' : '') . (isset($user_stats['head'][2]) ? '<th scope="col">' . $user_stats['head'][2] . '</th>' : '') . '</tr></thead><tbody><tr>' . (isset($user_stats['body'][0]) ? '<td>' . $user_stats['body'][0] . '</td>' : '') . (isset($user_stats['body'][1]) ? '<td>' . $user_stats['body'][1] . '</td>' : '') . (isset($user_stats['body'][2]) ? '<td>' . $user_stats['body'][2] . '</td>' : '') . '</tr></tbody>' . '</table>'; $all_stats .= "</br>Progress:</span>" . renderProgress($tot_complete, $tot_failed, $total, false); } $course_stats_table = ""; if (Docebo::course()->getValue('show_progress') == 1 && true) { $course_stats_table .= '<table id="course_stats" class="quick_table">' . '<thead><tr>' . '<th scope="col">' . Lang::t('_PROGRESS_ALL', 'course') . '</th>' . '<th scope="col">' . Lang::t('_PROGRESS_COMPLETED', 'course') . '</th>' . '<th scope="col">' . Lang::t('_PROGRESS_INCOMPLETE', 'course') . '</th>' . '</tr></thead><tbody><tr>' . '<td>' . $total . '</td>' . '<td>' . $tot_complete . '</td>' . '<td>' . $tot_incomplete . '</td>' . '</tr></tbody>' . '</table>'; $course_stats_table .= "\n";