Code Duplication    Length = 18-18 lines in 2 locations

main/exercice/exercise.class.php 2 locations

@@ 637-654 (lines=18) @@
634
     * Get question count per exercise from DB (any special treatment)
635
     * @return int
636
     */
637
    public function getQuestionCount()
638
    {
639
        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
640
        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
641
        $sql = "SELECT count(q.id) as count
642
                FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q
643
                    ON (e.question_id = q.id)
644
                WHERE e.c_id = {$this->course_id} AND e.exercice_id	= ".Database::escape_string($this->id);
645
        $result = Database::query($sql);
646
647
        $count = 0;
648
        if (Database::num_rows($result)) {
649
            $row = Database::fetch_array($result);
650
            $count = $row['count'];
651
        }
652
653
        return $count;
654
    }
655
656
    /**
657
     * @return array
@@ 659-676 (lines=18) @@
656
    /**
657
     * @return array
658
     */
659
    public function getQuestionOrderedListByName()
660
    {
661
        $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
662
        $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
663
664
        // Getting question list from the order (question list drag n drop interface ).
665
        $sql = "SELECT e.question_id
666
                FROM $TBL_EXERCICE_QUESTION e INNER JOIN $TBL_QUESTIONS q
667
                    ON (e.question_id= q.id)
668
                WHERE e.c_id = {$this->course_id} AND e.exercice_id	= '".Database::escape_string($this->id)."'
669
                ORDER BY q.question";
670
        $result = Database::query($sql);
671
        $list = array();
672
        if (Database::num_rows($result)) {
673
            $list = Database::store_result($result, 'ASSOC');
674
        }
675
        return $list;
676
    }
677
678
    /**
679
     * Gets the question list ordered by the question_order setting (drag and drop)