Student
Home
About

FAQs

General
Admin
Assist
Student

Docs

Admin
Assistant

CGI

Admin
Assistant
Download
Form
Student

Packages

AdminInterface
Assignments
AssistantInterface
Form
Interface
Record
Roster
StudentInterface
SystemVariables
Teams
VincentFile
VincentLog


  0 #!/usr/bin/perl -w -I /l/vincent3/modules/
  1 #Copyright 2000 Matt Jadud
  2 #This program is free software; you can redistribute it and/or
  3 #modify it under the terms of the GNU General Public License
  4 #as published by the Free Software Foundation; either version 2
  5 #of the License, or (at your option) any later version.
  6 #
  7 #This program is distributed in the hope that it will be useful,
  8 #but WITHOUT ANY WARRANTY; without even the implied warranty of
  9 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 10 #GNU General Public License for more details.
 11 #
 12 #You should have received a copy of the GNU General Public License
 13 #along with this program; if not, write to the Free Software
 14 #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 15 
 16 #Turn debugging on or off.
 17 $DEBUG = 1;
 18 
 19 #Perl libraries that will come in handy. Get these out of the way...
 20 use CGI qw(:standard); # import shortcuts
 21 use Fcntl qw(:flock);  # imports LOCK_EX, LOCK_SH, LOCK_NB
 22 
 23 use SystemVariables;
 24 use Record;
 25 use StudentInterface;
 26 use Assignments;
 27 use Roster;
 28 use VincentFile;
 29 use VincentLog;
 30 use Form;
 31 
 32 #use Jules;
 33 
 34 my ( $username,
 35      $query,
 36      $Dispatch,
 37      $dispatched,
 38      $choice
 39      );
 40 
 41 #Grab the CGI Query
 42 $query = CGI->new(); 
 43 #Print the header to start a good dialog
 44 # between the server and client browser
 45 print header;
 46 #The username is stored in the environment
 47 $username = $ENV{REMOTE_USER};
 48 
 49 %Dispatch = (
 50 	     #Choosers
 51 	     "ASSIGNMENTCHOOSER"  => &studentChooser,
 52 	     "ASSIGNMENTTOSUBMIT" => &assignmentToSubmit,
 53 	     "ASSIGNMENTDONE"     => &assignmentDone,
 54 	     "ASSIGNMENTHANDIN"   => &assignmentHandin,
 55 	     "VIEWGRADES"         => &viewGrades,
 56 	     "PEEREVALHANDIN"     => &peerEvalProcessor
 57              #Global Ops
 58 
 59              #Assignment ops
 60 
 61 	     #Roster Ops
 62 	     );
 63 
 64 $dispatched = 0;
 65 
 66 foreach $k ($query->param()) {
 67     
 68     if(!$dispatched) {
 69 	SystemVariables::DEBUG("student.cgi", "Dispatched on: $k");
 70 	dispatcher($k, %Dispatch);
 71     }
 72 }
 73 
 74 
 75   StudentInterface::mainMenu($username);   
 76 
 77 
 78 ############################################
 79 # Input routing
 80 ############################################
 81 sub studentChooser  {
 82     
 83     my ( $key,
 84 	 %Choices
 85 	 );
 86    
 87     $key = $_[0];
 88     chomp $key;
 89 
 90     %Choices = ("SubmitAssignment" => &submitAssignment,
 91 		"AcknowledgeDone"  => &acknowledgeDone,
 92 		"assignmentDownload" => &assignmentDownload
 93 		);
 94 		
 95     SystemVariables::DEBUG("student.cgi", "Choosing $key, ", $query->param($key));
 96     dispatcher($query->param($key), %Choices);
 97 }
 98 
 99 ############################################
 100 # Assignment Options
 101 ############################################
 102 # The following query parameters may be of use.
 103 # _sectionnumberboolean
 104 # _sectionnumber
 105 # _searchstringboolean
 106 # _searchstring
 107 # _searchdateboolean
 108 # _searchdateyear
 109 # _searchdatemonth
 110 # _searchdateday
 111 sub assignmentDownload  {
 112 
 113     my ($assignments_matching,
 114 	$studata,
 115 	$username);
 116 
 117     $username = $ENV{REMOTE_USER};
 118 
 119     $studata = Record::getStudentRecord($username);
 120     
 121     #The students don't get to search; set the 
 122     # parameters for them. The only things that 
 123     # don't get set are the date parameters. 
 124     # Other than that, we should only search within their
 125     # section, and for lines containing their username followed
 126     # immediately by a |. That should only catch the first field.
 127     #
 128     # This is not, for the record, foolproof.
 129 
 130     $query->param("_sectionnumberboolean", 1);
 131     $query->param("_sectionnumber", $$studata{"_SECTIONNUMBER"});
 132     $query->param("_searchstringboolean", 1);
 133     $query->param("_searchstring", "^$username");
 134     $query->param("_searchdateboolean", 0);
 135     $query->param("_searchdateyear", 1975);
 136     $query->param("_searchdatemonth", 10);
 137     $query->param("_searchdateday", 11);
 138 
 139     #Get a list of filelog entries matching the criteria.
 140     $assignments_matching = 
 141       Assignments::getAssignmentsMatching($query);
 142 
 143     #Of course, filelogs don't tell if the assignment
 144     # is on-time. 
 145     #Assignments::filterOnTime($assignments_matching);    
 146     #For the moment, I'll come back to this part...
 147 
 148   #AssistantInterface::assignmentDownload($assignments_matching);
 149   StudentInterface::mainMenu("assignmentDownload", $assignments_matching);
 150 }
 151 
 152 sub assignmentHandin  {
 153 
 154     my ( @files,
 155 	 $param,
 156 	 $path,
 157 	 %checkfiles,
 158 	 $filename,
 159 	 $sysname,
 160 	 $assignID
 161 	 );
 162 
 163     $assignID = $query->param("ASSIGNMENTHANDIN");
 164     DEBUG ("Turning in $assignID");
 165 
 166     
 167 	##LOGGING
 168       VincentLog::clickLog("ASSIGNMENTS", "Submitting $assignID");
 169 
 170 
 171     foreach $param ($query->param()) {
 172 	
 173 	#If it is a file
 174 	if($param =~ /^FILE/) {
 175 	    #If there is actually a file in the field
 176 	    if($query->param($param)) {
 177 		#Generate a list of files to come back and 
 178 		# check to see that they are all valid...
 179 		($filename, $sysname) = Assignments::submitNextFile($query->param($param));
 180 
 181 		
 182 	##LOGGING
 183       VincentLog::clickLog("ASSIGNMENTS", "File Uploaded: $filename.");
 184 
 185 		$checkfiles{$sysname} = $filename;
 186 	    }
 187 	}
 188     } # End of foreach
 189     
 190     Assignments::checkFiles($assignID, %checkfiles);
 191     
 192 }
 193 
 194 sub submitAssignment  {
 195 
 196     SystemVariables::DEBUG("student.cgi", "Submitting assignment dialog.");
 197     
 198 	##LOGGING
 199       VincentLog::clickLog("ASSIGNMENTS", "Choose assignment dialog.");
 200 
 201   StudentInterface::mainMenu($username, "ChooseAssignment");
 202     exit();
 203 }
 204 
 205 sub assignmentDone  {
 206 
 207     my ($assignmentID,
 208 	$username,
 209 	%donehash
 210 	);
 211     
 212     $assignmentID = $query->param($_[0]);
 213     $username     = $ENV{REMOTE_USER};
 214     $systemID     = Assignments::getAssignmentSystemID($assignmentID);
 215 
 216 
 217 	##LOGGING
 218       VincentLog::clickLog("ASSIGNMENTS", "Acknowledge $assignmentID is done.");
 219 
 220 
 221     $donehash{$systemID . "_DONE"} = SystemVariables::currentTime();
 222 
 223     #Update the student record to indicate that this assignment
 224     # is now done.
 225   Record::updateStudentRecord($username, %donehash);
 226     
 227     #If the assignment is to be added to the Jules DB,
 228     # then do so now that they are done.
 229     #SystemVariables::DEBUG("student.cgi", "Jules Status: ", Jules::addToDB($username, $systemID));
 230 
 231 }
 232 
 233 sub assignmentToSubmit  {
 234     
 235     my ( $assign,
 236 	 $sysID,
 237 	 $record,
 238 	 $type);
 239     
 240     $username = $ENV{REMOTE_USER};
 241 
 242     #This is weird; the only way to pass data through
 243     # the mainMenu function to anything called from it...
 244     # the data of interest is tagged onto the branching parameters
 245     # and then split off as needed... 
 246     #
 247     # This isn't the best way to do it, but it keeps calling of 
 248     # things in the StudentInterface directly...
 249     #$param = "FileInputDialog" . "|" . $query->param("ASSIGNMENTTOSUBMIT");
 250     #SystemVariables::DEBUG("student.cgi", $param);
 251 
 252 
 253     ##############################################
 254     #SELECT FILE TYPE HERE
 255     # 
 256     # This is where to do the branch for filehandins. 
 257     # Check the "_TYPE" indicator on the file at this
 258     # point, and branch to the appropriate dialog box here.
 259     # For the moment, the only type of assignment designed into 
 260     # the system is the "FILE" type; but, that will change.
 261     $assign = $query->param("ASSIGNMENTTOSUBMIT");
 262     $sysID  = Assignments::getAssignmentSystemID($assign);
 263     $record = Record::getStudentRecord($username);
 264 
 265     $type = $$record{$sysID . "_TYPE"};
 266     
 267     if($type eq "FILE") {
 268 	
 269       StudentInterface::mainMenu($username, 
 270 				 "FileInputDialog",
 271 				 $query->param("ASSIGNMENTTOSUBMIT")
 272 				 );
 273     } 
 274     
 275     if($type eq "PEEREVAL") {
 276       StudentInterface::mainMenu($username,
 277 				 "DoPeerEval",
 278 				 $assign);
 279     }
 280 
 281     if($type eq "QUESTIONFORM") {
 282       Form::mainMenu($username,
 283 		     Assignments::getAssignmentSystemID($query->param("ASSIGNMENTTOSUBMIT")),
 284 		     "do");
 285     }
 286 
 287 	exit();
 288 }
 289 
 290 sub acknowledgeDone  {
 291   StudentInterface::mainMenu($ENV{REMOTE_USER},
 292 			     "AcknowledgeDone");
 293     exit();			     
 294 }
 295 
 296 sub viewGrades  {
 297 
 298 
 299 	##LOGGING
 300       VincentLog::clickLog("GRADES", "Viewed grades");
 301 
 302 
 303   StudentInterface::mainMenu($ENV{REMOTE_USER},
 304 			      "viewGrades",
 305 			     $query->param("VIEWGRADES"));
 306 }
 307 
 308 sub peerEvalProcessor  {
 309 
 310     my($username,
 311        $assignID,
 312        $sysID,
 313        $key,
 314        %data);
 315 
 316     $username = $ENV{REMOTE_USER};
 317 
 318     
 319     $assignID = $query->param("_assignID");
 320     $sysID    = Assignments::getAssignmentSystemID($assignID);
 321 
 322 	##LOGGING
 323   VincentLog::clickLog("PEEREVALS", "Submitted peer evals for $assignID");
 324 
 325     foreach $key ($query->param()) {
 326 	if($key =~ $sysID) {
 327 	    $data{$key} = VincentLog::textCleaner($query->param($key));
 328 	}
 329     }
 330   Record::updateStudentRecord($username, %data);
 331     
 332 
 333     $record   = Record::getStudentRecord($username);
 334     $team_string = $$record{"_TEAMMEMBERS"};
 335     $team_string =~ s/^(s*)//g;
 336     @team_array = (split(/s+/, $team_string));
 337     chomp(@team_array);
 338     SystemVariables::DEBUG("student.cgi", @team_array);
 339 
 340     $allscores = 1;
 341     $allcomments = 1;
 342 
 343     #Go through each team member; if they failed to
 344     # assign a score or score that is a number, set the 
 345     # allscores flag to zero (which will send them back to the beginning.)
 346     # Likewise, make sure that they submitted something for the comments. 
 347     
 348     foreach $member (@team_array) {
 349 	$score = $$record{$sysID . "_SCORE_" . $member};
 350 	SystemVariables::DEBUG("student.cgi", "Score for $member: $score");
 351 
 352 	if(length($score) < 1) {
 353 	    $allscores = 0;
 354 	    SystemVariables::DEBUG("student.cgi", "NO SCORE for $member");
 355 	} 
 356 	
 357 	#If it doesn't match this regexp, then
 358 	# send them back...
 359 	if($score !~ /d+.*d*/) {
 360 	    $allscores = 0;
 361 	    SystemVariables::DEBUG("student.cgi", "Score not a score for $member.");
 362 	}
 363 
 364 	$comments = $$record{$sysID . "_COMMENTS_" . $member};
 365 
 366 	SystemVariables::DEBUG("student.cgi", "Comments for $member: $comments");
 367 	if(length($comments) < 1) {
 368 	    $allcomments = 0;
 369 	    SystemVariables::DEBUG("student.cgi", "NO COMMENTS for $member");
 370 	}
 371     }
 372     
 373     if((!$allscores) || (!$allcomments)) {
 374       StudentInterface::mainMenu($username, $assignID, "IncompletePeerEval");
 375     } else {
 376 	foreach $key ($query->param()) {
 377 	    if($key =~ $sysID) {
 378 		$data{$key} = VincentLog::textCleaner($query->param($key));
 379 	    }
 380 	}
 381 
 382       StudentInterface::mainMenu($assignID, "GoodPeerEval");
 383     }
 384 
 385     
 386 
 387   Record::updateStudentRecord($username, %data);
 388 }
 389 
 390 
 391 ############################################
 392 # CGI Query Helpers
 393 ############################################
 394 sub queryCount  {
 395     my ($query, $count);
 396     $query = $_[0];
 397     foreach (keys %$query) { $count++; }
 398     return $count;
 399 }
 400 
 401 sub dispatcher  {
 402 
 403     my(	$dispatch_id,
 404 	$dispatch_hash
 405 	);
 406 
 407     $dispatch_id = $_[0];
 408     chomp $dispatch_id;
 409     
 410     $dispatch_hash = $_[1];
 411 
 412     SystemVariables::DEBUG("student.cgi", "DispatchID: ", $dispatch_id);
 413 
 414     #Pass on the ID - this is the key to the 
 415     # $query hash!
 416     if($$dispatch_hash{$dispatch_id}) {
 417 	
 418 	SystemVariables::DEBUG("student.cgi", "Dispatch exists!");
 419 	$dispatched = 1;
 420 	$$dispatch_hash{$dispatch_id}->($dispatch_id);
 421     }
 422 }
 423 
 424 sub useDebugging())'>DEBUG { if(SystemVariables::useDebugging())  { print "student.cgi: ", @_, "n<P>"; } }
 425 
 426 
 427 
 428 
 429 
 430 
 431 
 432 
 433 
 434 

Last update: 1/6/01; 9:32:32 AM