View site source code
index.php | header.inc | leftside.inc | rightside.inc | footer.inc | style.css | Account tools | Logout page | Email page | Create account | File upload | Schedule | View code | Forgot password | View homework | Project details | Monthly Poll Form Ajax files => Display uploads | Change password | Create account | Login code | New password | Send email | View comments | Display HW | Show grades | Display assigns | show_poll_results.php
Source code of show_grades_ajax.php
<?php
session_start();
?>
<script type="text/javascript">
$("document").ready(function() {
$(".show_link").click(function() {
var href = $(this);
var id = $(this).attr("id").substring(6);
if( href.html() == "view comment" )
{
$.ajax( {
url: "ajax_files/view_comment_ajax.php",
type: "POST",
data: "comment_id=" + id,
success: function(msg) {
$("#feature_" + id).html(msg);
$("#feature_" + id).show('blind');
href.html("hide comment");
}
} );
}
else
{
$("#feature_" + id).hide('blind');
href.html("view comment");
}
} );
var useridnum = <?php echo $_SESSION[ 'idnum' ]; ?>;
$.ajax( {
url: "ajax_files/show_ups_ajax.php",
type: "POST",
data: "idnum=" + useridnum + "&caller=viewproj" + "&assigntype=2",
success: function(msg) {
$( "div#projects_div" ).html( msg );
}
} );
} );
</script>
<?php
if( isset( $_POST['idnum'] ) )
{
echo "<div class=\"featurebox_center\">";
require_once( '../main_includes/.htpasswd' );
$weight_query = "select * from grade_weights where course_id=";
$weight_query .= "(select course from auth where idnum=". mysql_real_escape_string( $_POST['idnum'] ) .")";
$weight_result = mysql_query( $weight_query )
or die( 'Could not connect: '. mysql_error() );
$weight_row = mysql_fetch_row( $weight_result );
if( $_POST['caller'] == "viewgrade" || $_POST['caller'] == "admin" )
{
$type_query = "select type from courses where idnum=";
$type_query .= "(select course from auth where idnum=". mysql_real_escape_string( $_POST['idnum'] ) .")";
$type_result = mysql_query( $type_query )
or die( 'Could not connect: '. mysql_error() );
$type_row = mysql_fetch_row( $type_result );
if( $type_row[0] == "c" )
{
// show homework grade
echo "<div class=\"featurebox_center\">";
echo "<h4>Homework grade ( ". $weight_row[2] ."% of final grade )</h4>\n";
$hw_query = "select idnum from master_assigns where coursenum=";
$hw_query .= "(select course from auth where idnum=". mysql_real_escape_string( $_POST['idnum'] ) .")";
$hw_query .= " and assign_type=1 and assign_stamp <= ". time() ." order by idnum";
$hw_result = mysql_query( $hw_query )
or die( 'Could not connect: '. mysql_error() );
if( mysql_num_rows( $hw_result ) != 0 )
{
$complete_assigns = 0;
for( $hw = 0 ; $hw < mysql_num_rows( $hw_result ); $hw++ )
{
$hw_row = mysql_fetch_row( $hw_result );
$complete_hw_query = "select status from homework where assign_id=". $hw_row[0];
$complete_hw_query .= " and studentid=". mysql_real_escape_string( $_POST['idnum'] ) ." order by idnum desc" ;
$complete_hw_result = mysql_query( $complete_hw_query )
or die( 'Could not connect: '. mysql_error() );
if( mysql_num_rows( $complete_hw_result ) != 0 )
{
$complete_hw_row = mysql_fetch_row( $complete_hw_result );
if( $complete_hw_row[0] == 2 )
$complete_assigns++;
}
}
if( mysql_num_rows( $hw_result ) > 0 )
{
if( mysql_num_rows( $hw_result ) == 1 && $complete_assigns == 1 )
{
echo "There has been <span style=\"color:#603311\">1</span> homework assignment";
echo " as of ". date( 'm/d/y') ." which you have completed<br />";
}
else
{
echo "There have been <span style=\"color:#603311\">". mysql_num_rows( $hw_result ) ."</span> homework assignments";
echo " as of ". date( 'm/d/y') ." of which you have completed <span style=\"color:#603311\">". $complete_assigns ."</span><br />";
}
}
$assign_percent = round( $complete_assigns * ( 100 / mysql_num_rows( $hw_result ) ) );
echo "<font color=\"#603311\">Homework grade:</font> ";
if( $assign_percent >= 65 )
echo "<img src=\"img/check.gif\"> <font color=\"#397D02\">";
else
echo "<font color=\"#FF0000\">";
echo $assign_percent ."</font>\n";
}
else
{
echo "There have been 0 homework assignments either assigned nor/or graded as of ". date( 'm/d/y') ."<br />";
echo "<font color=\"#603311\">Homework grade: <img src=\"img/check.gif\"> <font color=\"#397D02\">100</font></font> ";
}
echo "</div>\n";
}
// show exam grades
echo "<div class=\"featurebox_center\">";
echo "<h4>Exam grades";
if( $type_row[0] == "c" )
echo " ( ". $weight_row[3] ."% of final grade )";
echo "</h4>\n";
$assign_query = "select * from master_assigns where coursenum=";
$assign_query .= "(select course from auth where idnum=". mysql_real_escape_string( $_POST['idnum'] ) .")";
$assign_query .= "and assign_type=3 order by idnum";
$assign_result = mysql_query( $assign_query )
or die( 'Could not connect: '. mysql_error() );
if( mysql_num_rows( $assign_result ) != 0 )
{
if( $type_row[0] == "m" )
$mat_grade_sum = 0;
echo "<div style=\"margin-top:10px;margin-bottom:10px;\">";
echo "<table id=\"myTable\" cellspacing=\"0\" border=\"0\" width=\"80%\">\n";
echo "<thead>\n";
echo "<tr bgcolor=\"#4E7DD1\" text=\"#FFFFFF\">\n";
echo "<th><font color=\"#FFFFFF\">Exam</font></th>\n";
echo "<th><font color=\"#FFFFFF\">Exam date</font></th>\n";
echo "<th><font color=\"#FFFFFF\">Grade</font></th>\n";
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
for( $i = 0; $i < mysql_num_rows( $assign_result ); $i++ )
{
$assign_row = mysql_fetch_row( $assign_result );
if( $i % 2 != 0 )
echo "<tr>\n";
else
echo "<tr bgcolor=\"#F1F6FE\">\n";
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">". $assign_row[4] .":</td> ";
if( time() < $assign_row[6] )
{
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">Will be administered on ". date('m/d/y', $assign_row[6] ) ."</td>";
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">-------</td>";
}
else
{
if( ( $type_row[0] == "m" ) && ( $assign_row[3] == 1 ) )
{
echo "<td style=\"border-bottom:1px solid #CDCDCD;\"><font color=\"#603311\">Website account created";
$date_query = "select join_date from auth where idnum=". mysql_real_escape_string( $_POST['idnum'] );
$date_result = mysql_query( $date_query )
or die( 'Could not connect: '. mysql_error() );
$date_row = mysql_fetch_row( $date_result );
echo " (". date( 'm/d/y', $date_row[0] ) .")</font></td>\n";
}
else
echo "<td style=\"border-bottom:1px solid #CDCDCD;\"><font color=\"#603311\">Was administered on ". date('m/d/y', $assign_row[6] ) ."</font></td>";
$grade_query = "select * from master_grades where assign_id=". $assign_row[0];
$grade_query .= " and student_id=". mysql_real_escape_string( $_POST['idnum'] );
$grade_result = mysql_query( $grade_query )
or die( 'Could not connect: '. mysql_error() );
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">";
if( mysql_num_rows( $grade_result ) != 0 )
{
$grade_row = mysql_fetch_row( $grade_result );
if( $grade_row[3] >= 65 )
echo "<font color=\"#397D02\">";
else
echo "<font color=\"#FF0000\">";
echo $grade_row[3] ."</font>\n";
if( $type_row[0] == "m" )
$mat_grade_sum += $grade_row[3];
if( $grade_row[3] == 100 )
echo " ( <img src=\"img/check.gif\"> <font color=\"#397D02\">Excellent!</font> )\n";
if( $grade_row[3] >= 90 && $grade_row[3] < 100 )
echo " ( <img src=\"img/check.gif\"> <font color=\"#397D02\">Good job!</font> )\n";
if( $assign_row[7] == 1 )
echo " | <a href=\"index.php?location=grade_details&assign_id=". $assign_row[0] ."\" style=\"font-size:9px;\">View details</a>\n";
}
else
echo "Grade not posted yet\n";
echo "</td>";
echo "</tr>";
}
}
echo "</tbody>\n";
echo "</table>\n";
echo "</div>";
}
else
echo "There have been no exams either administered nor/or graded as of ". date('m/d/y');
echo "</div>\n";
if( $type_row[0] == "m" && mysql_num_rows( $assign_result ) > 0 )
{
echo "<div class=\"featurebox_center\">";
$mat_avg = round( $mat_grade_sum / mysql_num_rows( $assign_result ) );
echo "Your average as of ". date('m/d/y') ." is ";
if( $mat_avg >= 50 )
echo "<font color=\"#397D02\">";
else
echo "<font color=\"#FF0000\">";
echo $mat_avg;
if( $mat_avg >= 70 )
echo " (<img src=\"img/check.gif\"> Excellent, keep up the good work!)";
else
if( $mat_avg >= 50 )
echo " (<img src=\"img/check.gif\"> Good job!)";
else
echo " <img src=\"img/error.gif\">";
echo "</font><br />\n";
echo "So far, you have earned ";
if( $mat_avg >= 70 )
echo "<font color=\"#397D02\">2";
else
if( $mat_avg >= 50 )
echo "<font color=\"#397D02\">1";
else
echo "<font color=\"#FF0000\">0";
echo "</font> attempt(s) at the final exam for this course";
echo "</div>";
}
// show project grades
$c_query = "select course from auth where idnum=". $_POST['idnum'];
$c_result = mysql_query( $c_query );
$c_row = mysql_fetch_row( $c_result );
if( $type_row[0] == "c" && ( $c_row[0] != 100 && $c_row[0] != 200 ) )
{
echo "<div class=\"featurebox_center\">";
echo "<h4>Project grades ( ". $weight_row[4] ."% of final grade )</h4>\n";
echo "<div id=\"projects_div\" style=\"margin-top:10px;\"></div>\n";
}
// show quiz grades
if( $type_row[0] == "c" && ( $c_row[0] == 100 || $c_row[0] == 200 ) )
{
echo "<div class=\"featurebox_center\">";
echo "<h4>Quiz grades";
echo " ( ". $weight_row[5] ."% of final grade )";
echo "</h4>\n";
$assign_query = "select * from master_assigns where coursenum=";
$assign_query .= "(select course from auth where idnum=". mysql_real_escape_string( $_POST['idnum'] ) .")";
$assign_query .= "and assign_type=4 order by idnum";
$assign_result = mysql_query( $assign_query )
or die( 'Could not connect: '. mysql_error() );
if( mysql_num_rows( $assign_result ) != 0 )
{
echo "<div style=\"margin-top:10px;margin-bottom:10px;\">";
echo "<table id=\"myTable\" cellspacing=\"0\" border=\"0\" width=\"80%\">\n";
echo "<thead>\n";
echo "<tr bgcolor=\"#4E7DD1\" text=\"#FFFFFF\">\n";
echo "<th><font color=\"#FFFFFF\">Quiz</font></th>\n";
echo "<th><font color=\"#FFFFFF\">Quiz date</font></th>\n";
echo "<th><font color=\"#FFFFFF\">Grade</font></th>\n";
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
for( $i = 0; $i < mysql_num_rows( $assign_result ); $i++ )
{
$assign_row = mysql_fetch_row( $assign_result );
if( $i % 2 != 0 )
echo "<tr>\n";
else
echo "<tr bgcolor=\"#F1F6FE\">\n";
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">". $assign_row[4] .":</td> ";
if( time() < $assign_row[6] )
{
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">Will be administered on ". date('m/d/y', $assign_row[6] ) ."</td>";
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">-------</td>";
}
else
{
echo "<td style=\"border-bottom:1px solid #CDCDCD;\"><font color=\"#603311\">Was administered on ". date('m/d/y', $assign_row[6] ) ."</font></td>";
$grade_query = "select * from master_grades where assign_id=". $assign_row[0];
$grade_query .= " and student_id=". mysql_real_escape_string( $_POST['idnum'] );
$grade_result = mysql_query( $grade_query )
or die( 'Could not connect: '. mysql_error() );
echo "<td style=\"border-bottom:1px solid #CDCDCD;\">";
if( mysql_num_rows( $grade_result ) != 0 )
{
$grade_row = mysql_fetch_row( $grade_result );
if( $grade_row[3] >= 65 )
echo "<font color=\"#397D02\">";
else
echo "<font color=\"#FF0000\">";
echo $grade_row[3] ."</font>\n";
if( $grade_row[3] == 100 )
echo " ( <img src=\"img/check.gif\"> <font color=\"#397D02\">Excellent!</font> )\n";
if( $grade_row[3] >= 90 && $grade_row[3] < 100 )
echo " ( <img src=\"img/check.gif\"> <font color=\"#397D02\">Good job!</font> )\n";
if( $assign_row[7] == 1 )
echo " | <a href=\"index.php?location=grade_details&assign_id=". $assign_row[0] ."\" style=\"font-size:9px;\">View details</a>\n";
}
else
echo "Grade not posted yet\n";
echo "</td>";
echo "</tr>";
}
}
echo "</tbody>\n";
echo "</table>\n";
echo "</div>";
}
else
echo "There have been no quizes either administered nor/or graded as of ". date('m/d/y');
echo "</div>\n";
}
echo "</div>\n";
}
}
?>

You must be logged in to view this content.
