Location: PHPKode > projects > MyPHPSchool > MyPHPSchool-0.3.1/html/gradebook/showgradebook.php
<?
//Basmati -- Version 2.0P
//Copyright 2000, James B. Bassett (hide@address.com)
//All rights reserved.  Please read enclosed license.
//Module:  showgradebook.php

include("../main.inc.php");

list($ulvl, $loggedin) = check_auth();
$type = $cookie_type;
	if(($ulvl < 10)){
		print_header("Error");
		echo "Sorry You Do Not have a High Enough User Level to use this page";
		print_footer();
		exit;
	}
print_header("Gradebook:Detail");
	if(($ulvl >= "10") && ($ulvl < "25")){
		$sql = "SELECT * FROM user_$type WHERE username = '$cookie_user'";  //Make SQL
		$result = mysql_query($sql, $db);  //Execute SQL
		$myrow = mysql_fetch_array($result);
		$CurrentSID = $myrow["sid"]; 
		} else {
		$CurrentSID = $sid;
  		}
  $school = "Mead";
  $sid = intval($CurrentSID); 
  //check for invalid student ID
  if (intval($sid)<=0){
   echo("Invalid Student ID");
   exit;
  }
  
  
 //determine school...
  $sql_query = "SELECT * from SCHOOLS where school_id = '" . $school ."'";
   //echo $sql_query;
  $sql_query = "SELECT * from COURSEINFO inner join GMSCORES on COURSEINFO.cc = GMSCORES.cc where GMSCORES.sid = "  . $sid. " and GMSCORES.schoolid = '" . $school . "' and GMSCORES.cc = '" . $cc . "';";
  $mysql_query = "SELECT COURSEINFO.cc as cc, COURSEINFO.coursename as coursename, COURSEINFO.facultyname as facultyname,
                 COURSEINFO.modified as 'modified', GMSCORES.grade as grade, GMSCORES.percent as percent, COURSEINFO.email as email,
                 COURSEINFO.assignlist as assignlist, COURSEINFO.ealr as ealr,GMSCORES.scores as scores, COURSEINFO.assignvals as assignvals, COURSEINFO.phone as phone,
                 COURSEINFO.misc as misc
                 FROM COURSEINFO left join GMSCORES on COURSEINFO.cc = GMSCORES.cc and COURSEINFO.schoolid = GMSCORES.schoolid where GMSCORES.cc = '$cc' and GMSCORES.sid = "  . $sid. " and GMSCORES.schoolid = '" . $school . "' order by GMSCORES.cc;";


  // echo $mysql_query;
  // echo $sql_query;
  $sql_result = mysql_query($mysql_query,$db);
  echo mysql_error($db);
  if (mysql_num_rows($sql_result)!=0){  
    $nfields = mysql_num_fields($sql_result);
    for($r==0;$r<mysql_num_rows($sql_result);$r++){
     $nrows++;     
     for ($i=0;$i<$nfields;$i++){
       $fieldname = mysql_field_name($sql_result,$i);
       $fieldvalu = mysql_result($sql_result,$r,mysql_field_name($sql_result,$i));
       $grade_array[$fieldname][$nrows]=$fieldvalu;
       $hyperlink = mysql_result($sql_result,0,email);
       if (!eregi("http://",$hyperlink)){
        $hyperlink = "mailto:" . $hyperlink . "@mead.k12.wa.us";
       }
       $grade_array["email"][$i] = $hyperlink;

     } // for $i    
    } //for $r
    mysql_free_result($sql_result);
   }//If numrows != 0
   $row_n = $nrows;




//Explode COURSEINFO.assignlist, COURSEINFO.assignvals, COURSEINFO.ealr and GMSCORES.scores
  
  $assign_names = explode(chr(169),stripslashes($grade_array[assignlist][1]));
  $assign_vals = explode(chr(169),$grade_array[assignvals][1]);
  $ealr_names = explode(chr(169),$grade_array[ealr][1]);
  $student_scores = explode(chr(169),$grade_array[scores][1]);
  $nrows = count($assign_names);


//Start drawing page...
  echo("<font size=+2 color=black>");
  echo("<center><b>Detailed Gradebook Report for $sid</b><p>");



