SCHLARB

Eine selbstaufrufende PHP-Datei zur Berechnung einer Notenstatistik nach Schularbeiten.

Sourcecode von SCHLARB:

<body bgcolor="#CCCCCC">
<?php
$_sum = 0;
$_av = 0;
$_sd = 0;
if(isset($_POST['btn_schick']))
{
$_n = $_POST['txt_note'];

// Summe
for($i=0;$i<5;$i++)
{
$_sum += $_n[$i];
}

//Durchnschnitt und Standardabweichung
if($_sum!=0)
{
for($i=0;$i<5;$i++)
{
$_av += ($i+1)* $_n[$i];
}
$_av = $_av/$_sum;
for($i=0;$i<5;$i++)
{
$_sd += ($_n[$i])* pow($i+1-$_av,2);
}
$_sd = sqrt($_sd/$_sum);
$_av = round($_av,2);
$_sd = round($_sd,2);
}
}
?>
<form name="form1" method="post" action="schlarb.php">
<table width="400" border="0" align="center" cellpadding="3" cellspacing="5" bordercolor="#666666" bgcolor="#999999">
<tr>
<td colspan="2" bgcolor="#336699"> <div align="center">
<p><strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">SCHLARB</font></strong></p>
</div></td>
</tr>
<tr>
<td colspan="2"> <div align="center"><em><font color="#CCCCCC" size="-1" face="Verdana, Arial, Helvetica, sans-serif">Bitte
die Notenh&auml;ufigkeiten eintragen:</font></em></div></td>
</tr>
<tr>
<td width="50%"> <div align="right"><strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">Sehr
gut:</font></strong></div></td>
<td width="159"> <strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">
<input name="txt_note[]" type="text" id="txt_note[]">
</font></strong></td>
</tr>
<tr>
<td width="50%"> <div align="right"><strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">Gut:</font></strong></div></td>
<td> <strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">
<input name="txt_note[]" type="text" id="txt_note[]">
</font></strong></td>
</tr>
<tr>
<td width="50%"> <div align="right"><strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">Befriedigend:</font></strong></div></td>
<td> <strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">
<input name="txt_note[]" type="text" id="txt_note[]">
</font></strong></td>
</tr>
<tr>
<td width="50%"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">Gen&uuml;gend:</font></strong></font></div></td>
<td> <strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">
<input name="txt_note[]" type="text" id="txt_note[]">
</font></strong></td>
</tr>
<tr>
<td width="50%"> <div align="right"><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font color="#CCCCCC">Nicht
gen&uuml;gend:</font></strong></font></div></td>
<td> <strong><font color="#CCCCCC" face="Verdana, Arial, Helvetica, sans-serif">
<input name="txt_note[]" type="text" id="txt_note[]">
</font></strong></td>
</tr>
<tr>
<td width="50%">&nbsp;</td>
<td><font color="#CCCCCC">&nbsp;</font></td>
</tr>
<tr>
<td width="50%"> <div align="center">
<input name="btn_zurueck" type="reset" id="btn_zurueck" value="Zur&uuml;cksetzen">
</div></td>
<td> <div align="center">
<input name="btn_schick" type="submit" id="btn_schick" value="Abschicken">
</div></td>
</tr>
<tr>
<td width="50%"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCCC">Anzahl:</font></b></div></td>
<td><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCCC">
<?php
if(isset($_POST['btn_schick']))
{
echo $_sum;
}
?>
</font></b></td>
</tr>
<tr>
<td width="50%"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCCC">Durchschnitt:</font></b></div></td>
<td><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCCC">
<?php
if(isset($_POST['btn_schick']))
{
echo $_av;
}
?>
</font></b></td>
</tr>
<tr>
<td width="50%" height="25"> <div align="right"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCCC">
Standardabweichung: </font></b></div></td>
<td><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#CCCCCC">
<?php
if(isset($_POST['btn_schick']))
{
echo $_sd;
}
?>
</font></b></td>
</tr>
</table>

</form>
</body>

 

<<zurück>>