//$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().' ';
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().' ';
$result = Database::query($sql);
$number=Database::fetch_row($result);
return ($number[0] != 0);
@ -314,9 +325,6 @@ class ExerciseLink extends AbstractLink
return false;
}
// INTERNAL FUNCTIONS
/**
* Lazy load function to get the database table of the exercise
*/
@ -343,10 +351,20 @@ class ExerciseLink extends AbstractLink
if ($this->is_hp == 1) {
$ref_id = intval($this->get_ref_id());
$sql = "SELECT * FROM $tbl_exercise ex, $TBL_ITEM_PROPERTY ip
WHERE ip.ref = ex.id AND ip.c_id = $this->course_id AND ip.ref = $ref_id AND ex.c_id = $this->course_id AND ip.tool = '".TOOL_DOCUMENT."' AND (ex.path LIKE '%htm%')AND (ex.path LIKE '%HotPotatoes_files%') AND ip.visibility = 1";
WHERE
ip.ref = ex.id AND
ip.c_id = $this->course_id AND
ex.c_id = $this->course_id AND
ip.ref = $ref_id AND
ip.tool = '".TOOL_DOCUMENT."' AND
ex.path LIKE '%htm%' AND
ex.path LIKE '%HotPotatoes_files%' AND
ip.visibility = 1";
} else {
$sql = 'SELECT * FROM '.$tbl_exercise.'
WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';