Code Duplication    Length = 16-19 lines in 5 locations

main/survey/survey.lib.php 1 location

@@ 1588-1606 (lines=19) @@
1585
     * @param int $course_id
1586
     * @return bool
1587
     */
1588
    public static function is_user_filled_survey($user_id, $survey_id, $course_id)
1589
    {
1590
        $table_survey_answer = Database :: get_course_table(TABLE_SURVEY_ANSWER);
1591
1592
        $user_id	= intval($user_id);
1593
        $course_id	= intval($course_id);
1594
        $survey_id	= intval($survey_id);
1595
1596
        $sql = "SELECT DISTINCT user FROM $table_survey_answer
1597
                WHERE
1598
                    c_id		= $course_id AND
1599
                    user		= $user_id AND
1600
                    survey_id	= $survey_id";
1601
        $result = Database::query($sql);
1602
        if (Database::num_rows($result)) {
1603
            return true;
1604
        }
1605
        return false;
1606
    }
1607
1608
    /**
1609
     * This function gets all the persons who have filled the survey

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

@@ 1305-1320 (lines=16) @@
1302
     * @param int $group_id iid
1303
     * @return int Number of students in the given group.
1304
     */
1305
    public static function number_of_students($group_id, $course_id = null)
1306
    {
1307
        $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
1308
        $group_id = intval($group_id);
1309
        if (empty($course_id)) {
1310
            $course_id = api_get_course_int_id();
1311
        } else {
1312
            $course_id = intval($course_id);
1313
        }
1314
        $sql = "SELECT  COUNT(*) AS number_of_students
1315
                FROM $table_group_user
1316
                WHERE c_id = $course_id AND group_id = $group_id";
1317
        $result = Database::query($sql);
1318
        $db_object = Database::fetch_object($result);
1319
1320
        return $db_object->number_of_students;
1321
    }
1322
1323
    /**
@@ 1733-1751 (lines=19) @@
1730
     * @todo use the function user_has_access that includes this function
1731
     * @author Patrick Cool <[email protected]>, Ghent University
1732
     */
1733
    public static function is_tutor_of_group($user_id, $group_id)
1734
    {
1735
        $table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
1736
        $user_id = intval($user_id);
1737
        $group_id = intval($group_id);
1738
        $course_id = api_get_course_int_id();
1739
1740
        $sql = "SELECT * FROM $table_group_tutor
1741
                WHERE 
1742
                    c_id = $course_id AND 
1743
                    user_id = $user_id AND 
1744
                    group_id = $group_id";
1745
        $result = Database::query($sql);
1746
        if (Database::num_rows($result) > 0) {
1747
            return true;
1748
        } else {
1749
            return false;
1750
        }
1751
    }
1752
1753
    /**
1754
     * Is the user part of this group? This can be a tutor or a normal member

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

@@ 163-181 (lines=19) @@
160
     * Get the maximum display order of the thematic item
161
     * @return int	Maximum display order
162
     */
163
    public function get_max_thematic_item($use_session = true)
164
    {
165
        // Database table definition
166
        $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
167
        $session_id   = api_get_session_id();
168
        if ($use_session) {
169
            $condition_session = api_get_session_condition($session_id);
170
        } else {
171
            $condition_session = '';
172
        }
173
        $course_id = api_get_course_int_id();
174
        $sql = "SELECT MAX(display_order)
175
                FROM $tbl_thematic
176
                WHERE c_id = $course_id AND active = 1 $condition_session";
177
        $rs = Database::query($sql);
178
        $row = Database::fetch_array($rs);
179
180
        return $row[0];
181
    }
182
183
    /**
184
     * Move a thematic

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

@@ 5409-5426 (lines=18) @@
5406
     * @param int $userId
5407
     * @return array
5408
     */
5409
    public static function getCourseAccessPerSessionAndUser($sessionId, $userId, $limit = null)
5410
    {
5411
        $table = Database:: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
5412
5413
        $sessionId = intval($sessionId);
5414
        $userId = intval($userId);
5415
5416
        $sql = "SELECT * FROM $table
5417
                WHERE session_id = $sessionId AND user_id = $userId";
5418
5419
        if (!empty($limit)) {
5420
            $limit = intval($limit);
5421
            $sql .= " LIMIT $limit";
5422
        }
5423
        $result = Database::query($sql);
5424
5425
        return Database::store_result($result);
5426
    }
5427
5428
    /**
5429
     * Get information from the track_e_course_access table