|
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 #System Interface Package 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 17 use SystemVariables; 18 use Interface; 19 use VincentLog; 20 use Record; 21 22 package Interface; 23 24 use Fcntl qw(:flock); # imports LOCK_EX, LOCK_SH, LOCK_NB 25 26 my ($DEBUG, 27 $VincentColor); 28 29 #Turn debugging on or off; 30 $DEBUG = 1; 31 $VincentColor = "006600"; 32 33 sub startForm { 34 my ( $target_script ); 35 $target_script = $_[0]; 36 chomp $target_script; 37 38 print "<FORM ENCTYPE="multipart/form-data" method="POST" ACTION="$target_script">"; 39 } 40 41 sub endForm { 42 print "<CENTER><INPUT TYPE='SUBMIT' VALUE='Submit'></CENTER></FORM>"; 43 } 44 45 sub file { 46 47 my ($text, $name); 48 $text = $_[0]; 49 $name = $_[1]; 50 51 print "<TABLE WIDTH='100%'>"; 52 print "<TR><TD WIDTH='15%'>"; 53 print "$text</TD><TD>"; 54 print "<INPUT TYPE='FILE' NAME='$name' SIZE='30'>"; 55 print "</TD></TR></TABLE>"; 56 } 57 58 59 sub radio { 60 61 my ($name, $value , $text, $status); 62 $value = $_[0]; 63 $name = $_[1]; 64 $text = $_[2]; 65 $status = $_[3]; 66 67 if(!$status) { $status = ""; } 68 69 print "<TABLE WIDTH='100%'>"; 70 print "<TR><TD WIDTH='5%'>"; 71 print "<INPUT TYPE='RADIO' NAME='$name' VALUE='$value' $status>"; 72 print "</TD><TD>$text</TD></TR></TABLE>"; 73 74 } 75 76 sub checkbox { 77 78 my ($name, $value , $text, $status); 79 $value = $_[0]; 80 $name = $_[1]; 81 $text = $_[2]; 82 $status = $_[3]; 83 84 if(!$status) { $status = ""; } 85 86 print "<TABLE WIDTH='100%'>"; 87 print "<TR><TD WIDTH='5%'>"; 88 print "<INPUT TYPE='CHECKBOX' NAME='$name' VALUE='$value' $status>"; 89 print "</TD><TD>$text</TD></TR></TABLE>"; 90 91 } 92 93 sub hidden { 94 95 my ($name, $value ); 96 97 ($name, $value) = @_; 98 99 print "<INPUT TYPE='HIDDEN' NAME='$name' VALUE='$value'>"; 100 } 101 102 sub selectInput { 103 104 my ( $text, 105 $name, 106 @options 107 ); 108 109 ($text, $name, @options) = @_; 110 chomp $text; 111 chomp $name, 112 chomp @options; 113 114 print "<TABLE WIDTH='100%'><TR><TD WIDTH='40%'>"; 115 print "$text</TD><TD WIDTH='60%'> "; 116 print "<SELECT NAME='$name'>"; 117 118 print "<OPTION SELECTED>", shift @options, "</OPTION>"; 119 120 foreach (@options) { 121 print "<OPTION>$_</OPTION>"; 122 } 123 124 print "</SELECT>"; 125 print "</TD><TD>"; 126 print "</TD></TR></TABLE>"; 127 128 } 129 130 sub optionInput { 131 132 my ( $text, 133 $name, 134 @options 135 ); 136 137 ($text, $name, @options) = @_; 138 chomp $text; 139 chomp $name, 140 chomp @options; 141 142 print "<TABLE WIDTH='100%'><TR><TD WIDTH='40%'>"; 143 print "$text</TD><TD WIDTH='60%'> "; 144 print "<SELECT NAME='$name' MULTIPLE>"; 145 146 print "<OPTION SELECTED>", shift @options, "</OPTION>"; 147 148 foreach (@options) { 149 print "<OPTION>$_</OPTION>"; 150 } 151 152 print "</SELECT>"; 153 print "</TD><TD>"; 154 print "</TD></TR></TABLE>"; 155 156 } 157 158 sub textInput { 159 my ( $text, 160 $name, 161 $width, 162 $value, 163 $lpercent, 164 $rpercent 165 ); 166 167 ($text, $name, $value, $width, $lpercent, $rpercent) = @_; 168 169 if(!$value) { $value = ""; } 170 if(! ( $lpercent && $rpercent)) { 171 $lpercent = 40; 172 $rpercent = 60; 173 } 174 175 print "<TABLE WIDTH='100%'><TR><TD WIDTH='$lpercent%'>"; 176 print "$text</TD><TD WIDTH='$rpercent%' ALIGN="LEFT"> "; 177 print "<INPUT TYPE='TEXT' SIZE='$width' NAME='$name' VALUE='$value'>"; 178 print "</TD><TD>"; 179 print "</TD></TR></TABLE>"; 180 181 } 182 183 sub textArea { 184 185 my($text, 186 $name, 187 $value, 188 $cols, 189 $rows, 190 $lpercent, 191 $rpercent 192 ); 193 194 ($text, $name, $value, $cols, $rows) = @_; 195 196 if(!$value) { $value = ""; } 197 if(! ( $lpercent && $rpercent)) { 198 $lpercent = 40; 199 $rpercent = 60; 200 } 201 202 print "<TABLE WIDTH='100%'><TR><TD WIDTH='$lpercent%' VALIGN='TOP'>"; 203 print "$text</TD><TD WIDTH='$rpercent%' ALIGN="LEFT"> "; 204 print "<TEXTAREA name='$name' rows='$rows' cols='$cols' wrap='soft'>"; 205 print "$value"; 206 print "</TEXTAREA>"; 207 print "</TD><TD>"; 208 print "</TD></TR></TABLE>"; 209 210 211 } 212 213 214 215 216 sub tableTop { 217 218 print "<CENTER>"; 219 print "<TABLE WIDTH='90%'>"; 220 print "<TR><TD BGCOLOR='#$VincentColor'>"; 221 print "<FONT COLOR='#FFFFFF'>"; 222 print @_; 223 print "</FONT><CENTER><TABLE WIDTH='99%'><TR><TD BGCOLOR='#FFFFFF'>"; 224 225 226 227 } 228 229 sub tableBottom { 230 print "</TD></TR></TABLE>"; 231 print "</TD></TR></TABLE>"; 232 print "</CENTER>"; 233 } 234 235 sub menuTop { 236 237 my ($title, 238 @tags, 239 $caller, 240 $TYPE, 241 $ID, 242 $username 243 ); 244 245 @tags = @_; 246 $title = SystemVariables::getClassID(); 247 $title .= " "; 248 $title .= SystemVariables::getClassTagline(); 249 $username = $ENV{REMOTE_USER}; 250 251 $caller = SystemVariables::getCallingScript(); 252 253 if($caller =~ /admin/) { 254 $TYPE = "admin"; 255 } elsif ($caller =~ /assistant/) { 256 $TYPE = "assist"; 257 } else { 258 $TYPE = "student"; 259 } 260 261 print "<HTML><HEAD><TITLE>$title</TITLE></HEAD>"; 262 print "<BODY BGCOLOR='#FFFFFF'>"; 263 print "<TABLE WIDTH='100%'>"; 264 265 if( ($TYPE eq "admin") || ($TYPE eq "assist")) { 266 $ID .= SystemVariables::getClassTagline(); 267 } else { 268 $ID = Record::getFirstName($username) . " " . Record::getLastName($username); 269 } 270 271 $date = localtime; 272 print "<TR><TD>"; 273 print "<TABLE WIDTH='100%'>"; 274 print "<TR>"; 275 276 print "<TD VALIGN='top'><H1>"; 277 print SystemVariables::getClassID(); 278 print "</H1></TD>"; 279 280 $ID =~ s/s+/<BR>/g; 281 print "<TD><CENTER><H2><FONT COLOR='#$VincentColor'>"; 282 print "$ID"; 283 print "</FONT></H2></CENTER>"; 284 print "</TD>"; 285 286 print "<TD ALIGN='right' VALIGN='top'>"; 287 print "<H2>$date</H2>"; 288 print "</TD></TR></TABLE>"; 289 print "<HR NOSHADE>"; 290 print "</TD></TR>"; 291 292 } 293 294 295 sub menuBottom { 296 297 print "</TABLE>"; 298 299 } 300 301 302 sub progressBar { 303 304 my ( $text, 305 $inbartext, 306 $current, 307 $max, 308 $percentage_remaining, 309 $percentage_gone, 310 $referencebar, 311 $red, $green, $blue, $hex, 312 $shownumbers 313 ); 314 315 ($text, $inbartext, $current, $max, $referencebar, $shownumbers) = @_; 316 317 $percentage_remaining = $current/$max; 318 $percentage_gone = 1 - $percentage_remaining; 319 320 #$red = 255 * $percentage_remaining; 321 #$blue = 255 * $percentage_gone; 322 #$green = "00"; 323 324 #$red = sprintf("%lx", $red); 325 #$blue = sprintf("%lx", $blue); 326 327 #$hex = "$red$green$blue"; 328 329 $hex = makeRelativeHexColor($current, $max); 330 331 if($percentage_remaining == 0) { 332 $hex = "000000"; 333 } 334 335 $percentage_remaining = $percentage_remaining * 100; 336 $percentage_gone = $percentage_gone * 100; 337 338 339 print "<TABLE WIDTH='98%'>"; 340 print "<TR><TD WIDTH='10%'>"; 341 print $text; 342 print "</TD><TD WIDTH='90%'>"; 343 344 print "<CENTER>"; 345 print "<TABLE WIDTH='100%'>"; 346 347 if($percentage_remaining != 0) { 348 print "<TR><TD WIDTH='$percentage_remaining' BGCOLOR='$hex'>"; 349 350 #If we have more than 50% remaining, the text should 351 # be in the colored region 352 if($percentage_remaining >= 50) { 353 print "<CENTER><FONT COLOR='#FFFFFF'>"; 354 355 if($shownumbers) { 356 print "$current $inbartext"; 357 } else { 358 print "$inbartext"; 359 } 360 361 print "</FONT></CENTER>"; 362 } else { 363 print " "; 364 } 365 366 print "</TD>"; 367 368 #Place the text outside the colored region if it is 369 # less than 50% 370 if($percentage_remaining < 50) { 371 print "<TD WIDTH='$percentage_gone' ALIGN='LEFT'>"; 372 373 374 if($shownumbers) { 375 print "$current $inbartext"; 376 } else { 377 print "$inbartext"; 378 } 379 380 } else { 381 print "<TD WIDTH='$percentage_gone' BGCOLOR='#FFFFFF'> </TD>"; 382 } 383 384 print "</TR>"; 385 386 } else { 387 print "<TR><TD WIDTH='100%'>"; 388 print "<FONT COLOR='#000000'><CENTER>"; 389 390 if($shownumbers) { 391 print "$current $inbartext"; 392 } else { 393 print "$inbartext"; 394 } 395 396 print "</CENTER></FONT>"; 397 print "</TD></TR>"; 398 } 399 400 401 print "</TABLE>"; 402 print "</CENTER>"; 403 404 print "</TD></TR>"; 405 406 if($referencebar) { 407 print "<TR>"; 408 print "<TD> </TD><TD><TABLE WIDTH='94%'><TR>"; 409 print "<TD WIDTH='2%' ALIGN='LEFT'>0</TD>"; 410 print "<TD WIDTH='96%'><HR NOSHADE></TD>"; 411 print "<TD WIDTH='2%' ALIGN='RIGHT'>$max</TD>"; 412 print "</TR></TABLE></TD></TR>"; 413 } 414 415 print "</TABLE>"; 416 417 418 } 419 420 sub dateSorter { 421 422 my($line, 423 $number); 424 425 $line = $_[0]; 426 427 ($number) = (split(/|/,$line))[4]; 428 429 chomp $number; 430 $number =~ s/,//g; 431 $number =~ s/://g; 432 433 return $number; 434 435 } 436 437 sub assignmentDownload { 438 439 my ($assignments, 440 @assn, 441 $assignmentword, 442 $assignmnt, 443 @ziparray 444 ); 445 446 447 ##LOGGING 448 VincentLog::clickLog("ASSIGNMENTS", "Download assignments page"); 449 450 $assignments = $_[1]; 451 print "<TR><TD>n"; 452 @assn = @{$assignments}; 453 454 if(!@assn) { 455 SystemVariables::DEBUG("Int: ", "No assignments line 440"); 456 } 457 458 459 #SystemVariables::DEBUG("Int: Found @assn"); 460 461 # Reverse sort by date. 462 @assn = reverse sort {dateSorter($a) <=> dateSorter($b)} @assn; 463 464 #This bit of silliness tags the s 465 # on properly for plural/singular agreement... 466 $assignmentword = "assignment"; 467 if($#assn > 0) { 468 $assignmentword = $assignmentword . "s"; 469 } 470 471 tableTop($#assn+1, " $assignmentword matching query"); 472 473 print "<TABLE WIDTH='100%'>"; 474 475 print "<TR BGCOLOR='CCCCCC'>"; 476 print "<TD><STRONG>Username</STRONG></TD>"; 477 print "<TD><STRONG>Assignment</STRONG></TD>"; 478 print "<TD><STRONG>File Link</STRONG></TD>"; 479 print "<TD><STRONG>Size (bytes)</STRONG></TD>"; 480 print "<TD><STRONG>Date</STRONG></TD>"; 481 print "</TR>"; 482 483 #For some reason, the foreach over @assn rips it to 484 # shreds, and I can't reuse it. This is weird. 485 @ziparray = @assn; 486 487 foreach $assignmnt (@assn) { 488 assignmentEntry($assignmnt); 489 } 490 491 print "</TABLE>"; 492 493 print "<CENTER>"; 494 print "<TABLE WIDTH='50%'><TR><TD BGCOLOR='FFCCCC'>Files with a "; 495 print "pink background are considered late.</STRONG>"; 496 print "</TD></TR></TABLE>"; 497 print "</CENTER>"; 498 499 #Create the zipfile 500 501 createZipFile(@ziparray); 502 503 tableBottom(); 504 505 print "</TR></TD>"; 506 } 507 508 509 510 sub assignmentEntry { 511 512 my ($assign, 513 @split, 514 $size, 515 $username, 516 $assignID, 517 $sysfilename, 518 $stufilename, 519 $date, 520 $background, 521 $image, 522 $filelink); 523 524 $assign = $_[0]; 525 526 SystemVariables::DEBUG("Int:", $assign); 527 528 ($username, $assignID, $sysfilename, 529 $stufilename, $date, $ontime, $sliphoursused)= split(/|/, $assign); 530 531 #Visually flag the fact it is late. 532 #if(Assignments::isAssignmentLate($username, $assignID, $date)) { 533 if(!$ontime) { 534 $background = "FFCCCC"; 535 } else { 536 $background = "FFFFFF"; 537 } 538 539 #username|assignment|sysfilename|stufilename|date 540 541 print "<TR bgcolor='#$background'><TD>", $username, "</TD>"; 542 543 #If the students are done with the assignment, stick a whiz-bang 544 #graphic in there... 545 #if(Assignments::isDone($username, $assignID)) { 546 #if(SystemVariables::useDoneness()) { 547 # $image = "<IMG SRC='" . SystemVariables::getImageWebPath() . "done.png" . "' HEIGHT='15' WIDTH='30'>"; 548 #} 549 #} else { 550 #$image = ""; 551 #} 552 553 print "<TD>", $assignID, "</TD>"; 554 555 #$filelink = Assignments::createFileLink($username, 556 # $sysfilename, 557 # $stufilename); 558 559 $filelink = "<A HREF='download.cgi"; 560 $filelink .= "?SYSID=$sysfilename&FILENAME=$stufilename&TYPE=student"; 561 $filelink .= "'>$stufilename</A>"; 562 563 print "<TD>", $filelink, "</TD>"; 564 565 $path = SystemVariables::getStudentRecordPath($username); 566 $path .= $sysfilename; 567 568 ($size) = (stat($path))[7]; 569 print "<TD ALIGN='RIGHT'>$size</TD>"; 570 571 #print "<TD ALIGN='RIGHT'>", $image, " ", $date, "</TD></TR>"; 572 print "<TD ALIGN='RIGHT'> ", $date, "</TD></TR>"; 573 574 575 } 576 577 578 sub createZipFile { 579 580 my(@assign 581 ); 582 583 @assign = @_; 584 @full_path_array = (); 585 $classID = SystemVariables::getClassID(); 586 $classID = VincentLog::filenameCleaner($classID); 587 $pid = $$; 588 589 mkdir("/tmp/$classID$pid"); 590 $caller = SystemVariables::getCallingScript(); 591 592 if(!@assign) { 593 594 return 0; 595 596 597 } 598 599 foreach $entry (@assign) { 600 601 if(!($entry =~ /|\|/)) { 602 603 ($username, $assignID, $sysfilename, 604 $stufilename, $date)= split(/|/, $entry); 605 606 #Get a full path to the file 607 $path = SystemVariables::getStudentRecordPath($username); 608 609 #Make a directory if it doesn't exist 610 if( ! -d "/tmp/$classID$pid/$username") { 611 mkdir("/tmp/$classID$pid/$username"); 612 } 613 614 #Copy the student's file in 615 system("cp", "-p", $path . $sysfilename, "/tmp/$classID$pid/$username/$stufilename"); 616 #Debug mirroring copy 617 SystemVariables::DEBUG("Int:", "cp ", $path . $sysfilename, " /tmp/$classID$pid/$username/$stufilename"); 618 619 push(@full_path_array, "/tmp/$classID$pid/$username/$stufilename"); 620 } 621 622 $date = SystemVariables::getCurrentTime(); 623 $date =~ s/://g; 624 $date =~ s/,//g; 625 626 } 627 628 #Make the zipfile in that directory, and print a link. 629 chdir("/tmp/$classID$pid"); 630 system("zip", "-Rq", "/tmp/$classID$pid/$date.zip", "*"); 631 632 633 if($caller =~ /admin/) { 634 $ADMIN = 1; 635 $TYPE = "admin"; 636 } elsif ($caller =~ /assistant/) { 637 $ASSIST = 1; 638 $TYPE = "assist"; 639 } 640 641 $webPath = SystemVariables::getDownloadWebPath(); 642 643 if($caller =~ /(admin|assistant)/) { 644 if(-f "/tmp/$classID$pid/$date.zip") { 645 print "<CENTER>"; 646 print "<A HREF='$webPath/", "download.cgi?TYPE=ZIPFILE&FILENAME=$classID$date.zip&ZIPPATH=/tmp/$classID$pid/$date.zip", "'>Download zipfile of all files listed.</A>"; 647 print "</CENTER>"; 648 } 649 } 650 651 #Simply have the download script remove all files of type "ZIPFILE" immediately after 652 # downloading. 653 654 #Clean out any zipfiles that are older than 2 minutes old. 655 opendir(DIR, "/tmp"); 656 @alldirs = readdir(DIR); 657 close(DIR); 658 659 foreach $dir (@alldirs) { 660 SystemVariables::DEBUG("Int:", "Checking $dir"); 661 662 if( $dir =~ /^$classIDd+$/) { 663 664 chomp $dir; 665 $dir = "/tmp/$dir"; 666 SystemVariables::DEBUG("Int:", "Statting $dir"); 667 668 669 #print STDERR "Statting $dir\n"; 670 671 if(-d $dir) { 672 673 ($mtime) = (stat($dir))[9]; 674 675 #These lines should check the difference between the 676 # current time and the modify time on the directory; 677 # if they are greater than 2 minutes (120 sec), then 678 # the directory and everything in it can be nuked. 679 # 680 681 $currentTime = time(); 682 683 #print STDERR "C: $currentTime \t T: " . time() . "\n"; 684 685 if(( $currentTime - $mtime ) > 120) { 686 687 system("rm", "-rf", $dir); 688 } 689 } 690 } 691 } 692 } 693 694 695 sub downloadChooser { 696 697 my ( @sectionnumbers, 698 $webPath, 699 $caller, 700 $assignmentIDs 701 ); 702 703 $caller = SystemVariables::getCallingScript(); 704 $assignmentIDs = Assignments::getAssignmentIDs(); 705 706 if($caller =~ /admin/) { 707 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 708 } elsif ($caller =~ /assistant/) { 709 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 710 } else { 711 $webPath = SystemVariables::getStudentWebPath() . "student.cgi"; 712 } 713 714 print "<TR><TD>n"; 715 716 tableTop("Download Assignments"); 717 718 print "<P>All criteria you select will be used to limit your search.</P>"; 719 startForm($webPath); 720 721 hidden("DOWNLOAD", "1"); 722 ####### 723 # Section number selection 724 print "<TABLE WIDTH='100%'>n"; 725 print "<TR><TD WIDTH='30%'>"; 726 727 #if($caller eq Admin) { 728 checkbox(1, "_sectionnumberboolean", 729 "Section Number", 730 CHECKED); 731 #} else { 732 #radio(1, "_sectionnumberboolean", 733 #"Section Number", 734 #CHECKED); 735 #} 736 737 print "</TD><TD WIDTH='70%'>"; 738 739 @sectionnumbers = Record::getAllSectionNumbers(); 740 selectInput(" ", 741 "_sectionnumber", 742 @sectionnumbers); 743 744 print "</TD></TR></TABLE>"; 745 746 ############ 747 # Search string 748 print "<TABLE WIDTH='100%'>n"; 749 print "<TR><TD WIDTH='30%'>"; 750 751 checkbox(1, "_searchstringboolean", 752 "Search String "); 753 754 print "</TD><TD WIDTH='70%'>"; 755 756 757 #selectInput("", 758 # "_searchstring", 759 # @{$assignmentIDs}); 760 761 textInput("", 762 "_searchstring", 763 "", 764 20); 765 766 print "</TD></TR></TABLE>"; 767 768 769 ############ 770 # Assignment 771 print "<TABLE WIDTH='100%'>n"; 772 print "<TR><TD WIDTH='30%'>"; 773 774 checkbox(1, "_assignmentboolean", 775 "Assignment"); 776 777 print "</TD><TD WIDTH='70%'>"; 778 779 780 selectInput("", 781 "_assignmentsearch", 782 @{$assignmentIDs}); 783 784 #textInput("", 785 # "_assignmentsearch", 786 # " ", 787 # 20); 788 789 print "</TD></TR></TABLE>"; 790 791 #print "<!--" ; 792 793 ############ 794 # Date 795 print "<TABLE WIDTH='100%'>n"; 796 print "<TR><TD WIDTH='30%'>"; 797 798 checkbox(1, "_searchdateboolean", 799 "By Date"); 800 801 print "</TD><TD WIDTH='70%'>"; 802 803 804 print "<TABLE WIDTH='100%'>n"; 805 print "<TR><TD>n"; 806 print "<CENTER><SMALL>Year</SMALL></CENTER><BR>"; 807 selectInput(" ", 808 "_searchdateyear", 809 SystemVariables::getCurrentYear(), 810 SystemVariables::getCurrentYear(-1), 811 SystemVariables::getCurrentYear(+1), 812 ); 813 814 print "</TD><TD>n"; 815 print "<CENTER><SMALL>Month</SMALL></CENTER><BR>"; 816 selectInput(" ", 817 "_searchdatemonth", 818 SystemVariables::getCurrentMonth(), 819 SystemVariables::getCurrentMonth(-1), 820 "01","02","03","04","05","06", 821 "07","08","09","10","11","12" 822 ); 823 824 print"</TD><TD>n"; 825 print "<CENTER><SMALL>Day</SMALL></CENTER><BR>"; 826 selectInput(" ", 827 "_searchdateday", 828 SystemVariables::getCurrentDay(), 829 "01","02","03","04","05","06","07","08","09", 830 10, 831 11,12,13,14,15,16,17,18,19,20, 832 21,22,23,24,25,26,27,28,29,30,31); 833 834 print "</TD></TR></TABLE>n"; 835 836 print "</TD></TR></TABLE>n"; 837 838 checkbox(1, "_mostrecent", 839 "<STRONG>Only</STRONG> most recent version if multiple submissions exist."); 840 841 #print "-->"; 842 endForm(); 843 tableBottom(); 844 845 print "</TD></TR>"; 846 } 847 848 sub gradesChooser { 849 850 851 my ( $webPath, 852 $caller, 853 $ADMIN, $ASSIST, $STU, 854 @sectionnumbers, $students 855 ); 856 857 $ADMIN = 0; 858 $ASSIST = 0; 859 $STU = 0; 860 861 $caller = SystemVariables::getCallingScript(); 862 863 if($caller =~ /admin/) { 864 $ADMIN = 1; 865 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 866 } elsif ($caller =~ /assistant/) { 867 $ASSIST = 1; 868 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 869 } elsif ($caller =~ /form/) { 870 $ASSIST = 1; 871 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 872 } 873 874 print "<TR><TD>n"; 875 876 tableTop("Handling Grades"); 877 startForm($webPath); 878 879 $assignmentIDs = Assignments::getAssignmentIDs(); 880 @sectionnumbers = Record::getAllSectionNumbers(); 881 882 883 if($ASSIST || $ADMIN) { 884 885 #Assignment and section number selection 886 print "<TABLE WIDTH='100%'><TR><TD WIDTH='1'>"; 887 888 radio("SubmitGrades", 889 "GRADESCHOOSER", 890 "", 891 "CHECKED"); 892 893 print "</TD><TD>"; 894 895 selectInput("Submit grades for ", 896 "SUBMITGRADECHOOSEASSIGN", 897 @{$assignmentIDs}); 898 print "</TD><TD>"; 899 900 @sectionnumbers = Record::getAllSectionNumbers(); 901 selectInput("in section", 902 "_sectionnumber", 903 @sectionnumbers); 904 print "</TD></TR></TABLE>"; 905 906 #Grades overview 907 print "<TABLE WIDTH='100%'><TR><TD WIDTH='1'>"; 908 909 radio( "ViewGrades", 910 "GRADESCHOOSER", 911 "", 912 ""); 913 914 print "</TD><TD>"; 915 selectInput("View grades for section ", 916 "VIEWGRADESSECTION", 917 @sectionnumbers); 918 print "</TD><TD>"; 919 optionInput("for assignments ", 920 "_assignments", 921 @{Assignments::getAssignmentIDs()}); 922 print "</TD></TR></TABLE>"; 923 924 } 925 926 endForm(); 927 tableBottom(); 928 929 print "</TD></TR>"; 930 931 } 932 933 sub viewGrades { 934 935 my ($tag, $sectionnumber, @assignIDs, 936 $students, $mod, $assn, $total, 937 $studata, $sysID, $rownumber, $max, $maxtotal, 938 $callingScript, $MAPINPUT, $MAPOUTPUT); 939 940 ($tag, $sectionnumber, @assignIDs) = @_; 941 942 ##LOGGING 943 VincentLog::clickLog("GRADES", "View grades for " . $sectionnumber); 944 945 $callingScript = SystemVariables::getCallingScript(); 946 947 #Wouldn't it be cool if I sorted by due date here... 948 # it can be done... I just need a way to 949 # sort { dueDateAsNumber($a) <=> dueDateAsNumber($b) } @assignIDs 950 @assignIDs = sort(@assignIDs); 951 952 $students = Record::getAllUsernamesInSection($sectionnumber); 953 954 print "<TR><TD>"; 955 956 tableTop("Grades for section $sectionnumber"); 957 958 print "<TABLE WIDTH='100%'><TR BGCOLOR='CCCCCC'>"; 959 print "<TD><CENTER><STRONG>Last</STRONG></CENTER></TD>"; 960 print "<TD><CENTER><STRONG>First</STRONG></CENTER></TD>"; 961 print "<TD><CENTER><STRONG>Username</STRONG></CENTER></TD>"; 962 963 #Print the names of the assignments vertically. 964 # The regexp. inserts lots of <BR> tags to create 965 # this effect. 966 967 968 foreach $assn (@assignIDs) { 969 $mod = $assn; 970 print "<TD><CENTER><SMALL><SMALL>"; 971 $mod =~ s/(w)/$1<BR>/g; 972 print $mod; 973 974 $max = Assignments::getAssignmentMaxValue($assn); 975 $maxtotal += $max; 976 print "</SMALL></SMALL><BR>$max"; 977 978 print "</CENTER></TD>"; 979 #For something more 'normal' 980 #print "<TD>$assn</TD>"; 981 } 982 983 #If it is the administrator, add the total field. 984 if($callingScript eq "admin") { 985 #Add a total field as well, for fun... 986 print "<TD><CENTER><STRONG>"; 987 $total = "Total"; 988 $total =~ s/(w)/$1<BR>/g; 989 print $total; 990 print "</STRONG></CENTER></TD>"; 991 } 992 993 print "</TR>"; 994 995 #Generate a table row for each student 996 # in the section. 997 foreach $stu (@{$students}) { 998 #Reset the total (for points) to zero, 999 # and start a row. 1000 $total = 0; 1001 $maxtotal = 0; 1002 1003 if ( 0 == (++$rownumber % 2)) { 1004 $rowcolor = "CCCCCC"; 1005 } else { 1006 $rowcolor = "FFFFFF"; 1007 } 1008 1009 #Lets show expired students in a slightly 1010 # different light; 1011 if(Record::isStudentExpired($stu)) { 1012 $flagstart = "<EM><FONT COLOR='#FFCC99'>"; 1013 $flagend = "</FONT></EM>"; 1014 } else { 1015 $flagstart = ""; 1016 $flagend = ""; 1017 } 1018 1019 1020 print "<TR BGCOLOR='$rowcolor'>"; 1021 1022 #Grab their record. 1023 $studata = Record::getStudentRecord($stu); 1024 1025 #Print the name, and then username of the student 1026 print "<TD>$flagstart", $$studata{"_LASTNAME"}, "$flagend</TD>"; 1027 print "<TD>$flagstart", $$studata{"_FIRSTNAME"}, "$flagend</TD>"; 1028 print "<TD ALIGN='RIGHT'>$flagstart $stu $flagend</TD>"; 1029 1030 #Print the values of the assignments that 1031 # exist. Reverse video all zeros so they stand 1032 # out. 1033 1034 foreach $assn (@assignIDs) { 1035 1036 $sysID = Assignments::getAssignmentSystemID($assn); 1037 1038 if($callingScript ne "admin") { 1039 #Load the mapping up front; eval it over and over. 1040 $map = Assignments::loadGradeMapping($$studata{$sysID . "_GRADEMAPPING"}); 1041 } 1042 1043 #First, check to see if the grade has been 1044 # submitted for the assignment. 1045 if(defined($$studata{$sysID . "_GRADE"}) && length($$studata{$sysID . "_GRADE"}) >= 1) { 1046 1047 #Check to make sure it wasn't larger 1048 # than the max allowed value, and 1049 # set reverse video if that is the case. 1050 1051 $bgcolor = makeRelativeHexColor($$studata{$sysID . "_GRADE"}, $$studata{$sysID . "_MAXVALUE"}); 1052 $font = "FFFFFF"; 1053 1054 #Don't color fields where a number is greater than 1055 # the max score for that field... 1056 if($$studata{$sysID . "_GRADE"} > 1057 $$studata{$sysID . "_MAXVALUE"}) { 1058 $bgcolor = "FFFFFF"; 1059 $font = "000000"; 1060 } 1061 1062 print "<TD ALIGN='RIGHT' BGCOLOR='$bgcolor'>"; 1063 print "<FONT COLOR='#$font'>"; 1064 1065 #The admin always sees numbers; the assistants, 1066 # because they might be working with students, 1067 # only see letter grades. 1068 if($callingScript eq "admin") { 1069 print $$studata{$sysID . "_GRADE"}, " </FONT></TD>"; 1070 } else { 1071 $MAPINPUT = $$studata{$sysID . "_GRADE"}; 1072 #Eval the input, generate an output 1073 eval $map; 1074 print $MAPOUTPUT, " </FONT></TD>"; 1075 } 1076 1077 $total += $$studata{$sysID . "_GRADE"}; 1078 1079 1080 $max = $$studata{$sysID . "_MAXVALUE"}; 1081 $maxtotal += $max; 1082 1083 } else { 1084 #Need to parameterize as to what this symbol is... "X" or "Z" or 1085 # whatever... 1086 #$bgcolor = makeRelativeHexColor(0, $$studata{$sysID . "_MAXVALUE"}); 1087 $bgcolor = "666666"; 1088 $font = "FFFFFF"; 1089 print "<TD ALIGN='RIGHT' BGCOLOR='$bgcolor'><FONT COLOR='$font'>"; 1090 print "<CENTER>X</CENTER>"; 1091 print "</FONT></TD>"; 1092 } 1093 } 1094 1095 #Print the total if it is the admin script 1096 if($callingScript eq "admin") { 1097 $bgcolor = makeRelativeHexColor($total, $maxtotal); 1098 $font = "FFFFFF"; 1099 1100 if($total > $maxtotal) { 1101 $bgcolor = "FFFFFF"; 1102 $font = "000000"; 1103 } 1104 1105 print "<TD ALIGN='RIGHT' BGCOLOR='$bgcolor'><FONT COLOR='$font'>$total </FONT></TD>"; 1106 } 1107 1108 print "</TR>"; 1109 } 1110 1111 print "</TABLE>"; 1112 1113 tableBottom(); 1114 print "</TD></TR>"; 1115 1116 } 1117 1118 1119 sub makeRelativeHexColor { 1120 1121 my($percentage_remaining, 1122 $percentage_gone, 1123 $current, 1124 $max, 1125 $red, 1126 $blue, 1127 $green, 1128 $hex); 1129 1130 ($current, $max) = @_; 1131 1132 if($max != 0) { 1133 $percentage_remaining = $current/$max; 1134 $percentage_gone = 1 - $percentage_remaining; 1135 1136 $red = 255 * $percentage_remaining; 1137 $blue = 255 * $percentage_gone; 1138 $green = "00"; 1139 1140 $red = sprintf("%lx", $red); 1141 $blue = sprintf("%lx", $blue); 1142 1143 $hex = "$red$green$blue"; 1144 } else { 1145 $hex = "000000"; 1146 } 1147 1148 return $hex; 1149 } 1150 1151 sub submitGradesForm { 1152 1153 1154 my ( $webPath, 1155 $caller, 1156 $ADMIN, $ASSIST, $STU, 1157 $students, 1158 $sectionnumber, 1159 $studata, 1160 $grade, $bgcolor 1161 ); 1162 1163 $ADMIN = 0; 1164 $ASSIST = 0; 1165 $STU = 0; 1166 1167 $caller = SystemVariables::getCallingScript(); 1168 $assignID = $_[1]; 1169 $sysID = Assignments::getAssignmentSystemID($assignID); 1170 $sectionnumber = $_[2]; 1171 1172 ##LOGGING 1173 VincentLog::clickLog("GRADES", "Submit grades form for section " . $sectionnumber); 1174 1175 1176 if($caller =~ /admin/) { 1177 $ADMIN = 1; 1178 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 1179 } elsif ($caller =~ /assistant/) { 1180 $ASSIST = 1; 1181 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 1182 } 1183 1184 1185 $students = Record::getAllUsernamesInSection($sectionnumber); 1186 1187 1188 print "<TR><TD>n"; 1189 1190 tableTop("Submit Grades for Assignment $assignID in section $sectionnumber."); 1191 startForm($webPath); 1192 #Let the processing script know what 1193 # assignment is being graded. 1194 hidden("GRADESUBMISSION", $sysID); 1195 1196 #Generate the web form 1197 foreach $student (@{$students}) { 1198 1199 $studata = Record::getStudentRecord($student); 1200 1201 #If they already have a grade, insert it. Otherwise, 1202 # leave the grade space blank. 1203 if(defined($$studata{$sysID . "_GRADE"}) 1204 && (length($$studata{$sysID . "_GRADE"}) >= 1)) { 1205 1206 $grade = $$studata{$sysID . "_GRADE"}; 1207 1208 #If someone entered a value too high, flag it. 1209 if($grade <= $$studata{$sysID . "_MAXVALUE"}) { 1210 $bgcolor = "FFCCCC"; 1211 $font = "000000"; 1212 }else { 1213 $bgcolor = "000000"; 1214 $font = "FFFFFF"; 1215 } 1216 } else { 1217 $grade = ""; 1218 $bgcolor = "FFFFFF"; 1219 $font = "000000"; 1220 } 1221 1222 my($flagstart, 1223 $flagend, 1224 $expired); 1225 1226 #Lets show expired students in a slightly 1227 # different light; 1228 if(Record::isStudentExpired($student)) { 1229 $flagstart = "<EM><FONT COLOR='#FFCC99'>"; 1230 $flagend = "</FONT></EM>"; 1231 $expired = 1; 1232 } else { 1233 $flagstart = ""; 1234 $flagend = ""; 1235 $expired = 0; 1236 } 1237 1238 1239 #HIDING ALL STUDENTS WHO ARE EXPIRED FROM THIS FORM 1240 # This way, graders don't go looking for papers from 1241 # people who are no longer in the course. 1242 1243 if(!$expired) { 1244 print "<TABLE WIDTH='100%' BGCOLOR='$bgcolor'><TR><TD WIDTH='40%'>"; 1245 textInput("<FONT COLOR='$font'>$flagstart $student $flagend</FONT>", 1246 $student . "|" . $sysID . "_GRADE", 1247 $grade, 1248 "3", 1249 60, 1250 40); 1251 print "</TD><TD WIDTH='40%'><FONT COLOR='$font'>"; 1252 print "(<SMALL>$flagstart", $$studata{"_FIRSTNAME"}, " ", $$studata{"_LASTNAME"}, "$flagend</SMALL>) "; 1253 print "</FONT></TD><TD WIDTH='20%'><FONT COLOR='$font'>$flagstart"; 1254 print "of a possible <STRONG>", $$studata{$sysID . "_MAXVALUE"}, "</STRONG>"; 1255 print "$flagend</FONT></TD></TR></TABLE>"; 1256 1257 } 1258 } 1259 1260 1261 endForm(); 1262 tableBottom(); 1263 1264 print "</TD></TR>"; 1265 1266 } 1267 1268 1269 1270 sub _template_for_new_functions { 1271 1272 1273 my ( @sectionnumbers, 1274 $webPath, 1275 $caller, 1276 $ADMIN, $ASSIST, $STU 1277 ); 1278 1279 $ADMIN = 0; 1280 $ASSIST = 0; 1281 $STU = 0; 1282 1283 $caller = SystemVariables::getCallingScript(); 1284 1285 if($caller =~ /admin/) { 1286 $ADMIN = 1; 1287 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 1288 } elsif ($caller =~ /assistant/) { 1289 $ASSIST = 1; 1290 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 1291 } else { 1292 $STU = 1; 1293 $webPath = SystemVariables::getStudentWebPath() . "student.cgi"; 1294 } 1295 1296 print "<TR><TD>n"; 1297 1298 tableTop("Handling Grades"); 1299 startForm($webPath); 1300 1301 $assignmentIDs = Assignments::getAssignmentIDs(); 1302 1303 if($ASSIST || $ADMIN) { 1304 selectInput("Submit grades for ", 1305 "SUBMITGRADECHOOSEASSIGN", 1306 @$assignmentIDs); 1307 } 1308 1309 1310 1311 endForm(); 1312 tableBottom(); 1313 1314 print "</TD></TR>"; 1315 1316 } 1317 1318 sub calendar { 1319 1320 my($month)=@_; 1321 my (@months, @start, @end); 1322 1323 my($day,$day1,$day2,$day3,$day4,$day5,$day6,$day7); 1324 1325 @months = ("NULL", "January", "February", "March", 1326 "April", "May", "June", 1327 "July", "August", "September", 1328 "October", "November", "December"); 1329 @start = (0,6,2,3,6,1,4,6,2,5,0,3,5); 1330 @end = (0,31,28,31,30,31,30,31,31,30,31,30,31); 1331 1332 $year = SystemVariables::getCurrentYear(); 1333 1334 if ($month==0) { 1335 my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); 1336 $secs=time(); 1337 $secs-=($mday-1)*24*60*60; 1338 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs); 1339 $month=$mon+1; 1340 $day=1-$wday; 1341 } else { 1342 $day=1-$start[$month]; 1343 } 1344 1345 print "<CENTER><TABLE BORDER=2 WIDTH='98%' CELLSPACING=0 CELLPADDING=8>n"; 1346 print "<TR><TH COLSPAN=7>" . $months[$month] . " $year"; 1347 print " Whole Month: <INPUT TYPE='CHECKBOX' NAME='$month-ALL' VALUE='1'></TH></TR>n"; 1348 print "<TR><TH WIDTH='14%'>Sunday</TH><TH WIDTH='14%'>Monday</TH><TH WIDTH='14%'>Tuesday</TH><TH WIDTH='14%'>Wednesday</TH><TH WIDTH='14%'>Thursday</TH><TH WIDTH='14%'>Friday</TH><TH WIDTH='14%'>Saturdayn"; 1349 while ($day<=$end[$month]) { 1350 if ($day>0 && $day<=$end[$month]) {$day1=$day;} else {$day1="";} $day++; 1351 if ($day>0 && $day<=$end[$month]) {$day2=$day;} else {$day2="";} $day++; 1352 if ($day>0 && $day<=$end[$month]) {$day3=$day;} else {$day3="";} $day++; 1353 if ($day>0 && $day<=$end[$month]) {$day4=$day;} else {$day4="";} $day++; 1354 if ($day>0 && $day<=$end[$month]) {$day5=$day;} else {$day5="";} $day++; 1355 if ($day>0 && $day<=$end[$month]) {$day6=$day;} else {$day6="";} $day++; 1356 if ($day>0 && $day<=$end[$month]) {$day7=$day;} else {$day7="";} $day++; 1357 if ($day1 ne "") {$day1.= "<BR>";} else {$day7.= "<BR>";} 1358 1359 @days = ($day1, $day2, $day3, $day4, $day5, $day6, $day7); 1360 print "<TR VALIGN=TOP>"; 1361 1362 foreach $d (@days) { 1363 1364 if($d) { 1365 print "<TD ALIGN=RIGHT>"; 1366 print "<INPUT TYPE='CHECKBOX' NAME='$month-$d' VALUE='1'>"; 1367 } else { 1368 print "<TD BGCOLOR='CCCCCC'> "; 1369 } 1370 1371 print "$d"; 1372 print "</TD>"; 1373 } 1374 } 1375 print "</TABLE></CENTER>n"; 1376 } 1377 1378 sub editTeams { 1379 1380 my ( $webPath, 1381 $caller, 1382 $ADMIN, $ASSIST, $STU, 1383 $sectionListRef, 1384 $stuInSection, 1385 $teamsInSection, 1386 @done, 1387 $record, 1388 $teammates, 1389 $teammate, 1390 $stu, 1391 $allTeams, 1392 @temp, 1393 @colors, 1394 $colorindex, 1395 @sorted, 1396 $max, 1397 $memberlist, 1398 @noteam, 1399 @sectiontemp 1400 ); 1401 1402 $sectionListRef = $_[0]; 1403 1404 @sectiontemp = @{$sectionListRef}; 1405 1406 undef %saw; 1407 @sectiontemp = grep(!$saw{$_}++, @sectiontemp); 1408 1409 $sectionListRef = @sectiontemp; 1410 1411 $ADMIN = 0; 1412 $ASSIST = 0; 1413 $STU = 0; 1414 1415 $caller = SystemVariables::getCallingScript(); 1416 1417 if($caller =~ /admin/) { 1418 $ADMIN = 1; 1419 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 1420 $allTeams = Teams::getAllTeamNumbers(); 1421 SystemVariables::DEBUG("Int:", @{$allTeams}); 1422 } elsif ($caller =~ /assistant/) { 1423 $ASSIST = 1; 1424 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 1425 } else { 1426 $STU = 1; 1427 $webPath = SystemVariables::getStudentWebPath() . "student.cgi"; 1428 } 1429 1430 @colors = ("FFCC00", 1431 "FFFF00", 1432 "FF99FF", 1433 "CCFF66", 1434 "CCCC99", 1435 "99FF00", 1436 "999999", 1437 "9999FF", 1438 "66CC33", 1439 "99CCFF", 1440 "33FF99", 1441 "00CCFF" 1442 ); 1443 1444 @colors = reverse(@colors); 1445 1446 $colorindex = 0; 1447 1448 print "n<TR><TD>n"; 1449 1450 tableTop("Edit Teams"); 1451 startForm($webPath); 1452 hidden("NEWTEAMLIST", 1); 1453 1454 @done = (); 1455 $oldTeam = -1; 1456 1457 foreach $section (@{$sectionListRef}) { 1458 1459 $stuInSection = Record::getAllUsernamesInSection($section); 1460 $teamsInSection = Teams::getAllTeamsInSection($section); 1461 1462 SystemVariables::DEBUG("Int:", "Teams: ", @{$teamsInSection}); 1463 1464 print "n\n<TABLE WIDTH='100%'>"; 1465 print "n<TR><TD COLSPAN='6' BGCOLOR='000000'>"; 1466 print "<h1><CENTER><FONT COLOR='FFFFFF'>Section $section</FONT></CENTER></H1>"; 1467 print "</TD></TR>"; 1468 1469 print "n<TR BGCOLOR='CCCCCC'>"; 1470 print "<TD WIDTH='20%'><STRONG>Last Name</STRONG></TD>"; 1471 print "<TD WIDTH='20%'><STRONG>First Name</STRONG></TD>"; 1472 print "<TD WIDTH='20%'><STRONG>Username</STRONG></TD>"; 1473 print "<TD WIDTH='20%'><STRONG>Team Number</STRONG></TD>"; 1474 print "<TD WIDTH='20%'><STRONG>Membership</STRONG></TD>"; 1475 print "<TD WIDTH='20%'><STRONG>Section Number</STRONG></TD>"; 1476 print "</TR>"; 1477 1478 $index = 0; 1479 1480 #Well, perl doesn't actually like some of what I'm trying to do. 1481 #So, first go through and build up a good list of people _with_ teams, 1482 # and a list without. 1483 1484 @temp = (); 1485 foreach $stu (@{$stuInSection}) { 1486 chomp $stu; 1487 if($stu) { 1488 $record = Record::getStudentRecord($stu); 1489 if(!(defined($$record{"_TEAMNUMBER"}))) { 1490 $$record{"_TEAMNUMBER"} = "X"; 1491 $$record{"_TEAMMEMBERS"} = "$stu"; 1492 } 1493 1494 Record::updateStudentRecord($stu, $record); 1495 } 1496 } 1497 1498 foreach $stu (@noteam) { 1499 SystemVariables::DEBUG("Int:", "No Team for $stu"); 1500 } 1501 1502 foreach $stu (@{$stuInSection}) { 1503 1504 $record = Record::getStudentRecord($stu); 1505 1506 $teammates = $$record{"_TEAMMEMBERS"}; 1507 $currentTeam = $$record{"_TEAMNUMBER"}; 1508 1509 if("$currentTeam" ne "$oldTeam") { 1510 $bgcolor = $colors[(($colorindex++)%(scalar(@colors)))]; 1511 } 1512 1513 #This shouldn't be an issue, but it is 1514 # better to be slow than sorry. 1515 $teammates =~ s/^(s*)//g; 1516 $teammates =~ s/(s*)$//g; 1517 1518 foreach $teammate ((split(/s+/, $teammates))) { 1519 if($teammate) { 1520 if(!SystemVariables::existInList($teammate, @done)) { 1521 $record = Record::getStudentRecord($teammate); 1522 1523 print "n<TR BGCOLOR='$bgcolor'>"; 1524 print "n<TD>", $$record{"_LASTNAME"}, "</TD>"; 1525 print "n<TD>", $$record{"_FIRSTNAME"}, "</TD>"; 1526 print "n<TD>", $teammate, "</TD>"; 1527 print "n<TD>"; 1528 1529 if($ADMIN) { 1530 @sorted = sort {$a <=> $b} @{$allTeams}; 1531 $max = $sorted[$#sorted]; 1532 $max++; 1533 Interface::selectInput("", 1534 $teammate . "_TEAMNUMBER", 1535 $$record{"_TEAMNUMBER"}, 1536 @sorted, 1537 $max); 1538 } else { 1539 Interface::selectInput("", 1540 $teammate . "_TEAMNUMBER", 1541 $$record{"_TEAMNUMBER"}, 1542 @{$teamsInSection}); 1543 } 1544 1545 print "</TD>"; 1546 $memberlist = $$record{"_TEAMMEMBERS"}; 1547 $memberlist =~ s/$teammate/<EM>$teammate</EM>/; 1548 print "n<TD><SMALL>", $memberlist, "</SMALL></TD>"; 1549 print "n<TD><CENTER>", $$record{"_SECTIONNUMBER"}, "</CENTER></TD>"; 1550 print "</TR>"; 1551 1552 push(@done, $teammate); 1553 } 1554 } 1555 } 1556 1557 $oldTeam = $currentTeam; 1558 1559 } 1560 1561 print "</TABLE>n"; 1562 } 1563 1564 endForm(); 1565 tableBottom(); 1566 1567 print "n\n</TD></TR>"; 1568 } 1569 1570 1571 sub teamChooser { 1572 1573 my ($adminWebPath, 1574 $ADMIN, 1575 $ASSIST, 1576 $STU, 1577 $webPath 1578 ); 1579 1580 1581 1582 $ADMIN = 0; 1583 $ASSIST = 0; 1584 $STU = 0; 1585 1586 $caller = SystemVariables::getCallingScript(); 1587 1588 if($caller =~ /admin/) { 1589 $ADMIN = 1; 1590 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 1591 } elsif ($caller =~ /assistant/) { 1592 $ASSIST = 1; 1593 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 1594 } 1595 1596 #If it is an administrator, and they can edit teams, 1597 # OR 1598 # if they are an admin, then continue 1599 if( 1600 (SystemVariables::canAssistantEditTeams() && $ASSIST) 1601 || 1602 ($ADMIN)) { 1603 1604 print "<TR><TD>n"; 1605 1606 Interface::tableTop("Team Operations"); 1607 Interface::startForm($webPath); 1608 1609 1610 print "<TABLE WIDTH='100%'><TR><TD>"; 1611 Interface::radio("ViewPeerEvals", 1612 "TEAMCHOOSER", 1613 "View PEs for ", 1614 "CHECKED"); 1615 print "</TD><TD>"; 1616 1617 Interface::selectInput("", 1618 "_peereval", 1619 @{Assignments::getAllPeerEvals()}); 1620 print "</TD><TD>"; 1621 1622 Interface::selectInput("in section ", 1623 "_sectionnumber", 1624 Record::getAllSectionNumbers()); 1625 print "</TD></TR></TABLE>"; 1626 1627 1628 print "<TABLE WIDTH='100%'><TR><TD>"; 1629 Interface::radio("EditSectionTeams", 1630 "TEAMCHOOSER", 1631 "Edit Teams in section", 1632 ""); 1633 print "</TD><TD>"; 1634 1635 Interface::selectInput("", 1636 "_sectionnumber", 1637 Record::getAllSectionNumbers()); 1638 print "</TD></TR></TABLE>"; 1639 1640 #Only present these big, global options to administrators. 1641 if($ADMIN) { 1642 1643 Interface::radio("EditAllTeams", 1644 "TEAMCHOOSER", 1645 "Edit All Teams", 1646 ""); 1647 1648 print "<TABLE WIDTH='100%'><TR><TD>"; 1649 Interface::radio("RandomizeAllTeams", 1650 "TEAMCHOOSER", 1651 "Randomize All Teams", 1652 ""); 1653 print "</TD><TD>"; 1654 1655 Interface::textInput("Average Size", 1656 "AverageTeamSize", 1657 "5", 1658 3); 1659 print "</TD><TD>"; 1660 Interface::checkbox(1, 1661 "AreYouSure", 1662 "I mean it!"); 1663 print "</TD></TR></TABLE>"; 1664 1665 } 1666 1667 1668 Interface::endForm(); 1669 Interface::tableBottom(); 1670 print "</TD></TR>"; 1671 } 1672 1673 } 1674 1675 sub viewPeerEvals { 1676 1677 my($section, 1678 $assign, 1679 $sysID, 1680 $caller, 1681 $ADMIN, 1682 $webpath, 1683 $ASSIST, 1684 $stuInSection, 1685 $teamsInSection, 1686 $stu, 1687 $record, 1688 $memarray, 1689 $index, 1690 %saw, 1691 @memarray, 1692 $team, 1693 @team_array, 1694 $mem, 1695 $all, 1696 $bgcolor, 1697 $fontcolor, 1698 $fontstart, 1699 $fontend, 1700 $memrec, 1701 $total, 1702 $score, 1703 $count, 1704 $grade, 1705 $correctedText, 1706 $comment); 1707 1708 1709 $section = $_[1]; 1710 $assign = $_[2]; 1711 $sysID = Assignments::getAssignmentSystemID($assign); 1712 $index = 0; 1713 1714 $caller = SystemVariables::getCallingScript(); 1715 if($caller =~ /admin/) { 1716 $ADMIN = 1; 1717 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 1718 } elsif ($caller =~ /assistant/) { 1719 $ASSIST = 1; 1720 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 1721 } 1722 1723 $stuInSection = Record::getAllUsernamesInSection($section); 1724 $teamsInSection = Teams::getAllTeamsInSection($section); 1725 1726 foreach $stu (@{$stuInSection}) { 1727 $record = Record::getStudentRecord($stu); 1728 $memarray[$index++] = $$record{"_TEAMMEMBERS"}; 1729 } 1730 1731 undef %saw; 1732 @memarray = grep(!$saw{$_}++, @memarray); 1733 1734 #memarray now holds a uniq list of each 1735 # set of members. So, present the data for each 1736 # student from these membership lists, building 1737 # up the scores and whatnot... 1738 1739 1740 Interface::tableTop("View Peer Evaluations for section $section"); 1741 Interface::startForm($webPath); 1742 Interface::hidden("GRADEPEEREVALS", 1); 1743 1744 #For each team in the memarray, grab the members of the team. 1745 foreach $team (@memarray) { 1746 $team =~ s/^(s*)//g; 1747 1748 @team_array = (split(/s+/, $team)); 1749 1750 #For each member of the team, present 1751 # their name, and the total score given to 1752 # them by everyone else. 1753 foreach $team_member (@team_array) { 1754 1755 1756 #Did they do all of their peer evals? 1757 # This check will be used throughout to determine 1758 # display and formatting. 1759 $record = Record::getStudentRecord($team_member); 1760 $all = 1; 1761 foreach $mem (@team_array) { 1762 if((!defined($$record{$sysID . "_SCORE_" . $mem})) 1763 || 1764 (length($$record{$sysID . "_SCORE_" . $mem})) < 1) { 1765 $all = 0; 1766 } 1767 } 1768 1769 1770 #If they did all of their peer evals, then 1771 # set appropriate background and foreground colors. 1772 if($all) { 1773 $fontcolor = "000000"; 1774 $bgcolor = "66CCFF"; 1775 } else { 1776 $bgcolor = "FFFFFF"; 1777 $fontcolor = "BBBBBB"; 1778 } 1779 1780 #This makes it easier to do throughout. 1781 $fontstart = "<FONT COLOR='$fontcolor'>"; 1782 $fontend = "</FONT>"; 1783 1784 #Note the doubly-nested tables... it looks nicer 1785 # that way. 1786 print "<TABLE WIDTH='100%' BGCOLOR='#$bgcolor'><TR><TD>"; 1787 print "<TABLE WIDTH='100%'>"; 1788 print "<TR><TD COLSPAN='4'>$fontstart Scores for <STRONG>"; 1789 print $$record{"_FIRSTNAME"}, " ", $$record{"_LASTNAME"}; 1790 print " </STRONG>(<STRONG>$team_member</STRONG>): $fontend</TD></TR>"; 1791 1792 $total = 0; 1793 $count = 0; 1794 foreach $mem (@team_array) { 1795 $memrec = Record::getStudentRecord($mem); 1796 1797 #Only print this out if they have actually submitted a score 1798 # for that person. 1799 #if(defined($$memrec{$sysID . "_SCORE_" . $team_member})) { 1800 $score = $$memrec{$sysID . "_SCORE_" . $team_member}; 1801 $comment = $$memrec{$sysID . "_COMMENTS_" . $team_member}; 1802 1803 print "<TR>"; 1804 print "<TD WIDTH='5%'> </TD>"; 1805 print "<TD WIDTH='30%'>$fontstart Score from $mem: $fontend</TD>"; 1806 1807 if(!$score) { 1808 print "<TD WIDTH='15%'>$fontstart X $fontend</TD>"; 1809 $score = 0; 1810 } else { 1811 print "<TD WIDTH='15%'>$fontstart $score $fontend</TD>"; 1812 $total += $score; 1813 $count++; 1814 } 1815 1816 #print "</TR>"; 1817 #print "<TR>"; 1818 #print "<TD></TD>"; 1819 #print "<TD>$fontstart Comments: $fontend </TD>"; 1820 1821 if(!$comment) { 1822 print "<TD WIDTH='50%'>$fontstart No comment made for $team_member by $mem. $fontend</TD>"; 1823 } else { 1824 1825 print "<TD WIDTH='50%'>$fontstart $comment $fontend</TD>"; 1826 } 1827 1828 print "</TR>"; 1829 1830 } 1831 1832 1833 if($all) { 1834 print "<TR><TD> </TD>"; 1835 print "<TD><STRONG>Average</STRONG>: </TD>"; 1836 1837 print "<TD> </TD>"; 1838 print "<TD>"; 1839 1840 #This if clause catches whether an incorrect average was 1841 # corrected by a human. 1842 $correctedText = ""; 1843 if(defined($$record{$sysID . "_GRADE"})) { 1844 $grade = $$record{$sysID . "_GRADE"}; 1845 if($grade != ($total/$count)) { 1846 $correctedText = "<STRONG>Corrected: </STRONG>"; 1847 } 1848 } else { 1849 $grade = $total/$count; 1850 } 1851 1852 Interface::textInput($correctedText, 1853 $sysID . "_GRADE_" . $team_member, 1854 $grade, 1855 3); 1856 print "</TD>"; 1857 1858 print "</TR>"; 1859 } else { 1860 print "<TR><TD COLSPAN='4'><CENTER>"; 1861 print "$fontstart $team_member has not turned in a peer eval yet.$fontend"; 1862 print "</CENTER></TD></TR>"; 1863 } 1864 1865 print "</TABLE></TD></TR></TABLE>"; 1866 } 1867 } 1868 1869 Interface::endForm(); 1870 Interface::tableBottom(); 1871 1872 } 1873 1874 sub permitFiles { 1875 1876 $caller = SystemVariables::getCallingScript(); 1877 if($caller =~ /admin/) { 1878 $ADMIN = 1; 1879 $webPath = SystemVariables::getAdminWebPath() . "admin.cgi"; 1880 } elsif ($caller =~ /assistant/) { 1881 $ASSIST = 1; 1882 $webPath = SystemVariables::getAssistantWebPath() . "assistant.cgi"; 1883 } 1884 1885 $filesAvailable = VincentFile::allPermissionIDsToday(); 1886 1887 1888 if(@{$filesAvailable}) { 1889 1890 print "<TR><TD>"; 1891 Interface::tableTop("Permit student files for download."); 1892 Interface::startForm($webPath); 1893 Interface::hidden("PERMITFILE", 1); 1894 1895 foreach (@{$filesAvailable}) { 1896 push(@desc, VincentFile::getDownloadableFileDescription($_)); 1897 1898 } 1899 1900 print "<TABLE WIDTH='100%'>"; 1901 print "<TR><TD>"; 1902 1903 selectInput("Permit", 1904 "FILEDESC", 1905 @desc); 1906 1907 print "</TD><TD>"; 1908 1909 selectInput("to section", 1910 "SECTION", 1911 Record::getAllSectionNumbers()); 1912 1913 print "</TD><TD>"; 1914 1915 textInput("for ", 1916 "MINUTES", 1917 "30", 1918 3); 1919 print "</TD><TD>"; 1920 print "minutes"; 1921 1922 print "</TD></TR>"; 1923 print "</TABLE>"; 1924 1925 Interface::endForm(); 1926 Interface::tableBottom(); 1927 print "</TD></TR>"; 1928 1929 } 1930 1931 } 1932 1933 1934 ##CONTRACT 1935 # DEBUG 1936 ##PURPOSE 1937 # Debugging. 1938 ##DEPENDANCIES 1939 # None. 1940 sub useDebugging())'>DEBUG { if(SystemVariables::useDebugging()) { print "Interface: ", @_, "n<P>"; } } 1941 |
|
Last update: 1/6/01; 9:32:35 AM |