Code Duplication    Length = 28-31 lines in 2 locations

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

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