From 2bf62cca9405934d4c2b5b6076c9d5b21b1dda97 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 24 Apr 2013 14:26:28 +0200 Subject: [PATCH] Adding c_id field in track_e_hotspot --- main/exercice/exercise.class.php | 42 ++++++++++++++----- main/exercice/exercise.lib.php | 20 ++++++--- main/exercice/hotspot_answers.as.php | 16 +++---- main/exercice/stats.php | 2 +- main/inc/lib/events.lib.inc.php | 6 +-- main/install/1.10.0/db_main.sql | 3 +- .../1.10.0/migrate-db-1.9.0-1.10.0-pre.sql | 4 +- 7 files changed, 62 insertions(+), 31 deletions(-) diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index a7a54533a9..bf5cafe513 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -630,7 +630,7 @@ class Exercise * returns the number of questions in this exercise * * @author - Olivier Brouckaert - * @return - integer - number of questions + * @return integer - number of questions */ function selectNbrQuestions() { @@ -646,7 +646,7 @@ class Exercise * Selects questions randomly in the question list * * @author - Olivier Brouckaert - * @return - array - if the exercise is not set to take questions randomly, returns the question list + * @return array - if the exercise is not set to take questions randomly, returns the question list * without randomizing, otherwise, returns the list with questions selected randomly * Modified by Hubert Borderiou 15 nov 2011 */ @@ -686,7 +686,8 @@ class Exercise * * @author - Olivier Brouckaert * @param - integer $questionId - question ID - * @return - boolean - true if in the list, otherwise false + * + * @return boolean - true if in the list, otherwise false */ function isInList($questionId) { @@ -718,7 +719,8 @@ class Exercise $this->attempts = $attempts; } - function updateActive($active) { + function updateActive($active) + { $this->active = $active; } @@ -759,19 +761,31 @@ class Exercise $this->propagate_neg = $value; } + /** + * @param $value + */ function updateReviewAnswers($value) { $this->review_answers = (isset($value) && $value) ? true : false; } + /** + * @param $value + */ function updatePassPercentage($value) { $this->pass_percentage = $value; } - function updateCategories($categories) { - $categories = array_map('intval', $categories); - $this->categories = $categories; + /** + * @param array $categories + */ + function updateCategories($categories) + { + if (!empty($categories)) { + $categories = array_map('intval', $categories); + $this->categories = $categories; + } } /** @@ -3190,9 +3204,11 @@ class Exercise if ($from_database) { if ($show_result) { $TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); - $query = "SELECT hotspot_correct FROM ".$TBL_TRACK_HOTSPOT." WHERE hotspot_exe_id = '".$exeId."' and hotspot_question_id= '".$questionId."' AND hotspot_answer_id='".Database::escape_string( - $answerId - )."'"; + $query = "SELECT hotspot_correct + FROM ".$TBL_TRACK_HOTSPOT." + WHERE hotspot_exe_id = '".$exeId."' and + hotspot_question_id= '".$questionId."' AND + hotspot_answer_id='".Database::escape_string($answerId)."'"; $resq = Database::query($query); $studentChoice = Database::result($resq, 0, "hotspot_correct"); @@ -3226,7 +3242,11 @@ class Exercise if ($from_database) { // getting the user answer $TBL_TRACK_HOTSPOT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); - $query = "SELECT hotspot_correct, hotspot_coordinate from ".$TBL_TRACK_HOTSPOT." where hotspot_exe_id = '".$exeId."' and hotspot_question_id= '".$questionId."' AND hotspot_answer_id='1'"; //by default we take 1 because it's a delineation + $query = "SELECT hotspot_correct, hotspot_coordinate + FROM ".$TBL_TRACK_HOTSPOT." + WHERE hotspot_exe_id = '".$exeId."' AND + hotspot_question_id= '".$questionId."' AND + hotspot_answer_id='1'"; //by default we take 1 because it's a delineation $resq = Database::query($query); $row = Database::fetch_array($resq, 'ASSOC'); diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 838fd8b6e0..ceebd72b61 100644 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1965,7 +1965,15 @@ function get_number_students_question_with_answer_count($question_id, $exercise_ return $return; } -function get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, $course_code, $session_id) +/** + * @param int $answer_id + * @param int $question_id + * @param int $exercise_id + * @param int $courseId + * @param int $session_id + * @return int + */ +function get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, $courseId, $session_id) { $track_exercises = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $track_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT); @@ -1974,14 +1982,16 @@ function get_number_students_answer_hotspot_count($answer_id, $question_id, $exe $question_id = intval($question_id); $answer_id = intval($answer_id); $exercise_id = intval($exercise_id); - $course_code = Database::escape_string($course_code); + $courseId = intval($courseId); $session_id = intval($session_id); $sql = "SELECT DISTINCT exe_user_id - FROM $track_exercises e INNER JOIN $track_hotspot a ON (a.hotspot_exe_id = e.exe_id) INNER JOIN $course_user cu - ON cu.course_code = a.hotspot_course_code AND cu.user_id = exe_user_id + FROM $track_exercises e + INNER JOIN $track_hotspot a ON (a.hotspot_exe_id = e.exe_id) + INNER JOIN $course_user cu + ON cu.c_id = a.c_id AND cu.user_id = exe_user_id WHERE exe_exo_id = $exercise_id AND - a.hotspot_course_code = '$course_code' AND + a.c_id = $courseId AND e.session_id = $session_id AND hotspot_answer_id = $answer_id AND hotspot_question_id = $question_id AND diff --git a/main/exercice/hotspot_answers.as.php b/main/exercice/hotspot_answers.as.php index 266808cfc6..7149bb9a96 100644 --- a/main/exercice/hotspot_answers.as.php +++ b/main/exercice/hotspot_answers.as.php @@ -1,7 +1,7 @@