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 .= "" . "" . ""; while ($row = $sql->fetch()) { if(is_numeric($row['count'])) { $text .= ''; } } $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 .= '
SubjectScoreNo.Questions
' . $row['subject'] . '' . $row['percent'] . '%' . $row['count'] . '
'; while ($row = $sql->fetch()) { if((int)$row['cntr']==1) { $text .= '

' . $row['cntr'] . ' question has been answered
today with ' . $row['percent'] . '% accuracy.

'; }elseif(!(int)$row['cntr']==0) { $text .= '

' . $row['cntr'] . ' questions have been answered
today with ' . $row['percent'] . '% accuracy.


'; if($settingsHolder['minQuestionCount']<=$row['cntr']) { $text .= '
'; $currentScore = e107::getDb()->retrieve('timekeeperScore', 'timekeeper_lifetimecorrect, timekeeper_lifetimequestions, timekeeper_minutes', 'timekeeper_username="' . $this->user . '"'); $text .= ''; }else{ $text .= ''; } } } e107::getRender()->tablerender('Score', $text); }