Code Duplication    Length = 28-31 lines in 2 locations

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

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