Code Duplication    Length = 18-18 lines in 2 locations

main/exercise/exercise.class.php 2 locations

@@ 682-699 (lines=18) @@
679
     * Get question count per exercise from DB (any special treatment)
680
     * @return int
681
     */
682
    public function getQuestionCount()
683
    {
684
        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
685
        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
686
        $sql = "SELECT count(q.id) as count
687
                FROM $TBL_EXERCICE_QUESTION e 
688
                INNER JOIN $TBL_QUESTIONS q
689
                ON (e.question_id = q.id AND e.c_id = q.c_id)
690
                WHERE 
691
                    e.c_id = {$this->course_id} AND 
692
                    e.exercice_id	= ".Database::escape_string($this->id);
693
        $result = Database::query($sql);
694
695
        $count = 0;
696
        if (Database::num_rows($result)) {
697
            $row = Database::fetch_array($result);
698
            $count = $row['count'];
699
        }
700
701
        return $count;
702
    }
@@ 707-724 (lines=18) @@
704
    /**
705
     * @return array
706
     */
707
    public function getQuestionOrderedListByName()
708
    {
709
        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
710
        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
711
712
        // Getting question list from the order (question list drag n drop interface ).
713
        $sql = "SELECT e.question_id
714
                FROM $TBL_EXERCICE_QUESTION e 
715
                INNER JOIN $TBL_QUESTIONS q
716
                ON (e.question_id= q.id AND e.c_id = q.c_id)
717
                WHERE 
718
                    e.c_id = {$this->course_id} AND 
719
                    e.exercice_id = '".Database::escape_string($this->id)."'
720
                ORDER BY q.question";
721
        $result = Database::query($sql);
722
        $list = array();
723
        if (Database::num_rows($result)) {
724
            $list = Database::store_result($result, 'ASSOC');
725
        }
726
        return $list;
727
    }