This commit is contained in:
Gerald Raab
2007-08-10 08:30:00 +00:00
parent 437fd51dcb
commit b74d0a29a7
12 changed files with 1601 additions and 529 deletions
+28
View File
@@ -362,7 +362,35 @@ class beispiel
return false;
}
}
function check_anzahl_studentbeispiel($beispiel_id)
{
if(!is_numeric($beispiel_id))
{
$this->errormsg = 'Beispiel_id muss eine gueltige Zahl sein';
return false;
}
$qry = "SELECT count(*) as anzahl FROM campus.tbl_studentbeispiel WHERE vorbereitet = true and beispiel_id='$beispiel_id'";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->anzahl_studentbeispiel = $row->anzahl;
return true;
}
else
{
$this->errormsg = 'Fehler beim laden der Anzahl der Einträge in Student_Beispiel';
return false;
}
}
else
{
$this->errormsg = 'Fehler beim laden der Anzahl der Einträge in Student_Beispiel';
return false;
}
}
// **
// * Prueft die studentbeispiel Daten auf gueltigkeit
// *
+3 -2
View File
@@ -200,7 +200,8 @@ class lvgesamtnote
$this->addslashes($this->student_uid).', '.
$this->addslashes($this->studiensemester_kurzbz).', '.
$this->addslashes($this->mitarbeiter_uid).', '.
$this->addslashes($this->note).', now(), '.
$this->addslashes($this->note).', '.
$this->addslashes($this->freigabedatum).', '.
$this->addslashes($this->benotungsdatum).', '.
$this->addslashes($this->bemerkung).', '.
$this->addslashes($this->updateamum).', '.
@@ -212,7 +213,7 @@ class lvgesamtnote
{
$qry='UPDATE campus.tbl_lvgesamtnote SET '.
'note='.$this->addslashes($this->note).', '.
'freigabedatum=now(), '.
'freigabedatum='.$this->addslashes($this->freigabedatum).', '.
'benotungsdatum='.$this->addslashes($this->benotungsdatum).', '.
'bemerkung='.$this->addslashes($this->bemerkung).', '.
'mitarbeiter_uid='.$this->addslashes($this->mitarbeiter_uid).', '.
+185 -77
View File
@@ -44,7 +44,7 @@ class studentnote
// * $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)
function studentnote($conn, $unicode=false)
{
$this->conn = $conn;
@@ -59,12 +59,54 @@ class studentnote
return false;
}
if($uebung_id)
}
function calc_gesamtnote($lehreinheit_id, $ss, $student_uid)
{
{
$this->calc_note($uebung_id, $student_uid);
$conn = $this->conn;
$studentgesamtnote = 0;
$counter = 0;
$gewichte = 0;
$negativ_all = false;
$note_x_gewicht = 0;
$note_x_gewicht_l1 = 0;
$gewichte_l1 = 0;
$fehlt_all = false;
$beispiele = false;
$ueb1_obj = new uebung($conn);
$ueb1_obj->load_uebung($lehreinheit_id,1);
foreach($ueb1_obj->uebungen as $ueb1)
{
$this->calc_l1_note($ueb1->uebung_id, $student_uid, $lehreinheit_id);
$note_x_gewicht_l1 += ($this->l1_note * $this->l1_gewicht);
$gewichte_l1 += $this->l1_gewicht;
if ($this->negativ)
$negativ_all = $this->negativ;
if ($this->fehlt)
$fehlt_all = $this->fehlt;
}
if ($gewichte_l1 > 0)
{
$this->studentgesamtnote = ($note_x_gewicht_l1 / $gewichte_l1);
$this->negativ = $negativ_all;
$this->fehlt = $fehlt_all;
}
else
{
$this->studentgesamtnote = "n";
$this->negativ = $negativ_all;
$this->fehlt = $fehlt_all;
}
}
else
}
function calc_l1_note($uebung_id, $student_uid, $lehreinheit_id)
{
{
$conn = $this->conn;
$studentgesamtnote = 0;
$counter = 0;
$gewichte = 0;
@@ -72,74 +114,129 @@ class studentnote
$note_x_gewicht = 0;
$note_x_gewicht_l1 = 0;
$gewichte_l1 = 0;
$fehlt = false;
$fehlt = false;
$beispiele = false;
$punkte_gesamt = 0;
$punkte_mitarbeit = 0;
$punkte_eingetragen = 0;
$l1_gewicht = 0;
$ueb1 = new uebung($conn, $uebung_id);
$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)
$ueb_obj = new uebung($conn);
$ueb_obj->load_uebung($lehreinheit_id, 2, $uebung_id);
if ($ueb_obj->uebungen)
{
$note_x_gewicht = 0;
$gewichte = 0;
$punkte_gesamt = 0;
foreach ($ueb_obj->uebungen as $ueb)
{
$note_x_gewicht = 0;
$gewichte = 0;
foreach ($ueb_obj->uebungen as $ueb)
{
if ($this->calc_note($ueb->uebung_id,$student_uid))
if ($ueb->abgabe)
{
if ($this->calc_note($ueb->uebung_id, $student_uid))
{
if (is_numeric($this->note))
{
if ($ueb->positiv && $this->note == 5)
$negativ = true;
$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;
{
$fehlt = true;
if ($ueb->positiv)
$negativ = true;
}
}
}
else
$fehlt = true;
{
$this->calc_punkte($ueb->uebung_id, $student_uid);
$punkte_gesamt += $this->punkte_gesamt;
$punkte_mitarbeit += $this->punkte_mitarbeit;
$punkte_eingetragen += $this->punkte_eingetragen;
$beispiele = true;
}
}
if ($gewichte > 0)
{
$l1_note = ($note_x_gewicht / $gewichte);
$l1_gewicht = $ueb1->gewicht;
}
//if ($punkte_gesamt > 0)
if ($beispiele)
{
$qry = "SELECT min(note) as note from campus.tbl_notenschluesseluebung where punkte <= '".$punkte_gesamt."' and uebung_id = '".$ueb1->uebung_id."'";
if($result=pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
$note = $row->note;
else
$note = 5;
}
if ($ueb1->positiv && ($note == 5))
$negativ = true;
$l1_note = ($note * $ueb1->gewicht);
$l1_gewicht = $ueb1->gewicht;
}
if ($ueb1->positiv && $beispiele && ($punkte_gesamt == 0))
$negativ = true;
//else if ($beispiele && ($punkte_gesamt == 0))
// $felt = true;
}
// 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;
$l1_note= $s->note;
$l1_gewicht = $ueb1->gewicht;
}
else
{
$fehlt = true;
if ($ueb1->positiv)
$negativ = true;
}
}
if ($gewichte_l1 > 0)
{
$this->studentgesamtnote = ($note_x_gewicht_l1 / $gewichte_l1);
if ($l1_gewicht > 0)
{
$this->l1_note = $l1_note;
$this->l1_gewicht = $l1_gewicht;
$this->negativ = $negativ;
$this->fehlt = $fehlt;
$this->punkte_gesamt_l1 = $punkte_gesamt;
$this->punkte_eingetragen_l1 = $punkte_eingetragen;
$this->punkte_mitarbeit_l1 = $punkte_mitarbeit;
}
else
{
$this->studentgesamtnote = "n";
$this->l1_note = null;
$this->l1_gewicht = 0;
$this->negativ = $negativ;
$this->fehlt = $fehlt;
$this->punkte_gesamt_l1 = null;
$this->punkte_eingetragen_l1 = null;
$this->punkte_mitarbeit_l1 = null;
}
}
}
}
// *********************************************************
// * berechnet die gesamtnote der übung
// * @param uebung_id, student_uid
// * berechnet die note der übung
// * @param uebung_id, student_uid
// * setzt this->note, this->gewicht
// *********************************************************
function calc_note($uebung_id, $student_uid)
{
@@ -156,8 +253,42 @@ class studentnote
$mitarbeit = 0;
$ueb = new uebung($this->conn);
$ueb->load($uebung_id);
if ($ueb->beispiele)
{
if($ueb->load_studentuebung($student_uid, $uebung_id))
{
$this->note = $ueb->note;
$this->gewicht = $ueb->gewicht;
return true;
}
else
{
$this->note = null;
$this->gewicht = 0;
return true;
}
}
}
// *********************************************************
// * berechnet die punkte der übung (kreuzerlliste)
// * @param uebung_id, student_uid
// * setzt this->punkte_gesamt
// *********************************************************
function calc_punkte($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);
//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;
@@ -171,35 +302,12 @@ class studentnote
$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;
$this->punkte_gesamt = $punkte_gesamt;
$this->punkte_eingetragen = $punkte_eingetragen;
$this->punkte_mitarbeit = $mitarbeit;
return true;
}
else
{
if($ueb->load_studentuebung($student_uid, $uebung_id))
{
$this->note = $ueb->note;
$this->gewicht = $ueb->gewicht;
return true;
}
else
{
$this->note = null;
return true;
}
}
}
}
}
}
?>
+135 -3
View File
@@ -57,7 +57,13 @@ class uebung
var $note; // smalint
var $mitarbeitspunkte; // smalint
var $anmerkung; // text
var $benotungsdatum; // timestamp
var $benotungsdatum; // timestamp
//Abgabe
var $abgabe_abgabe_id; // integer
var $abgabedatei; // varchar(64)
var $abgabezeit; // timestamp
var $abgabe_anmerkung; // text
// *************************************************************************
// * Konstruktor - Uebergibt die Connection und laedt optional eine Uebung
@@ -173,6 +179,33 @@ class uebung
return false;
}
}
function load_abgabe($abgabe_id)
{
$qry = "SELECT * FROM campus.tbl_abgabe WHERE abgabe_id = '$abgabe_id'";
if($result = pg_query($this->conn, $qry))
{
if($row = pg_fetch_object($result))
{
$this->abgabe_id = $row->abgabe_id;
$this->abgabedatei = $row->abgabedatei;
$this->abgabezeit = $row->abgabezeit;
$this->anmerkung = $row->anmerkung;
return true;
}
else
{
$this->errormsg = 'Es gibt keinen passenden Eintrag';
return false;
}
}
else
{
$this->errormsg = 'Fehler beim Laden des Eintrages';
return false;
}
}
function check_studentuebung($uebung_id)
{
@@ -186,9 +219,9 @@ class uebung
return false;
}
else
return false;
return false;
}
function load_uebung($lehreinheit_id, $level=null, $uebung_id=null)
{
@@ -457,6 +490,67 @@ class uebung
return false;
}
}
function abgabe_save($new=null)
{
if(is_null($new))
$new = $this->new;
if($new)
{
$qry = 'INSERT INTO campus.tbl_abgabe(abgabedatei, abgabezeit, anmerkung) VALUES('.
$this->addslashes($this->abgabedatei).','.
$this->addslashes($this->abgabezeit).','.
$this->addslashes($this->abgabe_anmerkung).');';
}
else
{
$qry = 'UPDATE campus.tbl_abgabe SET'.
' abgabe_id='.$this->addslashes($this->abgabe_id).','.
' abgabedatei='.$this->addslashes($this->abgabedatei).','.
' abgabezeit='.$this->addslashes($this->abgabezeit).','.
' anmerkung='.$this->addslashes($this->abgabe_anmerkung).
" WHERE abgabe_id=".$this->addslashes($this->abgabe_id).";";
}
if(pg_query($this->conn,$qry))
{
if($new)
{
$qry = "SELECT currval('campus.tbl_abgabe_abgabe_id_seq') as id;";
if($result = pg_query($this->conn, $qry))
{
if($row=pg_fetch_object($result))
{
$this->abgabe_id = $row->id;
pg_query($this->conn, 'COMMIT');
return true;
}
else
{
$this->errormsg = 'Fehler beim Auslesen der Sequence';
pg_query($this->conn,'ROLLBACK');
return false;
}
}
else
{
$this->errormsg = 'Fehler beim Auslesen der Sequence';
pg_query($this->conn,'ROLLBACK');
return false;
}
}
else
return true;
}
else
{
$this->errormsg = 'Fehler beim Speichern der StudentUebung';
return false;
}
}
// ************************************************************
// * Loescht eine Uebung plus die abhaengigen eintraege in den
@@ -521,5 +615,43 @@ class uebung
}
// ************************************************************
// * Loescht eine Uebung plus die abhaengigen eintraege in den
// * Tabellen studentuebung, studentbeispiel, und beispiel
// ************************************************************
function delete_abgabe($abgabe_id)
{
if(!is_numeric($abgabe_id))
{
$this->errormsg = 'abgabe_id ist ungueltig';
return false;
}
// subübungen wegräumen
$qry = "SELECT * FROM campus.tbl_abgabe WHERE abgabe_id = '".$abgabe_id."'";
if($result=pg_query($this->conn, $qry))
{
while($row = pg_fetch_object($result))
{
if(file_exists(BENOTUNGSTOOL_PATH."abgabe/".$row->abgabedatei))
unlink(BENOTUNGSTOOL_PATH."abgabe/".$row->abgabedatei);
$qry = "UPDATE campus.tbl_studentuebung set abgabe_id = null where abgabe_id = '$abgabe_id';
DELETE FROM campus.tbl_abgabe WHERE abgabe_id = '$abgabe_id'";
if(!pg_query($qry))
{
$this->errormsg = 'Fehler beim Loeschen der Daten';
return false;
}
else
return true;
}
}
}
}