Code Duplication    Length = 28-31 lines in 2 locations

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

@@ 3828-3858 (lines=31) @@
3825
     * including sessions, 0 = session is not filtered
3826
     * @return    array     tools data
3827
     */
3828
    public static function get_tools_most_used_by_course($courseId, $session_id = null)
3829
    {
3830
        $courseId = intval($courseId);
3831
        $data = array();
3832
        $TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
3833
        $condition_session     = '';
3834
        if (isset($session_id)) {
3835
            $session_id = intval($session_id);
3836
            $condition_session = ' AND access_session_id = '. $session_id;
3837
        }
3838
        $sql = "SELECT
3839
                    access_tool,
3840
                    COUNT(DISTINCT access_user_id),
3841
                    count(access_tool) as count_access_tool
3842
                FROM $TABLETRACK_ACCESS
3843
                WHERE
3844
                    access_tool IS NOT NULL AND
3845
                    access_tool != '' AND
3846
                    c_id = '$courseId'
3847
                    $condition_session
3848
                GROUP BY access_tool
3849
                ORDER BY count_access_tool DESC
3850
                LIMIT 0, 3";
3851
        $rs = Database::query($sql);
3852
        if (Database::num_rows($rs) > 0) {
3853
            while ($row = Database::fetch_array($rs)) {
3854
                $data[] = $row;
3855
            }
3856
        }
3857
        return $data;
3858
    }
3859
    /**
3860
     * Get total clicks
3861
     * 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,
@@ 3994-4021 (lines=28) @@
3991
     * @param    int        Limit (optional, default = 0, 0 = without limit)
3992
     * @return    array     documents downloaded
3993
     */
3994
    public static function get_documents_most_downloaded_by_course($course_code, $session_id = null, $limit = 0)
3995
    {
3996
        //protect data
3997
        $courseId = api_get_course_int_id($course_code);
3998
        $data = array();
3999
4000
        $TABLETRACK_DOWNLOADS   = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
4001
        $condition_session = '';
4002
        if (isset($session_id)) {
4003
            $session_id = intval($session_id);
4004
            $condition_session = ' AND down_session_id = '. $session_id;
4005
        }
4006
        $sql = "SELECT down_doc_path, COUNT(DISTINCT down_user_id), COUNT(down_doc_path) as count_down
4007
                FROM $TABLETRACK_DOWNLOADS
4008
                WHERE c_id = $courseId
4009
                    $condition_session
4010
                GROUP BY down_doc_path
4011
                ORDER BY count_down DESC
4012
                LIMIT 0,  $limit";
4013
        $rs = Database::query($sql);
4014
4015
        if (Database::num_rows($rs) > 0) {
4016
            while ($row = Database::fetch_array($rs)) {
4017
                $data[] = $row;
4018
            }
4019
        }
4020
        return $data;
4021
    }
4022
4023
    /**
4024
     * get links most visited by course