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

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

main/exercise/exercise.class.php 1 location

@@ 7380-7402 (lines=23) @@
7377
     * @param int $sessionId
7378
     * @return array exercises
7379
     */
7380
    public function getExercisesByCourseSession($courseId, $sessionId)
7381
    {
7382
        $courseId = intval($courseId);
7383
        $sessionId = intval($sessionId);
7384
7385
        $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
7386
        $sql = "SELECT * FROM $tbl_quiz cq
7387
                WHERE
7388
                    cq.c_id = %s AND
7389
                    (cq.session_id = %s OR cq.session_id = 0) AND
7390
                    cq.active = 0
7391
                ORDER BY cq.id";
7392
        $sql = sprintf($sql, $courseId, $sessionId);
7393
7394
        $result = Database::query($sql);
7395
7396
        $rows = array();
7397
        while ($row = Database::fetch_array($result, 'ASSOC')) {
7398
            $rows[] = $row;
7399
        }
7400
7401
        return $rows;
7402
    }
7403
7404
    /**
7405
     *