Code Duplication    Length = 7-9 lines in 3 locations

main/gradebook/lib/be/exerciselink.class.php 1 location

@@ 382-390 (lines=9) @@
379
    /**
380
     * Check if this still links to an exercise
381
     */
382
    public function is_valid_link()
383
    {
384
        $sql = 'SELECT count(id) 
385
                FROM '.$this->get_exercise_table().'
386
                WHERE 
387
                    c_id = '.$this->course_id.' AND 
388
                    id = '.(int) $this->get_ref_id().' ';
389
        $result = Database::query($sql);
390
        $number = Database::fetch_row($result);
391
392
        return ($number[0] != 0);
393
    }

main/gradebook/lib/be/forumthreadlink.class.php 1 location

@@ 311-318 (lines=8) @@
308
    /**
309
     * Check if this still links to an exercise
310
     */
311
    public function is_valid_link()
312
    {
313
        $sql = 'SELECT count(id) from '.$this->get_forum_thread_table().'
314
                WHERE c_id = '.$this->course_id.' AND thread_id = '.$this->get_ref_id().' AND session_id='.api_get_session_id().'';
315
        $result = Database::query($sql);
316
        $number = Database::fetch_row($result);
317
        return ($number[0] != 0);
318
    }
319
320
    public function get_test_id()
321
    {

main/gradebook/lib/be/learnpathlink.class.php 1 location

@@ 216-222 (lines=7) @@
213
    /**
214
     * Check if this still links to a learnpath
215
     */
216
    public function is_valid_link()
217
    {
218
        $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().'
219
                WHERE c_id = ' . $this->course_id.' AND id = '.$this->get_ref_id().' ';
220
        $result = Database::query($sql);
221
        $number = Database::fetch_row($result, 'NUM');
222
        return ($number[0] != 0);
223
    }
224
225
    public function get_type_name()