diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 149fdfa3de..6bb26f426b 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -964,7 +964,6 @@ switch ($action) { } break; case 'get_exercise_grade': - //@TODO replace this for a more efficient function (not retrieving the whole data) $objExercise = new Exercise(); $exercises = $objExercise->getExercisesByCouseSession($_GET['course_id'], $_GET['session_id']); $cntExer = 3; @@ -975,19 +974,32 @@ switch ($action) { $columns = array(); //Get dynamic column names $i = 1; + $column_names = array(); foreach (range(1, $cntExer) as $cnt) { switch ($cnt) { case 1: - $columns[] = 'username'; + $columns[] = 'session'; + $column_names[] = get_lang('Section'); break; case 2: + $columns[] = 'username'; + $column_names[] = get_lang('Username'); + break; + case 3: $columns[] = 'name'; + $column_names[] = get_lang('Name'); break; case $cntExer: $columns[] = 'finalScore'; + $column_names[] = get_lang('FinalScore'); break; default: + $title = ""; + if (!empty($exercises[$cnt - 4]['title'])) { + $title = ucwords(strtolower(trim($exercises[$cnt - 4]['title']))); + } $columns[] = 'exer' . $i; + $column_names[] = $title; $i++; break; } @@ -1009,13 +1021,15 @@ switch ($action) { $exeResults = $objExercise->getExerciseAndResult($_GET['course_id'], $_GET['session_id'], $quizIds); $arrGrade = array(); - foreach($exeResults as $exeResult) { + foreach ($exeResults as $exeResult) { $arrGrade[$exeResult['exe_user_id']][$exeResult['exe_exo_id']] = $exeResult['exe_result']; } - + $result = array(); $i = 0; - foreach($users as $user) { + foreach ($users as $user) { + $sessionInfo = SessionManager::fetch($listUserSess[$user['user_id']]['id_session']); + $result[$i]['session'] = $sessionInfo['name']; $result[$i]['username'] = $user['user_id']; $result[$i]['name'] = $user['lastname'] . " " . $user['firstname']; $j = 1; @@ -1037,7 +1051,7 @@ switch ($action) { $i++; } - $count = count($users); + //$count = count($users); break; case 'get_extra_field_options': $obj = new ExtraFieldOption($type); diff --git a/main/mySpace/myspace.lib.php b/main/mySpace/myspace.lib.php index 1dd9378342..c7c95cf2bd 100644 --- a/main/mySpace/myspace.lib.php +++ b/main/mySpace/myspace.lib.php @@ -443,6 +443,15 @@ class MySpace { 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', @@ -451,7 +460,7 @@ class MySpace { 'search' => 'true', ); break; - case 2: + case 3: $column[] = get_lang('FirstName'); $column_model[] = array( 'name' => 'name', @@ -472,8 +481,8 @@ class MySpace { break; default: $title = ""; - if (!empty($exercises[$cnt - 3]['title'])) { - $title = ucwords(strtolower(trim($exercises[$cnt - 3]['title']))); + if (!empty($exercises[$cnt - 4]['title'])) { + $title = ucwords(strtolower(trim($exercises[$cnt - 4]['title']))); } $column[] = $title;