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); } } $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"] = "******";
/** * 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}"; } }
$names_array[] = $name->fullname; } $names_str = implode(', ', $names_array); $ellipsized_names_str = q(ellipsize($names_str, 60)); } $answers_table .= "\n <tr>\n <td>" . $q_answer . "</td>\n <td>{$answer->count}</td>" . ($thePoll->anonymized == 1 ? '' : '<td>' . $ellipsized_names_str . ($ellipsized_names_str != $names_str ? ' <a href="#" class="trigger_names" data-type="multiple" id="show">' . $showall . '</a>' : '') . '</td><td class="hidden_names" style="display:none;">' . q($names_str) . ' <a href="#" class="trigger_names" data-type="multiple" id="hide">' . $shownone . '</a></td>') . "</tr>"; unset($names_array); } $answers_table .= "</table><br>"; $chart->normalize(); $tool_content .= $chart->plot(); $tool_content .= $answers_table; } elseif ($theQuestion->qtype == QTYPE_SCALE) { $chart = new Plotter(800, 300); for ($i = 1; $i <= $theQuestion->q_scale; $i++) { $chart->addPoint($i, 0); } $answers = Database::get()->queryArray("SELECT answer_text, count(answer_text) as count FROM poll_answer_record WHERE qid = ?d GROUP BY answer_text", $theQuestion->pqid); $answer_total = Database::get()->querySingle("SELECT COUNT(*) AS total FROM poll_answer_record WHERE qid= ?d", $theQuestion->pqid)->total; $answers_table = "\n <table class='table-default'>\n <tr>\n <th>{$langAnswer}</th>\n <th>{$langSurveyTotalAnswers}</th>" . ($thePoll->anonymized == 1 ? '' : '<th>' . $langStudents . '</th>') . "</tr>"; foreach ($answers as $answer) { $percentage = round(100 * ($answer->count / $answer_total), 2); $chart->addPoint(q($answer->answer_text), $percentage); if ($thePoll->anonymized != 1) { $names = Database::get()->queryArray("SELECT CONCAT(b.surname, ' ', b.givenname) AS fullname FROM poll_answer_record AS a, user AS b WHERE a.answer_text = ?s AND a.user_id = b.id", $answer->answer_text); foreach ($names as $name) { $names_array[] = $name->fullname; } $names_str = implode(', ', $names_array); $ellipsized_names_str = q(ellipsize($names_str, 60)); }