$new_result = array(); if (!empty($result)) { foreach ($result as $item) { $item['display_text'] = $item['displayText']; $item['field_type'] = $obj->get_field_type_by_id($item['fieldType']); $item['changeable'] = $item['changeable'] ? Display::return_icon('check-circle.png', get_lang('Invisible')) : Display::return_icon('closed-circle.png', get_lang('Visible'), null, ICON_SIZE_SMALL); $item['visible'] = $item['visible'] ? Display::return_icon('check-circle.png', get_lang('Invisible')) : Display::return_icon('closed-circle.png', get_lang('Visible'), null, ICON_SIZE_SMALL); $item['filter'] = $item['filter'] ? Display::return_icon('check-circle.png', get_lang('Invisible')) : Display::return_icon('closed-circle.png', get_lang('Visible'), null, ICON_SIZE_SMALL); $new_result[] = $item; } $result = $new_result; } break; case 'get_exercise_grade': $objExercise = new Exercise(); $exercises = $objExercise->getExercisesByCouseSession($_GET['course_id'], $_GET['session_id']); $cntExer = 4; if (!empty($exercises)) { $cntExer += count($exercises); } $columns = array(); //Get dynamic column names $i = 1; $column_names = array(); foreach (range(1, $cntExer) as $cnt) { switch ($cnt) { case 1: $columns[] = 'session'; $column_names[] = get_lang('Section'); break; case 2:
/** * Display a sortable table that contains an overview off all the progress of the user in a session * @param int $sessionId The session ID * @param int $courseId The course ID * @param null $date_from * @param null $date_to * @internal param int $exerciseId The quiz ID * @internal param int $answer Answer status (0 = incorrect, 1 = correct, 2 = both) * @return string HTML array of results formatted for gridJS * @author Francis Gonzales <*****@*****.**>, Beeznest Team */ static function display_tracking_grade_overview($sessionId = 0, $courseId = 0, $date_from = null, $date_to = null) { /** * Column names * The column order is important. Check $column variable in the main/inc/ajax/model.ajax.php file */ $objExercise = new Exercise(); $exercises = $objExercise->getExercisesByCouseSession($courseId, $sessionId); $cntExer = 4; if (!empty($exercises)) { $cntExer += count($exercises); } $column = array(); $column_model = array(); $i = 1; //Get dynamic column names foreach (range(1, $cntExer) as $cnt) { switch ($cnt) { case 1: $column[] = get_lang('Section'); $column_model[] = array('name' => 'session', 'index' => 'session', 'align' => 'center', 'search' => 'true'); break; case 2: $column[] = get_lang('Username'); $column_model[] = array('name' => 'username', 'index' => 'username', 'align' => 'center', 'search' => 'true'); break; case 3: $column[] = get_lang('FirstName'); $column_model[] = array('name' => 'name', 'index' => 'name', 'align' => 'left', 'search' => 'true'); break; case $cntExer: $column[] = get_lang('FinalScore'); $column_model[] = array('name' => 'finalscore', 'index' => 'finalscore', 'align' => 'center', 'search' => 'true', 'wrap_cell' => "true"); break; default: $title = ""; if (!empty($exercises[$cnt - 4]['title'])) { $title = ucwords(strtolower(trim($exercises[$cnt - 4]['title']))); } $column[] = $title; $column_model[] = array('name' => 'exer' . $i, 'index' => 'exer' . $i, 'align' => 'center', 'search' => 'true', 'wrap_cell' => "true"); $i++; break; } } //end get dynamic column names // jqgrid will use this URL to do the selects $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_grade&session_id=' . $sessionId . '&course_id=' . $courseId; // Autowidth $extra_params['autowidth'] = 'true'; // height auto $extra_params['height'] = 'auto'; $tableId = 'exerciseGradeOverview'; $table = Display::grid_js($tableId, $url, $column, $column_model, $extra_params, array(), '', true); $return = '<script>$(function() {' . $table . 'jQuery("#' . $tableId . '").jqGrid("navGrid","#' . $tableId . '_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); jQuery("#' . $tableId . '").jqGrid("navButtonAdd","#' . $tableId . '_pager",{ caption:"", title:"' . get_lang('ExportExcel') . '", onClickButton : function () { jQuery("#' . $tableId . '").jqGrid("excelExport",{"url":"' . $url . '&export_format=xls"}); } }); });</script>'; $return .= Display::grid_html($tableId); return $return; }