| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- if (!defined('e107_INIT')) {
- exit;
- }
- if (!e107::isInstalled('timekeeper')) {
- return '';
- }
- //e107::includeLan(e_PLUGIN."rss_menu/languages/".e_LANGUAGE."_admin_rss_menu.php");
- if (check_class("Main Admin") || check_class("Admin") || check_class("TIMEKEEPER_STUDENT")) {
- $sql = e107::getDb();
- $userName = e107::getUser()->getLoginName();
- $settingsHolder = $sql->retrieve('timekeeper', '*', 'username="' . $userName . '"');
-
- $sql->gen("SELECT DISTINCT subject FROM e107_tkReport WHERE `username` = '$userName'");
- while ($row = $sql->fetch()) {
- $subjects[] = $row['subject'];
-
- }
- //$sql->gen("SELECT * FROM (SELECT CAST((SUM(correct) / COUNT(id) * 100) AS DECIMAL (5 , 2 )) AS percent, COUNT(id) as `count`,
- //'Math' AS `subject` FROM e107_tkReport WHERE `username` = '$userName'
- //AND (`subject` = 'numbers' OR `subject` = 'numeracy')) as subjects
- //UNION
- //(SELECT CAST((SUM(correct) / COUNT(id) * 100) AS DECIMAL (5 , 2 )) AS percent, COUNT(id) as `count`,'English' AS `subject`
- //FROM e107_tkReport WHERE `username` = '$userName' AND `subject` = 'spelling')");
- $first = true;
- foreach ($subjects as $subject) {
- if($selects!=''){$selects .= ' UNION ';}
- $selects .= "(SELECT CAST((SUM(correct) / COUNT(id) * 100) AS DECIMAL (5 , 2 )) AS percent, COUNT(id) as `count`,'".ucfirst($subject)."' AS `subject`
- FROM e107_tkReport WHERE `username` = '$userName' AND `subject` = '$subject')";
- if($first){
- $selects .= " as subjects";
- $first = false;
- }
- }
- $sql->gen("SELECT * FROM $selects;");
- $text .= "<table style='width:100%;text-align:center;'>"
- . "<thead><tr><td style='text-align:left'>Subject</td><td>Score</td><td>No.Questions</td></tr></thead>"
- . "<tbody>";
- while ($row = $sql->fetch()) {
- if(is_numeric($row['count'])) {
- $text .= '<tr><td style=\'text-align:left\'>' . $row['subject'] . '</td><td>' . $row['percent'] . '%</td><td>' . $row['count'] . '</td></tr>';
- }
- }
- $sql->gen("SELECT COUNT(id) as cntr, CAST((SUM(correct)/COUNT(id)*100) as DECIMAL(5,2)) as percent
- FROM e107.`e107_tkReport` WHERE username = '$userName'
- AND answereddatestamp >= unix_timestamp(CURRENT_DATE())
- AND answereddatestamp <= unix_timestamp(CURRENT_DATE() + INTERVAL 1 DAY)");
- $text .= '</tbody></table>';
- while ($row = $sql->fetch()) {
- if((int)$row['cntr']==1) {
- $text .= '<p>' . $row['cntr'] . ' question has been answered<br/>today with ' . $row['percent'] . '% accuracy.<p>';
- }elseif(!(int)$row['cntr']==0) {
- $text .= '<p>' . $row['cntr'] . ' questions have been answered<br/>today with ' . $row['percent'] . '% accuracy.<p><br/>';
- if($settingsHolder['minQuestionCount']<=$row['cntr']) {
- $text .= '<label style="background: Darkgreen;">Games enabled</label><br/>';
- $currentScore = e107::getDb()->retrieve('timekeeperScore', 'timekeeper_lifetimecorrect, timekeeper_lifetimequestions, timekeeper_minutes', 'timekeeper_username="' . $this->user . '"');
- $text .= '<label>You have '.$currentScore['timekeeper_minutes'].' minutes remaining.</label>';
- }else{
- $text .= '<label>Games disabled</label>';
- }
- }
- }
-
- e107::getRender()->tablerender('Score', $text);
- }
|