Code Duplication    Length = 8-12 lines in 7 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/api.lib.php 1 location

@@ 6012-6019 (lines=8) @@
6009
 * @param int The tool id
6010
 * @return array
6011
 */
6012
function api_get_tool_information($tool_id)
6013
{
6014
    $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
6015
    $course_id = api_get_course_int_id();
6016
    $sql = "SELECT * FROM $t_tool WHERE c_id = $course_id AND id = ".intval($tool_id);
6017
    $rs  = Database::query($sql);
6018
    return Database::fetch_array($rs);
6019
}
6020
6021
/**
6022
 * Gets all information of a tool into course

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

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

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/inc/lib/sessionmanager.lib.php 1 location

@@ 5915-5923 (lines=9) @@
5912
     * @param int $sessionId
5913
     * @param int $courseId
5914
     */
5915
    public static function removeCourseIntroduction($sessionId, $courseId)
5916
    {
5917
        $sessionId = intval($sessionId);
5918
        $courseId = intval($courseId);
5919
        $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
5920
        $sql = "DELETE FROM $TBL_INTRODUCTION
5921
                WHERE c_id = $courseId AND session_id = $sessionId";
5922
        Database::query($sql);
5923
    }
5924
5925
    /**
5926
     * @param int $sessionId

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