Code Duplication    Length = 18-18 lines in 2 locations

main/exercice/exercise.class.php 2 locations

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