#!/usr/local/bin/perl # Grade Server Program, gradescript.cgi, version 1.0 # Program is designed to allow students to view grades for a class over # over the WWW. Script will accept student's class number and student # id, look up the data in a roster file and display it. # Requires the cgi-utils.pl library, available at: # http://www-genome.wi.mit.edu/WWW/tools/scripting/cgi-utils.html # For more information see: # http://www.chem.vt.edu/chem-ed/CHP/scripts/perl/gradescript.html. # Program and concept by Ron Earp and Brian Tissue. # Copyright 1996 by Ronald L. Earp, all rights reserved. # Program and concept by Ron Earp # Copyright 1996 require "cgi-utils.pl"; # Provides the location of the grade data files $grade_path="/disk2/script-data/rosters/"; # Prepare for HTML Output &start_page; # Gets the enviroment variables using cgi-utils.pl, please download %parameters = &get_query; $grade_file = "$grade_path"."$parameters{'filename'}"; unless (open(GRADE_FILE, $grade_file)) { &error_message; } else { @grades = ; $file_length = @grades; $found = 0; for ($search = 0; $search <= $file_length; $search++) { if ($grades[$search] =~ /$parameters{'stid'}/) { $found = 1; print "

Grade Server

\n"; print "


Your class number is: $parameters{'filename'}

\n"; print "Your student ID is: $parameters{'stid'}

\n"; print "\n"; @student_grades = split(/,/, $grades[$search]); $student_grades_length = @student_grades; @header = split(/,/, $grades[0]); $header_length = @header; for ($loop_control = 0; $loop_control < $student_grades_length; $loop_control++) { print "\n"; } print "
$header[$loop_control]:
$student_grades[$loop_control]

\n"; print "Thank you for using GradeServer.

\n"; } } } if ($found != 1) { print "Sorry, could not find your student ID, please check with your professor."; } &endpage; sub endpage { print "\n"; } sub start_page { print ("Content-type: text/html\n\n"); print (""); print ""; } sub error_message { print "Script Error\n"; print "

\n"; print "


\n"; print "

There has been a problem fulfilling your request

\n"; print "

\n"; print "Please check to be sure you entered your class number and student ID."; print " If all of these items are correct and/or present please inform the"; print " Web Master, otherwise use your browser back button to try again."; print "


"; }