//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\'';
$session_id = api_get_session_id();
$sql = "SELECT * FROM $tbl_stats
WHERE exe_exo_id = ".intval($this->get_ref_id())." AND
orig_lp_id = 0 AND
orig_lp_item_id = 0 AND
status <> 'incomplete' AND
session_id = $session_id
";
if (isset($stud_id)) {
$course_code_exe = $this->get_course_code();
$sql .= ' AND exe_cours_id="'.$course_code_exe.'" AND exe_user_id = '."'".$stud_id."'";
$sql .= " AND exe_cours_id = '$course_code_exe' AND
if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user!=1) {
$url .= '&doexercise='.$this->get_ref_id();
}
@ -168,7 +179,7 @@ class ExerciseLink extends AbstractLink
* Get name to display: same as exercise title
*/
public function get_name() {
$data = $this->get_exercise_data();
$data = $this->get_exercise_data();
return $data['title'];
}
@ -184,15 +195,15 @@ class ExerciseLink extends AbstractLink
* Check if this still links to an exercise
*/
public function is_valid_link() {
$sql = 'SELECT count(id) from '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' AND session_id='.api_get_session_id().'';
//$sql = 'SELECT count(id) from '.$this->get_exercise_table().' WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' AND session_id='.api_get_session_id().'';
$sql = 'SELECT count(id) from '.$this->get_exercise_table().' WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';
$result = Database::query($sql);
$number=Database::fetch_row($result);
return ($number[0] != 0);
}
public function get_type_name() {
return get_lang('Exercises');
return get_lang('Quiz');
}
public function needs_name_and_description() {
@ -212,7 +223,7 @@ class ExerciseLink extends AbstractLink
}
// INTERNAL FUNCTIONS
// INTERNAL FUNCTIONS
/**
* Lazy load function to get the database table of the exercise
@ -225,13 +236,13 @@ class ExerciseLink extends AbstractLink
/**
* Lazy load function to get the database contents of this exercise
*/
private function get_exercise_data() {
$tbl_exercise=$this->get_exercise_table();
private function get_exercise_data() {
$tbl_exercise=$this->get_exercise_table();
if ($tbl_exercise=='') {
return false;
} elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * from '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' AND session_id ='.api_get_session_id().'';
$sql = 'SELECT * FROM '.$this->get_exercise_table().'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';
@ -232,7 +248,7 @@ class StudentPublicationLink extends AbstractLink
if ($tbl_name=='') {
return false;
} elseif (!isset($this->exercise_data)) {
$sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE c_id ='".$course_info['real_id']."' AND id = '".intval($this->get_ref_id())."' AND session_id=".api_get_session_id()."";
$sql = 'SELECT * FROM '.$this->get_studpub_table()." WHERE c_id ='".$course_info['real_id']."' AND id = '".intval($this->get_ref_id())."' ";