Adding c_id field in track_e_hotspot

skala
Julio Montoya 12 years ago
parent 6a12538a5e
commit 2bf62cca94
  1. 42
      main/exercice/exercise.class.php
  2. 20
      main/exercice/exercise.lib.php
  3. 16
      main/exercice/hotspot_answers.as.php
  4. 2
      main/exercice/stats.php
  5. 6
      main/inc/lib/events.lib.inc.php
  6. 3
      main/install/1.10.0/db_main.sql
  7. 4
      main/install/1.10.0/migrate-db-1.9.0-1.10.0-pre.sql

@ -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');

@ -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

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file generates the ActionScript variables code used by the
* This file generates the ActionScript variables code used by the
* HotSpot .swf
* @package chamilo.exercise
* @author Toon Keppens, Julio Montoya adding hotspot "medical" support
@ -72,11 +72,11 @@ while ($hotspot = Database::fetch_array($result)) {
// Delineation
if ($hotspot['hotspot_type'] == 'delineation') {
$output .= "&hotspot_".$hotspot_id."_type=delineation";
}
}
// oar
if ($hotspot['hotspot_type'] == 'oar') {
$output .= "&hotspot_".$hotspot_id."_type=delineation";
}
}
$output .= "&hotspot_".$hotspot_id."_coord=".$hotspot['hotspot_coordinates']."";
$i++;
}
@ -89,18 +89,18 @@ for ($i; $i <= 12; $i++) {
// Get clicks
if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate) {
$output2 .= $coordinate."|";
}
} else {
} else {
// get it from db
$tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$sql = "SELECT hotspot_coordinate
FROM $tbl_track_e_hotspot
WHERE hotspot_question_id = $questionId AND
hotspot_course_code = '$course_code' AND
hotspot_exe_id = $exe_id
WHERE hotspot_question_id = $questionId AND
c_id = $course_id AND
hotspot_exe_id = $exe_id
ORDER by hotspot_id";
$rs = @Database::query($sql); // don't output error because we are in Flash execution.
while($row = Database :: fetch_array($rs)) {

@ -182,7 +182,7 @@ if (!empty($question_list)) {
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = '-';
$count = get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$count = get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_int_id(), api_get_session_id());
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;

@ -582,9 +582,9 @@ function exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $
}
$tbl_track_e_hotspot = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
$sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, hotspot_course_code, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate)".
$sql = "INSERT INTO $tbl_track_e_hotspot (hotspot_user_id, c_id, hotspot_exe_id, hotspot_question_id, hotspot_answer_id, hotspot_correct, hotspot_coordinate)".
" VALUES ('".api_get_user_id()."',".
" '".api_get_course_id()."', ".
" '".api_get_course_int_id()."', ".
" '".Database :: escape_string($exe_id)."', ".
" '".Database :: escape_string($question_id)."',".
" '".Database :: escape_string($answer_id)."',".
@ -1565,7 +1565,7 @@ function delete_attempt_hotspot($exe_id, $user_id, $courseId, $question_id)
$sql = "DELETE FROM $table_track_attempt
WHERE hotspot_exe_id = $exe_id AND
hotspot_user_id = $user_id AND
hotspot_course_code = $courseId AND
c_id = $courseId AND
hotspot_question_id = $question_id ";
Database::query($sql);
}

@ -3338,6 +3338,7 @@ CREATE TABLE track_e_hotspot (
hotspot_answer_id int NOT NULL,
hotspot_correct tinyint(3) unsigned NOT NULL,
hotspot_coordinate text NOT NULL,
c_id int NOT NULL default 0,
PRIMARY KEY (hotspot_id),
KEY hotspot_course_code (hotspot_course_code),
KEY hotspot_user_id (hotspot_user_id),
@ -3458,4 +3459,4 @@ ALTER TABLE personal_agenda ADD INDEX idx_personal_agenda_parent (parent_event_i
ALTER TABLE user_course_category ADD INDEX idx_user_c_cat_uid (user_id);
-- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.0d46406' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.6a12538' WHERE variable = 'chamilo_database_version';

@ -165,7 +165,6 @@ ALTER TABLE track_e_course_access ADD COLUMN c_id INT NOT NULL DEFAULT 0;
UPDATE course_field SET field_type = 3 WHERE field_variable = 'special_course';
ALTER TABLE usergroup ADD COLUMN group_type INT unsigned NOT NULL default 0;
ALTER TABLE usergroup ADD COLUMN picture varchar(255) NOT NULL;
ALTER TABLE usergroup ADD COLUMN url varchar(255) NOT NULL;
ALTER TABLE usergroup ADD COLUMN visibility varchar(255) NOT NULL;
@ -194,6 +193,7 @@ ALTER TABLE announcement_rel_group ADD COLUMN id INT unsigned NOT NULL auto_incr
ALTER TABLE track_e_hotpotatoes ADD COLUMN c_id int unsigned NOT NULL default 0;
ALTER TABLE track_e_exercices ADD COLUMN c_id int unsigned NOT NULL default 0;
ALTER TABLE track_e_attempt ADD COLUMN c_id int unsigned NOT NULL default 0;
ALTER TABLE track_e_hotspot ADD COLUMN c_id int unsigned NOT NULL default 0;
ALTER TABLE c_quiz ADD COLUMN autolaunch int DEFAULT 0;
RENAME TABLE c_quiz_question_category TO c_quiz_category;
@ -202,4 +202,4 @@ ALTER TABLE c_quiz_category ADD COLUMN parent_id int unsigned NOT NULL default 0
CREATE TABLE c_quiz_rel_category (iid bigint unsigned NOT NULL auto_increment, c_id INT unsigned default 0, category_id int unsigned NOT NULL, exercise_id int unsigned NOT NULL, count_questions int NOT NULL default 0, PRIMARY KEY(iid));
-- Do not move this
UPDATE settings_current SET selected_value = '1.10.0.0d46406' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.6a12538' WHERE variable = 'chamilo_database_version';
Loading…
Cancel
Save