Code Duplication    Length = 15-21 lines in 7 locations

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

@@ 1664-1680 (lines=17) @@
1661
     *
1662
     * @return array
1663
     */
1664
    public static function getAllExerciseEventByExeId($exe_id)
1665
    {
1666
        $table_track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
1667
        $exe_id = intval($exe_id);
1668
        $list = array();
1669
1670
        $sql = "SELECT * FROM $table_track_attempt
1671
                WHERE exe_id = $exe_id
1672
                ORDER BY position";
1673
        $res_question = Database::query($sql);
1674
        if (Database::num_rows($res_question)) {
1675
            while ($row = Database::fetch_array($res_question, 'ASSOC')) {
1676
                $list[$row['question_id']][] = $row;
1677
            }
1678
        }
1679
        return $list;
1680
    }
1681
1682
    /**
1683
     *
@@ 1615-1634 (lines=20) @@
1612
     *
1613
     * @return array
1614
     */
1615
    public static function get_all_exercises_from_lp($lp_id, $course_id)
1616
    {
1617
        $lp_item_table = Database :: get_course_table(TABLE_LP_ITEM);
1618
        $course_id = intval($course_id);
1619
        $lp_id = intval($lp_id);
1620
        $sql = "SELECT * FROM $lp_item_table
1621
                WHERE
1622
                    c_id = $course_id AND
1623
                    lp_id = '".$lp_id."' AND
1624
                    item_type = 'quiz'
1625
                ORDER BY parent_item_id, display_order";
1626
        $res = Database::query($sql);
1627
1628
        $my_exercise_list = array();
1629
        while ($row = Database::fetch_array($res, 'ASSOC')) {
1630
            $my_exercise_list[] = $row;
1631
        }
1632
1633
        return $my_exercise_list;
1634
    }
1635
1636
    /**
1637
     * This function gets the comments of an exercise

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

@@ 707-726 (lines=20) @@
704
     * @param int $limit
705
     * @return array
706
     */
707
    public function searchByField($tag, $field_id, $limit = 10)
708
    {
709
        $field_id = intval($field_id);
710
        $limit = intval($limit);
711
        $tag = Database::escape_string($tag);
712
        $sql = "SELECT DISTINCT id, option_display_text
713
                FROM {$this->table}
714
                WHERE
715
                    field_id = '".$field_id."' AND
716
                    option_value LIKE '%$tag%'
717
                ORDER BY option_value
718
                LIMIT 0, $limit
719
                ";
720
        $result = Database::query($sql);
721
        $values = array();
722
        if (Database::num_rows($result)) {
723
            $values = Database::store_result($result, 'ASSOC');
724
        }
725
726
        return $values;
727
    }
728
729

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

@@ 647-661 (lines=15) @@
644
     * @param string $course_code The course (default = current course)
645
     * @return array
646
     */
647
    public static function get_categories($course_code = null)
648
    {
649
        $course_info = api_get_course_info($course_code);
650
        $course_id     = $course_info['real_id'];
651
        $table_group_cat = Database :: get_course_table(TABLE_GROUP_CATEGORY);
652
        $sql = "SELECT * FROM $table_group_cat
653
                WHERE c_id = $course_id
654
                ORDER BY display_order";
655
        $res = Database::query($sql);
656
        $cats = array ();
657
        while ($cat = Database::fetch_array($res)) {
658
            $cats[] = $cat;
659
        }
660
        return $cats;
661
    }
662
663
    /**
664
     * Get a group category

main/survey/survey.lib.php 1 location

@@ 4106-4122 (lines=17) @@
4103
     * @author Patrick Cool <[email protected]>, Ghent University
4104
     * @version September 2007
4105
     */
4106
    public static function get_invitations($survey_code)
4107
    {
4108
        $course_id = api_get_course_int_id();
4109
        // Database table definition
4110
        $table_survey_invitation 	= Database :: get_course_table(TABLE_SURVEY_INVITATION);
4111
4112
        $sql = "SELECT * FROM $table_survey_invitation
4113
		        WHERE
4114
		            c_id = $course_id AND
4115
		            survey_code = '".Database::escape_string($survey_code)."'";
4116
        $result = Database::query($sql);
4117
        $return = array();
4118
        while ($row = Database::fetch_array($result)) {
4119
            $return[$row['user']] = $row;
4120
        }
4121
        return $return;
4122
    }
4123
4124
    /**
4125
     * This function displays the form for searching a survey

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

@@ 6143-6163 (lines=21) @@
6140
     *
6141
     * @return array
6142
     */
6143
    public static function getDeletedDocuments($courseInfo, $sessionId = 0)
6144
    {
6145
        $table = Database::get_course_table(TABLE_DOCUMENT);
6146
        $courseId = $courseInfo['real_id'];
6147
        $sessionCondition = api_get_session_condition($sessionId);
6148
        $sql = "SELECT * FROM $table
6149
                WHERE
6150
                  path LIKE '%DELETED%' AND
6151
                  c_id = $courseId
6152
                  $sessionCondition
6153
                ORDER BY path
6154
        ";
6155
6156
        $result = Database::query($sql);
6157
        $files = array();
6158
        while ($document = Database::fetch_array($result, 'ASSOC')) {
6159
            $files[] = $document;
6160
        }
6161
6162
        return $files;
6163
    }
6164
6165
    /**
6166
     * @param int $id

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

@@ 5575-5591 (lines=17) @@
5572
 * @author Julio Montoya <[email protected]>
5573
 * @return int user id
5574
 */
5575
function api_get_access_url_from_user($user_id) {
5576
    $user_id = intval($user_id);
5577
    $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
5578
    $table_url          = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
5579
    $sql = "SELECT access_url_id
5580
            FROM $table_url_rel_user url_rel_user
5581
            INNER JOIN $table_url u
5582
            ON (url_rel_user.access_url_id = u.id)
5583
            WHERE user_id = ".intval($user_id);
5584
    $result = Database::query($sql);
5585
    $url_list = array();
5586
    while ($row = Database::fetch_array($result, 'ASSOC')) {
5587
        $url_list[] = $row['access_url_id'];
5588
    }
5589
    return $url_list;
5590
}
5591
5592
/**
5593
 * Gets the status of a user in a course
5594
 * @param int       $user_id