From 2863bb7ac171ed90d99b6f271c1e42ba67fc54a3 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 5 Dec 2011 14:49:45 +0100 Subject: [PATCH] Fixing tip bubble in exercise, + showing the status of the exercise result --- main/exercice/exercice.php | 38 ++++++++++++------------------- main/exercice/exercise.lib.php | 13 +++++------ main/exercice/exercise_report.php | 36 +++++++++++++++++++++-------- main/inc/lib/events.lib.inc.php | 29 +++++++++++++---------- 4 files changed, 65 insertions(+), 51 deletions(-) diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 27093656a8..d4e165b74a 100644 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -115,14 +115,6 @@ if ($page < 0) { } -//Deleting an attempt -if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !empty ($_GET['did']) && $_GET['did'] == strval(intval($_GET['did']))) { - $sql = 'DELETE FROM ' . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES) . ' WHERE exe_id = ' . $_GET['did']; //_GET[did] filtered by entry condition - Database::query($sql); - $filter=Security::remove_XSS($_GET['filter']); - header('Location: exercice.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&show=result&filter=' . $filter . '&exerciseId='.$exerciseId.'&filter_by_user='.$_GET['filter_by_user']); - exit; -} if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) { $_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']); @@ -456,7 +448,8 @@ if (!empty($exercise_list)) { $count = 0; if (!empty($exercise_list)) - foreach ($exercise_list as $row) { + foreach ($exercise_list as $row) { + $my_exercise_id = $row['id']; //echo '
'; $i++; //validacion when belongs to a session @@ -539,11 +532,13 @@ if (!empty($exercise_list)) { $title = Display::tag('font', $row['title'], array('style'=>'color:grey')); } else { $title = $row['title']; - } - $count = count_exercise_result($exid, $course_code, $session_id); + } + + $count = intval(count_exercise_result_not_validated($my_exercise_id, $course_code, $session_id)); + $class_tip = ''; - if ($count) { - $results_text = $count == 1 ? get_lang('Result') : get_lang('Results'); + if (!empty($count)) { + $results_text = $count == 1 ? get_lang('ResultNotRevised') : get_lang('ResultsNotRevised'); $title .= ''; $class_tip = 'link_tooltip'; } @@ -551,18 +546,15 @@ if (!empty($exercise_list)) { $url = ' '.$title.' '.$lp_blocked; $item = Display::tag('td', $url.' '.$session_img); - $exid = $row['id']; + //count number exercice - teacher - $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND exercice_id = $exid"; + $sqlquery = "SELECT count(*) FROM $TBL_EXERCICE_QUESTION WHERE c_id = $course_id AND exercice_id = $my_exercise_id"; $sqlresult = Database::query($sqlquery); - $rowi = Database :: result($sqlresult, 0); - - + $rowi = Database :: result($sqlresult, 0); if ($session_id == $row['session_id']) { - //Settings - //$actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),'',22), 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$row['id']); + //Settings $actions = Display::url(Display::return_icon('edit.png',get_lang('Edit'),'',22), 'admin.php?'.api_get_cidreq().'&exerciseId='.$row['id']); $actions .=''.Display :: return_icon('test_results.png', get_lang('Results'),'',22).''; //Export @@ -600,12 +592,12 @@ if (!empty($exercise_list)) { } if ($row['random_by_category'] > 0) { if (!class_exists("testcategory.class.php")) include_once "testcategory.class.php" ; - $nbQuestionsTotal = Testcategory::getNumberOfQuestionRandomByCategory($exid, $random_number_of_question); + $nbQuestionsTotal = Testcategory::getNumberOfQuestionRandomByCategory($my_exercise_id, $random_number_of_question); $number_of_questions .= $nbQuestionsTotal." "; $number_of_questions .= ($nbQuestionsTotal > 1) ? get_lang("QuestionsLowerCase") : get_lang("QuestionLowerCase") ; $number_of_questions .= " - "; - //$number_of_questions .= Testcategory::getNumberMaxQuestionByCat($exid).' '.get_lang('QuestionByCategory'); - $number_of_questions .= min(Testcategory::getNumberMaxQuestionByCat($exid), $random_number_of_question).' '.get_lang('QuestionByCategory'); + //$number_of_questions .= Testcategory::getNumberMaxQuestionByCat($my_exercise_id).' '.get_lang('QuestionByCategory'); + $number_of_questions .= min(Testcategory::getNumberMaxQuestionByCat($my_exercise_id), $random_number_of_question).' '.get_lang('QuestionByCategory'); } else { $random_label = ' ('.get_lang('Random').') '; $number_of_questions = $random_number_of_question . ' ' .$random_label.' '.$textByCategory; diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index bb7a21e096..af12026692 100644 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -879,10 +879,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } $first_and_last_name = api_is_western_name_order() ? "firstname as col0, lastname col1" : "lastname as col0, firstname as col1"; - - // + // sql for chamilo-type tests for teacher / tutor view - // + $sql = "SELECT user_id, $first_and_last_name, @@ -913,7 +912,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { // sql for hotpotatoes tests for teacher / tutor view - $hpsql="SELECT + $hpsql = "SELECT $first_and_last_name , username, tth.exe_name, @@ -1096,7 +1095,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } // Date conversion if ($is_allowedToEdit || $is_tutor) { - $date_list = api_get_local_time($results[$i]['col4']). ' / ' . api_get_local_time($results[$i]['exdate']); + $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']); } @@ -1137,7 +1136,6 @@ 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_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'thickbox'))."   "; @@ -1151,7 +1149,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction) { } $more_details_list = $html_link; if ($is_allowedToEdit || $is_tutor) { - $list_info[] = array($user_first_name,$user_last_name,$user_login,$user_groups,$quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list); + $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); } else { $list_info[] = array($quiz_name_list,$duration_list,$date_list,$result_list,$more_details_list); } diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index 81085a55f2..41a4f43ff2 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -63,11 +63,16 @@ $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); $course_id = api_get_course_int_id(); + +if (empty ($exerciseId)) { + $exerciseId = intval($_REQUEST['exerciseId']); +} + // // filter display by student group // if $_GET['filterByGroup'] = -1 => do not filter // else, filter by group_id (0 for no group) -// +// $filterByGroup = -1; if (isset($_GET['filterByGroup']) && is_numeric($_GET['filterByGroup'])) { $filterByGroup = Security::remove_XSS($_GET['filterByGroup']); @@ -167,8 +172,8 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G } else { $my_comments = ''; } - $my_questionid=$array_content_id_exe[$i]; - $sql = "SELECT question from $TBL_QUESTIONS WHERE id = '$my_questionid'"; + $my_questionid = intval($array_content_id_exe[$i]); + $sql = "SELECT question from $TBL_QUESTIONS WHERE c_id = $course_id AND id = '$my_questionid'"; $result =Database::query($sql); $ques_name = Database::result($result,0,"question"); @@ -176,7 +181,8 @@ if ($_REQUEST['comments'] == 'update' && ($is_allowedToEdit || $is_tutor) && $_G Database::query($query); //Saving results in the track recording table - $recording_changes = 'INSERT INTO '.$TBL_TRACK_ATTEMPT_RECORDING.' (exe_id, question_id, marks, insert_date, author, teacher_comment) VALUES ('."'$id','".$my_questionid."','$my_marks','".api_get_utc_datetime()."','".api_get_user_id()."'".',"'.$my_comments.'")'; + $recording_changes = 'INSERT INTO '.$TBL_TRACK_ATTEMPT_RECORDING.' (exe_id, question_id, marks, insert_date, author, teacher_comment) + VALUES ('."'$id','".$my_questionid."','$my_marks','".api_get_utc_datetime()."','".api_get_user_id()."'".',"'.$my_comments.'")'; Database::query($recording_changes); } @@ -250,6 +256,20 @@ if ($is_allowedToEdit && $origin != 'learnpath') { } + +//Deleting an attempt +if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !empty ($_GET['did']) && $_GET['did'] == strval(intval($_GET['did']))) { + $sql = 'DELETE FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = ' . intval($_GET['did']); //_GET[did] filtered by entry condition + Database::query($sql); + $sql = 'DELETE FROM ' . $TBL_TRACK_ATTEMPT . ' WHERE exe_id = ' . intval($_GET['did']); //_GET[did] filtered by entry condition + Database::query($sql); + + $filter=Security::remove_XSS($_GET['filter']); + header('Location: exercise_report.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&filter=' . $filter . '&exerciseId='.$exerciseId.'&filter_by_user='.$_GET['filter_by_user']); + exit; +} + + if (api_is_allowed_to_edit(null,true)) { if (!$_GET['filter']) { $filter_by_not_revised = true; @@ -316,9 +336,10 @@ if ($is_allowedToEdit || $is_tutor) { $table->set_header(3, get_lang('Group'),false); $table->set_header(4, get_lang('Exercice'),false); $table->set_header(5, get_lang('Duration'),false); - $table->set_header(6, get_lang('Date')); + $table->set_header(6, get_lang('Date')); $table->set_header(7, get_lang('Score'),false); - $table->set_header(8, get_lang('CorrectTest'), false); + $table->set_header(8, get_lang('Status'), false); + $table->set_header(9, get_lang('CorrectTest'), false); } else { $table->set_header(0, get_lang('Exercice')); @@ -329,9 +350,6 @@ if ($is_allowedToEdit || $is_tutor) { } $content = $table->return_table(); -if (empty ($exerciseId)) { - $exerciseId = intval($_REQUEST['exerciseId']); -} if ($is_allowedToEdit || $is_tutor) { $nameTools = get_lang('StudentScore'); diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index c20497a7bb..ca8ea64e6a 100644 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -794,6 +794,9 @@ function delete_student_lp_events($user_id, $lp_id, $course, $session_id) { $lp_view_table = Database::get_course_table(TABLE_LP_VIEW); $lp_item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW); $course_id = $course['real_id']; + if (empty($course_id)) { + $course_id = api_get_course_int_id(); + } $track_e_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $track_attempts = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); @@ -1122,24 +1125,26 @@ function get_best_exercise_results_by_user($exercise_id, $course_code, $session_ return $best_score_return; } -function count_exercise_result($exercise_id, $course_code, $session_id = 0) { +function count_exercise_result_not_validated($exercise_id, $course_code, $session_id = 0) { $table_track_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); - - $course_code = Database::escape_string($course_code); - + $table_track_attempt = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING); + $course_code = Database::escape_string($course_code); $session_id = intval($session_id); $exercise_id = intval($exercise_id); - $select = '*'; - $sql = "SELECT count(*) as count FROM $table_track_exercises - WHERE status = '' AND - exe_exo_id = $exercise_id AND + + $status = Database::escape_string($status); + + $sql = "SELECT count(e.exe_id) as count FROM $table_track_exercises e LEFT JOIN $table_track_attempt a ON e.exe_id = a.exe_id + WHERE exe_exo_id = $exercise_id AND exe_cours_id = '$course_code' AND - session_id = $session_id AND + e.session_id = $session_id AND orig_lp_id = 0 AND - orig_lp_item_id = 0 ORDER BY exe_id"; - $res = Database::query($sql); + marks IS NULL AND + status = '' AND + orig_lp_item_id = 0 ORDER BY e.exe_id"; + $res = Database::query($sql); + $row = Database::fetch_array($res,'ASSOC'); - $row = Database::fetch_array($res,'ASSOC'); return $row['count']; }