Skip to content

Commit

Permalink
Remove course_code field from all queries using track_e_attempt - ref…
Browse files Browse the repository at this point in the history
…s #7555
  • Loading branch information
ywarnier committed Mar 4, 2015
1 parent aba0111 commit 36bf640
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions main/exercice/calculated_answer.class.php
Expand Up @@ -260,9 +260,9 @@ public function isAnswered()
$table,
array(
'where' => array(
'question_id = ? AND course_code = ?' => array(
'question_id = ? AND c_id = ?' => array(
$this->id,
$this->course['code']
$this->course['real_id']
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion main/inc/lib/course.lib.php
Expand Up @@ -2254,7 +2254,7 @@ public static function delete_course($code)

$sql = "DELETE FROM $table_stats_hotpots WHERE c_id = $courseId";
Database::query($sql);
$sql = "DELETE FROM $table_stats_attempt WHERE course_code = '" . $codeFiltered . "'";
$sql = "DELETE FROM $table_stats_attempt WHERE c_id = $courseId";
Database::query($sql);
$sql = "DELETE FROM $table_stats_exercises WHERE c_id = $courseId";
Database::query($sql);
Expand Down
1 change: 0 additions & 1 deletion main/inc/lib/events.lib.inc.php
Expand Up @@ -490,7 +490,6 @@ public static function saveQuestionAttempt(
'question_id' => $question_id,
'answer' => $answer,
'marks' => $score,
'course_code' => $courseInfo['real_id'],
'c_id' => $course_id,
'session_id' => $session_id,
'position' => $position,
Expand Down
2 changes: 1 addition & 1 deletion main/inc/lib/exercise_show_functions.lib.php
Expand Up @@ -210,7 +210,7 @@ static function display_hotspot_answer($feedback_type, $answerId, $answer, $stud

/**
* Display the answers to a multiple choice question
*
* @param int $feedback_type Feedback type
* @param integer Answer type
* @param integer Student choice
* @param string Textual answer
Expand Down
11 changes: 5 additions & 6 deletions main/inc/lib/online.inc.php
Expand Up @@ -161,7 +161,7 @@ function LoginDelete($user_id)
{
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$user_id = intval($user_id);
$query = "DELETE FROM ".$online_table ." WHERE login_user_id = '".$user_id."'";
$query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id";
Database::query($query);
}

Expand Down Expand Up @@ -403,7 +403,7 @@ function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit
$number_of_items = intval($number_of_items);

$query = "SELECT login_user_id, login_date FROM $track_online_table
WHERE login_user_id <> 2 AND c_id='$courseId' AND login_date >= '$current_date'
WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date'
LIMIT $from, $number_of_items ";

$result = Database::query($query);
Expand Down Expand Up @@ -433,12 +433,11 @@ function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null)

$online_time = time() - $time_limit * 60;
$current_date = api_get_utc_datetime($online_time);
$courseInfo = api_get_course_info($coursecode);
$courseId = api_get_course_int_id($coursecode);

$courseId = $courseInfo['real_id'];
$query = "SELECT count(login_user_id) as count
FROM ".$track_online_table ."
WHERE login_user_id <> 2 AND c_id='".$courseId."' AND login_date >= '$current_date' ";
FROM $track_online_table
WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' ";
$result = Database::query($query);
if (Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);
Expand Down
1 change: 0 additions & 1 deletion main/install/db_stats.sql
Expand Up @@ -209,7 +209,6 @@ CREATE TABLE track_e_online (
login_user_id int unsigned NOT NULL default 0,
login_date datetime NOT NULL default '0000-00-00 00:00:00',
user_ip varchar(39) NOT NULL default '',
course varchar(40) default NULL,
c_id int NOT NULL,
session_id INT NOT NULL DEFAULT 0,
access_url_id INT NOT NULL DEFAULT 1,
Expand Down

0 comments on commit 36bf640

Please sign in to comment.