Code Duplication    Length = 17-23 lines in 5 locations

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

@@ 24-41 (lines=18) @@
21
     * @author Isaac Flores <[email protected]>
22
     * @return array Contain glossary terms
23
     */
24
    public static function get_glossary_terms()
25
    {
26
        $glossary_data  = array();
27
        $glossary_table = Database::get_course_table(TABLE_GLOSSARY);
28
        $session_id = api_get_session_id();
29
        $sql_filter = api_get_session_condition($session_id);
30
        $course_id = api_get_course_int_id();
31
32
        $sql = "SELECT glossary_id as id, name, description
33
		        FROM $glossary_table
34
		        WHERE c_id = $course_id $sql_filter";
35
        $rs = Database::query($sql);
36
        while ($row = Database::fetch_array($rs)) {
37
            $glossary_data[] = $row;
38
        }
39
40
        return $glossary_data;
41
    }
42
43
    /**
44
     * Get glossary term by glossary id

main/inc/lib/sub_language.class.php 1 location

@@ 75-91 (lines=17) @@
72
     * @param int $sub_language_id The sub language id
73
     * @return array All information about sub-language
74
     */
75
    public static function get_all_information_of_sub_language($parent_id, $sub_language_id)
76
    {
77
        $table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
78
        $parent_id = intval($parent_id);
79
        $sub_language_id = intval($sub_language_id);
80
        $sql = "SELECT * FROM $table 
81
                WHERE
82
                    parent_id = $parent_id AND
83
                    id = $sub_language_id";
84
        $rs = Database::query($sql);
85
        $all_information = array();
86
        while ($row = Database::fetch_array($rs, 'ASSOC')) {
87
            $all_information = $row;
88
        }
89
90
        return $all_information;
91
    }
92
93
    /**
94
     * Get all information of language

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

@@ 1118-1138 (lines=21) @@
1115
     * @param array $groupInfo
1116
     * @return array
1117
     */
1118
    public static function getTutors($groupInfo)
1119
    {
1120
        $groupTable = Database::get_course_table(TABLE_GROUP);
1121
        $tutor_user_table = Database::get_course_table(TABLE_GROUP_TUTOR);
1122
        $course_id = api_get_course_int_id();
1123
        $group_id = intval($groupInfo['iid']);
1124
1125
        $sql = "SELECT user_id 
1126
                FROM $tutor_user_table gu
1127
                INNER JOIN $groupTable g
1128
                ON (gu.group_id = g.id and g.c_id = gu.c_id)
1129
                WHERE gu.c_id = $course_id AND g.iid = $group_id";
1130
        $res = Database::query($sql);
1131
1132
        $users = array();
1133
        while ($obj = Database::fetch_object($res)) {
1134
            $users[] = api_get_user_info($obj->user_id);
1135
        }
1136
1137
        return $users;
1138
    }
1139
1140
    /**
1141
     * Get only students from a group (not tutors)
@@ 2037-2056 (lines=20) @@
2034
     * @param int $user_id
2035
     * @return array
2036
     */
2037
    public static function get_user_group_name($user_id)
2038
    {
2039
        $table_group_user = Database::get_course_table(TABLE_GROUP_USER);
2040
        $table_group = Database::get_course_table(TABLE_GROUP);
2041
        $user_id = intval($user_id);
2042
        $course_id = api_get_course_int_id();
2043
        $sql = "SELECT name
2044
                FROM $table_group g 
2045
                INNER JOIN $table_group_user gu
2046
                ON (gu.group_id = g.iid)
2047
                WHERE
2048
                  gu.c_id= $course_id AND
2049
                  g.c_id= $course_id AND
2050
                  gu.user_id = $user_id";
2051
        $res = Database::query($sql);
2052
        $groups = array();
2053
        while ($group = Database::fetch_array($res)) {
2054
            $groups[] .= $group['name'];
2055
        }
2056
        return $groups;
2057
    }
2058
2059
    /**

main/exercise/exercise.class.php 1 location

@@ 7260-7282 (lines=23) @@
7257
     * @param int $sessionId
7258
     * @return array exercises
7259
     */
7260
    public function getExercisesByCourseSession($courseId, $sessionId)
7261
    {
7262
        $courseId = intval($courseId);
7263
        $sessionId = intval($sessionId);
7264
7265
        $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
7266
        $sql = "SELECT * FROM $tbl_quiz cq
7267
                WHERE
7268
                    cq.c_id = %s AND
7269
                    (cq.session_id = %s OR cq.session_id = 0) AND
7270
                    cq.active = 0
7271
                ORDER BY cq.id";
7272
        $sql = sprintf($sql, $courseId, $sessionId);
7273
7274
        $result = Database::query($sql);
7275
7276
        $rows = array();
7277
        while ($row = Database::fetch_array($result, 'ASSOC')) {
7278
            $rows[] = $row;
7279
        }
7280
7281
        return $rows;
7282
    }
7283
7284
    /**
7285
     *