Code Duplication    Length = 18-18 lines in 2 locations

main/exercise/exercise.class.php 2 locations

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