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
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstra<EFBFBD>e 93
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
@ -27,15 +27,15 @@
* along with this program; if not, write to the Free Software
* 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;
if (isset($_REQUEST['katalog'])) {
@ -44,27 +44,26 @@ if (isset($_REQUEST['katalog'])) {
$abschnitte = getTopics();
foreach ($abschnitte as $nr => $description) {
$tpl->addVars(Array(
'abschnittNr' => $nr,
'abschnittName' => htmlspecialchars($description),
'navAntwortenAbschnitt' => ($katalog == $nr) ? 'current':''
$GLOBALS['tpl']->addVars(array(
'abschnittNr' => $nr,
'abschnittName' => htmlspecialchars($description),
'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($_GET['clear']) && intval($_GET['clear']) == '1') {
if (isset($_GET['clear']) && intval($_GET['clear']) == '1') {
unset($_SESSION['bogen']);
unset($_SESSION['zufallsfragen']);
unset($_SESSION['frage_nr']);
unset($_SESSION['fragen_cnt']);
unset($_SESSION['zufallstats']);
unset($_SESSION['bogen']);
}
else {
$tpl->addTemplates(Array('content' => 'aufloesung-error'));
return;
} else {
$GLOBALS['tpl']->addTemplates(array('content' => 'aufloesung-error'));
return;
}
}
@ -78,20 +77,20 @@ if ($katalog > 0) {
$stmt->bind_result($selectedNr, $selectedDescription);
$stmt->fetch();
addBreadcrumb($_REQUEST['show'].'&katalog=' . $selectedNr, $selectedDescription);
addBreadcrumb($_REQUEST['show'] . '&katalog=' . $selectedNr, $selectedDescription);
$tpl->addTemplates(Array(
'content' => 'aufloesung-antworten'
$GLOBALS['tpl']->addTemplates(array(
'content' => 'aufloesung-antworten'
));
$tpl->addVars(Array(
'abschnittNr' => $selectedNr,
'abschnittName' => htmlspecialchars($selectedDescription)
$GLOBALS['tpl']->addVars(array(
'abschnittNr' => $selectedNr,
'abschnittName' => htmlspecialchars($selectedDescription)
));
$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->execute();
$questions = $stmt->get_result();
@ -99,33 +98,35 @@ if ($katalog > 0) {
$I = 1;
while ($question = $questions->fetch_array(MYSQLI_ASSOC)) {
ShowAnswer($question);
$tpl->parseBlock('content', 'Antworten', 'Row', TRUE, TRUE);
if ($I%10==0) {
$tpl->parseBlock('content', 'Antworten', 'Topline', TRUE);
ShowAnswer($question);
$GLOBALS['tpl']->parseBlock('content', 'Antworten', 'Row', TRUE, TRUE);
if ($I % 10 == 0) {
$GLOBALS['tpl']->parseBlock('content', 'Antworten', 'Topline', TRUE);
}
$I++;
$I++;
}
$questions->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->execute();
$stmt->bind_result($nr, $description);
while ($stmt->fetch()) {
$tpl->addVars(Array(
'abschnittNr' => $nr,
'abschnittName' => $description
$GLOBALS['tpl']->addVars(array(
'abschnittNr' => $nr,
'abschnittName' => $description
));
$tpl->parseBlock('content', 'Abschnitte', 'Row', TRUE);
$GLOBALS['tpl']->parseBlock('content', 'Abschnitte', 'Row', TRUE);
}
}
?>

View File

@ -1,15 +1,12 @@
<?php
if (isset($_POST['normal'])) {
setcookie("stylesheet", "normal", time()+60*60*24*365);
$tpl->addVars('extraStyleSheet', '');
}
if (isset($_POST['barrierefrei'])) {
setcookie("stylesheet", "barrierefrei", time()+60*60*24*365);
}
$tpl->addTemplates(Array("content" => "barrierefreiheit"));
?>
<?php
if (isset($_POST['normal'])) {
setcookie("stylesheet", "normal", time()+60*60*24*365);
$GLOBALS['tpl']->addVars('extraStyleSheet', '');
}
if (isset($_POST['barrierefrei'])) {
setcookie("stylesheet", "barrierefrei", time()+60*60*24*365);
}
$GLOBALS['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
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$GLOBALS['db'] = new mysqli("localhost", "DBUSER", "DBPASSWD", "DBDATABASE");
if ($GLOBALS['db']->connect_error) {
header("HTTP/1.0 500 Internal Server Error");
readfile('templates/db-error.html');
die();
}
function callBindParamArray($stmt, $bindArguments = null) {
if ($bindArguments === null) {
return;
}
$args = array();
foreach($bindArguments as $k => &$arg){
$args[$k] = &$arg;
}
call_user_func_array(array($stmt, "bind_param"), $args);
}
function getSingleResult($query, $bindArguments = null) {
$stmt = $GLOBALS['db']->prepare($query);
callBindParamArray($stmt, $bindArguments);
$stmt->execute();
$stmt->bind_result($retVal);
$stmt->fetch();
$stmt->close();
return $retVal;
}
<?php
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
$GLOBALS['db'] = new mysqli("localhost", "DBUSER", "DBPASSWD", "DBDATABASE");
if ($GLOBALS['db']->connect_error) {
header("HTTP/1.0 500 Internal Server Error");
readfile('templates/db-error.html');
die();
}
function callBindParamArray($stmt, $bindArguments = null) {
if ($bindArguments === null) {
return;
}
$args = array();
foreach($bindArguments as $k => &$arg){
$args[$k] = &$arg;
}
call_user_func_array(array($stmt, "bind_param"), $args);
}
function getSingleResult($query, $bindArguments = null) {
$retVal = '';
$stmt = $GLOBALS['db']->prepare($query);
callBindParamArray($stmt, $bindArguments);
$stmt->execute();
$stmt->bind_result($retVal);
$stmt->fetch();
$stmt->close();
return $retVal;
}

View File

@ -1,284 +1,293 @@
<?php
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Holt eine Einzelne Frage aus der DB
*
* @param $id Die Frage-ID
*
* @return array Die Frage
*/
function getQuestionById($id) {
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?');
$stmt->bind_param('i', $id);
$stmt->execute();
$result = $stmt->get_result();
$question = $result->fetch_array(MYSQLI_ASSOC);
return $question;
}
/**
* Holt eine Liste aller Abschnitte im aktuellen Jahr
*
* @return array
*/
function getTopics() {
$stmt = $GLOBALS['db']->prepare('SELECT `Nr`,`Beschreibung` FROM `abschnitte` WHERE `Jahr` = ? ORDER BY `Nr` ASC');
$stmt->bind_param('i', $_SESSION['jahr']);
$stmt->execute();
$stmt->bind_result($nr, $description);
$topics = array();
while ($stmt->fetch()) {
$topics[$nr] = $description;
}
$stmt->close();
return $topics;
}
/******************************************************************************
*
* Kopfzeile mit Informationen über Fragennummer und Lernabschnitt
*
/******************************************************************************/
function questionHeader($id, $nr, $questionCount)
{
$section = getSingleResult('SELECT Abschnitt FROM fragen WHERE ID=? AND Jahr=?',
array('ii', $id, $_SESSION['jahr']));
$sectionName = getSingleResult('SELECT Beschreibung FROM abschnitte WHERE Nr=? AND Jahr=?',
array('ii', $section, $_SESSION['jahr']));
$GLOBALS['tpl']->addVars(Array(
'aktuelleFrage' => $nr,
'fragenCnt' => $questionCount,
'abschnittNr' => $section,
'abschnitt' => $sectionName
));
$GLOBALS['tpl']->parseBlock('content', 'Kopf', 'Content');
}
/******************************************************************************
*
* Eine einzelne Frage mit Kopfzeile ausgeben
*
/******************************************************************************/
function SingleQuestion($id, $Nr, $questionCount)
{
questionHeader($id, $Nr, $questionCount);
showQuestion($id);
}
/******************************************************************************
*
* Fragengenerator
* Erzeugt eine Tabelle mit Frage, Antworten und Formularinformationen
* zur übergebenen Fragen-ID
*
/******************************************************************************/
function showQuestion($id)
{
// Frage aus DB holen
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?');
$stmt->bind_param('i', $id);
$stmt->execute();
$result = $stmt->get_result();
$question = $result->fetch_array(MYSQLI_ASSOC);
$GLOBALS['tpl']->addVars(Array(
'frageID' => $id,
'frageNr' => $question['Nr'],
'abschnittNr' => $question['Abschnitt'],
'frageText' => $question['Frage'],
'Antwort1' => $question['Antwort1'],
'Antwort2' => $question['Antwort2'],
'Antwort3' => $question['Antwort3']
));
if ($question['Antwort3'] == '') {
$GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
}
else {
$GLOBALS['tpl']->addVars('rowCnt', '3');
$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)
*
/******************************************************************************/
function Answer($id, $answer, $showStatus = TRUE)
{
// Frage aus DB holen
$question = getQuestionById($id);
// Einzelne Antworten aus Flag in Array splitten
$solution = array( 1 => ( $question['Loesung'] & 0x1),
2 => (($question['Loesung'] & 0x2) >> 1),
3 => (($question['Loesung'] & 0x4) >> 2));
$correct = (($solution[1] == (isset($answer[$id][1]) ? $answer[$id][1] : 0))
&& ($solution[2] == (isset($answer[$id][2]) ? $answer[$id][2] : 0))
&& ($solution[3] == (isset($answer[$id][3]) ? $answer[$id][3] : 0)));
// Aufräumen
$GLOBALS['tpl']->delHandle('antwortStatus');
$GLOBALS['tpl']->delHandle('antwort1Loesung');
$GLOBALS['tpl']->delHandle('antwort2Loesung');
$GLOBALS['tpl']->delHandle('antwort3Loesung');
$GLOBALS['tpl']->delBlockHandle('content', 'A1L');
$GLOBALS['tpl']->delBlockHandle('content', 'A2L');
$GLOBALS['tpl']->delBlockHandle('content', 'A3L');
if ($showStatus) {
if ($correct)
$GLOBALS['tpl']->parseBlock('content', 'Status', 'Richtig');
else
$GLOBALS['tpl']->parseBlock('content', 'Status', 'Falsch');
} else {
if ($correct)
$GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Richtig');
else
$GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Falsch');
}
$GLOBALS['tpl']->addVars(Array(
'abschnittNr' => $question['Abschnitt'],
'frageNr' => $question['Nr'],
'frageText' => $question['Frage'],
'antwort1Status' => $solution[1] ? 'korrekt' : 'falsch',
'antwort2Status' => $solution[2] ? 'korrekt' : 'falsch',
'antwort3Status' => $solution[3] ? 'korrekt' : 'falsch',
'Antwort1' => $question['Antwort1'],
'Antwort2' => $question['Antwort2'],
'Antwort3' => $question['Antwort3']
));
if ($question['Antwort3'] == '') {
$GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
}
else {
$GLOBALS['tpl']->addVars('rowCnt', '3');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row');
}
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');
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);
return $correct;
}
/******************************************************************************
*
* Antwort
* Zeigt die Frage und die zugehörigen korrekten Antworten an
* Antworten sind farblich gekennzeichnet (grün=richtig, rot=falsch)
*
/******************************************************************************/
function addBreadcrumb($params, $title)
{
$GLOBALS['tpl']->addVars(Array(
'page' => htmlspecialchars($params),
'pageTitle' => htmlspecialchars($title)
));
$GLOBALS['tpl']->parseBlock('page-body', 'Breadcrumb', 'Link', TRUE);
}
function ShowAnswer(&$frage)
{
// Einzelne Antworten aus Flag in Array splitten
$loesung = array( 1 => ( $frage['Loesung'] & 0x1),
2 => (($frage['Loesung'] & 0x2) >> 1),
3 => (($frage['Loesung'] & 0x4) >> 2));
// Aufräumen
$GLOBALS['tpl']->delHandle('antwortStatus');
$GLOBALS['tpl']->delHandle('antwort1Loesung');
$GLOBALS['tpl']->delHandle('antwort2Loesung');
$GLOBALS['tpl']->delHandle('antwort3Loesung');
$GLOBALS['tpl']->addVars(Array(
'abschnittNr' => $frage['Abschnitt'],
'frageNr' => $frage['Nr'],
'frageText' => $frage['Frage'],
'antwort1Status' => $loesung[1]?'korrekt':'falsch',
'antwort2Status' => $loesung[2]?'korrekt':'falsch',
'antwort3Status' => $loesung[3]?'korrekt':'falsch',
'Antwort1' => $frage['Antwort1'],
'Antwort2' => $frage['Antwort2'],
'Antwort3' => $frage['Antwort3']
));
$GLOBALS['tpl']->delBlockHandle('content', 'A1L');
$GLOBALS['tpl']->delBlockHandle('content', 'A2L');
$GLOBALS['tpl']->delBlockHandle('content', 'A3L');
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');
}
}
?>
<?php
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Holt eine einzelne Frage aus der Datenbank.
* @param int $id Die Frage-ID
* @return array Die Fragen-Inhalte als assoziatives Array.
*/
function getQuestionById(int $id): array
{
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?');
$stmt->bind_param('i', $id);
$stmt->execute();
$result = $stmt->get_result();
$question = $result->fetch_array(MYSQLI_ASSOC);
return $question;
}
/**
* Holt eine Liste aller Abschnitte im aktuellen Jahr
* @return array Liste der Themenbereiche.
*/
function getTopics(): array
{
$nr = 0;
$description = '';
$stmt = $GLOBALS['db']->prepare('SELECT `Nr`,`Beschreibung` FROM `abschnitte` WHERE `Jahr` = ? ORDER BY `Nr`');
$stmt->bind_param('i', $_SESSION['jahr']);
$stmt->execute();
$stmt->bind_result($nr, $description);
$topics = array();
while ($stmt->fetch()) {
$topics[$nr] = $description;
}
$stmt->close();
return $topics;
}
/**
* Kopfzeile mit Informationen über Fragen-Nummer und Lernabschnitt.
* @param int $id Frage-ID
* @param int $nr Frage-Nummer
* @param int $questionCount Anzahl Fragen
* @return void
*/
function questionHeader(int $id, int $nr, int $questionCount): void
{
$section = getSingleResult('SELECT Abschnitt FROM fragen WHERE ID=? AND Jahr=?',
array('ii', $id, $_SESSION['jahr']));
$sectionName = getSingleResult('SELECT Beschreibung FROM abschnitte WHERE Nr=? AND Jahr=?',
array('ii', $section, $_SESSION['jahr']));
$GLOBALS['tpl']->addVars(Array(
'aktuelleFrage' => $nr,
'fragenCnt' => $questionCount,
'abschnittNr' => $section,
'abschnitt' => $sectionName
));
$GLOBALS['tpl']->parseBlock('content', 'Kopf', 'Content');
}
/**
* Eine einzelne Frage mit Kopfzeile ausgeben.
* @param int $id Frage-ID
* @param int $nr Frage-Nummer
* @param int $questionCount Anzahl Fragen
* @return void
*/
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
* @param int $id Fragen-ID
* @return void
*/
function showQuestion(int $id): void
{
// Frage aus DB holen
$stmt = $GLOBALS['db']->prepare('SELECT * FROM fragen WHERE ID=?');
$stmt->bind_param('i', $id);
$stmt->execute();
$result = $stmt->get_result();
$question = $result->fetch_array(MYSQLI_ASSOC);
$GLOBALS['tpl']->addVars(Array(
'frageID' => $id,
'frageNr' => $question['Nr'],
'abschnittNr' => $question['Abschnitt'],
'frageText' => $question['Frage'],
'Antwort1' => $question['Antwort1'],
'Antwort2' => $question['Antwort2'],
'Antwort3' => $question['Antwort3']
));
if ($question['Antwort3'] == '') {
$GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
}
else {
$GLOBALS['tpl']->addVars('rowCnt', '3');
$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)
* @param int $id Frage-ID
* @param array $answer Antwort-Array
* @param bool $showStatus Status anzeigen
* @return bool true, falls korrekt beantwortet, sonst false.
*/
function Answer(int $id, array $answer, bool $showStatus = true): bool
{
// Frage aus DB holen
$question = getQuestionById($id);
// Einzelne Antworten aus Flag in Array splitten
$solution = array( 1 => ( $question['Loesung'] & 0x1),
2 => (($question['Loesung'] & 0x2) >> 1),
3 => (($question['Loesung'] & 0x4) >> 2));
$correct = (($solution[1] == (isset($answer[$id][1]) ? $answer[$id][1] : 0))
&& ($solution[2] == (isset($answer[$id][2]) ? $answer[$id][2] : 0))
&& ($solution[3] == (isset($answer[$id][3]) ? $answer[$id][3] : 0)));
// Aufräumen
$GLOBALS['tpl']->delHandle('antwortStatus');
$GLOBALS['tpl']->delHandle('antwort1Loesung');
$GLOBALS['tpl']->delHandle('antwort2Loesung');
$GLOBALS['tpl']->delHandle('antwort3Loesung');
$GLOBALS['tpl']->delBlockHandle('content', 'A1L');
$GLOBALS['tpl']->delBlockHandle('content', 'A2L');
$GLOBALS['tpl']->delBlockHandle('content', 'A3L');
if ($showStatus) {
if ($correct)
$GLOBALS['tpl']->parseBlock('content', 'Status', 'Richtig');
else
$GLOBALS['tpl']->parseBlock('content', 'Status', 'Falsch');
} else {
if ($correct)
$GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Richtig');
else
$GLOBALS['tpl']->parseBlock('content', 'BogenStatus', 'Falsch');
}
$GLOBALS['tpl']->addVars(Array(
'abschnittNr' => $question['Abschnitt'],
'frageNr' => $question['Nr'],
'frageText' => $question['Frage'],
'antwort1Status' => $solution[1] ? 'korrekt' : 'falsch',
'antwort2Status' => $solution[2] ? 'korrekt' : 'falsch',
'antwort3Status' => $solution[3] ? 'korrekt' : 'falsch',
'Antwort1' => $question['Antwort1'],
'Antwort2' => $question['Antwort2'],
'Antwort3' => $question['Antwort3']
));
if ($question['Antwort3'] == '') {
$GLOBALS['tpl']->addVars('rowCnt', '2');
$GLOBALS['tpl']->delBlockHandle('content', 'ThreeRows');
}
else {
$GLOBALS['tpl']->addVars('rowCnt', '3');
$GLOBALS['tpl']->parseBlock('content', 'ThreeRows', 'Row');
}
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');
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);
return $correct;
}
/**
* Brotkrumen-Navigation.
*
* Fügt einen Link zur Brotkrumen-Navigation hinzu.
* @param string $page Seiten-Link
* @param string $title Seiten-Titel
* @return void
*/
function addBreadcrumb(string $page, string $title): void
{
$GLOBALS['tpl']->addVars(Array(
'page' => htmlspecialchars($page),
'pageTitle' => htmlspecialchars($title)
));
$GLOBALS['tpl']->parseBlock('page-body', 'Breadcrumb', 'Link', TRUE);
}
/**
* Zeigt die Auflösung an.
* @param array $frage Referenz auf das assoziative Fragen-Array
* @return void
*/
function ShowAnswer(array &$frage): void
{
// Einzelne Antworten aus Flag in Array splitten
$loesung = array( 1 => ( $frage['Loesung'] & 0x1),
2 => (($frage['Loesung'] & 0x2) >> 1),
3 => (($frage['Loesung'] & 0x4) >> 2));
// Aufräumen
$GLOBALS['tpl']->delHandle('antwortStatus');
$GLOBALS['tpl']->delHandle('antwort1Loesung');
$GLOBALS['tpl']->delHandle('antwort2Loesung');
$GLOBALS['tpl']->delHandle('antwort3Loesung');
$GLOBALS['tpl']->addVars(Array(
'abschnittNr' => $frage['Abschnitt'],
'frageNr' => $frage['Nr'],
'frageText' => $frage['Frage'],
'antwort1Status' => $loesung[1]?'korrekt':'falsch',
'antwort2Status' => $loesung[2]?'korrekt':'falsch',
'antwort3Status' => $loesung[3]?'korrekt':'falsch',
'Antwort1' => $frage['Antwort1'],
'Antwort2' => $frage['Antwort2'],
'Antwort3' => $frage['Antwort3']
));
$GLOBALS['tpl']->delBlockHandle('content', 'A1L');
$GLOBALS['tpl']->delBlockHandle('content', 'A2L');
$GLOBALS['tpl']->delBlockHandle('content', 'A3L');
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
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* 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');
$stmt->execute();
$stmt->bind_result(
$fragen,
$richtig,
$falsch,
$boegen,
$bestanden,
$durchgefallen
);
$stmt->fetch();
$GLOBALS['tpl']->addVars(Array(
'statsFragen' => sprintf('%0.d', $fragen),
'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'
));
?>
<?php
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Holt die Gesamt-Statistiken aus der Datenbank und füllt das Template.
* @return void
*/
function getStats(): void
{
$fragen = 0;
$richtig = 0;
$falsch = 0;
$boegen = 0;
$bestanden = 0;
$durchgefallen = 0;
$stmt = $GLOBALS['db']->prepare('SELECT fragen,richtig,falsch,boegen,bestanden,durchgefallen FROM statistik');
$stmt->execute();
$stmt->bind_result(
$fragen,
$richtig,
$falsch,
$boegen,
$bestanden,
$durchgefallen
);
$stmt->fetch();
$GLOBALS['tpl']->addVars(array(
'statsFragen' => sprintf('%0.d', $fragen),
'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
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
require_once 'db.php';
require_once 'class.template.inc.php';
require_once 'functions.inc.php';
require_once 'init.inc.php';
if (!isset($_REQUEST['show'])) {
$_REQUEST['show'] = 'home';
}
switch ($_REQUEST['show']) {
case 'fragen':
addBreadcrumb($_REQUEST['show'], 'Zufallsfragen beantworten');
include ('zufallsfragen.inc.php');
break;
case 'bogen':
addBreadcrumb($_REQUEST['show'], 'Prüfungsbogen üben');
include ('pruefbogen.inc.php');
break;
case 'loesung':
addBreadcrumb($_REQUEST['show'], 'Antworten anzeigen');
include ('antworten.inc.php');
break;
case 'ordnung':
addBreadcrumb($_REQUEST['show'], 'Prüfungsordnung');
$tpl->addVars('navOrdnung', 'current');
$tpl->addTemplates(Array('content' => 'ordnung'));
break;
case 'stats':
$tpl->addVars(Array(
// Statistik Zufallsfragen
'fragenBisher' => $_SESSION['stats']['Fragen_Bisher'],
'fragenRichtig' => $_SESSION['stats']['Fragen_Richtig'],
'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')) . '%',
// Statistik Prüfungsbögen
'boegenBisher' => $_SESSION['stats']['Boegen_Bisher'],
'boegenRichtig' => $_SESSION['stats']['Boegen_Bestanden'],
'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')) . '%'
));
addBreadcrumb($_REQUEST['show'], 'Statistiken');
$tpl->addVars('navStats', 'current');
$tpl->addTemplates(Array('content' => 'stats'));
break;
case "barrierefreiheit":
addBreadcrumb($_REQUEST["show"], "Barrierefreiheit");
include "barrierefreiheit.inc.php";
break;
case 'impressum':
addBreadcrumb($_REQUEST['show'], 'Impressum');
$tpl->addTemplates(Array('content' => 'impressum'));
break;
case 'datenschutz':
addBreadcrumb($_REQUEST['show'], 'Datenschutzhinweis');
$tpl->addTemplates(Array('content' => 'datenschutz'));
break;
case "downloads":
addBreadcrumb($_REQUEST["show"], "Offline-Version");
$tpl->addVars("navOffline", "current");
$tpl->addTemplates(Array("content" => "offline"));
break;
default:
$title = '';
include('home.inc.php');
}
$tpl->parse('pageContent', 'content');
$tpl->printParse('pageMain', 'page-body');
?>
<?php
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
require_once 'db.php';
require_once 'class.template.inc.php';
require_once 'functions.inc.php';
require_once 'init.inc.php';
if (!isset($_REQUEST['show'])) {
$_REQUEST['show'] = 'home';
}
switch ($_REQUEST['show']) {
case 'fragen':
addBreadcrumb($_REQUEST['show'], 'Zufallsfragen beantworten');
include('zufallsfragen.inc.php');
break;
case 'bogen':
addBreadcrumb($_REQUEST['show'], 'Prüfungsbogen üben');
include('pruefbogen.inc.php');
break;
case 'loesung':
addBreadcrumb($_REQUEST['show'], 'Antworten anzeigen');
include('antworten.inc.php');
break;
case 'ordnung':
addBreadcrumb($_REQUEST['show'], 'Prüfungsordnung');
$GLOBALS['tpl']->addVars('navOrdnung', 'current');
$GLOBALS['tpl']->addTemplates(array('content' => 'ordnung'));
break;
case 'stats':
$GLOBALS['tpl']->addVars(array(
// Statistik Zufallsfragen
'fragenBisher' => $_SESSION['stats']['Fragen_Bisher'],
'fragenRichtig' => $_SESSION['stats']['Fragen_Richtig'],
'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')) . '%',
// Statistik Prüfungsbögen
'boegenBisher' => $_SESSION['stats']['Boegen_Bisher'],
'boegenRichtig' => $_SESSION['stats']['Boegen_Bestanden'],
'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')) . '%'
));
addBreadcrumb($_REQUEST['show'], 'Statistiken');
$GLOBALS['tpl']->addVars('navStats', 'current');
$GLOBALS['tpl']->addTemplates(array('content' => 'stats'));
break;
case "barrierefreiheit":
addBreadcrumb($_REQUEST["show"], "Barrierefreiheit");
include "barrierefreiheit.inc.php";
break;
case 'impressum':
addBreadcrumb($_REQUEST['show'], 'Impressum');
$GLOBALS['tpl']->addTemplates(array('content' => 'impressum'));
break;
case 'datenschutz':
addBreadcrumb($_REQUEST['show'], 'Datenschutzhinweis');
$GLOBALS['tpl']->addTemplates(array('content' => 'datenschutz'));
break;
case "downloads":
addBreadcrumb($_REQUEST["show"], "Offline-Version");
$GLOBALS['tpl']->addVars("navOffline", "current");
$GLOBALS['tpl']->addTemplates(array("content" => "offline"));
break;
default:
$title = '';
include('home.inc.php');
}
$GLOBALS['tpl']->parse('pageContent', 'content');
$GLOBALS['tpl']->printParse('pageMain', 'page-body');

View File

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

View File

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

View File

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

View File

@ -1,124 +1,124 @@
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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; }
img { border: none; }
acronym { border-bottom: 1px dashed #00F; cursor: help; }
.contentspalte a { text-decoration:underline; color:#000000;}
.contentspalte a:hover { text-decoration:underline; color:#3A428C;}
.korrekt { background-color: transparent; color: #008000; }
.falsch { background-color: transparent; color: #800000; }
.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.korrekt { background-color: white; color: #008000;}
.fragebkg tr td.falsch { background-color: white; color: #800000; }
.nav { font-size: 70%; margin-bottom: 40px; line-height: 1.4em; }
.nav ul { margin: 0px; padding: 0px; list-style-type: none; }
.nav li { margin: 0px; padding: 0px; }
.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 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 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; }
#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: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 a { text-decoration:none; color:#FFFFFF; }
#breadcrumb a:hover { text-decoration:underline; }
table.layout { width:100%; }
table.layout td.randlinks { width:12px; 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.identitaet { width:100%; }
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; }
.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 .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 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 p { margin-top:0px; margin-bottom:14px; padding-top:0px; line-height: 1.4em; }
.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 .caption { padding-top: 0px; padding-bottom: 8px;}
.contentspalte .autor { margin-left:1px; font-style: italic; }
.contentspalte .topspacer4px { margin-top:15px; }
.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 ol { margin-top:0px; margin-bottom:13px; margin-left:30px; padding-top:0px; padding-bottom:0px; }
.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 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 .right { float: right;}
.only-print { display: none }
.fragenr { font-size: 1.5em; font-weight: bold; margin-bottom: 0.5em }
@media print {
html, body { font-size: 80%; }
td.randlinks,
td.navspalte,
.nav,
.navvor,
table.identitaet,
#breadcrumb,
#service,
ul.seitenanfang,
input,
.no-print { display: none; }
.only-print { display: initial }
table.fragebkg {
page-break-inside: avoid;
margin-bottom: 0.5em;
margin-top: 0.5em;
max-width: none;
border-collapse: collapse;
}
table.fragebkg td {
border: 1px solid black;
}
.korrekt,
.falsch,
.fragebkg tr td.korrekt,
.fragebkg tr td.falsch { color: black; }
.print-checkbox {
width: 0.4cm;
height: 0.4cm;
border: 1px solid black;
}
acronym { border-bottom: none; }
.contentspalte h1 { font-size: 2em; }
/*
* Copyright (C) 2001 Kai Blaschke <webmaster@thw-theorie.de>
*
* 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
* of the
*
* Bundesanstalt Technisches Hilfswerk
* Provinzialstraße 93
* D-53127 Bonn
* Germany
* E-Mail: redaktion@thw.de
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
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; }
img { border: none; }
acronym { border-bottom: 1px dashed #00F; cursor: help; }
.contentspalte a { text-decoration:underline; color:#000000;}
.contentspalte a:hover { text-decoration:underline; color:#3A428C;}
.korrekt { background-color: transparent; color: #008000; }
.falsch { background-color: transparent; color: #800000; }
.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.korrekt { background-color: white; color: #008000;}
.fragebkg tr td.falsch { background-color: white; color: #800000; }
.nav { font-size: 70%; margin-bottom: 40px; line-height: 1.4em; }
.nav ul { margin: 0px; padding: 0px; list-style-type: none; }
.nav li { margin: 0px; padding: 0px; }
.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 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 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; }
#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: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 a { text-decoration:none; color:#FFFFFF; }
#breadcrumb a:hover { text-decoration:underline; }
table.layout { width:100%; }
table.layout td.randlinks { width:12px; 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.identitaet { width:100%; }
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; }
.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 .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 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 p { margin-top:0px; margin-bottom:14px; padding-top:0px; line-height: 1.4em; }
.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 .caption { padding-top: 0px; padding-bottom: 8px;}
.contentspalte .autor { margin-left:1px; font-style: italic; }
.contentspalte .topspacer4px { margin-top:15px; }
.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 ol { margin-top:0px; margin-bottom:13px; margin-left:30px; padding-top:0px; padding-bottom:0px; }
.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 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 .right { float: right;}
.only-print { display: none }
.fragenr { font-size: 1.5em; font-weight: bold; margin-bottom: 0.5em }
@media print {
html, body { font-size: 80%; }
td.randlinks,
td.navspalte,
.nav,
.navvor,
table.identitaet,
#breadcrumb,
#service,
ul.seitenanfang,
input,
.no-print { display: none; }
.only-print { display: initial }
table.fragebkg {
page-break-inside: avoid;
margin-bottom: 0.5em;
margin-top: 0.5em;
max-width: none;
border-collapse: collapse;
}
table.fragebkg td {
border: 1px solid black;
}
.korrekt,
.falsch,
.fragebkg tr td.korrekt,
.fragebkg tr td.falsch { color: black; }
.print-checkbox {
width: 0.4cm;
height: 0.4cm;
border: 1px solid black;
}
acronym { border-bottom: none; }
.contentspalte h1 { font-size: 2em; }
}

View File

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