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)
@@ 2039-2058 (lines=20) @@
2036
     * @param int $user_id
2037
     * @return array
2038
     */
2039
    public static function get_user_group_name($user_id)
2040
    {
2041
        $table_group_user = Database::get_course_table(TABLE_GROUP_USER);
2042
        $table_group = Database::get_course_table(TABLE_GROUP);
2043
        $user_id = intval($user_id);
2044
        $course_id = api_get_course_int_id();
2045
        $sql = "SELECT name
2046
                FROM $table_group g 
2047
                INNER JOIN $table_group_user gu
2048
                ON (gu.group_id = g.iid)
2049
                WHERE
2050
                  gu.c_id= $course_id AND
2051
                  g.c_id= $course_id AND
2052
                  gu.user_id = $user_id";
2053
        $res = Database::query($sql);
2054
        $groups = array();
2055
        while ($group = Database::fetch_array($res)) {
2056
            $groups[] .= $group['name'];
2057
        }
2058
        return $groups;
2059
    }
2060
2061
    /**

main/exercise/exercise.class.php 1 location

@@ 7472-7494 (lines=23) @@
7469
     * @param int $sessionId
7470
     * @return array exercises
7471
     */
7472
    public function getExercisesByCourseSession($courseId, $sessionId)
7473
    {
7474
        $courseId = intval($courseId);
7475
        $sessionId = intval($sessionId);
7476
7477
        $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
7478
        $sql = "SELECT * FROM $tbl_quiz cq
7479
                WHERE
7480
                    cq.c_id = %s AND
7481
                    (cq.session_id = %s OR cq.session_id = 0) AND
7482
                    cq.active = 0
7483
                ORDER BY cq.id";
7484
        $sql = sprintf($sql, $courseId, $sessionId);
7485
7486
        $result = Database::query($sql);
7487
7488
        $rows = array();
7489
        while ($row = Database::fetch_array($result, 'ASSOC')) {
7490
            $rows[] = $row;
7491
        }
7492
7493
        return $rows;
7494
    }
7495
7496
    /**
7497
     *