Testtool Erweiterung

This commit is contained in:
Andreas Österreicher
2007-04-04 15:35:09 +00:00
parent 30b23bc6ac
commit dfa4e83e68
7 changed files with 965 additions and 83 deletions
+353
View File
@@ -0,0 +1,353 @@
<?php
/* Copyright (C) 2006 Technikum-Wien
*
* 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.
*
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
*/
// Formular zum beantworten der Fragen
require_once('../config.inc.php');
require_once('../../include/functions.inc.php');
require_once('../../include/frage.class.php');
require_once('../../include/vorschlag.class.php');
require_once('../../include/antwort.class.php');
session_start();
//testumgebung
//$_SESSION['pruefling_id']=1;
//Connection Herstellen
if(!$conn = pg_pconnect(CONN_STRING))
die('Fehler beim oeffnen der Datenbankverbindung');
if(isset($_GET['gebiet_id']))
$gebiet_id = $_GET['gebiet_id'];
else
die('Gebiet muss uebergeben werden');
if(isset($_GET['frage_id']))
$frage_id = $_GET['frage_id'];
else
$frage_id = '';
$MAX_VORSCHLAEGE_PRO_ZEILE=4;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../skin/cis.css" rel="stylesheet" type="text/css">
<script language="Javascript">
function count_down(zeit)
{
if(zeit<=0)
{
document.location.href='gebietfertig.php';
//alert('finish');
}
else
{
zeit = zeit-1;
minuten = parseInt((zeit/60));
if(minuten<10)
minuten = '0'+minuten;
sekunden = zeit-minuten*60;
if(sekunden<10)
sekunden = '0'+sekunden;
document.getElementById('counter').innerHTML = minuten+':'+sekunden;
window.setTimeout('count_down('+zeit+')',1000);
}
}
function checkantwort()
{
val = document.getElementById('antwort').value;
if(val.length>1)
{
alert('Antwort darf nur 1 Buchstabe sein');
return false;
}
if(val.length==0)
return true;
if(val.toUpperCase()<'A' || val.toUpperCase>'Z')
{
alert('Antwort darf nur ein Buchstabe von A-Z sein');
return false;
}
else
{
return true;
}
}
</script>
</head>
<body>
<?php
if(!isset($_SESSION['pruefling_id']))
die('Bitte zuerst anmelden!');
//Gruppe des Prueflings holen
$qry = "SELECT * FROM testtool.tbl_pruefling WHERE pruefling_id='".addslashes($_SESSION['pruefling_id'])."'";
if($result = pg_query($conn, $qry))
{
if($row = pg_fetch_object($result))
{
$gruppe = $row->gruppe_kurzbz;
}
else
die('Pruefling wurde nicht gefunden');
}
else
die('Pruefling wurde nicht gefunden');
//Start des Pruefungsvorganges
if(isset($_GET['start']))
{
//Erste Frage holen und Begintime eintragen
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='$gruppe' AND demo=false AND nummer>0 ORDER BY nummer ASC LIMIT 1";
$result = pg_query($conn, $qry);
$row = pg_fetch_object($result);
$antwort = new antwort($conn);
$antwort->frage_id = $row->frage_id;
$antwort->pruefling_id = $_SESSION['pruefling_id'];
$antwort->begintime = date('Y-m-d H:i:s');
$antwort->new = true;
if(!$antwort->save())
die('Fehler beim Startvorgang');
}
//Speichern einer Antwort
if(isset($_POST['submitantwort']) && isset($_GET['frage_id']))
{
$antwort = new antwort($conn);
if($_POST['antwort_id']!='')
{
if(!$antwort->load($_POST['antwort_id']))
die('Antwort konnte nicht geladen werden');
else
{
$antwort->new = false;
$antwort->antwort_id = $_POST['antwort_id'];
}
}
else
$antwort->new = true;
$antwort->frage_id = $_GET['frage_id'];
$antwort->pruefling_id = $_SESSION['pruefling_id'];
$antwort->antwort = trim(strtoupper($_POST['antwort']));
$antwort->endtime = date('Y-m-d H:i:s');
if(!$antwort->save())
die('Fehler beim Speichern');
else
{
$frage = new frage($conn);
$frage_id = $frage->getNextFrage($gebiet_id, $gruppe, $frage_id);
}
}
//Schauen ob dieses Gebiet schon gestartet wurde
$qry = "SELECT count(*) as anzahl FROM testtool.tbl_antwort JOIN testtool.tbl_frage USING(frage_id) WHERE pruefling_id='".addslashes($_SESSION['pruefling_id'])."' AND gebiet_id='".addslashes($gebiet_id)."'";
if($result = pg_query($conn, $qry))
{
if($row = pg_fetch_object($result))
{
if($row->anzahl>0)
{
//Hat bereits Fragen beantwortet -> Frage anzeigen
$demo=false;
}
else
{
//Demo anzeigen
$demo=true;
}
}
else
die('error');
}
else
die('error');
//Zeit des Gebietes holen
echo '<table width="100%"><tr><td align="right">';
$qry = "SELECT zeit FROM testtool.tbl_gebiet WHERE gebiet_id='".addslashes($gebiet_id)."'";
$result = pg_query($conn, $qry);
if(!$row = pg_fetch_object($result))
die('Gebiet wurde nicht gefunden');
list($stunde, $minute, $sekunde) = split(':',$row->zeit);
if($demo)
{
//Wenn es sich um ein Demobeispiel handelt, dann wird die Maximale Gesamtzeit angezeigt
echo $minute.':'.$sekunde.' Minuten ';
echo "<input type=\"button\" value=\"Start\" onclick=\"document.location.href='$PHP_SELF?gebiet_id=$gebiet_id&start=true'\">";
}
else
{
//Wenn es sich um eine Testfrage handelt, dann wird die verbleibende Zeit angezeigt
$qry = "SELECT '$row->zeit'-(now()-min(begintime)) as time FROM testtool.tbl_antwort JOIN testtool.tbl_frage USING(frage_id) WHERE gebiet_id='".addslashes($gebiet_id)."' AND pruefling_id='".addslashes($_SESSION['pruefling_id'])."'";
$result = pg_query($conn, $qry);
$row = pg_fetch_object($result);
//Zeit in Sekunden umrechnen
list($stunde, $minute, $sekunde) = split(':',$row->time);
$zeit = (int) ($stunde*60*60+$minute*60+$sekunde);
//Wenn die Zeit negativ ist und die Stunde 0 ist,
//dann muss die Zeit mit -1 multipliziert werden
if(substr($stunde,0,1)=='-' && $stunde==0)
{
$zeit = $zeit*-1;
}
echo '<span id="counter"></span>&nbsp;Minuten';
echo "<script>count_down($zeit)</script>";
}
echo '</td></tr>';
echo '</table>';
//Laden der Frage
$frage = new frage($conn);
if($frage_id!='') //Frage wurde uebergeben
{
$frage->load($frage_id);
}
else
{
if($demo) //Demofrage wird angezeigt
{
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='$gruppe' AND demo=true ORDER BY nummer ASC LIMIT 1";
$result = pg_query($conn, $qry);
if($row = pg_fetch_object($result))
$frage->load($row->frage_id);
}
else //Testfrage wird angezeigt
{
$qry ="SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='$gruppe' AND nummer>0 AND demo=false ORDER BY nummer ASC LIMIT 1";
$result = pg_query($conn, $qry);
if($row = pg_fetch_object($result))
$frage->load($row->frage_id);
}
}
//Anzeigen der Frage
if($frage->frage_id!='')
{
$frage_id = $frage->frage_id;
if(!$demo)
{
//Nachschauen ob diese Frage bereits angesehen wurde
$antwort = new antwort($conn);
if(!$antwort->getAntwort($_SESSION['pruefling_id'],$frage_id))
{
//wenn diese noch nicht angesehen wurde, dann wird die begintime gesetzt
$antwort = new antwort($conn);
$antwort->begintime = date('Y-m-d H:i:s');
$antwort->pruefling_id = $_SESSION['pruefling_id'];
$antwort->frage_id = $frage_id;
$antwort->new = true;
if(!$antwort->save())
echo 'Fehler beim Speichern der Erstansicht';
}
}
echo '<br><br><center>';
//Bild und Text der Frage anzeigen
if($frage->bild!='')
echo "<img src='bild.php?src=frage&frage_id=$frage->frage_id'><br><br>\n";
echo "$frage->text<br><br>\n";
//Vorschlaege laden
$vs = new vorschlag($conn);
$vs->getVorschlag($frage->frage_id);
echo '<table cellspacing="30px">';
echo '<tr>';
$anzahl = 1;
//Vorschlaege anzeigen
foreach ($vs->result as $vorschlag)
{
echo "\n<td align=center>";
echo "$vorschlag->antwort<br>";
if($vorschlag->bild!='')
echo "<img src='bild.php?src=vorschlag&vorschlag_id=$vorschlag->vorschlag_id'><br>";
if($vorschlag->text!='')
echo $vorschlag->text.'<br>';
echo "</td>";
$anzahl++;
if($anzahl>$MAX_VORSCHLAEGE_PRO_ZEILE)
{
echo '</tr><tr>';
$anzahl=1;
}
}
echo '</tr></table>';
//Antwort laden falls bereits vorhanden
$antwort = new antwort($conn);
$antwort->getAntwort($_SESSION['pruefling_id'],$frage->frage_id);
echo "<form action=\"$PHP_SELF?gebiet_id=$gebiet_id&frage_id=$frage->frage_id\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"antwort_id\" value=\"$antwort->antwort_id\">";
echo "Antwort: <input type=\"text\" size=\"1\" id=\"antwort\" name=\"antwort\" value=\"".htmlentities(addslashes($antwort->antwort))."\">&nbsp;&nbsp;&nbsp;<input ".($demo?'type="button"':'type="submit"')." name=\"submitantwort\" onclick=\"return checkantwort()\" value=\"Speichern\">";
echo "</form>";
echo '<br><br><br>';
//Fusszeile mit Weiter Button und Sprung direkt zu einer Frage
if(!$demo)
{
$qry = "SELECT nummer, frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='$gruppe' AND demo=false ORDER BY nummer";
//Nummern der Fragen Anzeigen
$result = pg_query($conn, $qry);
while($row = pg_fetch_object($result))
{
if($row->frage_id==$frage_id)
echo " <u>$row->nummer</u> -";
else
echo " <a href='$PHP_SELF?gebiet_id=$gebiet_id&frage_id=$row->frage_id' class='Item'>$row->nummer</a> -";
}
}
//Naechste Frage holen und Weiter-Button anzeigen
$frage = new frage($conn);
$nextfrage = $frage->getNextFrage($gebiet_id, $gruppe, $frage_id, $demo);
if($nextfrage)
{
echo " <a href='$PHP_SELF?gebiet_id=$gebiet_id&frage_id=$nextfrage' class='Item'>Weiter &gt;&gt;</a>";
}
else
{
//Wenns der letzte Eintrag ist, wieder zum ersten springen
echo " <a href='$PHP_SELF?gebiet_id=$gebiet_id' class='Item'>Weiter &gt;&gt;</a>";
}
echo '</center>';
}
else
{
//Wenn kein Demo vorhanden ist
echo "<br><br><br><center><b>Start drücken um zu beginnen</b></center>";
}
?>
</body>
</html>
+36
View File
@@ -0,0 +1,36 @@
<?php
/* Copyright (C) 2006 Technikum-Wien
*
* 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.
*
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../../skin/cis.css" rel="stylesheet" type="text/css">
</head>
<body>
<br><br><br>
<center><b>Die Maximalzeit für dieses Gebiet ist bereits abgelaufen!</b></center>
</body>
</html>
+116 -52
View File
@@ -24,73 +24,137 @@ require_once('../config.inc.php');
//require_once('../../include/functions.inc.php');
require_once('../../include/person.class.php');
require_once('../../include/prestudent.class.php');
//require_once('../../include/studiengang.class.php');
require_once('../../include/pruefling.class.php');
//require_once('../../include/lehrveranstaltung.class.php');
session_start();
if (isset($_POST['logout']))
session_destroy();
session_start();
$reload=false;
$reload_parent=false;
if (isset($_POST['logout']))
{
$reload = true;
session_destroy();
}
//Connection Herstellen
if(!$db_conn = pg_pconnect(CONN_STRING))
die('Fehler beim oeffnen der Datenbankverbindung');
if (isset($_POST['prestudent']) && isset($_POST['gebdatum']))
{
$ps=new prestudent($db_conn,$_POST['prestudent']);
if ($_POST['gebdatum']==$ps->gebdatum)
{
$_SESSION['prestudent_id']=$_POST['prestudent'];
$_SESSION['studiengang_kz']=$ps->studiengang_kz;
$_SESSION['nachname']=$ps->nachname;
$_SESSION['vorname']=$ps->vorname;
$_SESSION['gebdatum']=$ps->gebdatum;
}
}
if (isset($_SESSION['prestudent_id']))
$prestudent_id=$_SESSION['prestudent_id'];
else
{
//$prestudent_id=null;
$ps=new prestudent($db_conn);
$datum=date('Y-m-d');
$ps->getPrestudentRT($datum,true);
if ($ps->num_rows==0)
$ps->getPrestudentRT($datum);
}
if (isset($_POST['prestudent']) && isset($_POST['gebdatum']))
{
$ps=new prestudent($db_conn,$_POST['prestudent']);
if ($_POST['gebdatum']==$ps->gebdatum)
{
$_SESSION['prestudent_id']=$_POST['prestudent'];
$_SESSION['studiengang_kz']=$ps->studiengang_kz;
$_SESSION['nachname']=$ps->nachname;
$_SESSION['vorname']=$ps->vorname;
$_SESSION['gebdatum']=$ps->gebdatum;
}
}
if (isset($_SESSION['prestudent_id']))
$prestudent_id=$_SESSION['prestudent_id'];
else
{
//$prestudent_id=null;
$ps=new prestudent($db_conn);
$datum=date('Y-m-d');
$ps->getPrestudentRT($datum,true);
if ($ps->num_rows==0)
$ps->getPrestudentRT($datum);
}
if(isset($_POST['save']) && isset($_SESSION['prestudent_id']))
{
$pruefling = new pruefling($db_conn);
if($_POST['pruefling_id']!='')
if(!$pruefling->load($_POST['pruefling_id']))
die('Pruefling wurde nicht gefunden');
else
$pruefling->new=false;
else
$pruefling->new=true;
$pruefling->studiengang_kz = $_SESSION['studiengang_kz'];
$pruefling->idnachweis = $_POST['idnachweis'];
$pruefling->registriert = date('Y-m-d H:i:s');
$pruefling->prestudent_id = $_SESSION['prestudent_id'];
$pruefling->gruppe_kurzbz = $_POST['gruppe'];
if($pruefling->save())
{
$_SESSION['pruefling_id']=$pruefling->pruefling_id;
$reload_parent=true;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../skin/cis.css" rel="stylesheet" type="text/css">
<?php
if($reload_parent)
echo '<script language="Javascript">parent.menu.location.reload()</script>';
if($reload)
echo "<script language=\"Javascript\">parent.location.reload();</script>";
?>
</head>
<body>
<h1>Login</h1>
<?php
if (isset($prestudent_id))
{
echo '<BR>Sie sind eingelogt als '.$_SESSION['vorname'].' '.$_SESSION['nachname'];
echo ' ('.$_SESSION['gebdatum'].') ID: '.$_SESSION['prestudent_id'];
echo '<form method="post">';
echo '&nbsp; <INPUT type="submit" value="Logout" name="logout" />';
echo '</form>';
}
else
<body>
<h1>Login</h1>
<?php
if (isset($prestudent_id))
{
echo '<form method="post">';
echo '<br>Sie sind eingelogt als '.$_SESSION['vorname'].' '.$_SESSION['nachname'];
echo ' ('.$_SESSION['gebdatum'].') ID: '.$_SESSION['prestudent_id'];
echo '&nbsp; <INPUT type="submit" value="Logout" name="logout" />';
echo '</form>';
echo '<br><br>';
$pruefling = new pruefling($db_conn);
$pruefling->getPruefling($prestudent_id);
if($pruefling->pruefling_id!='')
{
$_SESSION['pruefling_id']=$pruefling->pruefling_id;
echo '<script language="Javascript">parent.menu.location.reload()</script>';
}
echo '<FORM METHOD="POST">';
echo '<input type="hidden" name="pruefling_id" value="'.$pruefling->pruefling_id.'">';
echo '<table>';
echo '<tr><td>Gruppe:</td><td><SELECT name="gruppe">';
$qry = "SELECT * FROM testtool.tbl_gruppe ORDER BY gruppe_kurzbz";
if($result = pg_query($db_conn, $qry))
{
while($row = pg_fetch_object($result))
{
if($row->gruppe_kurzbz==$pruefling->gruppe_kurzbz)
echo '<OPTION value="'.$row->gruppe_kurzbz.'" selected>'.$row->gruppe_kurzbz.'</OPTION>';
else
echo '<OPTION value="'.$row->gruppe_kurzbz.'" >'.$row->gruppe_kurzbz.'</OPTION>';
}
}
echo '</SELECT></td></tr>';
echo '<tr><td>ID Nachweis:</td><td><INPUT type="text" maxsize="50" name="idnachweis" value="'.htmlentities($pruefling->idnachweis).'"></td></tr>';
echo '<tr><td></td><td><input type="submit" name="save" value="OK"></td>';
echo '</table>';
echo '</FORM>';
}
else
{
echo '<form method="post">
<SELECT name="prestudent">';
echo '<form method="post">
<SELECT name="prestudent">';
foreach($ps->result as $prestd)
echo '<OPTION value="'.$prestd->prestudent_id.'">'.$prestd->nachname.' '.$prestd->vorname."</OPTION>\n";
echo '</SELECT>';
echo '&nbsp; Geburtsdatum: <INPUT type="text" maxlength="10" size="10" name="gebdatum" />(YYYY-MM-TT)';
echo '&nbsp; <INPUT type="submit" value="Login" />';
echo '</form>';
}
?>
echo '</SELECT>';
echo '&nbsp; Geburtsdatum: <INPUT type="text" maxlength="10" size="10" name="gebdatum" />(YYYY-MM-TT)';
echo '&nbsp; <INPUT type="submit" value="Login" />';
echo '</form>';
}
?>
</body>
</html>
</html>
+36 -31
View File
@@ -20,14 +20,14 @@
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
*/
require_once('../config.inc.php');
require_once('../config.inc.php');
session_start();
session_start();
//Connection Herstellen
if(!$db_conn = pg_pconnect(CONN_STRING))
die('Fehler beim oeffnen der Datenbankverbindung');
?>
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
@@ -36,39 +36,44 @@ if(!$db_conn = pg_pconnect(CONN_STRING))
<link href="../../skin/cis.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
if (isset($_SESSION['prestudent_id']))
{
<body>
<?php
if (isset($_SESSION['pruefling_id']))
{
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-right-width:1px;border-right-color:#BCBCBC;">';
echo '<tr><td nowrap><img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;Gebiet</td></tr>';
echo '<tr><td nowrap>
<a class="MenuItem" href="index.html" target="_top">
<img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;Home
</a>
</td></tr>';
echo '<tr><td nowrap><img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;Gebiet</td></tr>';
echo '<tr><td nowrap>';
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" id="MeineCIS" style="display: visible;">';
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" id="Gebiet" style="display: visible;">';
$qry = 'SELECT * FROM testtool.vw_ablauf WHERE studiengang_kz='.$_SESSION['studiengang_kz'].' ORDER BY reihung';
//echo $qry;
if($result = pg_query($db_conn, $qry))
//echo $qry;
if($result = pg_query($db_conn, $qry))
while($row = pg_fetch_object($result))
echo '<tr>
echo '<tr>
<td width="10" nowrap>&nbsp;</td>
<td nowrap>
<a class="Item" href="profile/index.php" target="content"><img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;'.$row->gebiet_bez.'</a>
</td>
</tr>';
echo '</table>';
echo '</td></tr></table>';
}
else
{
<td nowrap>
<a class="Item" href="frage.php?gebiet_id='.$row->gebiet_id.'" target="content"><img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;'.$row->gebiet_bez.'</a>
</td>
</tr>';
echo '</table>';
echo '</td></tr></table>';
}
else
{
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-right-width:1px;border-right-color:#BCBCBC;">';
echo '<tr><td nowrap>
<a class="HyperItem" href="../index.html" target="_top">
<img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;Login
</a>
</td></tr>';
echo '</table>';
echo '</td></tr></table>';
}
echo '<tr><td nowrap>
<a class="HyperItem" href="index.html" target="_top">
<img src="../../skin/images/menu_item.gif" width="7" height="9">&nbsp;Login
</a>
</td></tr>';
echo '</table>';
echo '</td></tr></table>';
}
?>
</body>
</html>
</html>
+188
View File
@@ -0,0 +1,188 @@
<?php
/* Copyright (C) 2007 Technikum-Wien
*
* 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.
*
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
*/
class antwort
{
//Tabellenspalten
var $antwort_id;
var $frage_id;
var $antwort;
var $begintime;
var $endtime;
var $pruefling_id;
// ErgebnisArray
var $result=array();
var $num_rows=0;
var $errormsg;
var $new;
// *************************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Antwort
// * @param $conn Datenbank-Connection
// * $frage_id Frage die geladen werden soll (default=null)
// * $unicode Gibt an ob die Daten mit UNICODE Codierung
// * oder LATIN9 Codierung verarbeitet werden sollen
// *************************************************************************
function antwort($conn, $antwort_id=null, $unicode=false)
{
$this->conn = $conn;
if($unicode)
$qry = "SET CLIENT_ENCODING TO 'UNICODE';";
else
$qry = "SET CLIENT_ENCODING TO 'LATIN9';";
if(!pg_query($conn,$qry))
{
$this->errormsg = 'Encoding konnte nicht gesetzt werden';
return false;
}
if($antwort_id != null)
$this->load($antwort_id);
}
// ***********************************************************
// * Laedt antwort mit der uebergebenen ID
// * @param $antwort_id ID der Frage die geladen werden soll
// ***********************************************************
function load($antwort_id)
{
$qry = "SELECT * FROM testtool.tbl_antwort WHERE antwort_id='".addslashes($antwort_id)."'";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->antwort_id = $row->antwort_id;
$this->frage_id = $row->frage_id;
$this->antwort = $row->antwort;
$this->begintime = $row->begintime;
$this->endtime = $row->endtime;
$this->pruefling_id = $row->pruefling_id;
return true;
}
else
{
$this->errormsg = "Kein Eintrag gefunden fuer $antwort_id";
return false;
}
}
else
{
$this->errormsg = "Fehler beim laden: $qry";
return false;
}
}
// ************************************************
// * wenn $var '' ist wird NULL zurueckgegeben
// * wenn $var !='' ist werden Datenbankkritische
// * Zeichen mit Backslash versehen und das Ergbnis
// * unter Hochkomma gesetzt.
// ************************************************
function addslashes($var)
{
return ($var!=''?"'".addslashes($var)."'":'null');
}
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
return true;
}
// ******************************************************************
// * Speichert die Daten in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz angelegt
// * ansonsten upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ******************************************************************
function save()
{
//Variablen auf Gueltigkeit pruefen
if(!$this->validate())
return false;
if($this->new) //Wenn new true ist dann ein INSERT absetzen ansonsten ein UPDATE
{
$qry = 'INSERT INTO testtool.tbl_antwort (frage_id, antwort, begintime, endtime, pruefling_id) VALUES('.
"'".addslashes($this->frage_id)."',".
$this->addslashes($this->antwort).",".
$this->addslashes($this->begintime).",".
$this->addslashes($this->endtime).",".
$this->addslashes($this->pruefling_id).");";
}
else
{
$qry = 'UPDATE testtool.tbl_antwort SET'.
' antwort='.$this->addslashes($this->antwort).','.
" endtime='".$this->endtime."'".
" WHERE frage_id='".addslashes($this->frage_id)."' AND pruefling_id='".addslashes($this->pruefling_id)."'";
}
if(pg_query($this->conn,$qry))
{
//Log schreiben
return true;
}
else
{
$this->errormsg = 'Fehler beim Speichern der Antwort:'.$qry;
return false;
}
}
function getAntwort($pruefling_id, $frage_id)
{
$qry = "SELECT * FROM testtool.tbl_antwort WHERE pruefling_id='".addslashes($pruefling_id)."' AND frage_id='".addslashes($frage_id)."'";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->antwort_id = $row->antwort_id;
$this->frage_id = $row->frage_id;
$this->antwort = $row->antwort;
$this->begintime = $row->begintime;
$this->endtime = $row->endtime;
$this->pruefling_id = $row->pruefling_id;
return true;
}
else
{
$this->errormsg = 'Antwort wurde nicht gefunden';
return false;
}
}
else
{
$this->errormsg = 'Antwort konnte nicht geladen werden';
return false;
}
}
}
?>
+18
View File
@@ -201,5 +201,23 @@ class frage
return false;
}
}
function getNextFrage($gebiet_id, $gruppe_kurzbz, $frage_id, $demo=false)
{
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='".addslashes($gruppe_kurzbz)."' AND nummer>(SELECT nummer FROM testtool.tbl_frage WHERE frage_id='".addslashes($frage_id)."') ";
if($demo)
$qry.=" AND demo=true";
$qry.=" ORDER BY nummer ASC LIMIT 1";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
return $row->frage_id;
else
return false;
}
else
return false;
}
}
?>
+218
View File
@@ -0,0 +1,218 @@
<?php
/* Copyright (C) 2007 Technikum-Wien
*
* 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.
*
* Authors: Christian Paminger <christian.paminger@technikum-wien.at>,
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
*/
class pruefling
{
//Tabellenspalten
var $pruefling_id;
var $studiengang_kz;
var $idnachweis;
var $registriert;
var $prestudent_id;
var $gruppe_kurzbz;
// ErgebnisArray
var $result=array();
var $num_rows=0;
var $errormsg;
var $new;
// *************************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional einen pruefling
// * @param $conn Datenbank-Connection
// * $frage_id Frage die geladen werden soll (default=null)
// * $unicode Gibt an ob die Daten mit UNICODE Codierung
// * oder LATIN9 Codierung verarbeitet werden sollen
// *************************************************************************
function pruefling($conn, $pruefling_id=null, $unicode=false)
{
$this->conn = $conn;
if($unicode)
$qry = "SET CLIENT_ENCODING TO 'UNICODE';";
else
$qry = "SET CLIENT_ENCODING TO 'LATIN9';";
if(!pg_query($conn,$qry))
{
$this->errormsg = 'Encoding konnte nicht gesetzt werden';
return false;
}
if($pruefling_id != null)
$this->load($pruefling_id);
}
// ***********************************************************
// * Laedt Pruefling mit der uebergebenen ID
// * @param $pruefling_id ID der Frage die geladen werden soll
// ***********************************************************
function load($pruefling_id)
{
$qry = "SELECT * FROM testtool.tbl_pruefling WHERE pruefling_id='".addslashes($pruefling_id)."'";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->pruefling_id = $row->pruefling_id;
$this->studiengang_kz = $row->studiengang_kz;
$this->idnachweis = $row->idnachweis;
$this->registriert = $row->registriert;
$this->prestudent_id = $row->prestudent_id;
$this->gruppe_kurzbz = $row->gruppe_kurzbz;
return true;
}
else
{
$this->errormsg = "Kein Eintrag gefunden fuer $pruefling_id";
return false;
}
}
else
{
$this->errormsg = "Fehler beim laden: $qry";
return false;
}
}
// ************************************************
// * wenn $var '' ist wird NULL zurueckgegeben
// * wenn $var !='' ist werden Datenbankkritische
// * Zeichen mit Backslash versehen und das Ergbnis
// * unter Hochkomma gesetzt.
// ************************************************
function addslashes($var)
{
return ($var!=''?"'".addslashes($var)."'":'null');
}
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
return true;
}
// ******************************************************************
// * Speichert die Benutzerdaten in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz angelegt
// * ansonsten der Datensatz mit $uid upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ******************************************************************
function save()
{
//Variablen auf Gueltigkeit pruefen
if(!$this->validate())
return false;
if($this->new) //Wenn new true ist dann ein INSERT absetzen ansonsten ein UPDATE
{
$qry = 'BEGIN;INSERT INTO testtool.tbl_pruefling (studiengang_kz, idnachweis, registriert, prestudent_id, gruppe_kurzbz) VALUES('.
$this->addslashes($this->studiengang_kz).",".
$this->addslashes($this->idnachweis).",".
$this->addslashes($this->registriert).",".
$this->addslashes($this->prestudent_id).",".
$this->addslashes($this->gruppe_kurzbz).");";
}
else
{
$qry = 'UPDATE testtool.tbl_pruefling SET'.
' studiengang_kz='.$this->addslashes($this->studiengang_kz).','.
' idnachweis='.$this->addslashes($this->idnachweis).','.
' registriert='.$this->addslashes($this->registriert).','.
' prestudent_id='.$this->addslashes($this->prestudent_id).','.
' gruppe_kurzbz='.$this->addslashes($this->gruppe_kurzbz).
" WHERE pruefling_id='".addslashes($this->pruefling_id)."';";
}
if(pg_query($this->conn,$qry))
{
if($this->new)
{
$qry = "SELECT currval('testtool.tbl_pruefling_pruefling_id_seq') as id";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->pruefling_id = $row->id;
pg_query($this->conn, 'COMMIT;');
return true;
}
else
{
pg_query($this->conn, 'ROLLBACK;');
$this->errormsg = 'Fehler beim lesen der Sequence';
return false;
}
}
else
{
pg_query($this->conn, 'ROLLBACK;');
$this->errormsg = 'Fehler beim lesen der Sequence';
return false;
}
}
else
{
return true;
}
}
else
{
$this->errormsg = 'Fehler beim Speichern der Frage:'.$qry;
return false;
}
}
function getPruefling($prestudent_id)
{
$qry = "SELECT * FROM testtool.tbl_pruefling WHERE prestudent_id='".addslashes($prestudent_id)."'";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->pruefling_id = $row->pruefling_id;
$this->studiengang_kz = $row->studiengang_kz;
$this->idnachweis = $row->idnachweis;
$this->registriert = $row->registriert;
$this->prestudent_id = $row->prestudent_id;
$this->gruppe_kurzbz = $row->gruppe_kurzbz;
return true;
}
else
{
$this->errormsg = "Kein Eintrag gefunden fuer $prestudent_id";
return false;
}
}
else
{
$this->errormsg = "Fehler beim laden: $qry";
return false;
}
}
}
?>