示例#1
0
 public function getCourseStatsTotal($id_course, $filter)
 {
     $query = "SELECT COUNT(*) " . " FROM " . $this->tables['courseuser'] . " as cu " . " JOIN " . $this->tables['user'] . " as u " . " ON (cu.idUser = u.idst AND cu.idCourse=" . (int) $id_course . ") ";
     if (is_array($filter)) {
         $condition = array();
         if (isset($filter['text']) && $filter['text'] != "") {
             $conditions[] = " (u.userid LIKE '%" . $filter['text'] . "%' OR u.firstname LIKE '%" . $filter['text'] . "%' OR u.lastname LIKE '%" . $filter['text'] . "%') ";
         }
         if (isset($filter['selection']) && $filter['selection'] > 0) {
             switch ($filter['selection']) {
                 //begin only
                 case 1:
                     $conditions[] = " cu.status = 0 ";
                     break;
                     //itinere only
                 //itinere only
                 case 2:
                     $conditions[] = " cu.status = 1 ";
                     break;
                     //complete only
                 //complete only
                 case 3:
                     $conditions[] = " cu.status = 2 ";
                     break;
             }
         }
         $arr_idst = array();
         if (isset($filter['orgchart']) && $filter['orgchart'] > 0) {
             $umodel = new UsermanagementAdm();
             $use_desc = isset($filter['descendants']) && $filter['descendants'];
             $ulist = $umodel->getFolderUsers($filter['orgchart'], $use_desc);
             if (!empty($ulist)) {
                 $arr_idst = $ulist;
             }
             unset($ulist);
         }
         if (isset($filter['groups']) && $filter['groups'] > 0) {
             $gmodel = new GroupmanagementAdm();
             $ulist = $gmodel->getGroupAllUsers($filter['groups']);
             if (!empty($ulist)) {
                 if (!empty($arr_idst)) {
                     $arr_idst = array_merge($arr_idst, $ulist);
                 } else {
                     $arr_idst = $ulist;
                 }
             }
         }
         if (!empty($arr_idst)) {
             $conditions[] = " u.idst IN (" . implode(",", $arr_idst) . ") ";
         }
         if (!empty($conditions)) {
             $query .= " WHERE " . implode(" AND ", $conditions) . " ";
         }
     }
     $res = $this->db->query($query);
     if ($res) {
         list($count) = $this->db->fetch_row($res);
     } else {
         $count = false;
     }
     return $count;
 }
 public function showTask()
 {
     $id_course = isset($_SESSION['idCourse']) && $_SESSION['idCourse'] > 0 ? $_SESSION['idCourse'] : false;
     if ((int) $id_course <= 0) {
         //...
         return;
     }
     Util::get_js(Get::rel_path("base") . '/lib/js_utils.js', true, true);
     Util::get_js(Get::rel_path("lms") . '/views/coursestats/coursestats.js', true, true);
     $total_users = $this->model->getCourseStatsTotal($id_course, false);
     $lo_totals = $this->model->getLOsTotalCompleted($id_course);
     $_arr_js = array();
     foreach ($lo_totals as $id_lo => $total_lo) {
         $_arr_js[] = '{id:"lo_totals_' . $id_lo . '", total:"' . $total_lo . ' / ' . $total_users . '", ' . 'percent:"' . number_format($total_lo / $total_users, 2) . ' %"}';
     }
     $lo_totals_js = implode(",", $_arr_js);
     //WARNING: lo_list and lo_totals must have the same keys order
     $umodel = new UsermanagementAdm();
     $gmodel = new GroupmanagementAdm();
     $params = array('id_course' => $id_course, 'lo_list' => $this->model->getCourseLOs($id_course), 'filter_text' => "", 'filter_selection' => 0, 'filter_orgchart' => 0, 'filter_groups' => 0, 'filter_descendants' => false, 'is_active_advanced_filter' => false, 'orgchart_list' => $umodel->getOrgChartDropdownList(), 'groups_list' => $gmodel->getGroupsDropdownList(), 'total_users' => (int) $total_users, 'lo_totals_js' => $lo_totals_js, 'status_list' => $this->_getJsArrayStatus(), 'permissions' => $this->permissions);
     $this->render('show', $params);
 }