Fixing exercise results see #4441

skala
Julio Montoya 14 years ago
parent 559540b4e9
commit 29abbf113e
  1. 11
      main/exercice/exercise.lib.php
  2. 45
      main/inc/ajax/model.ajax.php

@ -859,10 +859,12 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
INNER JOIN $TBL_GROUP_REL_USER gru ON ( gru.user_id = u.user_id AND gru.c_id=".api_get_course_int_id().")
INNER JOIN $TBL_GROUP g ON (gru.group_id = g.id)
)";
}
if (strpos($extra_where_conditions, 'group_all')) {
}
if (strpos($extra_where_conditions, 'group_all')) {
$extra_where_conditions = str_replace("AND ( group_id = 'group_all' )", '', $extra_where_conditions);
$extra_where_conditions = str_replace("AND group_id = 'group_all'", '', $extra_where_conditions);
$sql_inner_join_tbl_user = "
(
SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name
@ -872,6 +874,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
if (strpos($extra_where_conditions, 'group_none')) {
$extra_where_conditions = str_replace("AND ( group_id = 'group_none' )", "AND ( group_id is null )", $extra_where_conditions);
$extra_where_conditions = str_replace("AND group_id = 'group_none'", "AND ( group_id is null )", $extra_where_conditions);
$sql_inner_join_tbl_user = "
(
SELECT u.user_id, firstname, lastname, email, username, g.name as group_name, g.id as group_id
@ -924,7 +927,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
AND orig_lp_item_id = 0
AND ce.c_id=".api_get_course_int_id()."
$exercise_where ";
//var_dump($sql );
// sql for hotpotatoes tests for teacher / tutor view
$hpsql = "SELECT

@ -9,24 +9,25 @@ require_once '../global.inc.php';
$libpath = api_get_path(LIBRARY_PATH);
require_once $libpath.'array.lib.php';
// 1. Setting variables needed by jqgrid
$action= $_GET['a'];
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); //quantity of rows
$sidx = $_REQUEST['sidx']; //index to filter
$sord = $_REQUEST['sord']; //asc or desc
$action = $_GET['a'];
$page = intval($_REQUEST['page']); //page
$limit = intval($_REQUEST['rows']); //quantity of rows
$sidx = $_REQUEST['sidx']; //index (field) to filter
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
}
if ($action != 'get_exercise_results')
if ($action != 'get_exercise_results') {
api_protect_admin_script(true);
}
//Search features
$ops = array(
$ops = array (
'eq' => '=', //equal
'ne' => '<>', //not equal
'lt' => '<', //less than
@ -43,7 +44,7 @@ $ops = array(
'nc' => 'NOT LIKE' //doesn't contain
);
//@todo move this in the display_class
//@todo move this in the display_class or somewhere else
function get_where_clause($col, $oper, $val) {
global $ops;
@ -86,6 +87,7 @@ if ($_REQUEST['_search'] == 'true') {
$where_condition .= ' ) ';
}
}
//var_dump($where_condition);
// get index row - i.e. user click to sort $sord = $_GET['sord'];
// get the direction
@ -157,7 +159,9 @@ switch ($action) {
$course = api_get_course_info();
$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"; //used inside get_exam_results_data()
//used inside get_exam_results_data()
$documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
if ($is_allowedToEdit || $is_tutor) {
$columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score','status','actions');
@ -199,9 +203,7 @@ switch ($action) {
} else {
$item['certificates'] = Display::return_icon('warning.png', get_lang('NoCertificate'), array(), ICON_SIZE_SMALL);
$item['has_certificates'] = '0';
}
$skills_string = '';
}
if (!empty($skills)) {
foreach($skills as $skill) {
$item['skills'] .= Display::span($skill['name'], array('class' => 'label_tag skill'));
@ -280,16 +282,15 @@ if (in_array($action, array('get_careers', 'get_promotions', 'get_usergroups', '
// if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235
if ($row['id'] == "") {
$response->rows[$i]['id']=$i;
}
else {
} else {
$response->rows[$i]['id']=$row['id'];
}
$array = array();
foreach($columns as $col) {
$array[] = $row[$col];
}
$response->rows[$i]['cell']=$array;
$i++;
$array = array();
foreach($columns as $col) {
$array[] = $row[$col];
}
$response->rows[$i]['cell']=$array;
$i++;
}
}
echo json_encode($response);

Loading…
Cancel
Save