| 1 | #!/usr/bin/perl |
1 | #!/usr/local/bin/perl |
| 2 | |
2 | |
| 3 | ## $Id$ |
3 | ## $Id$ |
| 4 | |
4 | |
| 5 | #################################################################### |
5 | #################################################################### |
| 6 | # Copyright @ 1995-1998 University of Rochester |
6 | # Copyright @ 1995-1998 University of Rochester |
| … | |
… | |
| 14 | |
14 | |
| 15 | # For these scoring subroutines to work, the calling script must require |
15 | # For these scoring subroutines to work, the calling script must require |
| 16 | # the following files, i.e. it must contain the lines: |
16 | # the following files, i.e. it must contain the lines: |
| 17 | # require "webwork.ph"; |
17 | # require "webwork.ph"; |
| 18 | # require "${scriptDirectory}$DBglue_pl"; |
18 | # require "${scriptDirectory}$DBglue_pl"; |
|
|
19 | # require "${scriptDirectory}$Global::classlist_DBglue_pl"; |
| 19 | # require "${scriptDirectory}FILE.pl"; |
20 | # require "${scriptDirectory}FILE.pl"; |
| 20 | |
21 | |
| 21 | my $debugOn=0; |
22 | my $debugOn=0; |
| 22 | |
23 | |
| 23 | # Things defined in Global.pl (can be over ridden by statements in webworkCourse.ph) |
24 | # Things defined in Global.pl (can be over ridden by statements in webworkCourse.ph) |
| … | |
… | |
| 44 | |
45 | |
| 45 | ## Prints message to scoring log and STDERR |
46 | ## Prints message to scoring log and STDERR |
| 46 | my ($string) = $_[0]; |
47 | my ($string) = $_[0]; |
| 47 | unless (-e "${scoringDirectory}${scoring_log}") { |
48 | unless (-e "${scoringDirectory}${scoring_log}") { |
| 48 | &createFile("${scoringDirectory}${scoring_log}", $Global::scoring_files_permission, $Global::numericalGroupID); |
49 | &createFile("${scoringDirectory}${scoring_log}", $Global::scoring_files_permission, $Global::numericalGroupID); |
| 49 | } |
50 | } |
| 50 | open(LOGFILE, ">>${scoringDirectory}${scoring_log}") or |
51 | open(LOGFILE, ">>${scoringDirectory}${scoring_log}") or |
| 51 | &wwerror("$0","Can't append to ${scoringDirectory}${scoring_log}"); |
52 | &wwerror("$0","Can't append to ${scoringDirectory}${scoring_log}"); |
| 52 | print LOGFILE "$string\n"; |
53 | print LOGFILE "$string\n"; |
| 53 | print STDERR "$string\n"; |
54 | print STDERR "$string\n"; |
| 54 | close(LOGFILE); |
55 | close(LOGFILE); |
| … | |
… | |
| 122 | &ful_dat_header($setNumber, $noOfProbs , $dueDate, $dueTime, \@probVal); |
123 | &ful_dat_header($setNumber, $noOfProbs , $dueDate, $dueTime, \@probVal); |
| 123 | &scr_dat_header($setNumber, $noOfProbs , $dueDate, $dueTime, \@probVal); |
124 | &scr_dat_header($setNumber, $noOfProbs , $dueDate, $dueTime, \@probVal); |
| 124 | |
125 | |
| 125 | |
126 | |
| 126 | foreach $pin (@pinNumbersArray) { |
127 | foreach $pin (@pinNumbersArray) { |
| 127 | &attachProbSetRecord($pin); |
128 | attachProbSetRecord($pin); |
|
|
129 | my $studentLogin = getStudentLogin($pin); |
|
|
130 | attachCLRecord($studentLogin); |
| 128 | |
131 | |
| 129 | #### initialize arrays |
132 | #### initialize arrays |
| 130 | @bakArray=($pin,&getStudentID($pin), &getStudentLastName($pin), &getStudentFirstName($pin),&getClassSection($pin),&getClassRecitation($pin)); |
133 | @bakArray=($pin,&CL_getStudentID($studentLogin), &CL_getStudentLastName($studentLogin), &CL_getStudentFirstName($studentLogin),&CL_getClassSection($studentLogin),&CL_getClassRecitation($studentLogin)); |
| 131 | @fulArray=@bakArray; |
134 | @fulArray=@bakArray; |
| 132 | shift @fulArray; |
135 | shift @fulArray; |
| 133 | @scrArray=@fulArray; |
136 | @scrArray=@fulArray; |
| 134 | |
137 | |
| 135 | @Yarray=(0) x ($noOfProbs+1); ##holds number of correct responses |
138 | @Yarray=(0) x ($noOfProbs+1); ##holds number of correct responses |
| … | |
… | |
| 599 | |
602 | |
| 600 | if ($cumm_db_non_empty) { |
603 | if ($cumm_db_non_empty) { |
| 601 | $_=$dbaArray{"NO OF FIELDS"}; |
604 | $_=$dbaArray{"NO OF FIELDS"}; |
| 602 | $temp=s/${DELIM}/${DELIM}/g; ##find number of delims in string |
605 | $temp=s/${DELIM}/${DELIM}/g; ##find number of delims in string |
| 603 | } |
606 | } |
| 604 | else {$temp =0}; |
607 | else {$temp =0}; |
| 605 | $dbNoOfFields=$temp+2; ##num of fields in dat file |
608 | $dbNoOfFields=$temp+2; ##num of fields in dat file |
| 606 | $_=$appenddbaArray{"NO OF FIELDS"}; |
609 | $_=$appenddbaArray{"NO OF FIELDS"}; |
| 607 | $temp=s/${DELIM}/${DELIM}/g; ##find number of delims in string |
610 | $temp=s/${DELIM}/${DELIM}/g; ##find number of delims in string |
| 608 | $appenddbNoOfFields=$temp+2; |
611 | $appenddbNoOfFields=$temp+2; |
| 609 | foreach $studID (keys %dbaArray) { |
612 | foreach $studID (keys %dbaArray) { |
| … | |
… | |
| 613 | @dbArray=&getRecord($dbString); |
616 | @dbArray=&getRecord($dbString); |
| 614 | &scoreMessage("No record for $dbArray[1] $dbArray[0] , ID = $studID,\n in the $appenddbFile database. The record will be padded with blanks."); |
617 | &scoreMessage("No record for $dbArray[1] $dbArray[0] , ID = $studID,\n in the $appenddbFile database. The record will be padded with blanks."); |
| 615 | $temp=" ${DELIM}" x ($appenddbNoOfFields-5); ##blanks for fields |
618 | $temp=" ${DELIM}" x ($appenddbNoOfFields-5); ##blanks for fields |
| 616 | $dbString.=$temp; |
619 | $dbString.=$temp; |
| 617 | $dbaArray{$studID}=$dbString; |
620 | $dbaArray{$studID}=$dbString; |
|
|
621 | |
| 618 | |
622 | } |
| 619 | } |
623 | else { |
| 620 | else { |
|
|
| 621 | $dbString=$appenddbaArray{$studID}; |
624 | $dbString=$appenddbaArray{$studID}; |
| 622 | $dbString=~s/^[^${DELIM}]*${DELIM}[^${DELIM}]*${DELIM}[^${DELIM}]*${DELIM}[^${DELIM}]*//; ##remove last and first names |
625 | $dbString=~s/^[^${DELIM}]*${DELIM}[^${DELIM}]*${DELIM}[^${DELIM}]*${DELIM}[^${DELIM}]*//; ##remove last and first names |
| 623 | ##and section ##and (8/16/000 recitation |
626 | ##and section ##and (8/16/000 recitation |
| 624 | $dbaArray{$studID}.=$dbString; |
627 | $dbaArray{$studID}.=$dbString; |
| 625 | } |
628 | } |
| 626 | } |
629 | } |
| 627 | ##end of foreach |
630 | ##end of foreach |
| 628 | |
631 | |
| 629 | foreach $studID (keys (%appenddbaArray)) { ##handle case where record is not in |
632 | foreach $studID (keys (%appenddbaArray)) { ##handle case where record is not in |
| 630 | ##cummulative database |
633 | ##cummulative database |
| … | |
… | |
| 666 | |
669 | |
| 667 | open(DATFILE,"${scoringDirectory}${fileName}.${DAT}") or |
670 | open(DATFILE,"${scoringDirectory}${fileName}.${DAT}") or |
| 668 | &wwerror("$0","can't open ${scoringDirectory}${fileName}.${DAT}"); |
671 | &wwerror("$0","can't open ${scoringDirectory}${fileName}.${DAT}"); |
| 669 | $_= <DATFILE>; |
672 | $_= <DATFILE>; |
| 670 | $firstLine=$_; |
673 | $firstLine=$_; |
| 671 | if (defined $firstLine) { |
674 | if (defined $firstLine) { |
| 672 | $noOfDelim=s/$DELIM/$DELIM/g; |
675 | $noOfDelim=s/$DELIM/$DELIM/g; |
| 673 | while (<DATFILE>) { |
676 | while (<DATFILE>) { |
| 674 | $dbString=$_; |
677 | $dbString=$_; |
| 675 | $num=s/$DELIM/$DELIM/g; |
678 | $num=s/$DELIM/$DELIM/g; |
| 676 | if ($num != $noOfDelim) { |
679 | if ($num != $noOfDelim) { |
| … | |
… | |
| 744 | |
747 | |
| 745 | open(BAKFILE,"${scoringDirectory}${fileName}.${DAT}") or |
748 | open(BAKFILE,"${scoringDirectory}${fileName}.${DAT}") or |
| 746 | &wwerror("$0","can't open ${scoringDirectory}${fileName}.${DAT}"); |
749 | &wwerror("$0","can't open ${scoringDirectory}${fileName}.${DAT}"); |
| 747 | while (<BAKFILE>) { |
750 | while (<BAKFILE>) { |
| 748 | chomp; |
751 | chomp; |
| 749 | @dbArray=&getRecord($_); |
752 | @dbArray=&getRecord($_); |
| 750 | shift(@dbArray); ## throw away first element |
753 | shift(@dbArray); ## throw away first element |
| 751 | my @outArray =(); |
754 | my @outArray =(); |
| 752 | for ($j=1; $j <= 5; $j++) { ## put back next 5 elements |
755 | for ($j=1; $j <= 5; $j++) { ## put back next 5 elements |
| 753 | push @outArray,shift(@dbArray); |
756 | push @outArray,shift(@dbArray); |
| 754 | } |
757 | } |
| 755 | while (@dbArray) { |
758 | while (@dbArray) { |
| 756 | push @outArray,shift(@dbArray); #save |
759 | push @outArray,shift(@dbArray); #save |
| 757 | shift(@dbArray); ## throw away |
760 | shift(@dbArray); ## throw away |
| 758 | shift(@dbArray); ## throw away |
761 | shift(@dbArray); ## throw away |
| 759 | } |
762 | } |
| 760 | $dbString=join($DELIM,@outArray); |
763 | $dbString=join($DELIM,@outArray); |
| 761 | print SCORES "$dbString\n"; |
764 | print SCORES "$dbString\n"; |
| 762 | } ## scr score file recovered |
765 | } ## scr score file recovered |
| 763 | |
766 | |
| 764 | close(BAKFILE); |
767 | close(BAKFILE); |
| 765 | close(FULLSCORES); |
768 | close(FULLSCORES); |
| 766 | close(SCORES); |
769 | close(SCORES); |
| 767 | |
770 | |
| 768 | %assocArray = &dat2aa("${fulFileName}"); |
771 | %assocArray = &dat2aa("${fulFileName}"); |
| … | |
… | |
| 877 | |
880 | |
| 878 | sub total_score { |
881 | sub total_score { |
| 879 | ## Takes two parameters, the filename (without the extension) of the score |
882 | ## Takes two parameters, the filename (without the extension) of the score |
| 880 | ## database and a caption for the total column. E.g. ("s5scr", "set 5"). |
883 | ## database and a caption for the total column. E.g. ("s5scr", "set 5"). |
| 881 | ## Computes the total score by calculating the sum over |
884 | ## Computes the total score by calculating the sum over |
| 882 | ## columns 5,6, ..., last column of round_score((prob value)*(prob scr)). |
885 | ## columns 5,6, ..., last column of round_score((prob value)*(prob scr)). |
| 883 | ## That is value of each problem is rounded then added. Note that col. 1 |
886 | ## That is value of each problem is rounded then added. Note that col. 1 |
| 884 | ## is the student id, col.'s 2 and 3 hold the student last and first names, |
887 | ## is the student id, col.'s 2 and 3 hold the student last and first names, |
| 885 | ## and column 4 holds the section number. |
888 | ## and column 4 holds the section number. |
| 886 | ## The total is appended as a new col in the score database with a prob value of 0 |
889 | ## The total is appended as a new col in the score database with a prob value of 0 |
| 887 | ## so that it will not contribute to future calculations of the total score. |
890 | ## so that it will not contribute to future calculations of the total score. |
| … | |
… | |
| 942 | #print "setNum is $setNum\n"; |
945 | #print "setNum is $setNum\n"; |
| 943 | #print "studID is $studID\n"; |
946 | #print "studID is $studID\n"; |
| 944 | #print "batchMode is $batchMode\n"; |
947 | #print "batchMode is $batchMode\n"; |
| 945 | |
948 | |
| 946 | |
949 | |
| 947 | my @keyList = &getAllProbSetKeysForSetSortedBySectionThenByName($setNum); |
950 | my @keyList = &getAllProbSetKeysForSet($setNum); |
| 948 | my (@problemList,@problemValues,@fixedProblemList,$fixedProblemValuesref,$num); |
951 | my (@problemList,@problemValues,@fixedProblemList,$fixedProblemValuesref,$num); |
| 949 | unless ($studID) {$studID = $keyList[0];} ##take a random studID if studID not defined |
952 | unless ($studID) {$studID = $keyList[0];} ##take a random studID if studID not defined |
| 950 | &attachProbSetRecord($studID) || &wwerror("$0","no Record $studID"); |
953 | &attachProbSetRecord($studID) || &wwerror("$0","no Record $studID"); |
| 951 | my $dueDate = &getDueDate($studID); |
954 | my $dueDate = &getDueDate($studID); |
| 952 | my $fixedLogin_name = &getStudentLogin($studID); |
955 | my $fixedLogin_name = &getStudentLogin($studID); |