Code Duplication    Length = 14-21 lines in 4 locations

main/inc/lib/skill.lib.php 1 location

@@ 1157-1170 (lines=14) @@
1154
     * @param int $user_id
1155
     * @return bool
1156
     */
1157
    public function get_user_skill_ranking($user_id)
1158
    {
1159
        $user_id = intval($user_id);
1160
        $sql = "SELECT count(skill_id) count FROM {$this->table} s
1161
                INNER JOIN {$this->table_skill_rel_user} su
1162
                ON (s.id = su.skill_id)
1163
                WHERE user_id = $user_id";
1164
        $result  = Database::query($sql);
1165
        if (Database::num_rows($result)) {
1166
            $result = Database::fetch_row($result);
1167
            return $result[0];
1168
        }
1169
        return false;
1170
    }
1171
1172
    /**
1173
     * @param $start

main/inc/lib/extra_field_value.lib.php 2 locations

@@ 732-751 (lines=20) @@
729
     *
730
     * @return array|bool
731
     */
732
    public function getValuesByFieldId($fieldId)
733
    {
734
        $fieldId = intval($fieldId);
735
        $extraFieldType = $this->getExtraField()->getExtraFieldType();
736
737
        $sql = "SELECT s.* FROM {$this->table} s
738
                INNER JOIN {$this->table_handler_field} sf
739
                ON (s.field_id = sf.id)
740
                WHERE
741
                    field_id = '".$fieldId."' AND
742
                    sf.extra_field_type = $extraFieldType
743
                ORDER BY s.value";
744
        $result = Database::query($sql);
745
746
        if (Database::num_rows($result)) {
747
            return Database::store_result($result, 'ASSOC');
748
        }
749
750
        return false;
751
    }
752
753
     /**
754
     * @param int $itemId
@@ 786-806 (lines=21) @@
783
     *
784
     * @return array
785
     */
786
    public function getAllValuesByItem($itemId)
787
    {
788
        $itemId = intval($itemId);
789
        $extraFieldType = $this->getExtraField()->getExtraFieldType();
790
791
        $sql = "SELECT s.value, sf.variable FROM {$this->table} s
792
                INNER JOIN {$this->table_handler_field} sf
793
                ON (s.field_id = sf.id)
794
                WHERE
795
                    item_id = '$itemId' AND
796
                    sf.extra_field_type = $extraFieldType
797
                ORDER BY s.value";
798
799
        $result = Database::query($sql);
800
801
        if (Database::num_rows($result)) {
802
            return Database::store_result($result, 'ASSOC');
803
        }
804
805
        return false;
806
    }
807
808
    /**
809
     * @param int $itemId

main/exercice/exercise.class.php 1 location

@@ 6298-6312 (lines=15) @@
6295
    /**
6296
     * Get total number of question that will be parsed when using the category/exercise
6297
     */
6298
    public function getNumberQuestionExerciseCategory()
6299
    {
6300
        $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
6301
        if (!empty($this->id)) {
6302
            $sql = "SELECT SUM(count_questions) count_questions
6303
                    FROM $table
6304
                    WHERE exercise_id = {$this->id} AND c_id = {$this->course_id}";
6305
            $result = Database::query($sql);
6306
            if (Database::num_rows($result)) {
6307
                $row = Database::fetch_array($result);
6308
                return $row['count_questions'];
6309
            }
6310
        }
6311
        return 0;
6312
    }
6313
6314
    /**
6315
     * Save categories in the TABLE_QUIZ_REL_CATEGORY table