Code Duplication    Length = 28-31 lines in 2 locations

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

@@ 3917-3947 (lines=31) @@
3914
     * including sessions, 0 = session is not filtered
3915
     * @return    array     tools data
3916
     */
3917
    public static function get_tools_most_used_by_course($courseId, $session_id = null)
3918
    {
3919
        $courseId = intval($courseId);
3920
        $data = array();
3921
        $TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
3922
        $condition_session     = '';
3923
        if (isset($session_id)) {
3924
            $session_id = intval($session_id);
3925
            $condition_session = ' AND access_session_id = '. $session_id;
3926
        }
3927
        $sql = "SELECT
3928
                    access_tool,
3929
                    COUNT(DISTINCT access_user_id),
3930
                    count(access_tool) as count_access_tool
3931
                FROM $TABLETRACK_ACCESS
3932
                WHERE
3933
                    access_tool IS NOT NULL AND
3934
                    access_tool != '' AND
3935
                    c_id = '$courseId'
3936
                    $condition_session
3937
                GROUP BY access_tool
3938
                ORDER BY count_access_tool DESC
3939
                LIMIT 0, 3";
3940
        $rs = Database::query($sql);
3941
        if (Database::num_rows($rs) > 0) {
3942
            while ($row = Database::fetch_array($rs)) {
3943
                $data[] = $row;
3944
            }
3945
        }
3946
        return $data;
3947
    }
3948
    /**
3949
     * Get total clicks
3950
     * THIS FUNCTION IS NOT BEEN USED, IT WAS MEANT TO BE USE WITH track_e_course_access.date_from and track_e_course_access.date_to,
@@ 4083-4110 (lines=28) @@
4080
     * @param    int        Limit (optional, default = 0, 0 = without limit)
4081
     * @return    array     documents downloaded
4082
     */
4083
    public static function get_documents_most_downloaded_by_course($course_code, $session_id = null, $limit = 0)
4084
    {
4085
        //protect data
4086
        $courseId = api_get_course_int_id($course_code);
4087
        $data = array();
4088
4089
        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4090
        $condition_session = '';
4091
        if (isset($session_id)) {
4092
            $session_id = intval($session_id);
4093
            $condition_session = ' AND down_session_id = '. $session_id;
4094
        }
4095
        $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4096
                FROM $TABLETRACK_DOWNLOADS
4097
                WHERE c_id = $courseId
4098
                    $condition_session
4099
                GROUP BY down_doc_path
4100
                ORDER BY count_down DESC
4101
                LIMIT 0,  $limit";
4102
        $rs = Database::query($sql);
4103
4104
        if (Database::num_rows($rs) > 0) {
4105
            while ($row = Database::fetch_array($rs)) {
4106
                $data[] = $row;
4107
            }
4108
        }
4109
        return $data;
4110
    }
4111
4112
    /**
4113
     * get links most visited by course