Пример #1
0
/**
* draws statistics graph
* @global type $uid
* @global type $langCourseVisits
s * @return type
*/
function courseVisitsPlot()
{
    global $uid, $langCourseVisits, $langNoStats;
    $totalHits = 0;
    $totalDuration = 0;
    $result = Database::get()->queryArray("SELECT a.code code, a.title title\n                                        FROM course AS a LEFT JOIN course_user AS b\n                                             ON a.id = b.course_id\n                                        WHERE b.user_id = ?d\n                                        AND a.visible != " . COURSE_INACTIVE . "\n                                        ORDER BY a.title", $uid);
    if (count($result) > 0) {
        // found courses ?
        foreach ($result as $row) {
            $course_codes[] = $row->code;
            $course_names[$row->code] = $row->title;
        }
        foreach ($course_codes as $code) {
            $cid = course_code_to_id($code);
            $row = Database::get()->querySingle("SELECT SUM(hits) AS cnt FROM actions_daily\n                                WHERE user_id = ?d\n                                AND course_id =?d", $uid, $cid);
            if ($row) {
                $totalHits += $row->cnt;
                $hits[$code] = $row->cnt;
            }
            $result = Database::get()->querySingle("SELECT SUM(duration) AS duration FROM actions_daily\n                                        WHERE user_id = ?d\n                                        AND course_id = ?d", $uid, $cid);
            $duration[$code] = $result->duration;
            $totalDuration += $duration[$code];
        }
        $chart = new Plotter(600, 300);
        $chart->setTitle($langCourseVisits);
        foreach ($hits as $code => $count) {
            if ($count > 0) {
                $chart->addPoint($course_names[$code], $count);
                $chart->modDimension(7, 0);
            }
        }
        return $chart->plot();
    } else {
        return "{$langNoStats}";
    }
}
Пример #2
0
        $cid = course_code_to_id($code);
        $row = Database::get()->querySingle("SELECT SUM(hits) AS cnt FROM actions_daily\n                                WHERE user_id = ?d\n                                AND course_id =?d", $uid, $cid);
        if ($row) {
            $totalHits += $row->cnt;
            $hits[$code] = $row->cnt;
        }
        $result = Database::get()->querySingle("SELECT SUM(duration) AS duration FROM actions_daily\n                                        WHERE user_id = ?d\n                                        AND course_id = ?d", $uid, $cid);
        $duration[$code] = $result->duration;
        $totalDuration += $duration[$code];
    }
    $chart = new Plotter(600, 300);
    $chart->setTitle($langCourseVisits);
    foreach ($hits as $code => $count) {
        if ($count > 0) {
            $chart->addPoint($course_names[$code], $count);
            $chart->modDimension(7, 0);
        }
    }
    $tool_content .= $chart->plot();
    $totalDuration = format_time_duration(0 + $totalDuration);
    $tool_content .= "<fieldset>\n                <legend>{$langPlatformGenStats}</legend>\n                <table class='table-default'>\n                <tr>\n                <th>{$langTotalVisitsCourses}:</th>\n                <td>{$totalHits}</td>\n                </tr>\n                <tr>\n                <th>{$langDurationVisits}:</th>\n                <td>{$totalDuration}</td>\n                </tr>\n                <tr>\n                <th valign='top'>{$langDurationVisitsPerCourse}:</th>\n                <td>\n                <table class='table-default' width='550'>\n                <tr>\n                <th>{$langCourseTitle}</th>                   \n                <th width='160'>{$langDuration}</th>\n                </tr>";
    foreach ($duration as $code => $time) {
        $tool_content .= "                \n                <td>" . q(course_code_to_title($code)) . "</td>\n                <td width='140'>" . format_time_duration(0 + $time) . "</td>\n                </tr>";
    }
    $tool_content .= "</table></td></tr>";
}
// End of chart display; chart unlinked at end of script.
$tool_content .= "<tr><th>{$langLastVisits}:</th><td>";
$tool_content .= "<table class='table-default' width='550'>\n            <tr>\n              <th>{$langDate}</th>\n              <th width='140'>{$langAction}</th>\n            </tr>";
$act["LOGIN"] = "******";
$act["LOGOUT"] = "<font color='#FF0000'>{$langLogout}</font>";