Code Duplication    Length = 28-31 lines in 2 locations

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

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