Parent Directory
|
Revision Log
initial import
1 #!/usr/bin/perl 2 3 ## $Id$ 4 5 #################################################################### 6 # Copyright @ 1995-1998 University of Rochester 7 # All Rights Reserved 8 #################################################################### 9 10 11 # This file is scoreProbSet.pl 12 13 use lib '/ww/webwork/development/'; # mainWeBWorKDirectory; 14 15 use strict; 16 use Global; 17 use Auth; 18 use CGI qw(:standard); 19 20 # Timing code 21 use Benchmark; 22 my $beginTime = new Benchmark; 23 # end Timing code 24 25 my $cgiMode = 0; # was script called from command line or via CGI? 26 my $batchMode = 0; 27 my $page =''; 28 $cgiMode = 1 if $ENV{'SERVER_SOFTWARE'}; 29 30 my %inputs; 31 my ($classID, $setNumber, $appendTotalsQ,$User,$Session_key,$sortOrder); 32 33 if ( $cgiMode == 1 ) { 34 &CGI::ReadParse; 35 %inputs = %main::in; 36 37 # get information from CGI inputs (see also below for additional information) 38 $classID = $inputs{'course'}; 39 $setNumber = $inputs{'setNo'}; 40 $appendTotalsQ = $inputs{'appendTotals'}; 41 $batchMode = $inputs{'batchMode'}; 42 $sortOrder = $inputs{'sortOrder'}; 43 $page = $inputs{'page'}; 44 $User = $inputs{'user'}; 45 $Session_key = $inputs{'key'}; 46 47 unless ($classID && $User && $Session_key) { 48 &wwerror("$0","The script scoreProbSet.pl did not receive the proper input data.","","", query_string()); 49 } 50 } 51 else { 52 # get information from command line arguments 53 ($classID, $setNumber) = @ARGV; 54 $appendTotalsQ = 1; 55 if (@ARGV != 2) { 56 print "\nSyntax is scoreProbSet.pl courseID setName \n"; 57 print " (e.g. scoreProbSet.pl MTH140A 7 ) \n\n"; 58 exit(0); 59 } 60 } 61 62 63 # CAUTION: FOR THIS SCRIPT TO WORK CORRECTLTY, ALL STUDENTS 64 # MUST HAVE BEEN ASSIGNED THE SAME NUMBER OF PROBLREMS 65 66 # print "set is $setNumber"; 67 # print "classID is $classID"; 68 69 &getCourseEnvironment($classID); 70 71 my $scriptDirectory = getWebworkScriptDirectory; 72 my $databaseDirectory = getCourseDatabaseDirectory; 73 my $templateDirectory = getCourseTemplateDirectory; 74 my $scoringDirectory = getCourseScoringDirectory; 75 my $cgiURL = getWebworkCgiURL; 76 my $DAT = &getDat; 77 78 require "${scriptDirectory}$Global::DBglue_pl"; 79 require "${scriptDirectory}$Global::FILE_pl"; 80 require "${scriptDirectory}$Global::SCRtools_pl"; 81 require "${scriptDirectory}$Global::HTMLglue_pl"; 82 83 # verify the identity of the user if from cgi 84 if ( $cgiMode == 1 ) { 85 my $keyFile = &Global::getCourseKeyFile($classID); 86 # log access 87 &Global::log_info('', query_string); 88 89 &verify_key($User, $Session_key, $keyFile, $classID); 90 my $permissionsFile = &Global::getCoursePermissionsFile($classID); 91 my $permissions = &get_permissions($User, $permissionsFile); 92 93 if ($permissions != $Global::instructor_permissions ) { 94 print "permissions = $permissions instructor_permissions= $Global::instructor_permissions\n"; 95 print &html_NO_PERMISSION; 96 exit(0); 97 } 98 } 99 100 # get list of problems and values from the database. Warn user if different students 101 # have different numbers of problems or different valuse for the same problem 102 103 my ($warningMsg,$dueDate, $problemListref,$problemValueListref) 104 = &readProblemsAndValuesFromDB($setNumber,0,$cgiMode,$batchMode); 105 106 if (( $cgiMode == 1 ) and ($warningMsg ne '')) { &warningMsgPage(\%inputs,$warningMsg);} 107 108 109 my @problemList = @$problemListref; 110 my @problemValueList = @$problemValueListref; 111 my $noOfProbs = @problemList; 112 113 114 $dueDate = &formatDateAndTime($dueDate); ##originally dueDate is in the form 4/15/96 at 2:00 AM 115 116 my $dueTime=$dueDate; 117 $dueDate=~s|^\s*||; 118 $dueDate=~s|\s*at.*$||; 119 $dueTime=~s|^.*at\s*||; 120 $dueTime=~s|\s*$||; 121 122 #print "$dueDate\n"; 123 #print "$dueTime\n"; 124 125 &get_raw_scores('db', $setNumber, $dueDate, $dueTime); 126 127 my $scrFileName = "s${setNumber}scr"; 128 129 if ( $cgiMode == 1 and $sortOrder ne 'AbySec') { 130 my %assocArray = &dat2aa("$scrFileName"); 131 &aa2dat(\%assocArray,"$scrFileName", $sortOrder); ##sort 132 } 133 134 my $fullTotalsFileName = "${scoringDirectory}${classID}_totals.${DAT}"; 135 my $fullScrFileName = "${scoringDirectory}s${setNumber}scr.${DAT}"; 136 137 if ( $cgiMode == 0 ) { 138 print "\n Number of Probs is $noOfProbs\n"; 139 print "\n\nDo you want to total the scores in the score file for this set,\n"; 140 print "$fullScrFileName, \n"; 141 print "and append these totals to the cummulative totals file,\n"; 142 print "$fullTotalsFileName, \n\n"; 143 print "We recommend that you do\? (Y or N)\n"; 144 145 my $ans; 146 147 $ans=<STDIN>; 148 chomp($ans); 149 unless (($ans eq "Y") || ($ans eq "y")) {$appendTotalsQ = 0;} 150 } 151 152 if ($appendTotalsQ == 1) { 153 154 my $totalsFileName = "${classID}_totals"; 155 &total_score($scrFileName,$setNumber); 156 157 my $gid = $Global::numericalGroupID; 158 $gid = $Global::numericalGroupID; ## hack to remove warning message about $Global::numericalGroupID used only once 159 160 unless (-e "$fullTotalsFileName") { 161 &createFile("$fullTotalsFileName", $Global::scoring_files_permission, $gid); 162 } 163 unless (-w "$fullTotalsFileName") { 164 &wwerror("$0","Can't write to the file $fullTotalsFileName."); 165 } 166 &append_score_db($totalsFileName,$scrFileName); 167 &delete_columns ($totalsFileName, -$noOfProbs-1, -2, 0); 168 if ( $cgiMode == 1 and $sortOrder ne 'AbySec') { 169 my %assocArray = &dat2aa("$totalsFileName"); 170 &aa2dat(\%assocArray,"$totalsFileName", $sortOrder); ##sort 171 } 172 } 173 174 175 if ( $cgiMode == 1 ) {&finishedMsgPage(\%inputs);} 176 177 178 179 sub finishedMsgPage { 180 181 my ($inputref) = @_; 182 my %inputs = %$inputref; 183 # print HTML text 184 print &htmlTOP("Scoring Utilities"); 185 186 # print navigation buttons ${cgiURL}profScoring.pl 187 print qq! 188 <A HREF="${cgiURL}profScoring.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 189 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p> 190 !; 191 192 print <<EOF; 193 <HR><BR> 194 <h3 align="left">WeBWorK scoring message for $classID:</h3> 195 EOF 196 197 print "Set $setNumber has been scored and the updated scoring files have been saved in the scoring directory 198 $scoringDirectory .<BR> <BR> 199 To return to the scoring page select the \"Up\" buttom. 200 <BR> To return to the Professor page select \"Professor page \". "; 201 202 print <<EOF; 203 <P> 204 205 <FORM METHOD = "POST" ACTION= "${cgiURL}profLogin.pl"> 206 <INPUT TYPE="SUBMIT" VALUE="Professor page"> 207 208 EOF 209 210 # resume printing the rest of the form 211 212 print <<EOF; 213 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 214 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 215 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 216 </FORM> 217 EOF 218 219 220 print &htmlBOTTOM("scoreProbSet.pl", \%inputs); 221 222 } #end of finished Page 223 224 225 sub warningMsgPage { 226 227 my ($inputref,$warningMsg) = @_; 228 my %inputs = %$inputref; 229 # print HTML text 230 print &htmlTOP("Scoring Utilities"); 231 232 # print navigation buttons 233 print qq! 234 <A HREF="${Global::cgiWebworkURL}profScoring.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 235 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p> 236 !; 237 238 print <<EOF; 239 <HR><BR> 240 <h3 align="left">WeBWorK scoring WARNING message for $classID:</h3> 241 EOF 242 print "<pre>"; 243 print $warningMsg; 244 print "</pre>"; 245 print "To Continue scoring set $setNumber, check the \"Continue\" check box and then select 246 \"Continue scoring set $setNumber\". <BR> To Quit and return to the Scoring page, select the \"Up\" 247 buttom."; 248 249 ## profScoring form -- allows you to score problem sets 250 print <<EOF; 251 <P> 252 253 <FORM METHOD = "POST" ACTION= "${cgiURL}scoreProbSet.pl"> 254 <INPUT TYPE="SUBMIT" VALUE="Continue scoring set $setNumber"> 255 256 EOF 257 258 259 print qq{ 260 <BR><INPUT TYPE=CHECKBOX NAME="batchMode" VALUE=1 >Continue 261 }; 262 263 # resume printing the rest of the form 264 265 print <<EOF; 266 <INPUT TYPE="HIDDEN" NAME="user" VALUE="$inputs{'user'}"> 267 <INPUT TYPE="HIDDEN" NAME="key" VALUE="$inputs{'key'}"> 268 <INPUT TYPE="HIDDEN" NAME="course" VALUE="$inputs{'course'}"> 269 <INPUT TYPE="HIDDEN" NAME="setNo" VALUE="$inputs{'setNo'}"> 270 <INPUT TYPE="HIDDEN" NAME="appendTotals" VALUE="$inputs{'appendTotals'}"> 271 <INPUT TYPE="HIDDEN" NAME="sortOrder" VALUE="$inputs{'sortOrder'}"> 272 273 </FORM> 274 EOF 275 276 277 print &htmlBOTTOM("scoreProbSet.pl", \%inputs); 278 exit; 279 } #end of warning Page 280 281 282 283 284 285
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |