Code Duplication    Length = 9-12 lines in 6 locations

main/exercise/TestCategory.php 1 location

@@ 180-191 (lines=12) @@
177
    /**
178
     * Gets the number of question of category id=in_id
179
     */
180
    public function getCategoryQuestionsNumber()
181
    {
182
        $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY);
183
        $id = intval($this->id);
184
        $sql = "SELECT count(*) AS nb
185
                FROM $table
186
                WHERE category_id = $id AND c_id=".api_get_course_int_id();
187
        $res = Database::query($sql);
188
        $row = Database::fetch_array($res);
189
190
        return $row['nb'];
191
    }
192
193
    /**
194
     * Return an array of all Category objects in the database

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

@@ 66-74 (lines=9) @@
63
    /**
64
     * @return array
65
     */
66
    public static function get_groups($courseId = null)
67
    {
68
        $table_group = Database::get_course_table(TABLE_GROUP);
69
        $courseId = !empty($courseId) ? (int) $courseId : api_get_course_int_id();
70
71
        $sql = "SELECT * FROM $table_group WHERE c_id = $courseId  ";
72
        $result = Database::query($sql);
73
        return Database::store_result($result, 'ASSOC');
74
    }
75
76
    /**
77
     * Get list of groups for current course.
@@ 636-647 (lines=12) @@
633
     * Get the total number of groups for the current course.
634
     * @return int The number of groups for the current course.
635
     */
636
    public static function get_number_of_groups()
637
    {
638
        $course_id = api_get_course_int_id();
639
        $table_group = Database::get_course_table(TABLE_GROUP);
640
        $sql = "SELECT COUNT(id) AS number_of_groups
641
                FROM $table_group
642
                WHERE c_id = $course_id ";
643
        $res = Database::query($sql);
644
        $obj = Database::fetch_object($res);
645
646
        return $obj->number_of_groups;
647
    }
648
649
    /**
650
     * Get all categories

main/survey/survey.lib.php 1 location

@@ 1569-1578 (lines=10) @@
1566
     * @author Patrick Cool <[email protected]>, Ghent University
1567
     * @version January 2007,december 2008
1568
     */
1569
    public static function delete_all_survey_answers($survey_id)
1570
    {
1571
        $course_id = api_get_course_int_id();
1572
        $table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
1573
        $survey_id = intval($survey_id);
1574
        $sql = "DELETE FROM $table_survey_answer 
1575
                WHERE c_id = $course_id AND survey_id=$survey_id";
1576
        Database::query($sql);
1577
        return true;
1578
    }
1579
1580
    /**
1581
     * @param int $user_id

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

@@ 2127-2136 (lines=10) @@
2124
     * Get the document id of the directory certificate
2125
     * @return int The document id of the directory certificate
2126
     */
2127
    public static function get_document_id_of_directory_certificate()
2128
    {
2129
        $tbl_document = Database::get_course_table(TABLE_DOCUMENT);
2130
        $course_id = api_get_course_int_id();
2131
        $sql = "SELECT id FROM $tbl_document 
2132
                WHERE c_id = $course_id AND path='/certificates' ";
2133
        $rs = Database::query($sql);
2134
        $row = Database::fetch_array($rs);
2135
        return $row['id'];
2136
    }
2137
2138
    /**
2139
     * Check if a directory given is for certificate

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

@@ 6031-6039 (lines=9) @@
6028
     * @param int $sessionId
6029
     * @param int $courseId
6030
     */
6031
    public static function removeCourseIntroduction($sessionId, $courseId)
6032
    {
6033
        $sessionId = intval($sessionId);
6034
        $courseId = intval($courseId);
6035
        $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
6036
        $sql = "DELETE FROM $TBL_INTRODUCTION
6037
                WHERE c_id = $courseId AND session_id = $sessionId";
6038
        Database::query($sql);
6039
    }
6040
6041
    /**
6042
     * @param int $sessionId