Admin
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 
  0 #Turn debugging on or off.
  1 $DEBUG = 1;
  2 
  3 #Perl libraries that will come in handy. Get these out of the way...
  4 use CGI qw(:standard); # import shortcuts
  5 use Fcntl qw(:flock);  # imports LOCK_EX, LOCK_SH, LOCK_NB
  6 
  7 use SystemVariables;
  8 use Record;
  9 use AdminInterface;
 10 use Assignments;
 11 use Roster;
 12 use Teams;
 13 
 14 my ( $username,
 15      $query,
 16      $Dispatch,
 17      $dispatched,
 18      $choice
 19      );
 20 
 21 #Grab the CGI Query
 22 $query = CGI->new(); 
 23 #Print the header to start a good dialog
 24 # between the server and client browser
 25 print header;
 26 #The username is stored in the environment
 27 $username = $ENV{REMOTE_USER};
 28 
 29 # Just so I can occasionally check on what variables
 30 # the system thinks I have access to...
 31 #foreach $key (keys %ENV) {
 32 #    print "$key ", $ENV{$key}, "<P>";
 33 #}
 34 
 35 
 36 %Dispatch = (
 37 	     #Choosers
 38 	     "GLOBALCHOOSER" => &chooseGlobalOperation,
 39 	     "ASSIGNCHOOSER" => &chooseAssignmentOperation,
 40 	     "ROSTERCHOOSER" => &chooseRosterOperation,
 41 	     "DOWNLOAD" => &assignmentDownload,
 42              #Global Ops
 43 	     "CLASSID" => &setClassID,
 44 	     "TAGLINE" => &setTagline,
 45 	     "UPDATESTUDENTDEFAULTS" => &updateStudentDefaults,
 46 	     "ADMINUPDATE" => &updateAdminandAssistants,
 47              #Assignment ops
 48 	     "CREATEASSIGNMENT" => &createAssignment,
 49              "MODIFYASSIGNMENT" => &modifyAssignment,
 50 	     "REMOVEASSIGNMENT" => &removeAssignment,
 51 	     "UPDATEASSIGNMENT" => &updateAssignment,
 52 	     "GRADESCHOOSER" => &chooseGradeOperation,
 53 	     "GRADESUBMISSION" => &updateGrades,
 54 	     "MAPPINGNAME"     => &createNewGradeMapping,
 55              #Roster Ops
 56 	     "SUBMITNEWROSTER"  => &uploadNewRoster,
 57 	     "ADDNEWSTUDENT"    => &addStudentToRoster,
 58 	     "MODIFIEDSTUDENT"  => &modifiedStudentUpdate,
 59 	     "DOWNLOADABLEFILE" => &chooseDatesForFile,
 60 	     "DOWNLOADCALENDAR" => &processDatesForFile,
 61 	     #Team Ops
 62 	     "TEAMCHOOSER"      => &chooseTeamOperation,
 63 	     "NEWTEAMLIST"      => &updateTeamList,
 64 	     "GRADEPEEREVALS"   => &gradePeerEvals
 65 	     
 66 	     );
 67 
 68 $dispatched = 0;
 69 
 70 #foreach $k (sort {$a cmp $b} $query->param()) {
 71 foreach $k ($query->param()) {
 72     
 73     if(!$dispatched) {
 74 	dispatcher($k, %Dispatch);
 75     }
 76 }
 77 
 78  AdminInterface::mainMenu($username);   
 79 
 80 ############################################
 81 # Input routing
 82 ############################################
 83 sub chooseTeamOperation  {
 84     my ( $key,
 85 	 %Choices
 86 	 );
 87    
 88     $key = $_[0];
 89     chomp $key;
 90 
 91     %Choices = ( "RandomizeAllTeams" => &randomizeAllTeams,
 92 		 "EditAllTeams"      => &editAllTeams,
 93 		 "EditSectionTeams"  => &editSectionTeams,
 94 		 "ViewPeerEvals"     => &viewPeerEvals
 95 		 );
 96 		
 97     SystemVariables::DEBUG("admin.cgi", "Choosing $key, ", $query->param($key));
 98     dispatcher($query->param($key), %Choices);
 99 }
 100 
 101 sub chooseGradeOperation  {
 102     
 103     my ( $key,
 104 	 %Choices
 105 	 );
 106    
 107     $key = $_[0];
 108     chomp $key;
 109 
 110     %Choices = ( "SubmitGrades" => &submitGrades,
 111 		 "ViewGrades" => &viewGrades
 112 		 );
 113 		
 114     SystemVariables::DEBUG("admin.cgi", "Choosing $key, ", $query->param($key));
 115     dispatcher($query->param($key), %Choices);
 116 }
 117 
 118 sub chooseGlobalOperation  {
 119     
 120     my ( $key,
 121 	 %Choices
 122 	 );
 123    
 124     $key = $_[0];
 125     chomp $key;
 126 
 127     %Choices = ( "ClassID" => &setClassID,
 128 		 "StudentDefaults" => &updateStudentDefaults,
 129 		 "AdminAndAssist" => &adminAndAssist
 130 		 );
 131 		
 132     SystemVariables::DEBUG("admin.cgi", "Choosing $key, ", $query->param($key));
 133     dispatcher($query->param($key), %Choices);
 134 }
 135 
 136 sub chooseRosterOperation  {
 137     
 138     my ( $key,
 139 	 %Choices
 140 	 );
 141    
 142     $key = $_[0];
 143     chomp $key;
 144 
 145     %Choices = ( "SelectRoster" => &selectRosterForUpload,
 146 		 "AddStudent"   => &addStudentToRoster,
 147 		 "ModifyStudent" => &modifyStudent
 148 		 );
 149 
 150     SystemVariables::DEBUG("admin.cgi", "Choosing $key, ", $query->param($key));
 151     dispatcher($query->param($key), %Choices);
 152 }
 153 
 154 sub chooseAssignmentOperation  {
 155     
 156     my ( $key,
 157 	 %Choices
 158 	 );
 159    
 160     $key = $_[0];
 161     chomp $key;
 162 
 163     %Choices = ( "Create" => &createAssignment,
 164 		 "Modify" => &modifyAssignment,
 165 		 "Remove" => &removeAssignment,
 166 		 "Mapping" => &createNewGradeMapping);
 167 
 168     SystemVariables::DEBUG("admin.cgi", "Choosing $key, ", $query->param($key));
 169     dispatcher($query->param($key), %Choices);
 170 }
 171 
 172 sub assignmentDownload  {
 173 
 174     my ($section,
 175 	$string,
 176 	$datestring,
 177 	$assignments_matching,
 178 	);
 179 
 180     #Get a list of filelog entries matching the criteria.
 181     $assignments_matching = 
 182       Assignments::getAssignmentsMatching($query);
 183 
 184     #Of course, filelogs don't tell if the assignment
 185     # is on-time. 
 186     #Assignments::filterOnTime($assignments_matching);    
 187     #For the moment, I'll come back to this part...
 188 
 189   AdminInterface::mainMenu("assignmentDownload", $assignments_matching);
 190 }
 191 
 192 ###########################################
 193 # Team Handlers
 194 ###########################################
 195 sub updateTeamList  {
 196 
 197     my($key, $stu, %data);
 198 
 199      ##LOGGING
 200   VincentLog::clickLog("TEAMS", "Update teams");
 201 
 202     foreach $key (keys (%{$query})) {
 203 	if($key =~ /_TEAMNUMBER/) {
 204 	    ($stu) = (split(/_/, $key))[0];
 205 	    $data{"_TEAMNUMBER"} = $query->param($key);
 206 	    Record::updateStudentRecord($stu, %data);
 207 	}
 208     }
 209     
 210   Teams::updateMembershipLists();
 211 }
 212 
 213 sub editAllTeams  {
 214     
 215     my(@allTeams);
 216 
 217     ##LOGGING
 218   VincentLog::clickLog("TEAMS", "Edit all teams form.");
 219 
 220     @allTeams =Record::getAllSectionNumbers();
 221     
 222   AdminInterface::mainMenu("EditTeams", @allTeams);
 223 
 224 
 225 }
 226 
 227 sub editSectionTeams  {
 228 
 229     my(@sections);
 230     
 231     ##LOGGING
 232   VincentLog::clickLog("TEAMS", "Edit teams in section " . $query->param("_sectionnumber"));
 233 
 234     @sections = ($query->param("_sectionnumber"));
 235     
 236   AdminInterface::mainMenu("EditTeams", @sections);
 237 }
 238 
 239 sub randomizeAllTeams  {
 240 
 241     
 242     ##LOGGING
 243   VincentLog::clickLog("TEAMS", "Randomize teams.");
 244 
 245 
 246     SystemVariables::DEBUG("admin.cgi", $query->param("AverageTeamSize"));
 247     SystemVariables::DEBUG("admin.cgi", "AYS: ", $query->param("AreYouSure"));
 248     if($query->param("AreYouSure")) {
 249       Teams::randomizeAllTeams($query->param("AverageTeamSize"));
 250     }
 251 
 252 }
 253 
 254 sub viewPeerEvals  {
 255 
 256     my($section, $assign);
 257 
 258     
 259     ##LOGGING
 260   VincentLog::clickLog("PEEREVALS", "View Peer evals.");
 261 
 262 
 263     $section = $query->param("_sectionnumber");
 264     $assign  = $query->param("_peereval");
 265 
 266     AdminInterface::mainMenu("ViewPeerEvals", $section, $assign);
 267 }
 268 
 269 sub gradePeerEvals  {
 270 
 271     my($key, $stu, %data, $sysID, $tag);
 272 
 273 
 274     ##LOGGING
 275   VincentLog::clickLog("PEEREVALS", "Grade peer evals.");
 276 
 277 
 278     foreach $key (keys (%{$query})) {
 279 	if($key =~ /_GRADE_/) {
 280 	    ($sysID, $tag, $stu) = (split(/_/, $key));
 281 	    $data{$sysID . "_GRADE"} = $query->param($key);
 282 	    Record::updateStudentRecord($stu, %data);
 283 	}
 284     }
 285     
 286 
 287 }
 288 ############################################
 289 # Roster Handlers
 290 ############################################
 291 sub modifiedStudentUpdate  {
 292 
 293     my ($student,
 294 	$param,
 295 	%data);
 296     
 297     $student = $query->param("MODIFIEDSTUDENT");
 298     
 299     foreach $param ($query->param()) {
 300 	if($param ne "MODIFIEDSTUDENT") {
 301 	    $data{$param} = $query->param($param);
 302 	}
 303     }
 304 
 305   Record::updateStudentRecord($student, %data);
 306 
 307     
 308     #In the event that this student is in a new 
 309     # section, call the updater for the 
 310     # section number list.
 311 
 312     Roster::createSectionNumberList();
 313 }
 314 sub modifyStudent  {
 315     my($stuusername);
 316     
 317     $stuusername = $query->param("_STUDENTUSERNAME");
 318 
 319   AdminInterface::mainMenu($username, "ModifyStudent", $stuusername);
 320 }
 321 
 322 sub addStudentToRoster  {
 323 
 324     my ( $key,
 325 	 $param,
 326 	 %studentparams
 327 	 );
 328 
 329     $key = $_[0];
 330     chomp $key;
 331 
 332     #If the student data is in, process it; otherwise,
 333     # present the student data input form.
 334     if($query->param($key)) {
 335 	#Load the hash with values that have been
 336 	# passed in from the add student form.
 337 	foreach $param ($query->param()) {
 338 	    if($param =~ /^_/) {
 339 		$studentparams{$param} = $query->param($param);
 340 	    }
 341 	}
 342 
 343 
 344     ##LOGGING
 345   VincentLog::clickLog("ROSTER", "Adding " . $query->param("_USERNAME") . " to roster.");
 346 	
 347       Roster::createStudent($query->param("_USERNAME"), %studentparams);
 348     } else {
 349       AdminInterface::mainMenu($username, "AddStudent");
 350 	exit();
 351     }
 352 }
 353 
 354 sub selectRosterForUpload  {
 355 
 356     my( $key );
 357     $key = $_[0];
 358     chomp $key;
 359 
 360     SystemVariables::DEBUG("admin.cgi", "Inside selectRosterForUpload");
 361     
 362   AdminInterface::mainMenu($username, "SelectRoster");
 363     exit();
 364 }
 365 
 366 sub uploadNewRoster  {
 367     
 368     my ($key,
 369 	$configpath);
 370     $key = $_[0];
 371     chomp $key;
 372 
 373 
 374     ##LOGGING
 375   VincentLog::clickLog("ROSTER", "Uploading roster " . $query->param("ROSTERFILE"));
 376 
 377 
 378     SystemVariables::DEBUG("admin.cgi", "uploadNewRoster: ", $query->param("ROSTERFILE"));
 379 
 380   Roster::newRoster($query->param("ROSTERFILE"));
 381   #Roster::expireWithdrawnStudents();
 382 }
 383 
 384 ############################################
 385 # Class ID handlers
 386 ############################################
 387 sub updateAdminandAssistants  {
 388 
 389     my ($adminlist,
 390 	$assistlist,
 391 	$listpath,
 392 	$godlist,
 393 	@admins,
 394 	@assists
 395 	);
 396     
 397     #Grab the new admins and assists from the form
 398     $adminlist  = $query->param("_ADMINISTRATORS");
 399     $assistlist = $query->param("_ASSISTANTS");
 400     #Grab the old gods from the file.
 401     $godlist    = SystemVariables::getGodList();
 402 
 403     $listpath = SystemVariables::getCourseConfigPath() . 
 404 	"adminassistlist";
 405 
 406     open(LIST, ">$listpath");
 407     flock(LIST, LOCK_EX);
 408     
 409     @admins  = (split(/s+/, $adminlist));
 410     @assists = (split(/s+/, $assistlist));
 411     
 412     print LIST "_ADMINISTRATORS";
 413     foreach (@admins) {
 414 	print LIST "|$_";
 415     }
 416     print LIST "n";
 417 
 418     print LIST "_ASSISTANTS";
 419     foreach (@assists) {
 420 	print LIST "|$_";
 421     }
 422     print LIST "n";
 423     
 424     print LIST "_GODS";
 425     foreach (@{$godlist}) {
 426 	print LIST "|$_";
 427     }
 428     print LIST "n";
 429 
 430     close(LIST);
 431 
 432     
 433     ##LOGGING
 434   VincentLog::clickLog("ADMINANDASSIST", "Updating admin and assist list.");
 435 }
 436 
 437 sub adminAndAssist  {
 438 
 439   AdminInterface::mainMenu("AdminAndAssist");
 440 
 441 }
 442 
 443 
 444 sub updateStudentDefaults  {
 445 
 446     my( $key,
 447 	$param,
 448 	%defaults
 449 	);
 450     $key = $_[0];
 451     chomp $key;
 452 
 453     if($query->param("UPDATESTUDENTDEFAULTS")) {
 454 	SystemVariables::DEBUG("admin.cgi", "Handle the updating of student defaults");
 455 	
 456 	#Load up the hash to be delivered to SystemVariables
 457 	# for writing
 458 	foreach $param ($query->param()) {
 459 		$defaults{$param} = $query->param($param);
 460 		SystemVariables::DEBUG("admin.cgi", $param, "::", $defaults{$param});
 461 	}
 462 	
 463 	##LOGGING
 464       VincentLog::clickLog("CONFIG", "Updated student defaults");
 465 	
 466       SystemVariables::writeStudentDefaults(%defaults);
 467     }
 468     else {
 469       AdminInterface::mainMenu($username, "StudentDefaults");
 470 	#on't draw the rest of the interface! 
 471 	exit();
 472     }
 473 }
 474 
 475 sub setClassID  {
 476     
 477     my( $key );
 478     $key = $_[0];
 479     chomp $key;
 480 
 481     if($query->param("CLASSID")) {
 482 	SystemVariables::DEBUG("admin.cgi", "setClassID: $key :: ", $query->param($key));
 483       SystemVariables::setClassID($query->param($key));	
 484 	setTagline("TAGLINE");      
 485     }
 486     else {
 487       AdminInterface::mainMenu($username, "ClassID");
 488 	#on't draw the rest of the interface! 
 489 	exit();
 490     }
 491 }
 492 
 493 sub setTagline  {
 494 
 495     my( $key );
 496     $key = $_[0];
 497     chomp $key;
 498     
 499     SystemVariables::DEBUG("admin.cgi", "setTagline: $key :: ", $query->param($key));
 500   SystemVariables::setClassTagline($query->param($key));
 501 }
 502 
 503 
 504 ############################################
 505 # Assignment Handlers
 506 ############################################
 507 
 508 sub createNewGradeMapping  {
 509     
 510     my($name,
 511        %Mapping,
 512        $i,
 513        $username);
 514 
 515     $username = $ENV{REMOTE_USER};
 516 
 517     #If the instructor gave the mapping
 518     # a name, process it. Otherwise, present 
 519     # the form.
 520     if($query->param("MAPPINGNAME")) {
 521 	$name = $query->param("MAPPINGNAME");
 522 	$Mapping{"NAME"} = $name;
 523 
 524 	
 525 	##LOGGING
 526       VincentLog::clickLog("GRADEMAPPING", "Creating mapping " . $query->param("MAPPINGNAME"));
 527 	
 528 	#If a category exists, grab the high
 529 	# and low for that category. Comma delimited
 530 	for($i=1;$i<16;$i++) {
 531 	    if($query->param("CATEGORY$i")) {
 532 		$Mapping{$query->param("CATEGORY" . $i)} = $query->param("LOW$i") 
 533 		    . "," . $query->param("HIGH$i");
 534 	    }
 535 	}
 536 	
 537 	#Pass the data to Assignments, which will create
 538 	# the grademapping file. 
 539       Assignments::createGradeMapping($name, %Mapping);
 540     } else {
 541       AdminInterface::mainMenu($username, "GradeMappingForm");
 542     }
 543 
 544 }
 545 
 546 sub updateGrades  {
 547     
 548     my($sysID,
 549        $key,
 550        %newdata,
 551        $student,
 552        $stukey);
 553     
 554     $sysID = $query->param("GRADESUBMISSION");
 555 
 556     
 557     ##LOGGING
 558   VincentLog::clickLog("GRADES", "Updating grades for " . $sysID);
 559 
 560 
 561     foreach $key (keys (%{$query})) {
 562 	%newdata = ();
 563 	#Keys are of the form username|sysID_GRADE
 564 	if($key =~ /$sysID/) {
 565 	    ($student, $stukey) = (split(/|/, $key));
 566 	    chomp $student;
 567 	    chomp $stukey;
 568 	    
 569 	    #If a grade was submitted for this student,
 570 	    # then update their record with the data.
 571 	    if(defined($query->param($key)) && length($query->param($key)) >= 1) {
 572 		$newdata{$stukey} = $query->param($key);
 573 	      Record::updateStudentRecord($student, %newdata);
 574 	    }
 575 	}
 576     }
 577 }
 578 
 579 sub submitGrades  {
 580 
 581   AdminInterface::mainMenu("submitGrades", 
 582 			   $query->param("SUBMITGRADECHOOSEASSIGN"),
 583 			   $query->param("_sectionnumber"));
 584 }
 585 
 586 sub viewGrades  {
 587 
 588   AdminInterface::mainMenu("ViewGrades",
 589 			       $query->param("VIEWGRADESSECTION"),
 590 			       $query->param("_assignments"));
 591   
 592 }
 593 sub createAssignment  {
 594     
 595     my ( %AssignmentHash,
 596 	 $key,
 597 	 $var
 598 	 );
 599     
 600     #If the ASSIGNID parameter is present, that 
 601     # means that the assignment has been given an ID by 
 602     # the instructor, and we can process the rest of the 
 603     # assignment data. Otherwise, we'll have to present the 
 604     # assignment creation form for them until they get 
 605     # the picture.
 606     if(!$query->param("_ASSIGNID")) {
 607       AdminInterface::mainMenu($username, "Create");
 608 	exit();
 609     } else {
 610 	
 611 	##LOGGING
 612       VincentLog::clickLog("ASSIGNMENTS", "Creating assignment " . $query->param("_ASSIGNID"));
 613 
 614 	foreach $param ($query->param()) {
 615 	    if($param =~ /^_[A-Z]+/) {
 616 
 617 		$AssignmentHash{$param} = $query->param($param);
 618 	    }
 619 	}   
 620 	
 621 	if($query->param("_TYPE") ne "QUESTIONFORM") {
 622 	    SystemVariables::DEBUG("admin.cgi", "Creating Assignment");
 623 	  Assignments::createAssignment(%AssignmentHash);
 624 	} else {
 625 	    
 626 	}
 627     }
 628 }
 629 
 630 sub modifyAssignment  {
 631     
 632     my ( $assign_id,
 633 	 );
 634 
 635     if(!($assign_id = $query->param("MODIFYASSIGNMENT")) ) {
 636 	AdminInterface::mainMenu($username, "ModifyChooser");
 637 	  exit();
 638       } else {
 639 	  #These are generating extra administrator
 640 	  # interfaces all over the place... too bad
 641 	  # the control flow is so fucked up...
 642 	  
 643 	  #Need to pass on the assignment ID!
 644 	AdminInterface::mainMenu($username, "ModifyForm", $assign_id);
 645 	#AdminInterface::modifyAssignmentForm($assign_id);
 646       }
 647 }
 648 
 649 
 650 sub removeAssignment  {
 651     
 652     my ( $assign_id,
 653 	 );
 654 
 655     if(!($assign_id = $query->param("REMOVEASSIGNMENT")) ) {
 656 	AdminInterface::mainMenu($username, "RemoveChooser");
 657 	  exit();
 658       } else {
 659 	  #These are generating extra administrator
 660 	  # interfaces all over the place... too bad
 661 	  # the control flow is so fucked up...
 662 	 
 663 	  #print "REMOVE $assign_id";
 664 
 665 	Assignments::removeAssignment($assign_id);
 666 
 667 	  #Need to pass on the assignment ID!
 668 	#AdminInterface::mainMenu($username, "ModifyForm", $assign_id);
 669 	#AdminInterface::modifyAssignmentForm($assign_id);
 670       }
 671 }
 672 
 673 
 674 sub updateAssignment  {
 675 
 676     my ( $sys_assign_id,
 677 	 %assignments,
 678 	 $param
 679 	 );
 680 
 681     $sys_assign_id = $query->param("UPDATEASSIGNMENT");
 682 
 683 
 684     ##LOGGING
 685   VincentLog::clickLog("ASSIGNMENTS", "Updating assignment " . $query->param("_ASSIGNID"));
 686 
 687 
 688     SystemVariables::DEBUG("admin.cgi", "Key: $_[0], Val: $sys_assign_id");
 689     
 690     #updateAssignment expects a hash of values (key, value);
 691     # therefore, the query must be prepackaged here for 
 692     # passing on to updateAssignment...
 693     
 694     foreach $param ($query->param()) {
 695 	if ( $param =~ /^_/ ) {
 696 	    $assignments{$param} = $query->param($param);
 697 	    SystemVariables::DEBUG("admin.cgi", "Ass: $param :::", $query->param($param));  
 698 	}
 699     }
 700 
 701     SystemVariables::DEBUG("admin.cgi", "Calling updateAssignment on $sys_assign_id");
 702 
 703     #updateAssignments will also update all the students...
 704   Assignments::updateAssignment($sys_assign_id, %assignments);
 705   #Assignments::writeAssignment($sys_assign_id, %assignments );
 706 
 707 }
 708 
 709 
 710 ############################################
 711 # CGI Query Helpers
 712 ############################################
 713 sub queryCount  {
 714     my ($query, $count);
 715     $query = $_[0];
 716     foreach (keys %$query) { $count++; }
 717     return $count;
 718 }
 719 
 720 sub dispatcher  {
 721 
 722     my(	$dispatch_id,
 723 	$dispatch_hash
 724 	);
 725 
 726     $dispatch_id = $_[0];
 727     chomp $dispatch_id;
 728     
 729     $dispatch_hash = $_[1];
 730 
 731     SystemVariables::DEBUG("admin.cgi", "DispatchID: ", $dispatch_id);
 732 
 733     #Pass on the ID - this is the key to the 
 734     # $query hash!
 735     if($$dispatch_hash{$dispatch_id}) {
 736 	
 737 	SystemVariables::DEBUG("admin.cgi", "Dispatch exists!");
 738 	$dispatched = 1;
 739 	$$dispatch_hash{$dispatch_id}->($dispatch_id);
 740     }
 741 }
 742 
 743 sub chooseDatesForFile  {
 744     
 745     my($sysname);
 746     
 747     #Upload the file; this takes care
 748     # of the upload, and placing a
 749     # line in all of the permissions files.
 750     $sysname = uploadDownloadableFile($query);
 751     
 752     #If the file is not available ALWAYS,
 753     # then present the calendar for scheduling 
 754     # purposes.
 755     if($query->param("_type") ne "ALWAYS") {
 756       AdminInterface::mainMenu("DOWNLOADABLEFILE",
 757 			       $query->param("_startmonth"),
 758 			       $query->param("_endmonth"),
 759 			       $query->param("_type"),
 760 			       $sysname
 761 			       );
 762     } else {
 763       AdminInterface::mainMenu();
 764     }
 765 }
 766 
 767 
 768 ##CONTRACT
 769 # uploadDownloadableFile : CGI Query -> string
 770 ##PURPOSE
 771 # Takes a query with the user's filename (from a file
 772 # upload dialog box), and a schedule type (ALWAYS,
 773 # SCHEDULE, or PERMISSION), and returns the system
 774 # name for the uploaded file.
 775 sub uploadDownloadableFile  {
 776 
 777     my ($query,
 778 	$theirName,
 779 	$sysName,
 780 	$type,
 781 	%data
 782 	);
 783     
 784     $query = $_[0];
 785     $theirName = $query->param("DOWNLOADABLEFILE");
 786     $description = $query->param("_description");
 787     $sysName   = SystemVariables::getNextAdminFileUploadName();
 788     $type      = $query->param("_type");
 789 
 790    
 791     #Upload the file
 792   VincentFile::uploadBinaryFile($theirName,
 793 			      SystemVariables::getCourseConfigPath() . 
 794 				$sysName
 795 			      );
 796 
 797      #Clean up the input!
 798     
 799     #Windows
 800     if($theirname =~ /w:\.*\(.*)$/i) {
 801 	$theirName = VincentLog::filenameCleaner($1);
 802     } 
 803     
 804     #Unix
 805     elsif($theirname =~ /.*/(.*)$/) {
 806 	$theirName = VincentLog::filenameCleaner($1);
 807     }
 808     
 809     #Otherwise
 810     else { $theirName = VincentLog::filenameCleaner($theirName); }
 811 
 812     #Add permissions to all the student records to download this
 813     # file
 814   VincentFile::updateAllDownloadPermissions($sysName, $theirName, $type);
 815     
 816     $data{$sysName . "_SYSID"} = $sysName;
 817     $data{$sysName . "_NAME"}  = $theirName;
 818     $data{$sysName . "_DESCRIPTION"} = $description;
 819     $data{$sysName . "_PERMISSION"} = $type;
 820  
 821     #If the file requires permission, set a date right now;
 822     # students won't be able to download the file until this number
 823     # is updated.
 824     if($type eq "PERMISSION") {
 825 	$data{$sysName . "_PERMISSIONDEADLINE"} = SystemVariables::currentTime();
 826     }
 827 
 828   VincentFile::updateDownloadableFileData($sysName, %data);
 829  Record::updateAllStudentRecords(%data);  
 830     
 831     return $sysName;
 832 }
 833 
 834 sub processDatesForFile  {
 835 
 836     my ($key, 
 837 	@dates,
 838 	$path,
 839 	$sysID,
 840 	$year,
 841 	$month,
 842 	$day,
 843 	%data,
 844 	$i,
 845 	@end,
 846 	$string
 847 	);
 848 
 849     $sysID = $query->param("_sysID");
 850     $year  = SystemVariables::getCurrentYear();
 851     @end = (0,31,28,31,30,31,30,31,31,30,31,30,31);
 852 
 853     #$path  = SystemVariables::getDownloadableFileData();
 854 
 855     foreach $key ($query->param()) {
 856 	
 857 	if( $key =~ /(d+)-(d+)/) {
 858 	    
 859 	    if($1 < 10) { 
 860 	 	$month = "0" . $1;
 861 	    } else {
 862 		$month = $1;
 863 	    }
 864 
 865 	    if($2 < 10) {
 866 		$day = "0" . $2;
 867 	    } else {
 868 		$day = $2;
 869 	    }
 870 
 871 	    chomp($year);
 872 	    chomp($month);
 873 	    chomp($day);
 874 
 875 	    #SystemVariables::DEBUG("admin.cgi", $year . "," . $month . "," . $day);
 876 	    $string = $year . "," . $month . "," . $day;
 877 
 878 	    #Push the partial date string onto the list of dates.
 879 	    push(@dates, $string);
 880  
 881 	}
 882 	
 883 	if ( $key =~ /(d+)-ALL/) {
 884 	    
 885 	    #Leading zero on the month, if necessary
 886 	    if($1 < 10) {
 887 		$month = "0" . $1;
 888 	    }
 889 	    
 890 	    for($i = 1; $i<=$end[$1]; $i++) {
 891 		#If we are on a day that is less than
 892 		# ten, add a leading zero.
 893 		if($i < 10) {
 894 		    $day = "0$i";
 895 		} else {
 896 		    $day = $i;
 897 		}
 898 
 899 		chomp($year);
 900 		chomp($month);
 901 		chomp($day);
 902 
 903 		#SystemVariables::DEBUG("admin.cgi", $year . "," . $month . "," . $day);
 904 		$string = $year . "," . $month . "," . $day;
 905 		
 906 		#Push the partial date string onto the list of dates.
 907 		push(@dates, $string);
 908 	    }
 909 	}
 910     }
 911 
 912     #SystemVariables::DEBUG("admin.cgi", @dates);
 913     $string = "";
 914     foreach $day (@dates) {
 915 	#SystemVariables::DEBUG("admin.cgi", $day);
 916 	chomp($day);
 917 	$string = $string . " " . $day;
 918 	#SystemVariables::DEBUG("admin.cgi", $string);
 919     }
 920 
 921     SystemVariables::DEBUG("admin.cgi", "Done: $string");
 922 
 923     #Now, all the dates that were submitted are in a list.
 924     # Simply update the datafile with this data.
 925     $data{$sysID . "_DATES"} = $string;
 926     
 927     #SystemVariables::DEBUG("admin.cgi", "Hash: ", $data{$sysID . "_DATES"});
 928   VincentFile::updateDownloadableFileData($sysID, %data);
 929   Record::updateAllStudentRecords(%data);
 930 
 931 }
 932 
 933 sub useDebugging())'>DEBUG { if(SystemVariables::useDebugging())  { print "admin.cgi: ", @_, "n<P>"; } }
 934 
 935 

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