Location: PHPKode > projects > LAMP School > valutazioni/val.php
<?php
 
 @include("../php-ini.php");
 @include("../funzioni.php");
    
 // istruzioni per tornare alla pagina di login se non c'è una sessione valida
 session_start();   
 $tipoutente=$_SESSION["tipoutente"]; //prende la variabile presente nella sessione
    if ($tipoutente=="")
       {
          header("location: ../login/login.php"); 
          die;
       } 


$nome=$_POST['ComboBox'];
$but=$_POST['visass'];
$giorno=$_POST['gio'];
$mese=$_POST['mese'];
$anno=$_POST['anno'];
$tipo=$_POST['tipo'];
$materia=$_POST['materia'];
$id_ut_doc = $_SESSION["idutente"];


//
//    Parte iniziale della pagina
//

print ('
<html>
<head>
</head>');

$menu='<a href="../login/ele_ges.php">PAGINA PRINCIPALE</a> - GESTIONE VOTI';
stampa_testata("$menu","$bgcolor_titolo","$nome_scuola","$comune_scuola");

//
//    Fine parte iniziale della pagina
//

     $con=mysql_connect("$db_server","$db_user","$db_password") or die ("Errore durante la connessione: ".mysql_error());
          mysql_select_db("registro",$con) or die("Errore durante la selezione del database: ".mysql_error());
print ('
   <form method="post" action="val.php">
   
   <p align="center">
   <table align="center">

      <tr>
      <td width="50%"><b>Data (gg/mm/aaaa)</b></td>
      <td width="50%">
       <input type="text" name="gio" size="2" maxlength="2" ');
    if ($giorno!='')
       echo ('value="'.$giorno.'"');    
    echo('>/<input type="text" name="mese" size="2" maxlength="2" ');
    if ($mese!='')
       echo ('value="'.$mese.'"');    
    echo('>/<input type="text" name="anno" size="4" maxlength="4" ');
    if ($anno!='')
       echo ('value="'.$anno.'"');
    echo('>        
      </td></tr>
      <tr>
          <td><b>Tipo voto</b>
          </td>
          <td span>
          <SELECT ID ="tipo" NAME="tipo">
              <option value="S"');
                   if ($tipo=="S") echo ' selected';
              echo '>Scritto';

              echo '<option value="O"';
                   if ($tipo=="O") echo ' selected';
              echo '>Orale';

              echo '<option value="P"';
                   if ($tipo=="S") echo ' selected';
              echo '>Pratico';

     echo('</select>
          
          </td>
          
      </tr>');
      //
      //   Leggo il nominativo del docente e lo visualizzo
      //
      $query="select iddocente, cognome, nome from docenti where idutente=$id_ut_doc";
          $ris=mysql_query($query,$con);
          if($nom=mysql_fetch_array($ris))
          {
             $iddocente=$nom["iddocente"];
             $cognomedoc=$nom["cognome"];
             $nomedoc=$nom["nome"];
             $nominativo =$nomedoc." ".$cognomedoc;  
          }
             
      print("    
             <tr>
              <td><b>Docente</b></td>

          <td>
          <INPUT TYPE='text' VALUE='$nominativo' disabled>
          <input type='hidden' value='$iddocente' name='iddocente'>
          </td></tr>");

   //
   //   Classi
     //

   print('
   <tr>
      <td width="50%"><b>Classe</b></p></td>
      <td width="50%">
      <SELECT ID="ComboBox" NAME="ComboBox">  '); 
      
  
       

          //
          //  Riempimento combobox delle classi
          //
          $query="select distinct classi.idclasse,anno,sezione,specializzazione from classi,cattedre where classi.idclasse=cattedre.idclasse and iddocente=$iddocente order by anno,sezione,specializzazione";
          $ris=mysql_query($query,$con);
          while($nom=mysql_fetch_array($ris))
          {
            print "<option value='";
            print ($nom["idclasse"]);
            print "'";
            if ($nome==$nom["idclasse"])
               print " selected";
            print ">";
            print ($nom["anno"]);
            print "&nbsp;"; 
            print($nom["sezione"]); 
            print "&nbsp;";
            print($nom["specializzazione"]);
          }
        
   echo('
      </SELECT>
      </td></tr>');


    
    //
    //    Leggo le materie e le visualizzo
    //
    


    print ('<tr><td><b>Materia</b>');

    print ('</td><td><SELECT ID="materia" NAME="materia">');

    $query="select distinct cattedre.idmateria, denominazione from cattedre, materie where cattedre.idmateria=materie.idmateria and iddocente=$iddocente order by denominazione";
    $ris=mysql_query($query,$con);
    while($nom=mysql_fetch_array($ris))
    {
       print "<option value=";
       print ($nom["idmateria"]);
       print ">";
       print ($nom["denominazione"]);
    }
    print("</select></td></tr>");
    echo('
      
    </table>
 
    <table align="center">
      <td>
        <p align="center"><input type="submit" value="Visualizza voti" name="b"></p>
     </form></td>
   
</table><hr>
 
    ');

  if ($mese=="")
     $m=0;
  else
     $m=$mese; 
  if ($giorno=="") 
     $g=0;
  else
     $g=$giorno; 

  if ($anno=="") 
     $a=0;
  else
     $a=$anno; 
  
  if (($nome!="")&&(checkdate($m,$g,$a)))
  {
   $idclasse=$nome;
   $classe="";
   $con=mysql_connect("$db_server","$db_user","$db_password") or die ("Errore durante la connessione: ".mysql_error());
   mysql_select_db("$db_nome",$con) or die("Errore durante la selezione del database: ".mysql_error());
   
   $query='select * from classi where idclasse="'.$idclasse.'" ';
   $ris=mysql_query($query,$con) or die ("Errore nella query: ". mysql_error());
   if($val=mysql_fetch_array($ris))
      $classe=$val["anno"]." ".$val["sezione"]." ".$val["specializzazione"];

   $query='select * from alunni where idclasse="'.$idclasse.'" order by cognome,nome';
   $ris=mysql_query($query,$con) or die ("Errore nella query: ". mysql_error());


   $c=mysql_fetch_array($ris);
   if ($c==NULL) {echo '
                    <p align="center">
            <font size=4 color="black">Nessun record presente nella classe '.$classe.'</font>
               '; exit;
               }

  echo '<p align="center">
        <font size=4 color="black">Alunni della classe '.$classe.'</font>
        <form method="post" action="insval.php">
        <table border=2 align="center">';
  echo'
   <tr bgcolor="'.$bgcolor_titolo.'">
          
          <td><b> Cognome </b></td>
          <td><b> Nome  </b></td>
          <td><b> Data di nascita </b></td>
          <td><b> Voto e giudizio  </b></td>
   </tr>
  ';
 

 $query='select * from alunni where idclasse="'.$idclasse.'" order by cognome,nome';
 $ris=mysql_query($query,$con) or die ("Errore nella query: ". mysql_error());
 while($val=mysql_fetch_array($ris))
  {
   $esiste_voto=false;
   echo ' 
        <tr>
          
          <td><b> '.$val["cognome"].' </b></td>
          <td><b> '.$val["nome"].'    </b></td>
          <td><b> '.$val["datanascita"].' </b></td> ';
         // Codice per ricerca voti già inseriti
                $queryval='select * from valutazioniintermedie where idalunno = '.$val["idalunno"].' and data = "'.$anno.'-'.$mese.'-'.$giorno.'" and tipo = "'.$tipo.'" and idmateria="'.$materia.'" ';
                $risval=mysql_query($queryval,$con) or die ("Errore nella query: ". mysql_error());
                if ($valval=mysql_fetch_array($risval))
                {
                    $esiste_voto = true;
                    $voto = $valval["voto"];
                    $giudizio = $valval["giudizio"];
                }

            // Fine codice per ricerca voti già inseriti
    if ($esiste_voto)
    {
        echo '<td>
          <select name="voto'.$val["idalunno"].'"><option value=99>&nbsp;';
        if ($voto==0) echo '<option value=0 selected>0'; else echo '<option value=0>';
        if ($voto==0.25) echo '<option value=0.25 selected>0+'; else echo '<option value=0.25>0+';
        if ($voto==0.5) echo '<option value=0.5 selected>0%'; else echo '<option value=0>0%';
        if ($voto==0.75) echo '<option value=0.75 selected>1-'; else echo '<option value=0.75>1-';
        if ($voto==1) echo '<option value=1 selected>1'; else echo '<option value=1>1';
        if ($voto==1.25) echo '<option value=1.25 selected>1+'; else echo '<option value=1.25>1+';
        if ($voto==1.5) echo '<option value=1.5 selected>1%'; else echo '<option value=1.5>1%';
        if ($voto==1.75) echo '<option value=1.75 selected>2-'; else echo '<option value=1.75>2-';
        if ($voto==2) echo '<option value=2 selected>2'; else echo '<option value=2>2';
        if ($voto==2.25) echo '<option value=2.25 selected>2+'; else echo '<option value=2.25>2+';
        if ($voto==2.5) echo '<option value=2.5 selected>2%'; else echo '<option value=2.5>2%';
        if ($voto==2.75) echo '<option value=2.75 selected>3-'; else echo '<option value=2.75>3-';
        if ($voto==3) echo '<option value=3 selected>3'; else echo '<option value=3>3';
        if ($voto==3.25) echo '<option value=3.25 selected>3+'; else echo '<option value=3.25>3+';
        if ($voto==3.5) echo '<option value=3.5 selected>3%'; else echo '<option value=3.5>3%';
        if ($voto==3.75) echo '<option value=3.75 selected>4-'; else echo '<option value=3.75>4-';
        if ($voto==4) echo '<option value=4 selected>4'; else echo '<option value=4>4';
        if ($voto==4.25) echo '<option value=4.25 selected>4+'; else echo '<option value=4.25>4+';
        if ($voto==4.5) echo '<option value=4.5 selected>4%'; else echo '<option value=4.5>4%';
        if ($voto==4.75) echo '<option value=4.75 selected>5-'; else echo '<option value=4.75>5-';
        if ($voto==5) echo '<option value=5 selected>5'; else echo '<option value=5>5';
        if ($voto==5.25) echo '<option value=5.25 selected>5+'; else echo '<option value=5.25>5+';
        if ($voto==5.5) echo '<option value=5.5 selected>5%'; else echo '<option value=5.5>5%';
        if ($voto==5.75) echo '<option value=5.75 selected>6-'; else echo '<option value=5.75>6-';
        if ($voto==6) echo '<option value=6 selected>6'; else echo '<option value=6>6';
        if ($voto==6.25) echo '<option value=6.25 selected>6+'; else echo '<option value=6.25>6+';
        if ($voto==6.5) echo '<option value=6.5 selected>6%'; else echo '<option value=6.5>6%';
        if ($voto==6.75) echo '<option value=6.75 selected>7-'; else echo '<option value=6.75>7-';
        if ($voto==7) echo '<option value=7 selected>7'; else echo '<option value=7>7';
        if ($voto==7.25) echo '<option value=7.25 selected>7+'; else echo '<option value=7.25>7+';
        if ($voto==7.5) echo '<option value=7.5 selected>7%'; else echo '<option value=7.5>7%';
        if ($voto==7.75) echo '<option value=7.75 selected>8-'; else echo '<option value=7.75>8-';
        if ($voto==8) echo '<option value=8 selected>8'; else echo '<option value=8>8';
        if ($voto==8.25) echo '<option value=8.25 selected>8+'; else echo '<option value=8.25>8+';
        if ($voto==8.5) echo '<option value=8.5 selected>8%'; else echo '<option value=8.5>8%';
        if ($voto==8.75) echo '<option value=8.75 selected>9-'; else echo '<option value=8.75>9-';
        if ($voto==9) echo '<option value=9 selected>9'; else echo '<option value=9>9';
        if ($voto==9.25) echo '<option value=9.25 selected>9+'; else echo '<option value=9.25>9+';
        if ($voto==9.5) echo '<option value=9.5 selected>9%'; else echo '<option value=9.5>9%';
        if ($voto==9.75) echo '<option value=9.75 selected>10-'; else echo '<option value=9.75>10-';
        if ($voto==10) echo '<option value=10 selected>10'; else echo '<option value=10>10';
         echo '</select>&nbsp
          <input type="text" size=20 maxlength=50 name="giudizio'.$val["idalunno"].'" value="'.$giudizio.'">
          </td></tr>';

    }
    else
    {
    echo '<td>
          <select name="voto'.$val["idalunno"].'"><option value=99>&nbsp;
          <option value=0>0
          <option value=0.25>0+
          <option value=0.5>0%
          <option value=0.75>1-
          <option value=1>1
          <option value=1.25>1+
          <option value=1.5>1%
          <option value=1.75>2-
          <option value=2>2
          <option value=2.25>2+
          <option value=2.5>2%
          <option value=2.75>3-
          <option value=3>3
          <option value=3.25>3+
          <option value=3.5>3%
          <option value=3.75>4-
          <option value=4>4
          <option value=4.25>4+
          <option value=4.5>4%
          <option value=4.75>5-
          <option value=5>5
          <option value=5.25>5+
          <option value=5.5>5%
          <option value=5.75>6-
          <option value=6>6
          <option value=6.25>6+
          <option value=6.5>6%
          <option value=6.75>7-
          <option value=7>7
          <option value=7.25>7+
          <option value=7.5>7%
          <option value=7.75>8-
          <option value=8>8
          <option value=8.25>8+
          <option value=8.5>8%
          <option value=8.75>9-
          <option value=9>9
          <option value=9.25>9+
          <option value=9.5>9%
          <option value=9.75>10-
          <option value=10>10
          </select>&nbsp;
          <input type="text" size=20 maxlength=50 name="giudizio'.$val["idalunno"].'">
          </td></tr>';
    }
  
  }
    echo'</table>';
 

 echo'
  <table align="center">
  <tr>
       
   </tr>
   </table>
    <p align="center"><input type=submit name=b value="Inserisci voti">
    <p align="center"><input type=hidden value='.$idclasse.' name=cl>
    <p align="center"><input type=hidden value='.$giorno.' name=gio>
    <p align="center"><input type=hidden value='.$mese.' name=mese>
    <p align="center"><input type=hidden value='.$anno.' name=anno>
    <p align="center"><input type=hidden value='.$materia.' name=materia>
    <p align="center"><input type=hidden value='.$tipo.' name=tipo>
    <p align="center"><input type=hidden value='.$iddocente.' name=iddocente>
  </form>';


} 


stampa_piede("$bgcolor_titolo"); 
?>
Return current item: LAMP School