| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- if (!defined('e107_INIT')) {
- require_once('../../class2.php');
- }
- if (!e107::isInstalled('timekeeper')) {
- return '';
- }
- $sql = e107::getDb();
- $userName = filter_input(INPUT_GET, 'user',FILTER_SANITIZE_SPECIAL_CHARS);
- $ext = vartrue(filter_input(INPUT_GET, 'extended', FILTER_VALIDATE_BOOL ),false);
- $settingsHolder = $sql->retrieve('timekeeper', '*', 'username="' . $userName . '"');
- if(count($settingsHolder)==0)
- {
- exit;
- }
- $sql->gen("SELECT DISTINCT subject FROM e107_tkReport WHERE `username` = '$userName'");
- while ($row = $sql->fetch()) {
- $subjects[] = $row['subject'];
-
- }
- $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 = '<div ><h1>Score for '.$userName.'</h1>';
-
- $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="' . $userName . '"');
- $text .= '<label>You have '.$currentScore['timekeeper_minutes'].' minutes remaining.</label>';
- }else{
- $text .= '<label>Games disabled</label>';
- }
- }
- }
-
- $text .= '</div>';
- if($ext)
- {
- print_r('hi');
- }
-
- echo '<head><meta http-equiv="refresh" content="60"></head><body style="background-color: #1a0000;color:white;">'.$text.'</body>';
|