Code Duplication    Length = 18-18 lines in 2 locations

main/exercise/exercise.class.php 2 locations

@@ 664-681 (lines=18) @@
661
     * Get question count per exercise from DB (any special treatment)
662
     * @return int
663
     */
664
    public function getQuestionCount()
665
    {
666
        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
667
        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
668
        $sql = "SELECT count(q.id) as count
669
                FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q
670
                    ON (e.question_id = q.id)
671
                WHERE e.c_id = {$this->course_id} AND e.exercice_id	= ".Database::escape_string($this->id);
672
        $result = Database::query($sql);
673
674
        $count = 0;
675
        if (Database::num_rows($result)) {
676
            $row = Database::fetch_array($result);
677
            $count = $row['count'];
678
        }
679
680
        return $count;
681
    }
682
683
    /**
684
     * @return array
@@ 686-703 (lines=18) @@
683
    /**
684
     * @return array
685
     */
686
    public function getQuestionOrderedListByName()
687
    {
688
        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
689
        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
690
691
        // Getting question list from the order (question list drag n drop interface ).
692
        $sql = "SELECT e.question_id
693
                FROM $TBL_EXERCICE_QUESTION e 
694
                INNER JOIN $TBL_QUESTIONS q
695
                ON (e.question_id= q.id AND e.c_id = q.c_id)
696
                WHERE 
697
                    e.c_id = {$this->course_id} AND 
698
                    e.exercice_id	= '".Database::escape_string($this->id)."'
699
                ORDER BY q.question";
700
        $result = Database::query($sql);
701
        $list = array();
702
        if (Database::num_rows($result)) {
703
            $list = Database::store_result($result, 'ASSOC');
704
        }
705
        return $list;
706
    }