From 238b445a1e1149a0a6bed18ed4b72e0d2a48bc79 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 14 Oct 2010 16:27:14 +0200 Subject: [PATCH] Adding date in the exercise_show.php --- main/exercice/exercise_show.php | 182 ++++++++++++-------------------- 1 file changed, 70 insertions(+), 112 deletions(-) diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 699d2f6589..3aa58d19e0 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -1,13 +1,15 @@ -0) { - echo str_repeat(' ',0).'Entered exercise_result.php'."
\n";var_dump($_POST); -} -// general parameters passed via POST/GET - -if ( empty ( $formSent ) ) { - $formSent= $_REQUEST['formSent']; -} -if ( empty ( $exerciseResult ) ) { - $exerciseResult = $_SESSION['exerciseResult']; -} -if ( empty ( $questionId ) ) { - $questionId = $_REQUEST['questionId']; -} -if ( empty ( $choice ) ) { - $choice = $_REQUEST['choice']; -} -if ( empty ( $questionNum ) ) { - $questionNum = $_REQUEST['questionNum']; -} -if ( empty ( $nbrQuestions ) ) { - $nbrQuestions = $_REQUEST['nbrQuestions']; -} -if ( empty ( $questionList ) ) { - $questionList = $_SESSION['questionList']; -} -if ( empty ( $objExercise ) ) { - $objExercise = $_SESSION['objExercise']; -} - -if ( empty ( $exeId ) ) { - $exeId = $_REQUEST['id']; -} +// General parameters passed via POST/GET +if($debug>0) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); } -if ( empty ( $action ) ) { - $action = $_GET['action']; -} +if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent']; } +if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];} +if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];} +if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];} +if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['questionNum'];} +if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestions'];} +if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];} +if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];} +if ( empty ( $exeId ) ) { $exeId = $_REQUEST['id'];} +if ( empty ( $action ) ) { $action = $_GET['action']; } -$current_time = time(); -$emailId = $_REQUEST['email']; -$id = $_REQUEST['id']; //exe id +//$emailId = $_REQUEST['email']; +$id = intval($_REQUEST['id']); //exe id +$current_time = time(); if (empty($id)) { api_not_allowed(); } -$is_allowedToEdit=api_is_allowed_to_edit(null,true) || $is_courseTutor; +$is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor; -//Getting results +//Getting results from the exe_id. This variable also contain all the information about the exercise $track_exercise_info = get_exercise_track_exercise_info($id); //No track info @@ -102,23 +80,25 @@ if (empty($track_exercise_info)) { api_not_allowed(); } - $exercise_id = $track_exercise_info['id']; +$exercise_date = $track_exercise_info['exe_date']; $student_id = $track_exercise_info['exe_user_id']; $learnpath_id = $track_exercise_info['orig_lp_id']; $learnpath_item_id = $track_exercise_info['orig_lp_item_id']; $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id']; $course_code = api_get_course_id(); +$current_user_id = api_get_user_id(); //Check if user can see the results if (!$is_allowedToEdit) { - $current_user_id = api_get_user_id(); + if ($track_exercise_info['results_disabled']) { + api_not_allowed(); + } if ($student_id != $current_user_id) { api_not_allowed(); } } - if (!exercise_time_control_is_valid($exercise_id)) { $sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks=0, position=0 WHERE exe_id = $id "; Database::query($sql_fraud); @@ -127,8 +107,6 @@ if (!exercise_time_control_is_valid($exercise_id)) { //Unset session for clock time exercise_time_control_delete($exercise_id); - - $nameTools=get_lang('CorrectTest'); if (isset($_SESSION['gradebook'])) { $gradebook= Security::remove_XSS($_SESSION['gradebook']); @@ -137,6 +115,7 @@ if (isset($_SESSION['gradebook'])) { if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); } + $fromlink = ''; if($origin=='user_course') { $interbreadcrumb[] = array ("url" => "../user/user.php?cidReq=".Security::remove_XSS($_GET['course']), "name" => get_lang("Users")); @@ -156,7 +135,6 @@ if($origin=='user_course') { } else { $this_section = SECTION_COURSES; } - } elseif($origin=='student_progress') { $this_section = SECTION_TRACKING; $interbreadcrumb[] = array ("url" => "../auth/my_progress.php?id_session".Security::remove_XSS($_GET['id_session'])."&course=".$_cid, "name" => get_lang('MyProgress')); @@ -166,9 +144,8 @@ if($origin=='user_course') { $this_section=SECTION_COURSES; } - if ($origin != 'learnpath') { - Display::display_header($nameTools,"Exercise"); + Display::display_header($nameTools,get_lang('Exercise')); } else { Display::display_reduced_header(); } @@ -221,17 +198,14 @@ function getFCK(vals,marksid) { - -
:
-
- */ + if ($show_results) { ?> @@ -305,34 +273,21 @@ if ($show_results) { - - + + + + + + @@ -348,14 +303,15 @@ if ($show_results) {
:
: + +
: + +
0){echo "ExerciseResult: "; var_dump($exerciseResult); echo "QuestionList: ";var_dump($questionList);} -$arrques = array(); -$arrans = array(); -if ($show_results) { - $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($_user['user_id'])." "; + $i=$totalScore=$totalWeighting=0; + + if($debug>0){error_log("ExerciseResult: ".print_r($exerciseResult,1)); error_log("QuestionList: ".print_r($questionList,1));} + + $arrques = array(); + $arrans = array(); + + $user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." "; $query = "SELECT attempts.question_id, answer from ".$TBL_TRACK_ATTEMPT." as attempts INNER JOIN ".$TBL_TRACK_EXERCICES." as stats_exercices ON stats_exercices.exe_id=attempts.exe_id INNER JOIN ".$TBL_EXERCICE_QUESTION." as quizz_rel_questions ON quizz_rel_questions.exercice_id=stats_exercices.exe_exo_id AND quizz_rel_questions.question_id = attempts.question_id @@ -363,9 +319,8 @@ if ($show_results) { WHERE attempts.exe_id='".Database::escape_string($id)."' $user_restriction GROUP BY quizz_rel_questions.question_order, attempts.question_id"; //GROUP BY questions.position, attempts.question_id"; - - $result =Database::query($query); - + + $result =Database::query($query); $questionList = array(); $exerciseResult = array(); @@ -374,7 +329,7 @@ if ($show_results) { $exerciseResult[$row['question_id']] = $row['answer']; } - //Fixing #2073 + //Fixing #2073 Fixing order of questions if (!empty($track_exercise_info['data_tracking']) && !empty($track_exercise_info['random']) ) { $tempquestionList = explode(',',$track_exercise_info['data_tracking']); if (is_array($tempquestionList) && count($tempquestionList) == count($questionList)) { @@ -633,6 +588,7 @@ if ($show_results) { } $answer = $pre_array[0]; + // splits weightings that are joined with a comma $answerWeighting = explode(',',$is_set_switchable[0]); @@ -659,6 +615,7 @@ if ($show_results) { // the loop will stop at the end of the text $i=0; //normal fill in blank + if (!$switchable_answer_set) { while (1) { // quits the loop if there are no more blanks @@ -680,6 +637,7 @@ if ($show_results) { $queryfill = "SELECT answer FROM ".$TBL_TRACK_ATTEMPT." WHERE exe_id = '".Database::escape_string($id)."' AND question_id= '".Database::escape_string($questionId)."'"; $resfill = Database::query($queryfill); $str = Database::result($resfill,0,'answer'); + preg_match_all('#\[([^[]*)\]#', $str, $arr); $str = str_replace('\r\n', '', $str);