Code-Modernisierungen für PHP-8-Kompatibilität.

Zusätzlich Charsets, Linebreaks und Kommentar-Blöcke korrigiert.
This commit is contained in:
Kai Blaschke 2023-01-24 15:12:37 +01:00
parent 4afbdaf52b
commit 7b28fea35c
No known key found for this signature in database
GPG Key ID: B014B6811527389F
13 changed files with 1934 additions and 1810 deletions

View File

@ -8,7 +8,7 @@
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstra<EFBFBD>e 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
@ -27,15 +27,15 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/* /*
Aufl<EFBFBD>sungen zu allen Fragen Auflösungen zu allen Fragen
*/ */
$tpl->addVars('navAntworten', 'current'); $GLOBALS['tpl']->addVars('navAntworten', 'current');
$katalog = -1; $katalog = -1;
if (isset($_REQUEST['katalog'])) { if (isset($_REQUEST['katalog'])) {
@ -44,27 +44,26 @@ if (isset($_REQUEST['katalog'])) {
$abschnitte = getTopics(); $abschnitte = getTopics();
foreach ($abschnitte as $nr => $description) { foreach ($abschnitte as $nr => $description) {
$tpl->addVars(Array( $GLOBALS['tpl']->addVars(array(
'abschnittNr' => $nr, 'abschnittNr' => $nr,
'abschnittName' => htmlspecialchars($description), 'abschnittName' => htmlspecialchars($description),
'navAntwortenAbschnitt' => ($katalog == $nr) ? 'current':'' 'navAntwortenAbschnitt' => ($katalog == $nr) ? 'current' : ''
)); ));
$tpl->parseBlock('page-body', 'NavAntworten', 'Sublinks', TRUE); $GLOBALS['tpl']->parseBlock('page-body', 'NavAntworten', 'Sublinks', TRUE);
} }
if (isset($_SESSION['zufallsfragen']) || isset($_SESSION['bogen'])) { if (isset($_SESSION['zufallsfragen']) || isset($_SESSION['bogen'])) {
if (isset($_GET['clear']) && intval($_GET['clear']) == '1') { if (isset($_GET['clear']) && intval($_GET['clear']) == '1') {
unset($_SESSION['bogen']); unset($_SESSION['bogen']);
unset($_SESSION['zufallsfragen']); unset($_SESSION['zufallsfragen']);
unset($_SESSION['frage_nr']); unset($_SESSION['frage_nr']);
unset($_SESSION['fragen_cnt']); unset($_SESSION['fragen_cnt']);
unset($_SESSION['zufallstats']); unset($_SESSION['zufallstats']);
unset($_SESSION['bogen']); unset($_SESSION['bogen']);
} } else {
else { $GLOBALS['tpl']->addTemplates(array('content' => 'aufloesung-error'));
$tpl->addTemplates(Array('content' => 'aufloesung-error')); return;
return;
} }
} }
@ -78,20 +77,20 @@ if ($katalog > 0) {
$stmt->bind_result($selectedNr, $selectedDescription); $stmt->bind_result($selectedNr, $selectedDescription);
$stmt->fetch(); $stmt->fetch();
addBreadcrumb($_REQUEST['show'].'&katalog=' . $selectedNr, $selectedDescription); addBreadcrumb($_REQUEST['show'] . '&katalog=' . $selectedNr, $selectedDescription);
$tpl->addTemplates(Array( $GLOBALS['tpl']->addTemplates(array(
'content' => 'aufloesung-antworten' 'content' => 'aufloesung-antworten'
)); ));
$tpl->addVars(Array( $GLOBALS['tpl']->addVars(array(
'abschnittNr' => $selectedNr, 'abschnittNr' => $selectedNr,
'abschnittName' => htmlspecialchars($selectedDescription) 'abschnittName' => htmlspecialchars($selectedDescription)
)); ));
$stmt->close(); $stmt->close();
$stmt = $GLOBALS['db']->prepare('SELECT * FROM `fragen` WHERE `Abschnitt` = ? AND `Jahr` = ? ORDER BY Abschnitt,Nr ASC'); $stmt = $GLOBALS['db']->prepare('SELECT * FROM `fragen` WHERE `Abschnitt` = ? AND `Jahr` = ? ORDER BY Abschnitt,Nr');
$stmt->bind_param('ii', $katalog, $_SESSION['jahr']); $stmt->bind_param('ii', $katalog, $_SESSION['jahr']);
$stmt->execute(); $stmt->execute();
$questions = $stmt->get_result(); $questions = $stmt->get_result();
@ -99,33 +98,35 @@ if ($katalog > 0) {
$I = 1; $I = 1;
while ($question = $questions->fetch_array(MYSQLI_ASSOC)) { while ($question = $questions->fetch_array(MYSQLI_ASSOC)) {
ShowAnswer($question); ShowAnswer($question);
$tpl->parseBlock('content', 'Antworten', 'Row', TRUE, TRUE); $GLOBALS['tpl']->parseBlock('content', 'Antworten', 'Row', TRUE, TRUE);
if ($I%10==0) { if ($I % 10 == 0) {
$tpl->parseBlock('content', 'Antworten', 'Topline', TRUE); $GLOBALS['tpl']->parseBlock('content', 'Antworten', 'Topline', TRUE);
} }
$I++; $I++;
} }
$questions->close(); $questions->close();
$stmt->close(); $stmt->close();
} } else {
else {
$tpl->addTemplates('content', 'aufloesung-abschnitte'); $GLOBALS['tpl']->addTemplates('content', 'aufloesung-abschnitte');
$stmt = $GLOBALS['db']->prepare('SELECT `Nr`,`Beschreibung` FROM `abschnitte` WHERE `Jahr` = ? ORDER BY Nr ASC'); $nr = 0;
$description = '';
$stmt = $GLOBALS['db']->prepare('SELECT `Nr`,`Beschreibung` FROM `abschnitte` WHERE `Jahr` = ? ORDER BY Nr');
$stmt->bind_param('i', $_SESSION['jahr']); $stmt->bind_param('i', $_SESSION['jahr']);
$stmt->execute(); $stmt->execute();
$stmt->bind_result($nr, $description); $stmt->bind_result($nr, $description);
while ($stmt->fetch()) { while ($stmt->fetch()) {
$tpl->addVars(Array( $GLOBALS['tpl']->addVars(array(
'abschnittNr' => $nr, 'abschnittNr' => $nr,
'abschnittName' => $description 'abschnittName' => $description
)); ));
$tpl->parseBlock('content', 'Abschnitte', 'Row', TRUE); $GLOBALS['tpl']->parseBlock('content', 'Abschnitte', 'Row', TRUE);
} }
} }
?>

View File

@ -1,15 +1,12 @@
<?php <?php
if (isset($_POST['normal'])) {
if (isset($_POST['normal'])) { setcookie("stylesheet", "normal", time()+60*60*24*365);
setcookie("stylesheet", "normal", time()+60*60*24*365); $GLOBALS['tpl']->addVars('extraStyleSheet', '');
$tpl->addVars('extraStyleSheet', ''); }
}
if (isset($_POST['barrierefrei'])) {
if (isset($_POST['barrierefrei'])) { setcookie("stylesheet", "barrierefrei", time()+60*60*24*365);
setcookie("stylesheet", "barrierefrei", time()+60*60*24*365); }
}
$GLOBALS['tpl']->addTemplates(Array("content" => "barrierefreiheit"));
$tpl->addTemplates(Array("content" => "barrierefreiheit"));
?>

File diff suppressed because it is too large Load Diff

124
db.php
View File

@ -1,61 +1,63 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included "THW Thema" templates, logos and the Q&A catalog are protected * The included "THW Thema" templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
$GLOBALS['db'] = new mysqli("localhost", "DBUSER", "DBPASSWD", "DBDATABASE"); $GLOBALS['db'] = new mysqli("localhost", "DBUSER", "DBPASSWD", "DBDATABASE");
if ($GLOBALS['db']->connect_error) { if ($GLOBALS['db']->connect_error) {
header("HTTP/1.0 500 Internal Server Error"); header("HTTP/1.0 500 Internal Server Error");
readfile('templates/db-error.html'); readfile('templates/db-error.html');
die(); die();
} }
function callBindParamArray($stmt, $bindArguments = null) { function callBindParamArray($stmt, $bindArguments = null) {
if ($bindArguments === null) { if ($bindArguments === null) {
return; return;
} }
$args = array(); $args = array();
foreach($bindArguments as $k => &$arg){ foreach($bindArguments as $k => &$arg){
$args[$k] = &$arg; $args[$k] = &$arg;
} }
call_user_func_array(array($stmt, "bind_param"), $args); call_user_func_array(array($stmt, "bind_param"), $args);
} }
function getSingleResult($query, $bindArguments = null) { function getSingleResult($query, $bindArguments = null) {
$stmt = $GLOBALS['db']->prepare($query); $retVal = '';
callBindParamArray($stmt, $bindArguments);
$stmt->execute(); $stmt = $GLOBALS['db']->prepare($query);
$stmt->bind_result($retVal); callBindParamArray($stmt, $bindArguments);
$stmt->fetch(); $stmt->execute();
$stmt->close(); $stmt->bind_result($retVal);
$stmt->fetch();
return $retVal; $stmt->close();
}
return $retVal;
}

View File

@ -1,284 +1,293 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included 'THW Thema' templates, logos and the Q&A catalog are protected * The included 'THW Thema' templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/** /**
* Holt eine Einzelne Frage aus der DB * Holt eine einzelne Frage aus der Datenbank.
* * @param int $id Die Frage-ID
* @param $id Die Frage-ID * @return array Die Fragen-Inhalte als assoziatives Array.
* */
* @return array Die Frage function getQuestionById(int $id): array
*/ {
function getQuestionById($id) { $stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?');
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?'); $stmt->bind_param('i', $id);
$stmt->bind_param('i', $id); $stmt->execute();
$stmt->execute(); $result = $stmt->get_result();
$result = $stmt->get_result();
$question = $result->fetch_array(MYSQLI_ASSOC);
$question = $result->fetch_array(MYSQLI_ASSOC);
return $question;
return $question; }
}
/**
/** * Holt eine Liste aller Abschnitte im aktuellen Jahr
* Holt eine Liste aller Abschnitte im aktuellen Jahr * @return array Liste der Themenbereiche.
* */
* @return array function getTopics(): array
*/ {
function getTopics() { $nr = 0;
$stmt = $GLOBALS['db']->prepare('SELECT `Nr`,`Beschreibung` FROM `abschnitte` WHERE `Jahr` = ? ORDER BY `Nr` ASC'); $description = '';
$stmt->bind_param('i', $_SESSION['jahr']);
$stmt->execute(); $stmt = $GLOBALS['db']->prepare('SELECT `Nr`,`Beschreibung` FROM `abschnitte` WHERE `Jahr` = ? ORDER BY `Nr`');
$stmt->bind_result($nr, $description); $stmt->bind_param('i', $_SESSION['jahr']);
$stmt->execute();
$topics = array(); $stmt->bind_result($nr, $description);
while ($stmt->fetch()) {
$topics[$nr] = $description; $topics = array();
} while ($stmt->fetch()) {
$stmt->close(); $topics[$nr] = $description;
}
return $topics; $stmt->close();
}
return $topics;
/****************************************************************************** }
*
* Kopfzeile mit Informationen über Fragennummer und Lernabschnitt /**
* * Kopfzeile mit Informationen über Fragen-Nummer und Lernabschnitt.
/******************************************************************************/ * @param int $id Frage-ID
* @param int $nr Frage-Nummer
function questionHeader($id, $nr, $questionCount) * @param int $questionCount Anzahl Fragen
{ * @return void
$section = getSingleResult('SELECT Abschnitt FROM fragen WHERE ID=? AND Jahr=?', */
array('ii', $id, $_SESSION['jahr'])); function questionHeader(int $id, int $nr, int $questionCount): void
{
$sectionName = getSingleResult('SELECT Beschreibung FROM abschnitte WHERE Nr=? AND Jahr=?', $section = getSingleResult('SELECT Abschnitt FROM fragen WHERE ID=? AND Jahr=?',
array('ii', $section, $_SESSION['jahr'])); array('ii', $id, $_SESSION['jahr']));
$GLOBALS['tpl']->addVars(Array( $sectionName = getSingleResult('SELECT Beschreibung FROM abschnitte WHERE Nr=? AND Jahr=?',
'aktuelleFrage' => $nr, array('ii', $section, $_SESSION['jahr']));
'fragenCnt' => $questionCount,
'abschnittNr' => $section, $GLOBALS['tpl']->addVars(Array(
'abschnitt' => $sectionName 'aktuelleFrage' => $nr,
)); 'fragenCnt' => $questionCount,
'abschnittNr' => $section,
$GLOBALS['tpl']->parseBlock('content', 'Kopf', 'Content'); 'abschnitt' => $sectionName
} ));
/****************************************************************************** $GLOBALS['tpl']->parseBlock('content', 'Kopf', 'Content');
* }
* Eine einzelne Frage mit Kopfzeile ausgeben
* /**
/******************************************************************************/ * Eine einzelne Frage mit Kopfzeile ausgeben.
* @param int $id Frage-ID
function SingleQuestion($id, $Nr, $questionCount) * @param int $nr Frage-Nummer
{ * @param int $questionCount Anzahl Fragen
questionHeader($id, $Nr, $questionCount); * @return void
showQuestion($id); */
} function SingleQuestion(int $id, int $nr, int $questionCount): void
{
/****************************************************************************** questionHeader($id, $nr, $questionCount);
* showQuestion($id);
* Fragengenerator }
* Erzeugt eine Tabelle mit Frage, Antworten und Formularinformationen
* zur übergebenen Fragen-ID /**
* * Fragengenerator
/******************************************************************************/ *
* Erzeugt eine Tabelle mit Frage, Antworten und Formularinformationen
function showQuestion($id) * zur übergebenen Fragen-ID
{ * @param int $id Fragen-ID
// Frage aus DB holen * @return void
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?'); */
$stmt->bind_param('i', $id); function showQuestion(int $id): void
$stmt->execute(); {
$result = $stmt->get_result(); // Frage aus DB holen
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?');
$question = $result->fetch_array(MYSQLI_ASSOC); $stmt->bind_param('i', $id);
$stmt->execute();
$GLOBALS['tpl']->addVars(Array( $result = $stmt->get_result();
'frageID' => $id,
'frageNr' => $question['Nr'], $question = $result->fetch_array(MYSQLI_ASSOC);
'abschnittNr' => $question['Abschnitt'],
'frageText' => $question['Frage'], $GLOBALS['tpl']->addVars(Array(
'Antwort1' => $question['Antwort1'], 'frageID' => $id,
'Antwort2' => $question['Antwort2'], 'frageNr' => $question['Nr'],
'Antwort3' => $question['Antwort3'] 'abschnittNr' => $question['Abschnitt'],
)); 'frageText' => $question['Frage'],
'Antwort1' => $question['Antwort1'],
if ($question['Antwort3'] == '') { 'Antwort2' => $question['Antwort2'],
$GLOBALS['tpl']->addVars('rowCnt', '2'); 'Antwort3' => $question['Antwort3']
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows'); ));
}
else { if ($question['Antwort3'] == '') {
$GLOBALS['tpl']->addVars('rowCnt', '3'); $GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row', TRUE); $GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
} }
else {
$result->close(); $GLOBALS['tpl']->addVars('rowCnt', '3');
$stmt->close(); $GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row', TRUE);
} }
/****************************************************************************** $result->close();
* $stmt->close();
* Auswertung }
* Erzeugt eine Tabelle mit Frage, Antworten und Markiert richtige/falsche
* Antworten farblich (grün=richtig, rot=falsch) /**
* * Auswertung
/******************************************************************************/ *
* Erzeugt eine Tabelle mit Frage, Antworten und Markiert richtige/falsche
function Answer($id, $answer, $showStatus = TRUE) * Antworten farblich (grün=richtig, rot=falsch)
{ * @param int $id Frage-ID
// Frage aus DB holen * @param array $answer Antwort-Array
$question = getQuestionById($id); * @param bool $showStatus Status anzeigen
* @return bool true, falls korrekt beantwortet, sonst false.
// Einzelne Antworten aus Flag in Array splitten */
$solution = array( 1 => ( $question['Loesung'] & 0x1), function Answer(int $id, array $answer, bool $showStatus = true): bool
2 => (($question['Loesung'] & 0x2) >> 1), {
3 => (($question['Loesung'] & 0x4) >> 2)); // Frage aus DB holen
$question = getQuestionById($id);
$correct = (($solution[1] == (isset($answer[$id][1]) ? $answer[$id][1] : 0))
&& ($solution[2] == (isset($answer[$id][2]) ? $answer[$id][2] : 0)) // Einzelne Antworten aus Flag in Array splitten
&& ($solution[3] == (isset($answer[$id][3]) ? $answer[$id][3] : 0))); $solution = array( 1 => ( $question['Loesung'] & 0x1),
2 => (($question['Loesung'] & 0x2) >> 1),
// Aufräumen 3 => (($question['Loesung'] & 0x4) >> 2));
$GLOBALS['tpl']->delHandle('antwortStatus');
$GLOBALS['tpl']->delHandle('antwort1Loesung'); $correct = (($solution[1] == (isset($answer[$id][1]) ? $answer[$id][1] : 0))
$GLOBALS['tpl']->delHandle('antwort2Loesung'); && ($solution[2] == (isset($answer[$id][2]) ? $answer[$id][2] : 0))
$GLOBALS['tpl']->delHandle('antwort3Loesung'); && ($solution[3] == (isset($answer[$id][3]) ? $answer[$id][3] : 0)));
$GLOBALS['tpl']->delBlockHandle('content', 'A1L'); // Aufräumen
$GLOBALS['tpl']->delBlockHandle('content', 'A2L'); $GLOBALS['tpl']->delHandle('antwortStatus');
$GLOBALS['tpl']->delBlockHandle('content', 'A3L'); $GLOBALS['tpl']->delHandle('antwort1Loesung');
$GLOBALS['tpl']->delHandle('antwort2Loesung');
if ($showStatus) { $GLOBALS['tpl']->delHandle('antwort3Loesung');
if ($correct)
$GLOBALS['tpl']->parseBlock('content', 'Status', 'Richtig'); $GLOBALS['tpl']->delBlockHandle('content', 'A1L');
else $GLOBALS['tpl']->delBlockHandle('content', 'A2L');
$GLOBALS['tpl']->parseBlock('content', 'Status', 'Falsch'); $GLOBALS['tpl']->delBlockHandle('content', 'A3L');
} else {
if ($correct) if ($showStatus) {
$GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Richtig'); if ($correct)
else $GLOBALS['tpl']->parseBlock('content', 'Status', 'Richtig');
$GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Falsch'); else
} $GLOBALS['tpl']->parseBlock('content', 'Status', 'Falsch');
} else {
$GLOBALS['tpl']->addVars(Array( if ($correct)
'abschnittNr' => $question['Abschnitt'], $GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Richtig');
'frageNr' => $question['Nr'], else
'frageText' => $question['Frage'], $GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Falsch');
'antwort1Status' => $solution[1] ? 'korrekt' : 'falsch', }
'antwort2Status' => $solution[2] ? 'korrekt' : 'falsch',
'antwort3Status' => $solution[3] ? 'korrekt' : 'falsch', $GLOBALS['tpl']->addVars(Array(
'Antwort1' => $question['Antwort1'], 'abschnittNr' => $question['Abschnitt'],
'Antwort2' => $question['Antwort2'], 'frageNr' => $question['Nr'],
'Antwort3' => $question['Antwort3'] 'frageText' => $question['Frage'],
)); 'antwort1Status' => $solution[1] ? 'korrekt' : 'falsch',
'antwort2Status' => $solution[2] ? 'korrekt' : 'falsch',
if ($question['Antwort3'] == '') { 'antwort3Status' => $solution[3] ? 'korrekt' : 'falsch',
$GLOBALS['tpl']->addVars('rowCnt', '2'); 'Antwort1' => $question['Antwort1'],
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows'); 'Antwort2' => $question['Antwort2'],
} 'Antwort3' => $question['Antwort3']
else { ));
$GLOBALS['tpl']->addVars('rowCnt', '3');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row'); if ($question['Antwort3'] == '') {
} $GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
if (isset($answer[$id][1]) && $answer[$id][1] === '1') $GLOBALS['tpl']->parseBlock('content', 'A1L', 'Haken'); }
if (isset($answer[$id][2]) && $answer[$id][2] === '1') $GLOBALS['tpl']->parseBlock('content', 'A2L', 'Haken'); else {
if (isset($answer[$id][3]) && $answer[$id][3] === '1') $GLOBALS['tpl']->parseBlock('content', 'A3L', 'Haken'); $GLOBALS['tpl']->addVars('rowCnt', '3');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row');
// Anhängen per default }
$GLOBALS['tpl']->parse('content', 'antwort', TRUE, TRUE);
if (isset($answer[$id][1]) && $answer[$id][1] === '1') $GLOBALS['tpl']->parseBlock('content', 'A1L', 'Haken');
return $correct; if (isset($answer[$id][2]) && $answer[$id][2] === '1') $GLOBALS['tpl']->parseBlock('content', 'A2L', 'Haken');
if (isset($answer[$id][3]) && $answer[$id][3] === '1') $GLOBALS['tpl']->parseBlock('content', 'A3L', 'Haken');
}
// Anhängen per default
/****************************************************************************** $GLOBALS['tpl']->parse('content', 'antwort', TRUE, TRUE);
*
* Antwort return $correct;
* Zeigt die Frage und die zugehörigen korrekten Antworten an
* Antworten sind farblich gekennzeichnet (grün=richtig, rot=falsch) }
*
/******************************************************************************/ /**
* Brotkrumen-Navigation.
function addBreadcrumb($params, $title) *
{ * Fügt einen Link zur Brotkrumen-Navigation hinzu.
$GLOBALS['tpl']->addVars(Array( * @param string $page Seiten-Link
'page' => htmlspecialchars($params), * @param string $title Seiten-Titel
'pageTitle' => htmlspecialchars($title) * @return void
)); */
$GLOBALS['tpl']->parseBlock('page-body', 'Breadcrumb', 'Link', TRUE); function addBreadcrumb(string $page, string $title): void
} {
$GLOBALS['tpl']->addVars(Array(
function ShowAnswer(&$frage) 'page' => htmlspecialchars($page),
{ 'pageTitle' => htmlspecialchars($title)
));
$GLOBALS['tpl']->parseBlock('page-body', 'Breadcrumb', 'Link', TRUE);
// Einzelne Antworten aus Flag in Array splitten }
$loesung = array( 1 => ( $frage['Loesung'] & 0x1),
2 => (($frage['Loesung'] & 0x2) >> 1), /**
3 => (($frage['Loesung'] & 0x4) >> 2)); * Zeigt die Auflösung an.
* @param array $frage Referenz auf das assoziative Fragen-Array
// Aufräumen * @return void
$GLOBALS['tpl']->delHandle('antwortStatus'); */
$GLOBALS['tpl']->delHandle('antwort1Loesung'); function ShowAnswer(array &$frage): void
$GLOBALS['tpl']->delHandle('antwort2Loesung'); {
$GLOBALS['tpl']->delHandle('antwort3Loesung');
$GLOBALS['tpl']->addVars(Array( // Einzelne Antworten aus Flag in Array splitten
'abschnittNr' => $frage['Abschnitt'], $loesung = array( 1 => ( $frage['Loesung'] & 0x1),
'frageNr' => $frage['Nr'], 2 => (($frage['Loesung'] & 0x2) >> 1),
'frageText' => $frage['Frage'], 3 => (($frage['Loesung'] & 0x4) >> 2));
'antwort1Status' => $loesung[1]?'korrekt':'falsch',
'antwort2Status' => $loesung[2]?'korrekt':'falsch', // Aufräumen
'antwort3Status' => $loesung[3]?'korrekt':'falsch', $GLOBALS['tpl']->delHandle('antwortStatus');
'Antwort1' => $frage['Antwort1'], $GLOBALS['tpl']->delHandle('antwort1Loesung');
'Antwort2' => $frage['Antwort2'], $GLOBALS['tpl']->delHandle('antwort2Loesung');
'Antwort3' => $frage['Antwort3'] $GLOBALS['tpl']->delHandle('antwort3Loesung');
));
$GLOBALS['tpl']->addVars(Array(
$GLOBALS['tpl']->delBlockHandle('content', 'A1L'); 'abschnittNr' => $frage['Abschnitt'],
$GLOBALS['tpl']->delBlockHandle('content', 'A2L'); 'frageNr' => $frage['Nr'],
$GLOBALS['tpl']->delBlockHandle('content', 'A3L'); 'frageText' => $frage['Frage'],
'antwort1Status' => $loesung[1]?'korrekt':'falsch',
if ($loesung[1]) $GLOBALS['tpl']->parseBlock('content', 'A1L', 'Haken'); 'antwort2Status' => $loesung[2]?'korrekt':'falsch',
if ($loesung[2]) $GLOBALS['tpl']->parseBlock('content', 'A2L', 'Haken'); 'antwort3Status' => $loesung[3]?'korrekt':'falsch',
if ($loesung[3]) $GLOBALS['tpl']->parseBlock('content', 'A3L', 'Haken'); 'Antwort1' => $frage['Antwort1'],
'Antwort2' => $frage['Antwort2'],
if ($frage['Antwort3'] == '') { 'Antwort3' => $frage['Antwort3']
$GLOBALS['tpl']->addVars('rowCnt', '2'); ));
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
} $GLOBALS['tpl']->delBlockHandle('content', 'A1L');
else { $GLOBALS['tpl']->delBlockHandle('content', 'A2L');
$GLOBALS['tpl']->addVars('rowCnt', '3'); $GLOBALS['tpl']->delBlockHandle('content', 'A3L');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row');
} if ($loesung[1]) $GLOBALS['tpl']->parseBlock('content', 'A1L', 'Haken');
} if ($loesung[2]) $GLOBALS['tpl']->parseBlock('content', 'A2L', 'Haken');
if ($loesung[3]) $GLOBALS['tpl']->parseBlock('content', 'A3L', 'Haken');
?>
if ($frage['Antwort3'] == '') {
$GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
}
else {
$GLOBALS['tpl']->addVars('rowCnt', '3');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row');
}
}

View File

@ -1,61 +1,73 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included 'THW Thema' templates, logos and the Q&A catalog are protected * The included 'THW Thema' templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
function getStats() { /**
$stmt = $GLOBALS['db']->prepare('SELECT fragen,richtig,falsch,boegen,bestanden,durchgefallen FROM statistik'); * Holt die Gesamt-Statistiken aus der Datenbank und füllt das Template.
$stmt->execute(); * @return void
$stmt->bind_result( */
$fragen, function getStats(): void
$richtig, {
$falsch, $fragen = 0;
$boegen, $richtig = 0;
$bestanden, $falsch = 0;
$durchgefallen $boegen = 0;
); $bestanden = 0;
$durchgefallen = 0;
$stmt->fetch();
$stmt = $GLOBALS['db']->prepare('SELECT fragen,richtig,falsch,boegen,bestanden,durchgefallen FROM statistik');
$GLOBALS['tpl']->addVars(Array( $stmt->execute();
'statsFragen' => sprintf('%0.d', $fragen), $stmt->bind_result(
'statsFragenRichtig' => sprintf('%0.d (%0.2f %%)', $richtig, ($fragen > 0 ? $richtig / $fragen * 100 : 0)), $fragen,
'statsFragenFalsch' => sprintf('%0.d (%0.2f %%)', $falsch, ($fragen > 0 ? $falsch / $fragen * 100 : 0)), $richtig,
'statsBoegen' => sprintf('%0.d', $boegen), $falsch,
'statsBoegenRichtig' => sprintf('%0.d (%0.2f %%)', $bestanden, ($boegen > 0 ? $bestanden / $boegen * 100 : 0)), $boegen,
'statsBoegenFalsch' => sprintf('%0.d (%0.2f %%)', $durchgefallen, ($boegen > 0 ? $durchgefallen / $boegen * 100 : 0)) $bestanden,
)); $durchgefallen
);
} $stmt->fetch();
getStats(); $GLOBALS['tpl']->addVars(array(
$GLOBALS['tpl']->addTemplates(Array( 'statsFragen' => sprintf('%0.d', $fragen),
'content' => 'home' 'statsFragenRichtig' => sprintf('%0.d (%0.2f %%)', $richtig, ($fragen > 0 ? $richtig / $fragen * 100 : 0)),
)); 'statsFragenFalsch' => sprintf('%0.d (%0.2f %%)', $falsch, ($fragen > 0 ? $falsch / $fragen * 100 : 0)),
?> 'statsBoegen' => sprintf('%0.d', $boegen),
'statsBoegenRichtig' => sprintf('%0.d (%0.2f %%)', $bestanden, ($boegen > 0 ? $bestanden / $boegen * 100 : 0)),
'statsBoegenFalsch' => sprintf('%0.d (%0.2f %%)', $durchgefallen, ($boegen > 0 ? $durchgefallen / $boegen * 100 : 0))
));
}
getStats();
$GLOBALS['tpl']->addTemplates(array(
'content' => 'home'
));

218
index.php
View File

@ -1,110 +1,108 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included 'THW Thema' templates, logos and the Q&A catalog are protected * The included 'THW Thema' templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
require_once 'db.php'; require_once 'db.php';
require_once 'class.template.inc.php'; require_once 'class.template.inc.php';
require_once 'functions.inc.php'; require_once 'functions.inc.php';
require_once 'init.inc.php'; require_once 'init.inc.php';
if (!isset($_REQUEST['show'])) { if (!isset($_REQUEST['show'])) {
$_REQUEST['show'] = 'home'; $_REQUEST['show'] = 'home';
} }
switch ($_REQUEST['show']) { switch ($_REQUEST['show']) {
case 'fragen': case 'fragen':
addBreadcrumb($_REQUEST['show'], 'Zufallsfragen beantworten'); addBreadcrumb($_REQUEST['show'], 'Zufallsfragen beantworten');
include ('zufallsfragen.inc.php'); include('zufallsfragen.inc.php');
break; break;
case 'bogen': case 'bogen':
addBreadcrumb($_REQUEST['show'], 'Prüfungsbogen üben'); addBreadcrumb($_REQUEST['show'], 'Prüfungsbogen üben');
include ('pruefbogen.inc.php'); include('pruefbogen.inc.php');
break; break;
case 'loesung': case 'loesung':
addBreadcrumb($_REQUEST['show'], 'Antworten anzeigen'); addBreadcrumb($_REQUEST['show'], 'Antworten anzeigen');
include ('antworten.inc.php'); include('antworten.inc.php');
break; break;
case 'ordnung': case 'ordnung':
addBreadcrumb($_REQUEST['show'], 'Prüfungsordnung'); addBreadcrumb($_REQUEST['show'], 'Prüfungsordnung');
$tpl->addVars('navOrdnung', 'current'); $GLOBALS['tpl']->addVars('navOrdnung', 'current');
$tpl->addTemplates(Array('content' => 'ordnung')); $GLOBALS['tpl']->addTemplates(array('content' => 'ordnung'));
break; break;
case 'stats': case 'stats':
$tpl->addVars(Array( $GLOBALS['tpl']->addVars(array(
// Statistik Zufallsfragen // Statistik Zufallsfragen
'fragenBisher' => $_SESSION['stats']['Fragen_Bisher'], 'fragenBisher' => $_SESSION['stats']['Fragen_Bisher'],
'fragenRichtig' => $_SESSION['stats']['Fragen_Richtig'], 'fragenRichtig' => $_SESSION['stats']['Fragen_Richtig'],
'fragenFalsch' => $_SESSION['stats']['Fragen_Falsch'], 'fragenFalsch' => $_SESSION['stats']['Fragen_Falsch'],
'fragenQuote' => (($_SESSION['stats']['Fragen_Bisher']>0)?(preg_replace('/\./is', ',', number_format($_SESSION['stats']['Fragen_Richtig']/$_SESSION['stats']['Fragen_Bisher']*100,2))):('0')) . '%', 'fragenQuote' => (($_SESSION['stats']['Fragen_Bisher'] > 0) ? (preg_replace('/\./is', ',', number_format($_SESSION['stats']['Fragen_Richtig'] / $_SESSION['stats']['Fragen_Bisher'] * 100, 2))) : ('0')) . '%',
// Statistik Prüfungsbögen // Statistik Prüfungsbögen
'boegenBisher' => $_SESSION['stats']['Boegen_Bisher'], 'boegenBisher' => $_SESSION['stats']['Boegen_Bisher'],
'boegenRichtig' => $_SESSION['stats']['Boegen_Bestanden'], 'boegenRichtig' => $_SESSION['stats']['Boegen_Bestanden'],
'boegenFalsch' => $_SESSION['stats']['Boegen_Durchgefallen'], 'boegenFalsch' => $_SESSION['stats']['Boegen_Durchgefallen'],
'boegenQuote' => (($_SESSION['stats']['Boegen_Bisher']>0)?(preg_replace('/\./is', ',', number_format($_SESSION['stats']['Boegen_Bestanden']/$_SESSION['stats']['Boegen_Bisher']*100,2))):('0')) . '%' 'boegenQuote' => (($_SESSION['stats']['Boegen_Bisher'] > 0) ? (preg_replace('/\./is', ',', number_format($_SESSION['stats']['Boegen_Bestanden'] / $_SESSION['stats']['Boegen_Bisher'] * 100, 2))) : ('0')) . '%'
)); ));
addBreadcrumb($_REQUEST['show'], 'Statistiken'); addBreadcrumb($_REQUEST['show'], 'Statistiken');
$tpl->addVars('navStats', 'current'); $GLOBALS['tpl']->addVars('navStats', 'current');
$tpl->addTemplates(Array('content' => 'stats')); $GLOBALS['tpl']->addTemplates(array('content' => 'stats'));
break; break;
case "barrierefreiheit": case "barrierefreiheit":
addBreadcrumb($_REQUEST["show"], "Barrierefreiheit"); addBreadcrumb($_REQUEST["show"], "Barrierefreiheit");
include "barrierefreiheit.inc.php"; include "barrierefreiheit.inc.php";
break; break;
case 'impressum': case 'impressum':
addBreadcrumb($_REQUEST['show'], 'Impressum'); addBreadcrumb($_REQUEST['show'], 'Impressum');
$tpl->addTemplates(Array('content' => 'impressum')); $GLOBALS['tpl']->addTemplates(array('content' => 'impressum'));
break; break;
case 'datenschutz': case 'datenschutz':
addBreadcrumb($_REQUEST['show'], 'Datenschutzhinweis'); addBreadcrumb($_REQUEST['show'], 'Datenschutzhinweis');
$tpl->addTemplates(Array('content' => 'datenschutz')); $GLOBALS['tpl']->addTemplates(array('content' => 'datenschutz'));
break; break;
case "downloads": case "downloads":
addBreadcrumb($_REQUEST["show"], "Offline-Version"); addBreadcrumb($_REQUEST["show"], "Offline-Version");
$tpl->addVars("navOffline", "current"); $GLOBALS['tpl']->addVars("navOffline", "current");
$tpl->addTemplates(Array("content" => "offline")); $GLOBALS['tpl']->addTemplates(array("content" => "offline"));
break; break;
default: default:
$title = ''; $title = '';
include('home.inc.php'); include('home.inc.php');
} }
$tpl->parse('pageContent', 'content'); $GLOBALS['tpl']->parse('pageContent', 'content');
$tpl->printParse('pageMain', 'page-body'); $GLOBALS['tpl']->printParse('pageMain', 'page-body');
?>

View File

@ -1,91 +1,86 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included 'THW Thema' templates, logos and the Q&A catalog are protected * The included 'THW Thema' templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstra<EFBFBD>e 93 * Provinzialstra<EFBFBD>e 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
header('Content-Type: text/html; charset=utf-8'); header('Content-Type: text/html; charset=utf-8');
$GLOBALS['tpl'] = new Template('./templates/'); $GLOBALS['tpl'] = new Template(__DIR__ . '/templates/');
$tpl =& $GLOBALS['tpl'];
$GLOBALS['tpl']->addTemplates(Array(
$tpl->addTemplates(Array( 'page-body' => 'page-body',
'page-body' => 'page-body', 'top-line' => 'top-line'
'top-line' => 'top-line' ));
));
session_start();
session_start();
if (isset($_REQUEST['resetstats']) && intval($_REQUEST['resetstats']) == '1') {
if (isset($_REQUEST['resetstats']) && intval($_REQUEST['resetstats']) == '1') { unset($_SESSION['stats']);
unset($_SESSION['stats']); }
}
if (!isset($_SESSION['stats'])) {
if (!isset($_SESSION['stats'])) {
$_SESSION['stats'] = array('Fragen_Bisher' => '0',
$_SESSION['stats'] = array('Fragen_Bisher' => '0', 'Fragen_Richtig' => '0',
'Fragen_Richtig' => '0', 'Fragen_Falsch' => '0',
'Fragen_Falsch' => '0', 'Boegen_Bisher' => '0',
'Boegen_Bisher' => '0', 'Boegen_Bestanden' => '0',
'Boegen_Bestanden' => '0', 'Boegen_Durchgefallen' => '0' );
'Boegen_Durchgefallen' => '0' ); }
}
if (isset($_REQUEST['jahr'])) {
if (isset($_REQUEST['jahr'])) { $_SESSION['jahr'] = intval($_REQUEST['jahr']);
$_SESSION['jahr'] = intval($_REQUEST['jahr']); } elseif (!isset($_SESSION['jahr'])) {
} elseif (!isset($_SESSION['jahr'])) { $_SESSION['jahr'] = 2020;
$_SESSION['jahr'] = 2020; }
}
mt_srand(intval(microtime()) * 10000);
srand(microtime()*(double)10000);
if ((isset($_COOKIE['stylesheet']) && $_COOKIE['stylesheet'] == 'barrierefrei')
if ((isset($_COOKIE['stylesheet']) && $_COOKIE['stylesheet'] == 'barrierefrei') || isset($_POST['barrierefrei'])
|| isset($_POST['barrierefrei']) || (isset($_GET['style']) && $_GET['style'] == 'rg')) {
|| (isset($_GET['style']) && $_GET['style'] == 'rg')) { $GLOBALS['tpl']->addVars('extraStyleSheet', '<link href="rg-styles.css" rel="stylesheet" type="text/css" />');
$tpl->addVars('extraStyleSheet', '<link href="rg-styles.css" rel="stylesheet" type="text/css" />'); }
} else {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
} $protocol = 'https';
// HSTS Policy aktivieren
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { header('Strict-Transport-Security: max-age=31536000; includeSubDomains;');
$protocol = 'https'; } else {
// HSTS Policy aktivieren $protocol = 'http';
header('Strict-Transport-Security: max-age=31536000; includeSubDomains;'); }
} else {
$protocol = 'http'; $GLOBALS['tpl']->addVars(Array(
} // Globale Variablen
'scriptName' => $_SERVER['SCRIPT_NAME'],
$tpl->addVars(Array( 'catalogYear' => $_SESSION['jahr'],
// Globale Variablen 'baseUrl' => $protocol . '://' . $_SERVER['HTTP_HOST'] . '/'
'scriptName' => $_SERVER['SCRIPT_NAME'], ));
'catalogYear' => $_SESSION['jahr'],
'baseUrl' => $protocol . '://thw-theorie.de/'
)); $GLOBALS['tpl']->parse('topLine', 'top-line');
$tpl->parse('topLine', 'top-line');
?>

View File

@ -1,216 +1,219 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included 'THW Thema' templates, logos and the Q&A catalog are protected * The included 'THW Thema' templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/* /*
* *
* Vollständiger Prüfungsbogen mit zufälligen Fragen * Vollständiger Prüfungsbogen mit zufälligen Fragen
* *
*/ */
$tpl->parseBlock('page-body', 'NavBogen', 'Sublinks'); $GLOBALS['tpl']->parseBlock('page-body', 'NavBogen', 'Sublinks');
$tpl->addVars('navBogen', 'current'); $GLOBALS['tpl']->addVars('navBogen', 'current');
if (isset($_REQUEST['create']) && $_REQUEST['create'] == '1') { if (isset($_REQUEST['create']) && $_REQUEST['create'] == '1') {
// Neuen Bogen erstellen // Neuen Bogen erstellen
unset($_SESSION['bogen']); unset($_SESSION['bogen']);
// Werte initialisieren // Werte initialisieren
$_SESSION['bogen']['StartTime'] = time(); $_SESSION['bogen']['StartTime'] = time();
$_SESSION['bogen']['Fragen'] = Array(); $_SESSION['bogen']['Fragen'] = array();
// Anz. Abschnitte und Fragen aus der DB holen // Anz. Abschnitte und Fragen aus der DB holen
$sectionCount = getSingleResult('SELECT COUNT(*) FROM abschnitte WHERE Jahr = ?', array('i', $_SESSION['jahr'])); $sectionCount = getSingleResult('SELECT COUNT(*) FROM abschnitte WHERE Jahr = ?', array('i', $_SESSION['jahr']));
$stmt = $GLOBALS['db']->prepare('SELECT ID, Abschnitt FROM fragen WHERE Jahr = ? ORDER BY Abschnitt, Nr ASC'); $questionId = 0;
$stmt->bind_param('i', $_SESSION['jahr']); $questionSection = 0;
$stmt->execute();
$stmt->bind_result($questionId, $questionSection); $stmt = $GLOBALS['db']->prepare('SELECT ID, Abschnitt FROM fragen WHERE Jahr = ? ORDER BY Abschnitt, Nr');
$stmt->bind_param('i', $_SESSION['jahr']);
// Fragen in Array übertragen $stmt->execute();
while ($stmt->fetch()) { $stmt->bind_result($questionId, $questionSection);
$fragen[$questionId] = $questionSection;
} // Fragen in Array übertragen
$stmt->close(); while ($stmt->fetch()) {
$fragen[$questionId] = $questionSection;
// Gesamtanzahl Fragen }
$count_ab = array_count_values($fragen); $stmt->close();
// Eine Frage pro Themengebiet aus der DB holen // Gesamtanzahl Fragen
for ($i = 1; $i <= $sectionCount; $i++) { $count_ab = array_count_values($fragen);
$nr = rand(1, $count_ab[$i]);
$id = getSingleResult('SELECT ID FROM fragen WHERE Nr = ? AND Abschnitt = ? AND Jahr = ?', // Eine Frage pro Themengebiet aus der DB holen
array('iii', $nr, $i, $_SESSION['jahr'])); for ($i = 1; $i <= $sectionCount; $i++) {
$nr = rand(1, $count_ab[$i]);
array_push($_SESSION['bogen']['Fragen'], (int)$id); $id = getSingleResult('SELECT ID FROM fragen WHERE Nr = ? AND Abschnitt = ? AND Jahr = ?',
array('iii', $nr, $i, $_SESSION['jahr']));
// Frage entfernen
unset($fragen[$id]); array_push($_SESSION['bogen']['Fragen'], (int)$id);
}
// Frage entfernen
// Restliche Fragen zufällig auffüllen unset($fragen[$id]);
// Dazu verbliebene Keys von $fragen als Values in neues Array $fragen2 kopieren, }
// da shuffle() die Keys verwirft!
$fragen2 = Array(); // Restliche Fragen zufällig auffüllen.
foreach ($fragen As $key => $value) { // Dazu verbliebene Keys von $fragen als Values in neues Array $fragen2 kopieren,
array_push($fragen2, $key); // da shuffle() die Keys verwirft!
} $fragen2 = array();
shuffle($fragen2); foreach ($fragen as $key => $value) {
for ($i = 0; $i < 40 - $sectionCount; $i++) { array_push($fragen2, $key);
array_push($_SESSION['bogen']['Fragen'], array_shift($fragen2)); }
}
shuffle($fragen2);
// Fragen erneut mischen for ($i = 0; $i < 40 - $sectionCount; $i++) {
shuffle($_SESSION['bogen']['Fragen']); array_push($_SESSION['bogen']['Fragen'], array_shift($fragen2));
}
}
// Fragen erneut mischen
if (isset($_SESSION['bogen'])) { shuffle($_SESSION['bogen']['Fragen']);
if (isset($_POST['antwort'])) {
// Fragen beantwortet }
$richtig = 0;
$falsch = 0; if (isset($_SESSION['bogen'])) {
$fragen_cnt = count($_SESSION['bogen']['Fragen']); if (isset($_POST['antwort'])) {
$zeit = time()-$_SESSION['bogen']['StartTime']; // Fragen beantwortet
$richtig = 0;
for ($i = 0; $i < $fragen_cnt; $i++) { $falsch = 0;
$id = $_SESSION['bogen']['Fragen'][$i]; $fragen_cnt = count($_SESSION['bogen']['Fragen']);
$solutionBitmask = getSingleResult('SELECT `Loesung` FROM `fragen` WHERE `ID` = ?', $zeit = time() - $_SESSION['bogen']['StartTime'];
array('i', $id));
for ($i = 0; $i < $fragen_cnt; $i++) {
$loesung = array( 1 => ( $solutionBitmask & 0x1), $id = $_SESSION['bogen']['Fragen'][$i];
2 => (($solutionBitmask & 0x2) >> 1), $solutionBitmask = getSingleResult('SELECT `Loesung` FROM `fragen` WHERE `ID` = ?',
3 => (($solutionBitmask & 0x4) >> 2)); array('i', $id));
if (isset($_POST['antwort'][$id])) { $loesung = array(1 => ($solutionBitmask & 0x1),
$korrekt = (($loesung[1] == (isset($_POST['antwort'][$id][1]) ? $_POST['antwort'][$id][1] : 0)) 2 => (($solutionBitmask & 0x2) >> 1),
&& ($loesung[2] == (isset($_POST['antwort'][$id][2]) ? $_POST['antwort'][$id][2] : 0)) 3 => (($solutionBitmask & 0x4) >> 2));
&& ($loesung[3] == (isset($_POST['antwort'][$id][3]) ? $_POST['antwort'][$id][3] : 0)));
} else{ if (isset($_POST['antwort'][$id])) {
$korrekt = false; $korrekt = (($loesung[1] == (isset($_POST['antwort'][$id][1]) ? $_POST['antwort'][$id][1] : 0))
} && ($loesung[2] == (isset($_POST['antwort'][$id][2]) ? $_POST['antwort'][$id][2] : 0))
&& ($loesung[3] == (isset($_POST['antwort'][$id][3]) ? $_POST['antwort'][$id][3] : 0)));
if ($korrekt) { } else {
$_SESSION["stats"]['Fragen_Richtig']++; $korrekt = false;
$richtig++; }
} else {
$_SESSION["stats"]['Fragen_Falsch']++; if ($korrekt) {
$falsch++; $_SESSION["stats"]['Fragen_Richtig']++;
} $richtig++;
$_SESSION["stats"]['Fragen_Bisher']++; } else {
} $_SESSION["stats"]['Fragen_Falsch']++;
$falsch++;
$_SESSION["stats"]['Boegen_Bisher']++; }
$_SESSION["stats"]['Fragen_Bisher']++;
if (($richtig / $fragen_cnt) >= 0.8) }
$_SESSION["stats"]['Boegen_Bestanden']++;
else $_SESSION["stats"]['Boegen_Bisher']++;
$_SESSION["stats"]['Boegen_Durchgefallen']++;
if (($richtig / $fragen_cnt) >= 0.8)
$GLOBALS['db']->query('UPDATE statistik SET fragen=fragen+' . $fragen_cnt $_SESSION["stats"]['Boegen_Bestanden']++;
.',richtig=richtig+' . $richtig else
.',falsch=falsch+' . $falsch $_SESSION["stats"]['Boegen_Durchgefallen']++;
.',boegen=boegen+1'
.',bestanden=bestanden+' . (($richtig / $fragen_cnt) >= 0.8?1:0) $GLOBALS['db']->query('UPDATE statistik SET fragen=fragen+' . $fragen_cnt
.',durchgefallen=durchgefallen+' . (($richtig / $fragen_cnt) < 0.8?1:0)); . ',richtig=richtig+' . $richtig
. ',falsch=falsch+' . $falsch
$tpl->addTemplates('content', 'bogen-ende'); . ',boegen=boegen+1'
. ',bestanden=bestanden+' . (($richtig / $fragen_cnt) >= 0.8 ? 1 : 0)
$tpl->addVars(Array( . ',durchgefallen=durchgefallen+' . (($richtig / $fragen_cnt) < 0.8 ? 1 : 0));
'anzFragen' => count($_SESSION['bogen']['Fragen']),
'zeit' => sprintf('%02d:%02d\'%02d', $zeit / 3600, ($zeit/60)%60, $zeit%60), $GLOBALS['tpl']->addTemplates('content', 'bogen-ende');
'fragenRichtig' => $richtig,
'fragenRichtigQuote' => sprintf('%.2f %%', $richtig / $fragen_cnt * 100), $GLOBALS['tpl']->addVars(array(
'fragenFalsch' => $falsch, 'anzFragen' => count($_SESSION['bogen']['Fragen']),
'fragenFalschQuote' => sprintf('%.2f %%', $falsch / $fragen_cnt * 100) 'zeit' => sprintf('%02d:%02d\'%02d', $zeit / 3600, ($zeit / 60) % 60, $zeit % 60),
)); 'fragenRichtig' => $richtig,
'fragenRichtigQuote' => sprintf('%.2f %%', $richtig / $fragen_cnt * 100),
if (($richtig / $fragen_cnt) >= 0.8) 'fragenFalsch' => $falsch,
$tpl->parseBlock('content', 'Bestanden', 'Ja'); 'fragenFalschQuote' => sprintf('%.2f %%', $falsch / $fragen_cnt * 100)
else ));
$tpl->parseBlock('content', 'Bestanden', 'Nein');
if (($richtig / $fragen_cnt) >= 0.8) {
for ($i=0; $i<count($_SESSION['bogen']['Fragen']); $i++) { $GLOBALS['tpl']->parseBlock('content', 'Bestanden', 'Ja');
if ($i>0 && $i%10==0) { }
// 'Nach oben'-Zeile an Handle anhängen else {
$tpl->parseBlock('content', 'Aufloesung', 'Topline', TRUE); $GLOBALS['tpl']->parseBlock('content', 'Bestanden', 'Nein');
} }
Answer($_SESSION['bogen']['Fragen'][$i], $_POST['antwort'], FALSE);
$tpl->parseBlock('content', 'Aufloesung', 'Antwort', TRUE, TRUE); for ($i = 0; $i < count($_SESSION['bogen']['Fragen']); $i++) {
} if ($i > 0 && $i % 10 == 0) {
// 'Nach oben'-Zeile an Handle anhängen
unset($_SESSION['bogen']); $GLOBALS['tpl']->parseBlock('content', 'Aufloesung', 'Topline', TRUE);
} }
else { Answer($_SESSION['bogen']['Fragen'][$i], $_POST['antwort'], FALSE);
// Fragen anzeigen $GLOBALS['tpl']->parseBlock('content', 'Aufloesung', 'Antwort', TRUE, TRUE);
$tpl->addTemplates(Array( }
'content' => 'bogen-fragen'
)); unset($_SESSION['bogen']);
} else {
$tpl->addVars(Array( // Fragen anzeigen
'zeit' => date('G:i', $_SESSION['bogen']['StartTime']) $GLOBALS['tpl']->addTemplates(array(
)); 'content' => 'bogen-fragen'
));
for ($i=0; $i<count($_SESSION['bogen']['Fragen']); $i++) {
if ($i>0 && $i%10==0) { $GLOBALS['tpl']->addVars(array(
$tpl->parseBlock('content', 'Bogen', 'Topline', TRUE); 'zeit' => date('G:i', $_SESSION['bogen']['StartTime'])
} ));
// Frage aus DB holen for ($i = 0; $i < count($_SESSION['bogen']['Fragen']); $i++) {
$question = getQuestionById($_SESSION['bogen']['Fragen'][$i]); if ($i > 0 && $i % 10 == 0) {
$GLOBALS['tpl']->parseBlock('content', 'Bogen', 'Topline', TRUE);
$tpl->addVars(Array( }
'frageIndex' => $i + 1,
'frageID' => $question['ID'], // Frage aus DB holen
'frageNr' => $question['Nr'], $question = getQuestionById($_SESSION['bogen']['Fragen'][$i]);
'abschnittNr' => $question['Abschnitt'],
'frageText' => $question['Frage'], $GLOBALS['tpl']->addVars(array(
'Antwort1' => $question['Antwort1'], 'frageIndex' => $i + 1,
'Antwort2' => $question['Antwort2'], 'frageID' => $question['ID'],
'Antwort3' => $question['Antwort3'] 'frageNr' => $question['Nr'],
)); 'abschnittNr' => $question['Abschnitt'],
'frageText' => $question['Frage'],
if ($question['Antwort3'] == '') { 'Antwort1' => $question['Antwort1'],
$tpl->addVars('rowCnt', '2'); 'Antwort2' => $question['Antwort2'],
$tpl->delBlockHandle('content', 'ThreeRows'); 'Antwort3' => $question['Antwort3']
} ));
else {
$tpl->addVars('rowCnt', '3'); if ($question['Antwort3'] == '') {
$tpl->parseBlock('content', 'ThreeRows', 'Row'); $GLOBALS['tpl']->addVars('rowCnt', '2');
} $GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
} else {
$tpl->parseBlock('content', 'Bogen', 'Frage', TRUE, TRUE); $GLOBALS['tpl']->addVars('rowCnt', '3');
} $GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row');
}
}
} $GLOBALS['tpl']->parseBlock('content', 'Bogen', 'Frage', TRUE, TRUE);
else { }
$tpl->addVars('navBogenNeu', 'current');
$tpl->addTemplates(Array('content' => 'bogen-start')); }
} } else {
$GLOBALS['tpl']->addVars('navBogenNeu', 'current');
$GLOBALS['tpl']->addTemplates(array('content' => 'bogen-start'));
}

View File

@ -1,32 +1,32 @@
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included "THW Thema" templates, logos and the Q&A catalog are protected * The included "THW Thema" templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
.korrekt { padding-left: 22px; background-image: url(img/richtig.gif); background-position: left center; background-repeat: no-repeat; color: #00A000; } .korrekt { padding-left: 22px; background-image: url(img/richtig.gif); background-position: left center; background-repeat: no-repeat; color: #00A000; }
.falsch { padding-left: 22px; background-image: url(img/falsch.gif); background-position: left center; background-repeat: no-repeat; color: #400000; } .falsch { padding-left: 22px; background-image: url(img/falsch.gif); background-position: left center; background-repeat: no-repeat; color: #400000; }
.fragebkg tr td.korrekt { background-color: white; color: #00A000;} .fragebkg tr td.korrekt { background-color: white; color: #00A000;}
.fragebkg tr td.falsch { background-color: white; color: #400000; } .fragebkg tr td.falsch { background-color: white; color: #400000; }

View File

@ -1,8 +1,8 @@
User-agent: * User-agent: *
Disallow: Disallow:
User-agent: WebReaper User-agent: WebReaper
Disallow: / Disallow: /
User-agent: Slurp User-agent: Slurp
Crawl-delay: 180 Crawl-delay: 180

View File

@ -1,124 +1,124 @@
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included "THW Thema" templates, logos and the Q&A catalog are protected * The included "THW Thema" templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
html, body { height: 100%; } html, body { height: 100%; }
body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; margin: 0px; padding: 0px;background-color: white; color: black; background-image:url(img/bg.gif); background-color: transparent; background-position: top left; background-repeat: repeat-y; display: block; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 100%; margin: 0px; padding: 0px;background-color: white; color: black; background-image:url(img/bg.gif); background-color: transparent; background-position: top left; background-repeat: repeat-y; display: block; }
img { border: none; } img { border: none; }
acronym { border-bottom: 1px dashed #00F; cursor: help; } acronym { border-bottom: 1px dashed #00F; cursor: help; }
.contentspalte a { text-decoration:underline; color:#000000;} .contentspalte a { text-decoration:underline; color:#000000;}
.contentspalte a:hover { text-decoration:underline; color:#3A428C;} .contentspalte a:hover { text-decoration:underline; color:#3A428C;}
.korrekt { background-color: transparent; color: #008000; } .korrekt { background-color: transparent; color: #008000; }
.falsch { background-color: transparent; color: #800000; } .falsch { background-color: transparent; color: #800000; }
.fragebkg { background-color: #A0A0A0; color: white; max-width: 1000px; width:100%; margin-bottom: 1em; margin-top: 1em; } .fragebkg { background-color: #A0A0A0; color: white; max-width: 1000px; width:100%; margin-bottom: 1em; margin-top: 1em; }
.fragebkg tr td { background-color: white; color: black; } .fragebkg tr td { background-color: white; color: black; }
.fragebkg tr td.korrekt { background-color: white; color: #008000;} .fragebkg tr td.korrekt { background-color: white; color: #008000;}
.fragebkg tr td.falsch { background-color: white; color: #800000; } .fragebkg tr td.falsch { background-color: white; color: #800000; }
.nav { font-size: 70%; margin-bottom: 40px; line-height: 1.4em; } .nav { font-size: 70%; margin-bottom: 40px; line-height: 1.4em; }
.nav ul { margin: 0px; padding: 0px; list-style-type: none; } .nav ul { margin: 0px; padding: 0px; list-style-type: none; }
.nav li { margin: 0px; padding: 0px; } .nav li { margin: 0px; padding: 0px; }
.nav a { text-decoration: none; color: #fff; display: block; } .nav a { text-decoration: none; color: #fff; display: block; }
.nav a:hover { text-decoration: none; color: #fff; background-image: url('img/pfeil.gif'); background-repeat: no-repeat; background-position: top left; } .nav a:hover { text-decoration: none; color: #fff; background-image: url('img/pfeil.gif'); background-repeat: no-repeat; background-position: top left; }
.nav ul a { background-color: #003399; border-bottom: 1px solid #001689; border-top: 1px solid #1443A1; width: 172px; padding: 4px 4px 4px 20px; } .nav ul a { background-color: #003399; border-bottom: 1px solid #001689; border-top: 1px solid #1443A1; width: 172px; padding: 4px 4px 4px 20px; }
.nav ul ul a { background-color: #436EB2; border-bottom: 1px solid #001689; border-top: 1px solid #6288BE; width: 164px; padding: 4px 4px 4px 28px; } .nav ul ul a { background-color: #436EB2; border-bottom: 1px solid #001689; border-top: 1px solid #6288BE; width: 164px; padding: 4px 4px 4px 28px; }
.nav ul ul ul a { background-color: #6288BE; border-bottom: 1px solid #001689; border-top: 1px solid #85A4CC; width: 156px; padding: 4px 4px 4px 36px; } .nav ul ul ul a { background-color: #6288BE; border-bottom: 1px solid #001689; border-top: 1px solid #85A4CC; width: 156px; padding: 4px 4px 4px 36px; }
ul#navlist li a#current { background-image: url('img/pfeil.gif'); background-repeat: no-repeat; background-position: top left; } ul#navlist li a#current { background-image: url('img/pfeil.gif'); background-repeat: no-repeat; background-position: top left; }
#service { font-size:70%; color:#000000; padding-right:12px; width:100%; height:20px; text-align:right;} #service { font-size:70%; color:#000000; padding-right:12px; width:100%; height:20px; text-align:right;}
#service a { text-decoration:none; color:#000000; } #service a { text-decoration:none; color:#000000; }
#service a:hover { text-decoration:underline; color:#000000; } #service a:hover { text-decoration:underline; color:#000000; }
#breadcrumb { font-size:69%; color:#FFFFFF; background-color:#003399; padding-top:3px; padding-bottom:2px; padding-left:20px; } #breadcrumb { font-size:69%; color:#FFFFFF; background-color:#003399; padding-top:3px; padding-bottom:2px; padding-left:20px; }
#breadcrumb a { text-decoration:none; color:#FFFFFF; } #breadcrumb a { text-decoration:none; color:#FFFFFF; }
#breadcrumb a:hover { text-decoration:underline; } #breadcrumb a:hover { text-decoration:underline; }
table.layout { width:100%; } table.layout { width:100%; }
table.layout td.randlinks { width:12px; height:20px; } table.layout td.randlinks { width:12px; height:20px; }
table.layout td.navspalte { background-color:#FFFFFF; width:196px; height:20px; } table.layout td.navspalte { background-color:#FFFFFF; width:196px; height:20px; }
table.layout td.navvor { border-bottom:solid 1px #001272; height:20px; } table.layout td.navvor { border-bottom:solid 1px #001272; height:20px; }
table.identitaet { width:100%; } table.identitaet { width:100%; }
table.identitaet td.thema { border-bottom:solid 1px #6288BE; width:360px; height:78px; } table.identitaet td.thema { border-bottom:solid 1px #6288BE; width:360px; height:78px; }
table.identitaet td.logo { background-color:#003399; border-bottom:solid 1px #6288BE; width:100%; height:78px; text-align:right; } table.identitaet td.logo { background-color:#003399; border-bottom:solid 1px #6288BE; width:100%; height:78px; text-align:right; }
.content { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:80%; padding-top:20px; padding-right:12px; padding-left:20px; width:100%; } .content { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:80%; padding-top:20px; padding-right:12px; padding-left:20px; width:100%; }
.contentspalte { padding-right:20px; padding-bottom:20px; width:100%; } .contentspalte { padding-right:20px; padding-bottom:20px; width:100%; }
.contentspalte .rubrik { font-weight:normal; font-size:80%; color:#003399; border-top:solid 1px #003399; margin-bottom:2px; text-align:right; } .contentspalte .rubrik { font-weight:normal; font-size:80%; color:#003399; border-top:solid 1px #003399; margin-bottom:2px; text-align:right; }
.contentspalte h1 { font-style:normal; font-size:125%; color:#000000; margin-top:0px; margin-bottom:13px; } .contentspalte h1 { font-style:normal; font-size:125%; color:#000000; margin-top:0px; margin-bottom:13px; }
.contentspalte h2 { font-size:100%; color:#000000; margin-top:16px; margin-bottom:14px; font-weight: bold; } .contentspalte h2 { font-size:100%; color:#000000; margin-top:16px; margin-bottom:14px; font-weight: bold; }
.contentspalte h3 { font-style:normal; font-size:125%; color:#000000; margin-top:0px; margin-bottom:16px; } .contentspalte h3 { font-style:normal; font-size:125%; color:#000000; margin-top:0px; margin-bottom:16px; }
.contentspalte p { margin-top:0px; margin-bottom:14px; padding-top:0px; line-height: 1.4em; } .contentspalte p { margin-top:0px; margin-bottom:14px; padding-top:0px; line-height: 1.4em; }
.contentspalte .textblau { color:#003399; } .contentspalte .textblau { color:#003399; }
.contentspalte .seitenueberschrift { font-weight:bold; font-size:125%; color:#000000; border-bottom:solid 1px #003399; margin-bottom:11px; padding-bottom:2px; text-align:left; } .contentspalte .seitenueberschrift { font-weight:bold; font-size:125%; color:#000000; border-bottom:solid 1px #003399; margin-bottom:11px; padding-bottom:2px; text-align:left; }
.contentspalte .caption { padding-top: 0px; padding-bottom: 8px;} .contentspalte .caption { padding-top: 0px; padding-bottom: 8px;}
.contentspalte .autor { margin-left:1px; font-style: italic; } .contentspalte .autor { margin-left:1px; font-style: italic; }
.contentspalte .topspacer4px { margin-top:15px; } .contentspalte .topspacer4px { margin-top:15px; }
.contentspalte ul { margin-top:0px; margin-bottom:13px; margin-left:24px; padding-top:0px; padding-bottom:0px; } .contentspalte ul { margin-top:0px; margin-bottom:13px; margin-left:24px; padding-top:0px; padding-bottom:0px; }
.contentspalte ul li { margin: 0; padding: 0px 0px 0px 6px;} .contentspalte ul li { margin: 0; padding: 0px 0px 0px 6px;}
.contentspalte ol { margin-top:0px; margin-bottom:13px; margin-left:30px; padding-top:0px; padding-bottom:0px; } .contentspalte ol { margin-top:0px; margin-bottom:13px; margin-left:30px; padding-top:0px; padding-bottom:0px; }
.contentspalte ol li { margin: 0; padding: 0;} .contentspalte ol li { margin: 0; padding: 0;}
.contentspalte ul.seitenanfang { border-bottom:1px solid #003399; list-style-type: none; margin: 24px 0px 16px 0px; padding: .5em 0 .5em 0px; clear: both;} .contentspalte ul.seitenanfang { border-bottom:1px solid #003399; list-style-type: none; margin: 24px 0px 16px 0px; padding: .5em 0 .5em 0px; clear: both;}
.contentspalte ul.seitenanfang li a { text-decoration:none; text-align:center; display: block; margin: 0; padding: 0;} .contentspalte ul.seitenanfang li a { text-decoration:none; text-align:center; display: block; margin: 0; padding: 0;}
.contentspalte ul.seitenanfang .left { float: left; padding:0;} .contentspalte ul.seitenanfang .left { float: left; padding:0;}
.contentspalte ul.seitenanfang .right { float: right;} .contentspalte ul.seitenanfang .right { float: right;}
.only-print { display: none } .only-print { display: none }
.fragenr { font-size: 1.5em; font-weight: bold; margin-bottom: 0.5em } .fragenr { font-size: 1.5em; font-weight: bold; margin-bottom: 0.5em }
@media print { @media print {
html, body { font-size: 80%; } html, body { font-size: 80%; }
td.randlinks, td.randlinks,
td.navspalte, td.navspalte,
.nav, .nav,
.navvor, .navvor,
table.identitaet, table.identitaet,
#breadcrumb, #breadcrumb,
#service, #service,
ul.seitenanfang, ul.seitenanfang,
input, input,
.no-print { display: none; } .no-print { display: none; }
.only-print { display: initial } .only-print { display: initial }
table.fragebkg { table.fragebkg {
page-break-inside: avoid; page-break-inside: avoid;
margin-bottom: 0.5em; margin-bottom: 0.5em;
margin-top: 0.5em; margin-top: 0.5em;
max-width: none; max-width: none;
border-collapse: collapse; border-collapse: collapse;
} }
table.fragebkg td { table.fragebkg td {
border: 1px solid black; border: 1px solid black;
} }
.korrekt, .korrekt,
.falsch, .falsch,
.fragebkg tr td.korrekt, .fragebkg tr td.korrekt,
.fragebkg tr td.falsch { color: black; } .fragebkg tr td.falsch { color: black; }
.print-checkbox { .print-checkbox {
width: 0.4cm; width: 0.4cm;
height: 0.4cm; height: 0.4cm;
border: 1px solid black; border: 1px solid black;
} }
acronym { border-bottom: none; } acronym { border-bottom: none; }
.contentspalte h1 { font-size: 2em; } .contentspalte h1 { font-size: 2em; }
} }

View File

@ -1,221 +1,218 @@
<?php <?php
/* /*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de> * Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
* *
* The included 'THW Thema' templates, logos and the Q&A catalog are protected * The included 'THW Thema' templates, logos and the Q&A catalog are protected
* by copyright laws, and must not be used without the written permission * by copyright laws, and must not be used without the written permission
* of the * of the
* *
* Bundesanstalt Technisches Hilfswerk * Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93 * Provinzialstraße 93
* D-53127 Bonn * D-53127 Bonn
* Germany * Germany
* E-Mail: redaktion@thw.de * E-Mail: redaktion@thw.de
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/* /*
* *
* Fragen in zufälliger Reihenfolge üben * Fragen in zufälliger Reihenfolge üben
* *
*/ */
$tpl->parseBlock('page-body', 'NavZufall', 'Sublinks'); $GLOBALS['tpl']->parseBlock('page-body', 'NavZufall', 'Sublinks');
$tpl->addVars('navZufall', 'current'); $GLOBALS['tpl']->addVars('navZufall', 'current');
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'neu') { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'neu') {
// Fragenkatalog löschen // Fragenkatalog löschen
unset($_SESSION['zufallsfragen']); unset($_SESSION['zufallsfragen']);
} }
if (isset($_SESSION['zufallsfragen'])) { if (isset($_SESSION['zufallsfragen'])) {
// Fragenkatalog schon vorhanden. Zu nächster unbeantworteter Frage // Fragenkatalog schon vorhanden. Zu nächster unbeantworteter Frage
// bzw. Antwort der letzten Frage springen // bzw. Antwort der letzten Frage springen.
// Wenn keine Fragen mehr im Katalog vorhanden sind, // Wenn keine Fragen mehr im Katalog vorhanden sind,
// Statistik anzeigen. // Statistik anzeigen.
if (count($_SESSION['zufallsfragen'])==0) { if (count($_SESSION['zufallsfragen']) == 0) {
// Alle Fragen beantwortet, Ergebnis zeigen // Alle Fragen beantwortet, Ergebnis zeigen
$tpl->addVars(Array( $GLOBALS['tpl']->addVars(array(
'anzFragen' => $_SESSION['fragen_cnt'], 'anzFragen' => $_SESSION['fragen_cnt'],
'fragenRichtig' => $_SESSION['zufallstats']['Richtig'], 'fragenRichtig' => $_SESSION['zufallstats']['Richtig'],
'fragenRichtigQuote' => sprintf('%.2f %%', $_SESSION['zufallstats']['Richtig'] / $_SESSION['fragen_cnt'] * 100), 'fragenRichtigQuote' => sprintf('%.2f %%', $_SESSION['zufallstats']['Richtig'] / $_SESSION['fragen_cnt'] * 100),
'fragenFalsch' => $_SESSION['zufallstats']['Falsch'], 'fragenFalsch' => $_SESSION['zufallstats']['Falsch'],
'fragenFalschQuote' => sprintf('%.2f %%', $_SESSION['zufallstats']['Falsch'] / $_SESSION['fragen_cnt'] * 100), 'fragenFalschQuote' => sprintf('%.2f %%', $_SESSION['zufallstats']['Falsch'] / $_SESSION['fragen_cnt'] * 100),
)); ));
$tpl->addTemplates('content', 'zufallsfragen-ende'); $GLOBALS['tpl']->addTemplates('content', 'zufallsfragen-ende');
if (($_SESSION['zufallstats']['Richtig'] / $_SESSION['fragen_cnt']) >= 0.8) {
if (($_SESSION['zufallstats']['Richtig'] / $_SESSION['fragen_cnt']) >= 0.8) { $GLOBALS['tpl']->parseBlock('content', 'Bestanden', 'Ja');
$tpl->parseBlock('content', 'Bestanden', 'Ja'); } else {
} else { $GLOBALS['tpl']->parseBlock('content', 'Bestanden', 'Nein');
$tpl->parseBlock('content', 'Bestanden', 'Nein'); }
}
// Sessiondaten löschen
// Sessiondaten löschen unset($_SESSION['zufallsfragen']);
unset($_SESSION['zufallsfragen']); unset($_SESSION['frage_nr']);
unset($_SESSION['frage_nr']); unset($_SESSION['fragen_cnt']);
unset($_SESSION['fragen_cnt']); unset($_SESSION['zufallstats']);
unset($_SESSION['zufallstats']); unset($_SESSION['bogen']);
unset($_SESSION['bogen']);
return;
return; }
}
if (!isset($_REQUEST['frage_id']) || $_REQUEST['frage_id'][0] <> $_SESSION['zufallsfragen'][0]) {
$GLOBALS['tpl']->addTemplates(array('content' => 'zufallsfragen-frage'));
if (!isset($_REQUEST['frage_id']) || $_REQUEST['frage_id'][0] <> $_SESSION['zufallsfragen'][0]) {
$tpl->addTemplates(Array('content' => 'zufallsfragen-frage')); // Frage stellen
SingleQuestion($_SESSION['zufallsfragen'][0], $_SESSION['frage_nr'], $_SESSION['fragen_cnt']);
// Frage stellen
SingleQuestion($_SESSION['zufallsfragen'][0], $_SESSION['frage_nr'], $_SESSION['fragen_cnt']); return;
}
return;
} $GLOBALS['tpl']->addTemplates(array('content' => 'zufallsfragen-aufloesung'));
$tpl->addTemplates(Array('content' => 'zufallsfragen-aufloesung')); // Antwort auswerten
// Antwort auswerten questionHeader($_REQUEST['frage_id'][0], $_SESSION['frage_nr'], $_SESSION['fragen_cnt']);
$korrekt = Answer($_REQUEST['frage_id'][0], $_REQUEST['antwort']);
questionHeader($_REQUEST['frage_id'][0], $_SESSION['frage_nr'], $_SESSION['fragen_cnt'], $_SESSION['jahr']);
$korrekt = Answer($_REQUEST['frage_id'][0], $_REQUEST['antwort']); // Statistik anpassen
if ($korrekt) {
// Statistik anpassen $_SESSION['zufallstats']['Richtig']++;
if ($korrekt) { $_SESSION['stats']['Fragen_Richtig']++;
$_SESSION['zufallstats']['Richtig']++; $stmt = $GLOBALS['db']->prepare('UPDATE statistik SET fragen=fragen+1,richtig=richtig+1');
$_SESSION['stats']['Fragen_Richtig']++; } else {
$stmt = $GLOBALS['db']->prepare('UPDATE statistik SET fragen=fragen+1,richtig=richtig+1'); $_SESSION['zufallstats']['Falsch']++;
$stmt->execute(); $_SESSION['stats']['Fragen_Falsch']++;
} else { $stmt = $GLOBALS['db']->prepare('UPDATE statistik SET fragen=fragen+1,falsch=falsch+1');
$_SESSION['zufallstats']['Falsch']++; }
$_SESSION['stats']['Fragen_Falsch']++; $stmt->execute();
$stmt = $GLOBALS['db']->prepare('UPDATE statistik SET fragen=fragen+1,falsch=falsch+1');
$stmt->execute(); $GLOBALS['tpl']->addVars(array(
} 'submitText' => ($_SESSION['frage_nr'] == $_SESSION['fragen_cnt']) ? 'Gesamtstatistik' : 'N&auml;chste Frage',
'aktuelleFrage' => $_SESSION['frage_nr'],
$tpl->addVars(Array( 'fragenRichtig' => $_SESSION['zufallstats']['Richtig'],
'submitText' => ($_SESSION['frage_nr']==$_SESSION['fragen_cnt'])?'Gesamtstatistik':'N&auml;chste Frage', 'fragenFalsch' => $_SESSION['zufallstats']['Falsch'],
'aktuelleFrage' => $_SESSION['frage_nr'], 'fragenQuote' => sprintf('%0.2f', $_SESSION['zufallstats']['Falsch'] / $_SESSION['frage_nr'] * 100) . '%'
'fragenRichtig' => $_SESSION['zufallstats']['Richtig'], ));
'fragenFalsch' => $_SESSION['zufallstats']['Falsch'],
'fragenQuote' => sprintf('%0.2f', $_SESSION['zufallstats']['Falsch']/$_SESSION['frage_nr']*100) . '%' // Frage entfernen
)); array_shift($_SESSION['zufallsfragen']);
// Frage entfernen $_SESSION['frage_nr']++;
array_shift($_SESSION['zufallsfragen']); $_SESSION['stats']['Fragen_Bisher']++;
$_SESSION['frage_nr']++; return;
$_SESSION['stats']['Fragen_Bisher']++; }
return; // Neuen Fragenkatalog erstellen
} if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'start') {
// Neuen Fragenkatalog erstellen $topicCount = getSingleResult('SELECT COUNT(*) AS Cnt FROM abschnitte WHERE Jahr = ?', array('i', $_SESSION['jahr']));
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'start') {
// Gewählte Abschnitte in Query einsetzen
$topicCount = getSingleResult('SELECT COUNT(*) AS Cnt FROM abschnitte WHERE Jahr = ?', $selectedTopics = array();
array('i', $_SESSION['jahr'])); for ($topic = 1; $topic <= $topicCount; $topic++) {
if (isset($_REQUEST['abschnitt'][$topic]) && $_REQUEST['abschnitt'][$topic] == '1') {
// Gewählte Abschnitte in Query einsetzen $selectedTopics[] = $topic;
$selectedTopics = array(); }
for ($topic = 1; $topic <= $topicCount; $topic++){ }
if (isset($_REQUEST['abschnitt'][$topic]) && $_REQUEST['abschnitt'][$topic] == '1') {
array_push($selectedTopics, $topic); if (count($selectedTopics) == 0) {
} // Kein Themenabschnitt gewählt
} $GLOBALS['tpl']->addTemplates(array('content' => 'zufallsfragen-error'));
if (count($selectedTopics) == 0) return;
{ }
// Kein Themenabschnitt gewählt
$tpl->addTemplates(Array('content' => 'zufallsfragen-error')); // Sessiondaten löschen
unset($_SESSION['zufallsfragen']);
return; unset($_SESSION['frage_nr']);
} unset($_SESSION['fragen_cnt']);
unset($_SESSION['zufallstats']);
// Sessiondaten löschen unset($_SESSION['bogen']);
unset($_SESSION['zufallsfragen']);
unset($_SESSION['frage_nr']); // Sessions-Variablen initialisieren
unset($_SESSION['fragen_cnt']); $_SESSION['zufallsfragen'] = array();
unset($_SESSION['zufallstats']); $_SESSION['frage_nr'] = 1;
unset($_SESSION['bogen']); $_SESSION['zufallstats'] = array('Richtig' => '0', 'Falsch' => '0');
// Sessions-Variablen initialisieren $GLOBALS['tpl']->addTemplates(array('content' => 'zufallsfragen-frage'));
$_SESSION['zufallsfragen'] = array();
$_SESSION['frage_nr'] = 1; // Fragen holen
$_SESSION['zufallstats'] = array('Richtig' => '0', 'Falsch' => '0'); $inClauseParams = implode(',', array_fill(0, count($selectedTopics), '?'));
$inClauseTypes = str_repeat('i', count($selectedTopics));
$tpl->addTemplates(Array('content' => 'zufallsfragen-frage')); $params = array_merge(array('i' . $inClauseTypes, $_SESSION['jahr']), $selectedTopics);
// Fragen holen $id = 0;
$inClauseParams = implode(',', array_fill(0, count($selectedTopics), '?'));
$inClauseTypes = str_repeat('i', count($selectedTopics)); $stmt = $GLOBALS['db']->prepare('SELECT ID FROM fragen WHERE Jahr = ? AND Abschnitt IN (' . $inClauseParams . ')');
$params = array_merge(array('i'.$inClauseTypes, $_SESSION['jahr']), $selectedTopics); callBindParamArray($stmt, $params);
$stmt->execute();
$stmt = $GLOBALS['db']->prepare('SELECT ID FROM fragen WHERE Jahr = ? AND Abschnitt IN (' . $inClauseParams . ')'); $stmt->bind_result($id);
callBindParamArray($stmt, $params);
$stmt->execute(); // Fragen in Array übertragen
$stmt->bind_result($id); while ($stmt->fetch()) {
$_SESSION['zufallsfragen'][] = $id;
// Fragen in Array übertragen }
while ($stmt->fetch()) { $stmt->close();
array_push($_SESSION['zufallsfragen'], $id);
} // Fragen zufällig mischen
$stmt->close(); shuffle($_SESSION['zufallsfragen']);
// Fragen zufällig mischen // Nur gewählte Anzahl Fragen zulassen
shuffle($_SESSION['zufallsfragen']); if ($_REQUEST['fragen'] > 0 && $_REQUEST['fragen'] < count($_SESSION['zufallsfragen'])) {
$_SESSION['zufallsfragen'] = array_slice($_SESSION['zufallsfragen'], 0, $_REQUEST['fragen']);
// Nur gewählte Anzahl Fragen zulassen }
if ($_REQUEST['fragen'] > 0 && $_REQUEST['fragen'] < count($_SESSION['zufallsfragen'])) {
$_SESSION['zufallsfragen'] = array_slice($_SESSION['zufallsfragen'], 0, $_REQUEST['fragen']); // Anzahl in Session speichern
} $_SESSION['fragen_cnt'] = count($_SESSION['zufallsfragen']);
// Anzahl in Session speichern // Erste Frage stellen
$_SESSION['fragen_cnt'] = count($_SESSION['zufallsfragen']); SingleQuestion($_SESSION['zufallsfragen'][0], $_SESSION['frage_nr'], $_SESSION['fragen_cnt']);
// Erste Frage stellen return;
SingleQuestion($_SESSION['zufallsfragen'][0], $_SESSION['frage_nr'], $_SESSION['fragen_cnt']);
}
return;
// Startseite mit Abschnittsauswahl
} $GLOBALS['tpl']->addVars('navZufallNeu', 'current');
$abschnitte = getTopics();
// Startseite mit Abschnittsauswahl $topicCount = getSingleResult('SELECT COUNT(*) AS Cnt FROM abschnitte WHERE Jahr = ?',
$tpl->addVars('navZufallNeu', 'current'); array('i', $_SESSION['jahr']));
$abschnitte = getTopics(); $maxFragen = getSingleResult('SELECT COUNT(*) AS Cnt FROM fragen WHERE Jahr = ?',
$topicCount = getSingleResult('SELECT COUNT(*) AS Cnt FROM abschnitte WHERE Jahr = ?', array('i', $_SESSION['jahr']));
array('i', $_SESSION['jahr']));
$maxFragen = getSingleResult('SELECT COUNT(*) AS Cnt FROM fragen WHERE Jahr = ?', $GLOBALS['tpl']->addVars(array(
array('i', $_SESSION['jahr'])); 'abschnitteAnz' => $topicCount,
'maxFragen' => $maxFragen
$tpl->addVars(Array( ));
'abschnitteAnz' => $topicCount,
'maxFragen' => $maxFragen $GLOBALS['tpl']->addTemplates('content', 'zufallsfragen-start');
));
foreach ($abschnitte as $nr => $description) {
$tpl->addTemplates('content', 'zufallsfragen-start'); $GLOBALS['tpl']->addVars(array(
'abschnittNr' => $nr,
foreach ($abschnitte as $nr => $description) { 'abschnittDesc' => htmlspecialchars($description)
$tpl->addVars(Array( ));
'abschnittNr' => $nr,
'abschnittDesc' => htmlspecialchars($description) $GLOBALS['tpl']->parseBlock('content', 'Abschnitte', 'Row', TRUE);
)); }
$tpl->parseBlock('content', 'Abschnitte', 'Row', TRUE);
}