WHERE att.id NOT IN (SELECT ref_id FROM '.$tbl_grade_links.' WHERE type = '.LINK_ATTENDANCE.' AND course_code = "'.Database::escape_string($this->get_course_code()).'")
WHERE att.c_id = '.$this->course_id.' AND att.id NOT IN (SELECT ref_id FROM '.$tbl_grade_links.' WHERE type = '.LINK_ATTENDANCE.' AND course_code = "'.Database::escape_string($this->get_course_code()).'")
AND att.session_id='.api_get_session_id().'';
$result = Database::query($sql);
@ -73,7 +74,9 @@ class AttendanceLink extends AbstractLink
}
$tbl_attendance = $this->get_attendance_table();
$session_id = api_get_session_id();
$sql = 'SELECT att.id, att.name, att.attendance_qualify_title FROM '.$tbl_attendance.' att WHERE att.active = 1 AND att.session_id = '.intval($session_id).'';
@ -206,7 +199,7 @@ class AttendanceLink extends AbstractLink
public function is_valid_link() {
$session_id = api_get_session_id();
$sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att
WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
$result = Database::query($sql);
$number = Database::fetch_row($result);
return ($number[0] != 0);
@ -222,7 +215,7 @@ class AttendanceLink extends AbstractLink
$session_id = api_get_session_id();
if ($tbl_name != '') {
$sql = 'SELECT * FROM '.$this->get_attendance_table().' att
WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id = '.intval($session_id).' ';
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' AND att.session_id = '.intval($session_id).' ';
$result = Database::query($sql);
$row = Database::fetch_array($result,'ASSOC');
$attendance_id = $row['id'];
@ -237,7 +230,8 @@ class AttendanceLink extends AbstractLink
if ($tbl_name == '') {
return false;
} elseif (!isset($this->attendance_data)) {
$sql = 'SELECT * FROM '.$this->get_attendance_table().' att WHERE att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
$sql = 'SELECT * FROM '.$this->get_attendance_table().' att
WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' AND att.session_id='.intval($session_id).'';
$sql = 'SELECT id,title from '.$this->get_exercise_table().'
WHERE c_id = '.$course_info['real_id'].' AND active=1 AND session_id='.api_get_session_id().'';
WHERE c_id = '.$this->course_id.' AND active=1 AND session_id='.api_get_session_id().'';
$result = Database::query($sql);
$cats=array();
while ($data=Database::fetch_array($result)) {
@ -98,10 +98,7 @@ class ExerciseLink extends AbstractLink
//the following query should be similar (in conditions) to the one used in exercice/exercice.php, look for note-query-exe-results marker
$sql = 'SELECT * FROM '.$tbl_stats.' WHERE exe_exo_id = '.(int)$this->get_ref_id().' AND orig_lp_id = 0 AND orig_lp_item_id = 0 AND status <>\'incomplete\'';
while ($data = Database::fetch_array($sql_result)) {
$sum += $data['answered'] ? $max_score : 0;
$rescount++;
}
$sum = $sum / $max_score;
if ($rescount == 0) {
return null;
}
return array($sum, $rescount);
}
}
/**
@ -198,7 +177,7 @@ class SurveyLink extends AbstractLink
public function is_valid_link() {
$session_id = api_get_session_id();
$sql = 'SELECT count(survey_id) FROM '.$this->get_survey_table().'
WHERE survey_id = '.intval($this->get_ref_id()).' AND session_id='.intval($session_id).'';
WHERE c_id = '.$this->course_id.' AND survey_id = '.intval($this->get_ref_id()).' AND session_id='.intval($session_id).'';
$result = Database::query($sql);
$number = Database::fetch_row($result);
return ($number[0] != 0);
@ -214,7 +193,7 @@ class SurveyLink extends AbstractLink
$session_id = api_get_session_id();
if ($tbl_name != '') {
$sql = 'SELECT survey_id FROM '.$this->get_survey_table().'
WHERE survey_id = '.intval($this->get_ref_id()).' AND session_id = '.intval($session_id).' ';
WHERE c_id = '.$this->course_id.' AND survey_id = '.intval($this->get_ref_id()).' AND session_id = '.intval($session_id).' ';
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
$survey_id = $row['survey_id'];
@ -230,7 +209,7 @@ class SurveyLink extends AbstractLink
if ($tbl_name == '') {
return false;
} elseif (!isset($this->survey_data)) {
$sql = 'SELECT * FROM '.$tbl_name.' WHERE survey_id = '.intval($this->get_ref_id()).' AND session_id='.intval($session_id).'';
$sql = 'SELECT * FROM '.$tbl_name.' WHERE c_id = '.$this->course_id.' AND survey_id = '.intval($this->get_ref_id()).' AND session_id='.intval($session_id).'';