Code Duplication    Length = 28-31 lines in 2 locations

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

@@ 3950-3980 (lines=31) @@
3947
     * including sessions, 0 = session is not filtered
3948
     * @return    array     tools data
3949
     */
3950
    public static function get_tools_most_used_by_course($courseId, $session_id = null)
3951
    {
3952
        $courseId = intval($courseId);
3953
        $data = array();
3954
        $TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
3955
        $condition_session     = '';
3956
        if (isset($session_id)) {
3957
            $session_id = intval($session_id);
3958
            $condition_session = ' AND access_session_id = '. $session_id;
3959
        }
3960
        $sql = "SELECT
3961
                    access_tool,
3962
                    COUNT(DISTINCT access_user_id),
3963
                    count(access_tool) as count_access_tool
3964
                FROM $TABLETRACK_ACCESS
3965
                WHERE
3966
                    access_tool IS NOT NULL AND
3967
                    access_tool != '' AND
3968
                    c_id = '$courseId'
3969
                    $condition_session
3970
                GROUP BY access_tool
3971
                ORDER BY count_access_tool DESC
3972
                LIMIT 0, 3";
3973
        $rs = Database::query($sql);
3974
        if (Database::num_rows($rs) > 0) {
3975
            while ($row = Database::fetch_array($rs)) {
3976
                $data[] = $row;
3977
            }
3978
        }
3979
        return $data;
3980
    }
3981
    /**
3982
     * Get total clicks
3983
     * 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,
@@ 4116-4143 (lines=28) @@
4113
     * @param    int        Limit (optional, default = 0, 0 = without limit)
4114
     * @return    array     documents downloaded
4115
     */
4116
    public static function get_documents_most_downloaded_by_course($course_code, $session_id = null, $limit = 0)
4117
    {
4118
        //protect data
4119
        $courseId = api_get_course_int_id($course_code);
4120
        $data = array();
4121
4122
        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4123
        $condition_session = '';
4124
        if (isset($session_id)) {
4125
            $session_id = intval($session_id);
4126
            $condition_session = ' AND down_session_id = '. $session_id;
4127
        }
4128
        $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4129
                FROM $TABLETRACK_DOWNLOADS
4130
                WHERE c_id = $courseId
4131
                    $condition_session
4132
                GROUP BY down_doc_path
4133
                ORDER BY count_down DESC
4134
                LIMIT 0,  $limit";
4135
        $rs = Database::query($sql);
4136
4137
        if (Database::num_rows($rs) > 0) {
4138
            while ($row = Database::fetch_array($rs)) {
4139
                $data[] = $row;
4140
            }
4141
        }
4142
        return $data;
4143
    }
4144
4145
    /**
4146
     * get links most visited by course