block("lightgreen", "added blackboard");
}
+ if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) {
+ block("red", "no students registered");
+ break;
+ }
+
block("black", "add blackboard");
?>
-blackboard.php
\ No newline at end of file
+nextsession.php
\ No newline at end of file
require 'include/session.inc';
require 'include/common.inc';
+ if (! isset($SESSIONS_actual)) {
+ block("red", "no next session");
+ break;
+ }
+
block("black", "summary for session " . $SESSIONS[$SESSIONS_actual]['timestr'] . " (" . $SESSIONS[$SESSIONS_actual]['examples'] . ")");
$result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY lastname");
require 'include/session.inc';
require 'include/common.inc';
+ if ($db->query("SELECT COUNT(*) FROM students")->fetch(PDO::FETCH_NUM)[0] == 0) {
+ block("red", "no students registered");
+ break;
+ }
+
block("black", "summary of everything for " . date("d.m.Y H:i"));
$result = $db->query("SELECT firstname, lastname, mnumber, blackboard FROM students ORDER BY lastname");
<?php
include 'db.inc';
- $result = $db->query("SELECT key, value FROM prefs");
- while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
- $PREFS[$row['key']] = $row['value'];
+ if (! isset($PREFS)) {
+ $result = $db->query("SELECT key, value FROM prefs");
+ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
+ $PREFS[$row['key']] = $row['value'];
+ }
}
-
?>
<?php
- $result=$db->query("SELECT id,examples,nexamples FROM sessions ORDER BY id");
- $SESSIONS_next = -1;
- $SESSIONS_actual = -1;
+ require 'db.inc';
+
+ if ( ! isset($SESSIONS) ) {
+ $result=$db->query("SELECT id,examples,nexamples FROM sessions ORDER BY id");
+ $SESSIONS_next = -1;
+ $SESSIONS_actual = -1;
- while ($session = $result->fetch(PDO::FETCH_ASSOC)) {
- $SESSIONS[$session['id']] = array("id" => $session['id'], "timestr" => date("d.m.Y H:i", $session['id']),
- "workdone" => $db->query("SELECT COUNT(*) FROM workdone WHERE session=" . $session['id'])->fetch(PDO::FETCH_NUM)[0],
- "examples" => $session['examples'], "nexamples" => $session['nexamples']);
- if ( strtotime("now") < $session['id'] && ( $SESSIONS_next==-1 || $SESSIONS_next > $session['id'] ) ) {
- $SESSIONS_next = $session['id'];
- }
- if ( strtotime("now") < $session['id'] + 3600 && ( $SESSIONS_actual==-1 || $SESSIONS_actual > $session['id'] ) ) {
- $SESSIONS_actual = $session['id'];
+ while ($session = $result->fetch(PDO::FETCH_ASSOC)) {
+ $SESSIONS[$session['id']] = array("id" => $session['id'], "timestr" => date("d.m.Y H:i", $session['id']),
+ "workdone" => $db->query("SELECT COUNT(*) FROM workdone WHERE session=" . $session['id'])->fetch(PDO::FETCH_NUM)[0],
+ "examples" => $session['examples'], "nexamples" => $session['nexamples']);
+ if ( strtotime("now") < $session['id'] && ( $SESSIONS_next==-1 || $SESSIONS_next > $session['id'] ) ) {
+ $SESSIONS_next = $session['id'];
+ }
+ if ( strtotime("now") < $session['id'] + 3600 && ( $SESSIONS_actual==-1 || $SESSIONS_actual > $session['id'] ) ) {
+ $SESSIONS_actual = $session['id'];
+ }
}
- }
- if($SESSIONS_next == -1) unset($SESSIONS_next);
+ if($SESSIONS_next == -1) unset($SESSIONS_next);
+ if($SESSIONS_actual == -1) unset($SESSIONS_actual);
- $SESSIONS_totex = 0;
- foreach ($SESSIONS as $session) {
- if($session['id'] < $SESSIONS_next) { $SESSIONS_totex += $session['nexamples']; }
- }
+ $SESSIONS_totex = 0;
+ foreach ($SESSIONS as $session) {
+ if($session['id'] < $SESSIONS_next) { $SESSIONS_totex += $session['nexamples']; }
+ }
- $SESSIONS_totex_nextinc = 0;
- foreach ($SESSIONS as $session) {
- if($session['id'] <= $SESSIONS_next) { $SESSIONS_totex_nextinc += $session['nexamples']; }
+ $SESSIONS_totex_nextinc = 0;
+ foreach ($SESSIONS as $session) {
+ if($session['id'] <= $SESSIONS_next) { $SESSIONS_totex_nextinc += $session['nexamples']; }
+ }
}
?>
<?php
require 'include/head.inc';
+require 'include/prefs.inc';
if(isset($_POST['submit']) && $_POST['firstname']!="" && $_POST['lastname']!=""
&& $_POST['mnumber']!="" && $_POST['email']!="" && $_POST['password']!="")
echo "$firstname $lastname was successfully registered.<br>";
// send password-email //
- $lec_lines = file('var/lecture.txt');
- foreach ($lec_lines as $line_num => $line) {
- $lecture[$line_num] = $line;
- }
- $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . trim($lecture[0]) . " " . trim($lecture[1]) . ".\nRemember your password: $password\n\nYours,\nBanana.";
- //$nachricht = wordwrap($nachricht,70);
+ $nachricht = "Hello $firstname($mnumber)!\nYou registered for " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ").\nRemember your password: $password\n\nYours,\nBanana.";
$empfaenger = 'niemand@example.com';
$betreff = 'Der Betreff';
$header = 'From: banana@treefish.org' . "\r\n" .
'Reply-To: noreply@treefish.org' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
- mail($email, "Banana Registration: " . trim($lecture[0]) . " " . trim($lecture[1]), $nachricht, $header);
+ mail($email, "Banana Registration: " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ")", $nachricht, $header);
break;
}