4 if ( ! isset($EXAMS) ) {
5 $result=$db->query("SELECT id,score FROM exams ORDER BY id");
10 while ($exam = $result->fetch(PDO::FETCH_ASSOC)) {
12 foreach (explode(',',$exam['score']) as $points) {
13 $totpoints = $totpoints + $points;
15 $EXAMS[$exam['id']] = array("id" => $exam['id'],
16 "timestr" => date("d.m.Y H:i", $exam['id']),
17 "scorestr" => $exam['score'],
18 "totscore" => $totpoints,
19 "nresults" => $db->query("SELECT COUNT(*) FROM examscore WHERE exam=" . $exam['id'])->fetch(PDO::FETCH_NUM)[0],
20 "nquests" => count(explode(',',$exam['score'])));
21 if ( strtotime("now") < $exam['id'] && ( $EXAMS_next==-1 || $EXAMS_next > $exam['id'] ) ) {
22 $EXAMS_next = $exam['id'];
24 if ( strtotime("now") < $exam['id'] + 3600 && ( $EXAMS_actual==-1 || $EXAMS_actual > $exam['id'] ) ) {
25 $EXAMS_actual = $exam['id'];
29 if($EXAMS_next == -1) unset($EXAMS_next);
30 if($EXAMS_actual == -1) unset($EXAMS_actual);
33 $EXAMS_totscore_nextinc = 0;
35 foreach ($EXAMS as $exam) {
36 if( (! isset($EXAMS_next)) || $exam['id'] < $EXAMS_next ) { $EXAMS_totscore += $exam['totscore']; }
37 if( (! isset($EXAMS_actual)) || $exam['id'] != $EXAMS_actual ) { $EXAMS_last = $exam['id']; }
38 if( (! isset($EXAMS_next)) || $exam['id'] <= $EXAMS_next ) { $EXAMS_totscore_nextinc += $exam['totscore']; }