user, * which doesn't exist in a menu file, so the minutes were always blank; * it uses the logged-in user name now * - one GROUP BY query replaces the hand-built UNION: a student with no * answers yet produced "SELECT * FROM ;" (invalid SQL) and undefined * variable notices * - a student with exactly one answer today now also gets the "games * enabled" line (the singular branch skipped it), and the unclosed
* tags are closed * - a student with no settings row no longer errors (uses the default * minimum of 100 questions that timer.php creates new rows with) * - user name escaped for SQL, subjects/values escaped for HTML, * `e107.e107_tkReport` -> MPREFIX */ if (!defined('e107_INIT')) { exit; } if (!e107::isInstalled('timekeeper')) { return ''; } if (check_class("Main Admin") || check_class("Admin") || check_class("TIMEKEEPER_STUDENT")) { $sql = e107::getDb(); $userName = e107::getUser()->getLoginName(); $u = $sql->escape($userName); $reportTable = '`' . MPREFIX . 'tkReport`'; $settingsHolder = $sql->retrieve('timekeeper', '*', 'username="' . $u . '"'); $minQuestions = is_array($settingsHolder) ? (int) $settingsHolder['minQuestionCount'] : 100; // Score per subject, all time. $sql->gen("SELECT `subject`, COUNT(id) AS `count`, CAST((SUM(correct) / COUNT(id) * 100) AS DECIMAL(5,2)) AS percent FROM $reportTable WHERE `username` = '$u' GROUP BY `subject` ORDER BY `subject`"); $subjectRows = []; while ($row = $sql->fetch()) { $subjectRows[] = $row; } $text = "
| Subject | Score | No.Questions |
| " . htmlspecialchars(ucfirst($row['subject']), ENT_QUOTES, 'UTF-8') . ' | ' . htmlspecialchars($row['percent']) . '% | ' . (int) $row['count'] . ' |
1 question has been answered
today with ' . $percent . '% accuracy.
' . $answeredToday . ' questions have been answered
today with ' . $percent . '% accuracy.