// Show contact Information
// Process any Misc 3 tags...
   if (eregi("-mail",$grade_array[misc][1])){
     $hlink = $grade_array[facultyname][1];
    } else{
     $hlink = "<a href=$hyperlink>".$grade_array[facultyname][1]."</a>";
    }
    if (eregi("-percent",$grade_array[misc][1])){
      $grade_array[percent][1] = " ";
    } else {
      $grade_array[percent][1] = "Percent: " . $grade_array[percent][1] . "% -- ";
    }     

  echo("<blockquote><center>");
  echo("<font size=+1>". $grade_array[coursename][1]."</font></font><br>");
  echo("$hlink<br>");
  echo("Phone:  ".$grade_array[phone][1]."<br>");
  echo("Last Updated: ".$grade_array[modified][1]."<p>");
  echo("<font size = +1>" . $grade_array[percent][1] . "</font>");
  echo("<font size = +1>  Grade: " . $grade_array[grade][1]."</font><p>");
   

  
  

//Now that we have an array, cycle through and create table... (independent of database)

  echo("<center>");                                                                                                                                         
  echo("<table border=1 ><tr>");
  echo("<td><b>Assignment</b></td><td><b>Your Score</b></td><td><b>Points <br>Possible</b></td>");
  if (!eregi("-misc",$grade_array[misc][1])){
    echo("<td><b>Misc.</b></td>");
  }
  echo("</tr>");

    
  for ($i = 0; $i < $nrows-1 ;$i++){
    echo("<tr>");
    echo("<td border=1>" . $assign_names[$i] . "</td>");
    echo("<td border=1>" . AddStarofDeath($student_scores[$i]) . "</td>");
    echo("<td border=1>" . $assign_vals[$i] . "</td>");
    if (!eregi("-misc",$grade_array[misc][1])){
       echo("<td border=1>" . ParseStandards($ealr_names[$i],$grade_array[misc][1]) . "</td>"); //process standards      
    }
    echo("</tr>");
  }
  echo ("</table>");
  echo ("</center></blockquote>");

 echo "<table border = 0><tr><td width=100></td><td width=*>";
 echo "<p><hr><b>Disclaimer:</b>  The scores contained in the table above may be weighted.  ";
 echo "It is not usually possible to simply add the number of points earned and divide ";
 echo "by the total number of points when scores are weighted.  The scores presented in ";
 echo "this table are for information only.<p>";
 echo "An asterisk (<font color=red>*</font>) indicates that this score is missing from the teacher's grade book.  Most likely this indicates ";
 echo "that the assignment was never turned into the teacher.  However, in rare occasions it may ";
 echo "also indicate that this assignment was not intended to be graded.";
 echo "<p>";
 echo "<br>";
 echo "</td></tr></table>";






function AddNA($string){
 if (trim($string) == ""){
   return "N/A";
 } else {
   return $string;
 }
}

function AddStarofDeath($string){
 if (trim($string) == ""){
   return "<font color=red ><b>*</b></font>";
 } else {
   return $string;
 }
}
 
function ParseStandards($standardtext,$processcode){
//process the EALRS 
 if (eregi("standard",$processcode)){
  //explode by commas...
  $newtext = "";
  $stands = explode(",",$standardtext);
  $nealr = count($stands);
  //determine state...
  $stateloc = strpos(strtoupper($processcode),"STANDARD:");
  $statecode = substr(strtolower($processcode),$stateloc+9,2);
  

   for ($j=0;$j < $nealr; $j++){
     $fullref = $stands[$j];     
     $page = "";
     $ref = "";
     $component = split(" ",trim($fullref),2);
     $page = $component[0];
     $ref = $component[1]; 
     if (trim($page)!=""){   
      $link = "<a href=http://basmati.esd189.org/standards/". $statecode. "/". strtolower(trim($page)) . ".htm#" . trim($ref).">$page $ref</a> ";
     }
     $newtext = $newtext."  ".$link;
   }
  
  

                              
  return(AddNA($newtext ));
 }
 //don't process the EALRS
 if (!eregi("standard",$processcode)){
  return(AddNA($standardtext));
 }
 
 
}


?>

Return current item: MyPHPSchool