diff --git a/main/admin/session_list.php b/main/admin/session_list.php index c39f8800de..238f066541 100644 --- a/main/admin/session_list.php +++ b/main/admin/session_list.php @@ -152,10 +152,7 @@ $(function() { jQuery("#sessions").jqGrid('filterToolbar',options); var sgrid = $("#sessions")[0]; sgrid.triggerToolbar(); - - }); -
-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 - AND ce.c_id=".api_get_course_int_id()." + AND ce.c_id=".api_get_course_int_id()." $exercise_where "; // sql for hotpotatoes tests for teacher / tutor view @@ -918,46 +906,35 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { AND tth.exe_cours_id = '" . api_get_course_id()."' $hotpotatoe_where $sqlWhereOption + AND $where_condition ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC"; } else { // get only this user's results - $user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' '; - - /*$sql="SELECT ".(api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1").", ce.title as extitle, te.exe_result as exresult, " . - "te.exe_weighting as exweight, te.exe_date as exdate, te.exe_id as exid, email as exemail, " . - "te.start_date as exstart, steps_counter as exstep, cuser.user_id as excruid, te.exe_duration as exduration, ce.results_disabled as exdisabled - FROM $TBL_EXERCICES AS ce , $TBL_TRACK_EXERCICES AS te, $TBL_USER AS user,$tbl_course_rel_user AS cuser - WHERE user.user_id=cuser.user_id AND te.exe_exo_id = ce.id AND te.status != 'incomplete' AND cuser.user_id=te.exe_user_id - AND te.exe_cours_id='" . Database :: escape_string($_cid) . "' - AND cuser.relation_type<>".COURSE_RELATION_TYPE_RRHH." $user_id_and $session_id_and AND ce.active <>-1 AND" . - " orig_lp_id = 0 AND orig_lp_item_id = 0 AND cuser.course_code=te.exe_cours_id ORDER BY col1, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";*/ - - $sql = "SELECT - ce.title as col0, - ce.title as col1, - te.exe_duration as exduration, + + $sql = "SELECT DISTINCT + te.exe_duration, + te.start_date, firstname, lastname, - te.exe_result as exresult, - te.exe_weighting as exweight, - te.exe_date as exdate, - te.exe_id as exid, - email as exemail, - te.start_date as col2, - steps_counter as exstep, - exe_user_id as excruid, - ce.results_disabled as exdisabled, + te.exe_result, + te.exe_weighting, + te.exe_date, + te.exe_id, + email as exemail, + steps_counter, + exe_user_id, + ce.results_disabled, propagate_neg FROM $TBL_EXERCICES AS ce INNER JOIN $TBL_TRACK_EXERCICES AS te ON (te.exe_exo_id = ce.id) INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id) - WHERE + WHERE $extra_where_conditions AND te.status != 'incomplete' AND te.exe_cours_id='" . api_get_course_id() . "' - $user_id_and $session_id_and + AND te.exe_user_id = ".api_get_user_id() . " $session_id_and AND ce.active <>-1 AND orig_lp_id = 0 AND orig_lp_item_id = 0 @@ -968,7 +945,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { FROM $TBL_TRACK_HOTPOTATOES WHERE exe_user_id = '" . api_get_user_id() . "' AND exe_cours_id = '" . api_get_course_id() . "' $hotpotatoe_where ORDER BY exe_cours_id ASC, exe_date DESC"; - } + } $teacher_list = CourseManager::get_teacher_list_from_course_code(api_get_course_id()); $teacher_id_list = array(); @@ -977,12 +954,13 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } if (empty($hotpotatoe_where)) { - $column = intval($column); + $column = empty($column) ? : Database::escape_string($column); $from = intval($from); $number_of_items = intval($number_of_items); - $sql .= " ORDER BY col$column $direction "; + $sql .= " ORDER BY $column $direction "; $sql .= " LIMIT $from, $number_of_items"; - + + //var_dump($sql); $results = array(); $resx = Database::query($sql); @@ -996,6 +974,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { $lang_nostartdate = get_lang('NoStartDate') . ' / '; if (is_array($results)) { + $users_array_id = array(); if ($_GET['gradebook'] == 'view') { $filter_by_no_revised = true; @@ -1003,69 +982,62 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } $sizeof = count($results); - $user_list_id = array (); - $user_last_name = ''; - $user_first_name = ''; + $user_list_id = array (); $quiz_name_list = ''; $duration_list = ''; $date_list = ''; $result_list = ''; $more_details_list = ''; + for ($i = 0; $i < $sizeof; $i++) { - $revised = false; - $sql_exe = 'SELECT exe_id FROM ' . $TBL_TRACK_ATTEMPT_RECORDING . ' WHERE author != "" AND exe_id = ' . Database :: escape_string($results[$i]['exid']) .' LIMIT 1'; + $revised = $results[$i]['revised']; + + /*$sql_exe = 'SELECT exe_id FROM ' . $TBL_TRACK_ATTEMPT_RECORDING . ' WHERE author != "" AND exe_id = ' . Database :: escape_string($results[$i]['exe_id']) .' LIMIT 1'; $query = Database::query($sql_exe); if (Database :: num_rows($query) > 0) { $revised = true; - } + }*/ if ($from_gradebook && ($is_allowedToEdit || $is_tutor)) { - if (in_array($results[$i]['col2'] . $results[$i]['col0'] . $results[$i]['col1'], $users_array_id)) { + if (in_array($results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname'], $users_array_id)) { continue; } - $users_array_id[] = $results[$i]['col2'] . $results[$i]['col0'] . $results[$i]['col1']; + $users_array_id[] = $results[$i]['username'] . $results[$i]['firstname'] . $results[$i]['lastname']; } - if ($is_allowedToEdit || $is_tutor) { - $user_first_name = $results[$i]['col0']; - $user_last_name = $results[$i]['col1']; - $user_login = $results[$i]['col2']; - $user = $results[$i]['col0'] . $results[$i]['col1']; - $test = $results[$i]['col3']; + if ($is_allowedToEdit || $is_tutor) { + $user = $results[$i]['firstname'] . $results[$i]['lastname']; + //$test = $results[$i]['col3']; $user_groups = displayGroupsForUser('
', $results[$i]['user_id']); - } else { - $user_first_name = $results[$i]['firstname']; - $user_last_name = $results[$i]['lastname']; + } else { $user = $results[$i]['firstname'] . $results[$i]['lastname']; - $test = $results[$i]['col0']; + //$test = $results[$i]['col0']; } - $user_list_id[] = $results[$i]['excruid']; - $id = $results[$i]['exid']; + $user_list_id[] = $results[$i]['exe_user_id']; + $id = $results[$i]['exe_id']; - $quiz_name_list = $test; - $dt = api_convert_and_format_date($results[$i]['exweight']); - $res = $results[$i]['exresult']; + //$quiz_name_list = $test; + $dt = api_convert_and_format_date($results[$i]['exe_weighting']); + $res = $results[$i]['exe_result']; - $duration = intval($results[$i]['exduration']); // we filter the results if we have the permission to - if (isset ($results[$i]['exdisabled'])) - $result_disabled = intval($results[$i]['exdisabled']); + if (isset ($results[$i]['results_disabled'])) + $result_disabled = intval($results[$i]['results_disabled']); else $result_disabled = 0; if ($result_disabled == 0) { $add_start_date = $lang_nostartdate; - if ($is_allowedToEdit || $is_tutor) { - //var_dump($results[$i]); - $user = $results[$i]['col0'] . $results[$i]['col1']; - $start_date = $results[$i]['col6']; + if ($is_allowedToEdit || $is_tutor) { + $user = $results[$i]['firstname'] . $results[$i]['lastname']; + $start_date = $results[$i]['start_date']; } else { - $start_date = $results[$i]['col2']; + $start_date = $results[$i]['start_date']; } if ($start_date != "0000-00-00 00:00:00") { $start_date_timestamp = api_strtotime($start_date); - $exe_date_timestamp = api_strtotime($results[$i]['exdate']); + $exe_date_timestamp = api_strtotime($results[$i]['exe_date']); $my_duration = ceil((($exe_date_timestamp - $start_date_timestamp) / 60)); //var_dump($start_date .' - '.$results[$i]['exdate'].' - '.$my_duration); @@ -1074,9 +1046,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } else { $duration_list = $my_duration. ' ' . get_lang('MinMinutes'); } - if ($results[$i]['exstep'] > 1) { - //echo ' ( ' . $results[$i][8] . ' ' . get_lang('Steps') . ' )'; - $duration_list = ' ( ' . $results[$i]['exstep'] . ' ' . get_lang('Steps') . ' )'; + if ($results[$i]['exstep'] > 1) { + $duration_list = ' ( ' . $results[$i]['steps_counter'] . ' ' . get_lang('Steps') . ' )'; } //$add_start_date = api_convert_and_format_date($start_date) . ' / '; } else { @@ -1084,28 +1055,24 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { //echo get_lang('NoLogOfDuration'); } // Date conversion - if ($is_allowedToEdit || $is_tutor) { - $date_list = api_get_local_time($results[$i]['col6']). ' / ' . api_get_local_time($results[$i]['exdate']); - } else { - $date_list = api_get_local_time($results[$i]['col2']). ' / ' . api_get_local_time($results[$i]['exdate']); - } + + $date_list = api_get_local_time($results[$i]['start_date']). ' / ' . api_get_local_time($results[$i]['exe_date']); + // there are already a duration test period calculated?? //echo ''.sprintf(get_lang('DurationFormat'), $duration).''; // if the float look like 10.00 we show only 10 - $my_res = $results[$i]['exresult']; - $my_total = $results[$i]['exweight']; + $my_res = $results[$i]['exe_result']; + $my_total = $results[$i]['exe_weighting']; if (!$results[$i]['propagate_neg'] && $my_res < 0) { $my_res = 0; } - $ex = show_score($my_res, $my_total); + $score = show_score($my_res, $my_total); - $result_list = $ex; - $html_link = ''; if ($is_allowedToEdit || $is_tutor) { - if (in_array($results[$i]['excruid'], $teacher_id_list)) { + if (in_array($results[$i]['exe_user_id'], $teacher_id_list)) { $html_link.= Display::return_icon('teachers.gif', get_lang('Teacher')); } if ($revised) { @@ -1126,23 +1093,30 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { $html_link.=' '; } } else { - $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$results[$i]['exid'].'&id_session='.api_get_session_id().'&height=500&width=750'; + $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$results[$i]['exe_id'].'&id_session='.api_get_session_id().'&height=500&width=750'; $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'thickbox a_button white small'))."   "; $html_link.= $attempt_link; - if ($revised) { - $html_link.= Display::span(get_lang('Validated'), array('class'=>'label_tag success')); - } else { - $html_link.= Display::span(get_lang('NotValidated'), array('class'=>'label_tag notice')); - } + } $more_details_list = $html_link; - if ($is_allowedToEdit || $is_tutor) { - $revised = $revised ? get_lang('Revised') : get_lang('NotRevised'); - $list_info[] = array($user_first_name,$user_last_name,$user_login,$user_groups,$quiz_name_list,$duration_list,$date_list,$result_list, $revised, $more_details_list); + if ($is_allowedToEdit || $is_tutor) { + if ($revised) { + $revised = Display::span(get_lang('Validated'), array('class'=>'label_tag success')); + } else { + $revised = Display::span(get_lang('NotValidated'), array('class'=>'label_tag notice')); + } + + //$list_info[] = array($user_first_name,$user_last_name,$user_login,$user_groups,$quiz_name_list,$duration_list,$date_list,$result_list, $revised, $more_details_list); + $results[$i]['status'] = $revised; + $results[$i]['score'] = $score; + $results[$i]['actions'] = $more_details_list; + $list_info[] = $results[$i]; } else { - $list_info[] = array($quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list); + $results[$i]['status'] = $revised; + $results[$i]['score'] = $score; + $list_info[] = $results[$i]; } } } @@ -1170,7 +1144,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } } } - } + } + //var_dump($list_info); return $list_info; } diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index 51042acdf1..c052243b0f 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -13,7 +13,7 @@ * Code */ // name of the language file that needs to be included -$language_file = array('exercice','tracking'); +$language_file = array('exercice'); // including the global library require_once '../inc/global.inc.php'; @@ -22,7 +22,7 @@ require_once '../gradebook/lib/be.inc.php'; // Setting the tabs $this_section = SECTION_COURSES; -$htmlHeadXtra[] = api_get_jquery_ui_js(); +$htmlHeadXtra[] = api_get_jquery_ui_js(true); // Access control api_protect_course_script(true); @@ -316,8 +316,7 @@ if (api_is_allowed_to_edit(null,true)) { $actions .= "  "; $actions .= Display::return_icon('group.gif', get_lang("FilterByGroup")); $actions .= displayGroupMenu("groupFilter", $filterByGroup, "doFilterByGroup()")." "; - } - + } } $parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook'])); @@ -400,6 +399,9 @@ $extra = ''; + + + $extra .= '
'; $extra .= Display::tag('p', Display::input('radio', 'export_format', 'csv', array('checked'=>'1', 'id'=>'export_format_csv_label')). Display::tag('label', get_lang('ExportAsCSV'), array('for'=>'export_format_csv_label'))); $extra .= Display::tag('p', Display::input('radio', 'export_format', 'xls', array('id'=>'export_format_xls_label')). Display::tag('label', get_lang('ExportAsXLS'), array('for'=>'export_format_xls_label'))); @@ -416,4 +418,114 @@ $tpl->assign('content', $content); $tpl->display_one_col_template(); */ + + + +$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results'; + +//$activeurl = '?sidx=session_active'; +// +if ($is_allowedToEdit || $is_tutor) { + + //The order is important you need to check the the $column variable in the model.ajax.php file + $columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), + get_lang('Group'), get_lang('Duration'), get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('Status'), get_lang('Actions')); + +//Column config + $column_model = array( + array('name'=>'firstname', 'index'=>'firstname', 'width'=>'50', 'align'=>'left', 'search' => 'true'), + array('name'=>'lastname', 'index'=>'lastname', 'width'=>'50', 'align'=>'left', 'search' => 'true'), + array('name'=>'login', 'index'=>'username', 'width'=>'40', 'align'=>'left', 'search' => 'true'), + array('name'=>'group', 'index'=>'s', 'width'=>'40', 'align'=>'left', 'search' => 'false'), + array('name'=>'duration', 'index'=>'exe_duration', 'width'=>'30', 'align'=>'left', 'search' => 'true'), + array('name'=>'start_date', 'index'=>'start_date', 'width'=>'60', 'align'=>'left', 'search' => 'true'), + array('name'=>'exe_date', 'index'=>'exe_date', 'width'=>'60', 'align'=>'left', 'search' => 'true'), + array('name'=>'score', 'index'=>'exe_result', 'width'=>'50', 'align'=>'left', 'search' => 'true'), + array('name'=>'status', 'index'=>'revised', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'stype'=>'select', + //for the bottom bar + 'searchoptions' => array( + 'defaultValue' => '1', + 'value' => ':'.get_lang('All').';1:'.get_lang('Revised').';0:'.get_lang('NotRevised')), + + //for the top bar + 'editoptions' => array('value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive'))), +//issue fixed in jqgrid +// array('name'=>'actions', 'index'=>'actions', 'width'=>'100', 'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false') + array('name'=>'actions', 'index'=>'actions', 'width'=>'60', 'align'=>'left', 'search' => 'false') + ); +} else { + + //The order is important you need to check the the $column variable in the model.ajax.php file + $columns = array(get_lang('Duration'), get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('Status')); + + //Column config + $column_model = array( + array('name'=>'duration', 'index'=>'exe_duration', 'width'=>'40', 'align'=>'left', 'search' => 'true'), + array('name'=>'start_date', 'index'=>'start_date', 'width'=>'80', 'align'=>'left', 'search' => 'true'), + array('name'=>'exe_date', 'index'=>'exe_date', 'width'=>'80', 'align'=>'left', 'search' => 'true'), + array('name'=>'score', 'index'=>'exe_result', 'width'=>'40', 'align'=>'left', 'search' => 'true'), + array('name'=>'status', 'index'=>'revised', 'width'=>'40', 'align'=>'left', 'search' => 'false') + + ); +} +//Autowidth +$extra_params['autowidth'] = 'true'; + +//height auto +$extra_params['height'] = 'auto'; +$extra_params['excel'] = 'excel'; + +$extra_params['rowList'] = array(10, 20 ,30); + +?> + + $total_pages) { $start = $limit * $page - $limit; if ($start < 0 ) { $start = 0; -} - +} //4. Deleting an element if the user wants to if ($_REQUEST['oper'] == 'del') { @@ -146,6 +155,22 @@ if ($_REQUEST['oper'] == 'del') { //4. Querying the DB for the elements $columns = array(); switch ($action) { + case 'get_exercise_results': + + + + $is_allowedToEdit = api_is_allowed_to_edit(null,true); + $is_tutor = api_is_allowed_to_edit(true); + $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . "/document"; + + if ($is_allowedToEdit || $is_tutor) { + $columns = array('firstname', 'lastname', 'username', 'groups', 'exe_duration', 'start_date', 'exe_date', 'score','status','actions'); + } else { + $columns = array('exe_duration', 'start_date', 'exe_date', 'score','status'); + } + $result = get_exam_results_data($start, $limit, $sidx, $sord, $where_condition); + + break; case 'get_sessions': $columns = array('name', 'nbr_courses','category_name', 'date_start','date_end', 'coach_name', 'session_active', 'visibility'); $result = SessionManager::get_sessions_admin(array('where'=> $where_condition, 'order'=>"$sidx $sord", 'limit'=> "$start , $limit")); @@ -186,9 +211,6 @@ switch ($action) { $item['skills'] .= Display::span($skill['name'], array('class' => 'label_tag skill')); } } - - - $new_result[] = $item; } $result = $new_result; @@ -250,7 +272,7 @@ switch ($action) { //var_dump($result); //5. Creating an obj to return a json -if (in_array($action, array('get_careers','get_promotions','get_usergroups','get_gradebooks', 'get_sessions'))) { +if (in_array($action, array('get_careers','get_promotions','get_usergroups','get_gradebooks', 'get_sessions','get_exercise_results'))) { $response = new stdClass(); $response->page = $page; $response->total = $total_pages;