This commit is contained in:
Gerald Raab
2007-07-27 11:02:55 +00:00
parent c2c0a1713c
commit fbe9649840
12 changed files with 1296 additions and 51 deletions
+228
View File
@@ -0,0 +1,228 @@
<?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>.
*/
class legesamtnote
{
var $conn; // resource DB-Handle
var $errormsg; // string
var $new; // boolean
var $legesamtnoten = array(); // lehreinheit Objekt
//Tabellenspalten
var $student_uid; // varchar(16)
var $lehreinheit_id; // int
var $note; // smallint
var $benotungsdatum; //date
var $updateamum; // timestamp
var $updatevon; // varchar(16)
var $insertamum; // timestamp
var $insertvon; // varchar(16)
// *************************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Uebung
// * @param $conn Datenbank-Connection
// * $uebung_id
// * $unicode Gibt an ob die Daten mit UNICODE Codierung
// * oder LATIN9 Codierung verarbeitet werden sollen
// *************************************************************************
function legesamtnote($conn, $student_uid=null, $lehreinheit_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($this->conn,$qry))
{
$this->errormsg = 'Encoding konnte nicht gesetzt werden';
return false;
}
if($student_uid != null)
$this->load($student_uid, $lehreinheit_id);
}
// *********************************************************
// * Laedt die legesamtnote
// * @param student_uid, lehreinheit_id
// *********************************************************
function load($student_uid, $lehreinheit_id)
{
if(!is_numeric($lehreinheit_id))
{
$this->errormsg='lehreinheit_id muss eine gueltige Zahl sein';
return false;
}
$qry = "SELECT * FROM campus.tbl_legesamtnote where student_uid = '".$student_uid."' and lehreinheit_id = '".$lehreinheit_id."'";
if($result=pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->lehreinheit_id = $row->lehreinheit_id;
$this->student_uid = $row->student_uid;
$this->note = $row->note;
$this->benotungsdatum = $row->benotungsdatum;
$this->updateamum = $row->updateamum;
$this->updatevon = $row->updatevon;
$this->insertamum = $row->insertamum;
$this->insertvon = $row->insertvon;
return true;
}
else
{
$this->errormsg = "Es ist keine legesamtnote mit der fuer diesen studenten vorhanden";
return false;
}
}
else
{
$this->errormsg = 'Fehler beim laden der Uebung';
return false;
}
}
function load_legesamtnote($lehreinheit_id)
{
if(!is_numeric($lehreinheit_id))
{
$this->errormsg = 'Lehreinheit_id muss eine gueltige Zahl sein';
return false;
}
$qry = "SELECT * FROM campus.tbl_legesamtnote WHERE lehreinheit_id='".$lehreinheit_id."' order by student_uid";
if($result=pg_query($this->conn, $qry))
{
while($row = pg_fetch_object($result))
{
$legesamtnote_obj = new uebung($this->conn);
$legesamtnote_obj->student_uid = $row->student_uid;
$legesamtnote_obj->note = $row->note;
$legesamtnote_obj->lehreinheit_id = $row->lehreinheit_id;
$legesamtnote_obj->benotungsdatum = $row->benotungsdatum;
$legesamtnote_obj->updateamum = $row->updateamum;
$legesamtnote_obj->updatevon = $row->updatevon;
$legesamtnote_obj->insertamum = $row->insertamum;
$legesamtnote_obj->insertvon = $row->insertvon;
$this->legesamtnoten[] = $legesamtnote_obj;
}
return true;
}
else
{
$this->errormsg = 'Fehler beim laden der legesamtnoten';
return false;
}
}
// *******************************************
// * Prueft die Variablen vor dem Speichern
// * auf Gueltigkeit.
// * @return true wenn ok, false im Fehlerfall
// *******************************************
function validate()
{
if(!is_numeric($this->lehreinheit_id))
{
$this->errormsg = 'Lehreinheit_id muss eine gueltige Zahl sein';
return false;
}
if(!is_numeric($this->note))
{
$this->errormsg = 'Note muss eine gueltige Zahl sein';
return false;
}
return true;
}
// ************************************************
// * 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');
}
// ************************************************************
// * Speichert Uebung in die Datenbank
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz
// * angelegt, ansonsten der Datensatz upgedated
// * @return true wenn erfolgreich, false im Fehlerfall
// ************************************************************
function save()
{
//if(is_null($new))
// $new = $this->new;
//Variablen auf Gueltigkeit pruefen
if(!$this->validate())
return false;
if($this->new)
{
$qry = 'INSERT INTO campus.tbl_legesamtnote(student_uid, lehreinheit_id, note, benotungsdatum, updateamum, updatevon, insertamum, insertvon) VALUES('.
$this->addslashes($this->student_uid).','.
$this->addslashes($this->lehreinheit_id).','.
$this->addslashes($this->note).','.
$this->addslashes($this->benotungsdatum).','.
'null,'.
'null,'.
$this->addslashes($this->insertamum).','.
$this->addslashes($this->insertvon).');';
}
else
{
$qry = 'UPDATE campus.tbl_legesamtnote SET'.
' student_uid='.$this->addslashes($this->student_uid).','.
' lehreinheit_id ='.$this->addslashes($this->lehreinheit_id).','.
' note='.$this->addslashes($this->note).','.
' benotungsdatum='.$this->addslashes($this->benotungsdatum).','.
' updateamum='.$this->addslashes($this->updateamum).','.
' updatevon='.$this->addslashes($this->updatevon).
" WHERE lehreinheit_id=".$this->addslashes($this->lehreinheit_id)." and student_uid = '".$this->student_uid."';";
}
if(pg_query($this->conn,$qry))
{
return true;
}
else
{
$this->errormsg = 'Fehler beim Speichern der legesamtnote:'.$qry;
return false;
}
}
}
+3 -4
View File
@@ -195,8 +195,7 @@ class lvgesamtnote
if($new)
{
//Neuen Datensatz einfuegen
$qry='INSERT INTO campus.tbl_lvgesamtnote (lehrveranstaltung_id, student_uid, studiensemester_kurzbz, mitarbeiter_uid, note, freigabedatum, benotungsdatum, bemerkung,
updateamum, updatevon, insertamum, insertvon) VALUES('.
$qry='INSERT INTO campus.tbl_lvgesamtnote (lehrveranstaltung_id, student_uid, studiensemester_kurzbz, mitarbeiter_uid, note, freigabedatum, benotungsdatum, bemerkung, updateamum, updatevon, insertamum, insertvon) VALUES('.
$this->addslashes($this->lehrveranstaltung_id).', '.
$this->addslashes($this->student_uid).', '.
$this->addslashes($this->studiensemester_kurzbz).', '.
@@ -220,8 +219,8 @@ class lvgesamtnote
'mitarbeiter_uid='.$this->addslashes($this->mitarbeiter_uid).', '.
'updateamum= '.$this->addslashes($this->updateamum).', '.
'updatevon='.$this->addslashes($this->updatevon).' '.
'WHERE lehrveranstaltung_id='.$this->addslashes($this->lehrveranstaltung_id).', '.
'AND student_uid='.$this->addslashes($this->student_uid).', '.
'WHERE lehrveranstaltung_id='.$this->addslashes($this->lehrveranstaltung_id).' '.
'AND student_uid='.$this->addslashes($this->student_uid).' '.
'AND studiensemester_kurzbz='.$this->addslashes($this->studiensemester_kurzbz).';';
}
+200
View File
@@ -0,0 +1,200 @@
<?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>,
* Rudolf Hangl <rudolf.hangl@technikum-wien.at> and
* gerald Raab <gerald.raab@technikum-wien.at>.
*/
class studentnote
{
var $conn; // resource DB-Handle
var $errormsg; // string
var $new; // boolean
var $beispiele = array(); // lehreinheit Objekt
//Vars
var $uebung_id; // serial
var $gewicht; // smalint
var $punkte; // Real
var $note;
var $note_gesamt;
var $negativ;
var $fehlt;
// *************************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Uebung
// * @param $conn Datenbank-Connection
// * $uebung_id
// * $unicode Gibt an ob die Daten mit UNICODE Codierung
// * oder LATIN9 Codierung verarbeitet werden sollen
// *************************************************************************
function studentnote($conn, $lehreinheit_id=null, $ss=null, $student_uid=null, $uebung_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($this->conn,$qry))
{
$this->errormsg = 'Encoding konnte nicht gesetzt werden';
return false;
}
if($uebung_id)
{
$this->calc_note($uebung_id, $student_uid);
}
else
{
$studentgesamtnote = 0;
$counter = 0;
$gewichte = 0;
$negativ = false;
$note_x_gewicht = 0;
$note_x_gewicht_l1 = 0;
$gewichte_l1 = 0;
$fehlt = false;
$ueb1_obj = new uebung($conn);
$ueb1_obj->load_uebung($lehreinheit_id,1);
foreach($ueb1_obj->uebungen as $ueb1)
{
$ueb_obj = new uebung($conn);
//if ($ueb_obj->load_uebung($lehreinheit_id, 2, $ueb1->uebung_id))
$ueb_obj->load_uebung($lehreinheit_id, 2, $ueb1->uebung_id);
if ($ueb_obj->uebungen)
{
$note_x_gewicht = 0;
$gewichte = 0;
foreach ($ueb_obj->uebungen as $ueb)
{
if ($this->calc_note($ueb->uebung_id,$student_uid))
{
if (is_numeric($this->note))
{
if ($ueb->positiv && $this->note == 5)
$negativ = true;
$note_x_gewicht += ($this->note * $this->gewicht);
$gewichte += $this->gewicht;
}
else
$fehlt = true;
}
}
if ($gewichte > 0)
{
$note_x_gewicht_l1 += ($note_x_gewicht / $gewichte);
$gewichte_l1 += $ueb1->gewicht;
}
}
// keine kreuzerllisten/abgaben
else
{
$s = new uebung($conn);
$s->load_studentuebung($student_uid, $ueb1->uebung_id);
if ($s->note && $ueb1->gewicht)
{
if ($s->note == 5 && $ueb1->positiv)
$negativ = true;
$note_x_gewicht_l1 += ($s->note * $ueb1->gewicht);
$gewichte_l1 += $ueb1->gewicht;
}
else
$fehlt = true;
}
}
if ($gewichte_l1 > 0)
{
$this->studentgesamtnote = ($note_x_gewicht_l1 / $gewichte_l1);
$this->negativ = $negativ;
$this->fehlt = $fehlt;
}
else
{
$this->studentgesamtnote = "n";
$this->negativ = $negativ;
$this->fehlt = $fehlt;
}
}
}
// *********************************************************
// * berechnet die gesamtnote der übung
// * @param uebung_id, student_uid
// *********************************************************
function calc_note($uebung_id, $student_uid)
{
if(!is_numeric($uebung_id))
{
$this->errormsg='Uebung_id muss eine gueltige Zahl sein';
return false;
}
else
{
$note = null;
$punkte_eingetragen = 0;
$punkte_gesamt = 0;
$mitarbeit = 0;
$ueb = new uebung($this->conn);
$ueb->load($uebung_id);
if ($ueb->beispiele)
{
//Eingetragen diese Kreuzerlliste
$qry = "SELECT sum(punkte) as punkteeingetragen FROM campus.tbl_beispiel JOIN campus.tbl_studentbeispiel USING(beispiel_id) WHERE uebung_id='$uebung_id' AND student_uid='$student_uid' AND vorbereitet=true";
$punkte_eingetragen=0;
if($result=pg_query($this->conn, $qry))
if($row = pg_fetch_object($result))
$punkte_eingetragen = ($row->punkteeingetragen!=''?$row->punkteeingetragen:0);
if($ueb->load_studentuebung($student_uid, $uebung_id))
{
$mitarbeit = $ueb->mitarbeitspunkte;
}
$punkte_gesamt = $punkte_eingetragen + $mitarbeit;
$qry = "SELECT min(note) as note from campus.tbl_notenschluesseluebung where punkte <= '".$punkte_gesamt."' and uebung_id = '".$uebung_id."'";
if($result=pg_query($this->conn, $qry))
if($row = pg_fetch_object($result))
$note = $row->note;
else
$note = 5;
$this->note = $note;
$this->gewicht = $ueb->gewicht;
return true;
}
else
{
if($ueb->load_studentuebung($student_uid, $uebung_id))
{
$this->note = $ueb->note;
$this->gewicht = $ueb->gewicht;
return true;
}
}
}
}
}
?>
+55 -4
View File
@@ -137,6 +137,7 @@ class uebung
return false;
}
}
function load_studentuebung($student_uid, $uebung_id)
{
$qry = "SELECT * FROM campus.tbl_studentuebung WHERE student_uid='$student_uid' AND uebung_id='$uebung_id'";
@@ -172,7 +173,23 @@ class uebung
return false;
}
}
function check_studentuebung($uebung_id)
{
$qry = "SELECT * FROM campus.tbl_studentuebung WHERE uebung_id='$uebung_id'";
if($result = pg_query($this->conn, $qry))
{
if (pg_num_rows($result) >0)
return true;
else
return false;
}
else
return false;
}
function load_uebung($lehreinheit_id, $level=null, $uebung_id=null)
{
if(!is_numeric($lehreinheit_id))
@@ -452,15 +469,46 @@ class uebung
$this->errormsg = 'Uebung_id ist ungueltig';
return false;
}
// subübungen wegräumen
$qry = "SELECT * FROM campus.tbl_uebung WHERE liste_id = '".$uebung_id."'";
if($result=pg_query($this->conn, $qry))
{
while($row = pg_fetch_object($result))
{
foreach (glob(BENOTUNGSTOOL_PATH."angabe/*".$row->uebung_id.".*") as $angabe)
{
if(file_exists($angabe))
unlink($angabe);
}
$qry = "DELETE FROM campus.tbl_studentbeispiel WHERE beispiel_id IN(SELECT beispiel_id FROM campus.tbl_beispiel WHERE uebung_id='$row->uebung_id');
DELETE FROM campus.tbl_abgabe WHERE abgabe_id IN(SELECT abgabe_id FROM campus.tbl_studentuebung WHERE uebung_id='$row->uebung_id');
DELETE FROM campus.tbl_studentuebung WHERE uebung_id='$row->uebung_id';
DELETE FROM campus.tbl_beispiel WHERE uebung_id='$row->uebung_id';
DELETE FROM campus.tbl_uebung WHERE uebung_id='$row->uebung_id';
DELETE FROM campus.tbl_studentuebung WHERE uebung_id = '$row->uebung_id'";
if(!pg_query($qry))
{
$this->errormsg = 'Fehler beim Loeschen der Daten';
return false;
}
}
}
foreach (glob(BENOTUNGSTOOL_PATH."angabe/*".$uebung_id.".*") as $angabe)
{
if(file_exists($angabe))
unlink($angabe);
}
$qry = "DELETE FROM campus.tbl_studentuebung WHERE uebung_id='$uebung_id';
DELETE FROM campus.tbl_studentbeispiel WHERE beispiel_id IN(SELECT beispiel_id FROM campus.tbl_beispiel WHERE uebung_id='$uebung_id');
$qry = "DELETE FROM campus.tbl_studentbeispiel WHERE beispiel_id IN(SELECT beispiel_id FROM campus.tbl_beispiel WHERE uebung_id='$uebung_id');
DELETE FROM campus.tbl_abgabe WHERE abgabe_id IN(SELECT abgabe_id FROM campus.tbl_studentuebung WHERE uebung_id='$uebung_id');
DELETE FROM campus.tbl_studentuebung WHERE uebung_id='$uebung_id';
DELETE FROM campus.tbl_beispiel WHERE uebung_id='$uebung_id';
DELETE FROM campus.tbl_uebung WHERE uebung_id='$uebung_id'";
DELETE FROM campus.tbl_uebung WHERE uebung_id='$uebung_id';
DELETE FROM campus.tbl_studentuebung WHERE uebung_id = '$uebung_id'";
if(pg_query($qry))
return true;
@@ -468,7 +516,10 @@ class uebung
{
$this->errormsg = 'Fehler beim Loeschen der Daten';
return false;
}
}
}
}
?>