Parent Directory
|
Revision Log
changed #! lines to /usr/bin/env perl THIS SHOULD BE THE LAST TIME #! LINES ARE CHANGED!!!!!!!
1 #!/usr/bin/env perl 2 3 ## $Id$ 4 5 #################################################################### 6 # Copyright @ 1995-1998 University of Rochester 7 # All Rights Reserved 8 #################################################################### 9 10 11 ## This file is profChangeDates.pl 12 ## It provides access to utilities for building, correcting and viewing problem sets 13 ## 14 15 16 use lib '.'; use webworkInit; # WeBWorKInitLine 17 require 5.001; 18 use strict; 19 20 21 use Global; 22 use Auth; 23 use TimeLocal; 24 use CGI qw(:standard); 25 26 27 # Timing code 28 use Benchmark; 29 my $beginTime = new Benchmark; 30 # end Timing code 31 32 # variables global to this file 33 my ($setNumber,$setHeaderFileName,$probHeaderFileName,$dueDate,$openDate,$answerDate,$problemListref,$problemValueListref,$problemAttemptLimitListref); 34 my (@problemList,@problemValueList,@problemAttemptLimitList); 35 36 my $cgi = new CGI; 37 my %inputs = $cgi->Vars(); 38 39 my ($classID, $fileName); 40 41 # establish environment for this script 42 43 my $Course = $inputs{'course'}; 44 &Global::getCourseEnvironment($Course); 45 46 47 my $cgiURL = getWebworkCgiURL($Course); 48 my $courseScriptsDirectory = getCourseScriptsDirectory($Course); 49 my $databaseDirectory = getCourseDatabaseDirectory($Course); 50 my $htmlURL = getCourseHtmlURL($Course); 51 my $scriptDirectory = getWebworkScriptDirectory($Course); 52 my $templateDirectory = getCourseTemplateDirectory; 53 54 require "${scriptDirectory}$Global::DBglue_pl"; 55 require "${scriptDirectory}$Global::FILE_pl"; 56 require "${scriptDirectory}$Global::HTMLglue_pl"; 57 require "${scriptDirectory}$Global::classlist_DBglue_pl"; 58 59 my $updateMethod =$inputs{'updateMethod'}; 60 61 # log access 62 &Global::log_info('', query_string); 63 64 &webDatePage; 65 66 # begin Timing code 67 my $endTime = new Benchmark; 68 &Global::logTimingInfo($beginTime,$endTime,"profChangeDates.pl",$inputs{'course'},$inputs{'course'}); 69 # end Timing code 70 exit; 71 72 #####################################END###################################### 73 74 sub webDatePage { 75 # verify the identity of the user. 76 my $keyFile = &Global::getCourseKeyFile($inputs{'course'}); 77 &verify_key($inputs{'user'}, $inputs{'key'}, "$keyFile", $inputs{'course'}); 78 my $permissionsFile = &Global::getCoursePermissionsFile($inputs{'course'}); 79 my $permissions = &get_permissions($inputs{'user'}, $permissionsFile); 80 if ($permissions != $Global::instructor_permissions ) { 81 print "permissions = $permissions instructor_permissions= $Global::instructor_permissions\n"; 82 print &html_NO_PERMISSION; 83 exit(0); 84 } 85 86 87 if ($inputs{'pCD'}==1) { 88 print &htmlTOP("Change Open/Due/Answer Date: Page 2"); 89 # print navigation buttons 90 print qq! 91 <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 92 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p> 93 !; 94 $setNumber=$inputs{'setNo'}; 95 &printForms($setNumber); 96 print &htmlBOTTOM("profChangeDates.pl", \%inputs); 97 } 98 99 else { 100 101 print &htmlTOP("Change Open/Due/Answer Date: Page 3"); 102 # print navigation buttons 103 print qq! 104 <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 105 <IMG SRC="${Global::upImgUrl}" align="right" BORDER=1 ALT="[Up]"></A><p> 106 !; 107 if ($inputs{'dateMode'} eq 'READWRITE') { 108 &changeDates(); 109 &sendBack; 110 } 111 else { 112 print '<H2>Read only mode, no changes made </H2>'; 113 print 'Go back and select Read/Write mode if you want to save changes.'; 114 &sendBack; 115 } 116 print &htmlBOTTOM("profChangeDates.pl", \%inputs); 117 } 118 } 119 120 sub printForms { 121 my ($setNumber) = @_; 122 print qq!<FORM method="post" action="profChangeDates.pl">\n!; 123 &printChangeOpenForm(&findOpenDateForSet($setNumber)); 124 &printChangeDueForm( &findDueDateForSet($setNumber)); 125 &printChangeAnswerForm(&findAnswerDateForSet($setNumber)); 126 127 &printChangeSetHeaderFileForm(&findSetHeaderFileForSet($setNumber)); 128 &printChangeProbHeaderFileForm(&findProbHeaderFileForSet($setNumber)); 129 130 131 print qq! 132 <TABLE><TR>\n<TD> 133 <input type=hidden name="dateMode" value="READWRITE">\n 134 </TD><TD> 135 <input type=submit value="Make the Above Changes">\n 136 </TD></TR></TABLE>\n 137 <input type=hidden name="pCD" value=2>\n 138 <input type=hidden name="setNo" value=$setNumber>\n 139 !; 140 print &sessionKeyInputs(\%inputs); 141 print "</FORM>\n"; 142 143 &printChangeProblemFileNamesForm(); 144 145 146 } 147 148 149 sub changeDates { 150 my $newOpenDate=$inputs{'openDate'}; 151 my $newDueDate=$inputs{'dueDate'}; 152 my $newAnswerDate=$inputs{'ansDate'}; 153 my $newSetHeaderFile = stripWhiteSpace($inputs{'setHeaderFile'}); 154 my $newProbHeaderFile = stripWhiteSpace($inputs{'probHeaderFile'}); 155 156 my $time1 = &unformatDateAndTime($newOpenDate); 157 my $time2 = &unformatDateAndTime($newDueDate); 158 my $time3 = &unformatDateAndTime($newAnswerDate); 159 if ($time2 < $time1 or $time3 < $time2) { 160 &Global::error('Dates not in chronological order', "The open date: $newOpenDate, 161 due date: $newDueDate, and answer date: $newAnswerDate must be in chronologicasl order."); 162 } 163 164 my $setNumber=$inputs{'setNo'}; 165 166 changeDatesAndHeaderFiles($setNumber,$newOpenDate,$newDueDate,$newAnswerDate,$newSetHeaderFile,$newProbHeaderFile); 167 168 } 169 170 sub findOpenDateForSet { 171 my ($setNumber) = @_; 172 my (@probSetKeys)=&getAllProbSetKeysForSet($setNumber); 173 &attachProbSetRecord($probSetKeys[0]); 174 &detachProbSetRecord($probSetKeys[0]); 175 &formatDateAndTime( &getOpenDate($probSetKeys[0])); 176 } 177 178 sub printChangeOpenForm { 179 my ( $prettyOldOpenDate) = @_; 180 181 print <<EOF; 182 <H3 ALIGN ="CENTER">Class Identification: $inputs{'course'}</H3> 183 Use this form to makes changes for all students in a course. To make changes 184 for an individual student go back and use "Examine or change individual problem set for:" 185 186 <HR SIZE =2> 187 <H3> Change opening and closing dates for set number $setNumber</H3> 188 Please enter the new dates in the following format:<BR>6/28/96 at 189 9:59 AM (June 28, 1996 at 9:59 AM)<p> 190 191 Select the method you want to use. 192 If you have given some students an extension and do not want to override those changes, select the second method. 193 <br> 194 Check the check box and select section(s) if you only want want to change dates for students in certain sections.<p> 195 <INPUT TYPE=RADIO NAME='updateMethod' VALUE='all' > New dates for all (selected) students.<BR> 196 <INPUT TYPE=RADIO NAME='updateMethod' VALUE='some' CHECKED> 197 New dates only if the new date extends the student\'s current date. 198 <BR> 199 <INPUT TYPE='CHECKBOX' NAME='bySection' VALUE='1'> 200 201 Change dates only for students in these section(s): 202 EOF 203 # Current Sections list 204 205 print qq! <SELECT Name = 'selectedSections' Size =3 multiple>\n!; 206 my @sorted_section_names = sort keys (%{getAllSections()}); 207 for my $ind (@sorted_section_names) { 208 print "<OPTION VALUE = \"$ind\">$ind\n"; 209 } 210 print qq!</SELECT>\n!; 211 212 print <<EOF; 213 <P> 214 215 The current openDate is 216 ${prettyOldOpenDate}. 217 218 Make <input type="text" size=20 maxlength=20 name="openDate" 219 value="$prettyOldOpenDate"> the new openDate.<p> 220 221 EOF 222 } 223 224 sub findDueDateForSet { 225 my (@probSetKeys)=&getAllProbSetKeysForSet($setNumber); 226 &attachProbSetRecord($probSetKeys[0]); 227 &detachProbSetRecord($probSetKeys[0]); 228 &formatDateAndTime( &getDueDate($probSetKeys[0])); 229 } 230 231 sub printChangeDueForm { 232 my ( $prettyOldDueDate) = @_; 233 print <<EOF; 234 235 236 <p> The current DueDate is ${prettyOldDueDate}. 237 238 Make <input type="text" size=20 maxlength=20 name="dueDate" 239 value="$prettyOldDueDate"> the new DueDate.<p> 240 241 EOF 242 } 243 244 sub findAnswerDateForSet { 245 my (@probSetKeys)=&getAllProbSetKeysForSet($setNumber); 246 &attachProbSetRecord($probSetKeys[0]); 247 &detachProbSetRecord($probSetKeys[0]); 248 &formatDateAndTime( &getAnswerDate($probSetKeys[0])); 249 } 250 251 sub printChangeAnswerForm { 252 my ( $prettyOldAnswerDate) = @_; 253 print <<EOF; 254 255 256 <p> The current AnswerDate is ${prettyOldAnswerDate}. 257 258 Make <input type="text" size=20 maxlength=20 name="ansDate" 259 value="$prettyOldAnswerDate"> the new AnswerDate.<p> 260 261 EOF 262 } 263 264 sub changeDatesAndHeaderFiles { 265 my ($setNumber,$newOpenDate,$newDueDate,$newAnswerDate,$newSetHeaderFileName,$newProbHeaderFileName) = @_; 266 267 my $newOpenDateTime = &unformatDateAndTime($newOpenDate); 268 my $newDueDateTime = &unformatDateAndTime($newDueDate); 269 my $newAnswerDateTime = &unformatDateAndTime($newAnswerDate); 270 271 my $oldOpenDateTime; 272 my $oldDueDateTime; 273 my $oldAnswerDateTime; 274 275 my @probSetKeys=&getAllProbSetKeysForSet($setNumber); 276 my $probSetKey; 277 278 # 279 # change Davide Cevone's selection method 280 # 281 my ($studentID, $section); 282 my @sections = $cgi -> param('selectedSections'); 283 my %selected_sections =(); 284 foreach my $sec (@sections) { 285 $selected_sections{$sec} = 1; 286 } 287 my $count = 0; 288 289 290 foreach $probSetKey (@probSetKeys) { 291 &attachProbSetRecord($probSetKey); 292 293 # 294 # DPVC -- check for selected sections. Further modified by AKP 295 # 296 if ($inputs{'bySection'}) { 297 $studentID = getStudentLogin($probSetKey); 298 attachCLRecord($studentID); 299 $section = CL_getClassSection($studentID); 300 unless ($selected_sections{$section}) { 301 next; 302 } 303 $count++; 304 } 305 # 306 # End DPVC 307 # 308 309 if ($updateMethod eq 'all') { 310 &putOpenDate($newOpenDateTime,$probSetKey); 311 &putDueDate($newDueDateTime,$probSetKey); 312 &putAnswerDate($newAnswerDateTime,$probSetKey); 313 } 314 else { 315 $oldOpenDateTime = &getOpenDate($probSetKey); 316 &putOpenDate($newOpenDateTime,$probSetKey) unless ($oldOpenDateTime > $newOpenDateTime); 317 318 $oldDueDateTime = &getDueDate($probSetKey); 319 &putDueDate($newDueDateTime,$probSetKey) unless ($oldDueDateTime > $newDueDateTime); 320 321 $oldAnswerDateTime = &getAnswerDate($probSetKey); 322 &putAnswerDate($newAnswerDateTime,$probSetKey) unless ($oldAnswerDateTime > $newAnswerDateTime); 323 } 324 &putSetHeaderFileName( $newSetHeaderFileName,$probSetKey); 325 &putProbHeaderFileName( $newProbHeaderFileName,$probSetKey); 326 327 &detachProbSetRecord($probSetKey); 328 } 329 330 print "<BR><BR>The new open date is now set to: $newOpenDate for all students\n"; 331 print "except if their original open date was later than $newOpenDate\n" unless ($updateMethod eq 'all'); 332 print "<HR><BR>\n"; 333 334 print "The new due date is now set to: $newDueDate for all students\n"; 335 print "except if their original due date was later than $newDueDate\n" unless ($updateMethod eq 'all'); 336 print "<HR><BR>\n"; 337 338 print "The new answer date is now set to: $newAnswerDate for all students\n"; 339 print "except if their original answer date was later than $newAnswerDate\n" unless ($updateMethod eq 'all'); 340 print "<HR><BR>\n"; 341 342 print "The new Paper HeaderFile is: $newSetHeaderFileName \n"; 343 print "<HR><BR>\n"; 344 345 print "The new Screen HeaderFile is: $newProbHeaderFileName \n"; 346 print "<HR><BR>\n"; 347 348 # 349 # DPVC -- for when selected sections are used 350 # 351 print "<CENTER><B>The above changes have been made for $count students in the selected section(s).</B></CENTER><BR>\n<HR><BR>\n" 352 if ($inputs{'bySection'}); 353 # 354 # End DPVC 355 # 356 357 } 358 359 360 361 sub findSetHeaderFileForSet { 362 my ($setNumber) = @_; 363 my (@probSetKeys)=&getAllProbSetKeysForSet($setNumber); 364 &attachProbSetRecord($probSetKeys[0]); 365 my $setHeaderFileName = &getSetHeaderFileName($probSetKeys[0]); 366 $setHeaderFileName; 367 } 368 sub findProbHeaderFileForSet { 369 my ($setNumber) = @_; 370 my (@probSetKeys)=&getAllProbSetKeysForSet($setNumber); 371 &attachProbSetRecord($probSetKeys[0]); 372 my $probHeaderFileName = &getProbHeaderFileName($probSetKeys[0]); 373 $probHeaderFileName; 374 } 375 sub printChangeSetHeaderFileForm { 376 my ( $oldSetHeaderFileName) = @_; 377 $oldSetHeaderFileName = "" unless defined($oldSetHeaderFileName); 378 print <<EOF; 379 380 <H3> Change the Paper and Screen HeaderFiles for set number $setNumber</H3> 381 The current Paper HeaderFile is ${oldSetHeaderFileName}. 382 383 Make <input type="text" size=30 maxlength=50 name="setHeaderFile" 384 value="$oldSetHeaderFileName"> the new SetHeaderFile.<p> 385 386 EOF 387 } 388 389 sub printChangeProbHeaderFileForm { 390 my ( $oldProbHeaderFileName) = @_; 391 $oldProbHeaderFileName = "" unless defined $oldProbHeaderFileName; 392 print <<EOF; 393 394 The current Screen HeaderFile is ${oldProbHeaderFileName}. 395 396 Make <input type="text" size=30 maxlength=50 name="probHeaderFile" 397 value="$oldProbHeaderFileName"> the new ProbHeaderFile.<p> 398 399 EOF 400 } 401 402 sub changeSetHeaderFile { 403 my ($newSetHeaderFileName,$setNumber) = @_; 404 my @probSetKeys=&getAllProbSetKeysForSet($setNumber); 405 my $probSetKey; 406 foreach $probSetKey (@probSetKeys){ 407 &attachProbSetRecord($probSetKey); 408 &deleteSetHeaderFileName($probSetKey); 409 &putSetHeaderFileName( $newSetHeaderFileName,$probSetKey); 410 &detachProbSetRecord($probSetKey); 411 } 412 &attachProbSetRecord($probSetKeys[0]); 413 $newSetHeaderFileName = &getSetHeaderFileName($probSetKeys[0]); 414 print "The new Paper HeaderFile is: $newSetHeaderFileName \n"; 415 print "_"x80 . "\n"; 416 &detachProbSetRecord($probSetKeys[0]); 417 } 418 sub changeProbHeaderFile { 419 my ($newProbHeaderFileName,$setNumber) = @_; 420 my @probSetKeys=&getAllProbSetKeysForSet($setNumber); 421 my $probSetKey; 422 foreach $probSetKey (@probSetKeys){ 423 &attachProbSetRecord($probSetKey); 424 &deleteProbHeaderFileName($probSetKey); 425 &putProbHeaderFileName( $newProbHeaderFileName,$probSetKey); 426 &detachProbSetRecord($probSetKey); 427 } 428 &attachProbSetRecord($probSetKeys[0]); 429 $newProbHeaderFileName = &getProbHeaderFileName($probSetKeys[0]); 430 print "The new Screen HeaderFile is: $newProbHeaderFileName \n"; 431 print "_"x80 . "\n"; 432 &detachProbSetRecord($probSetKeys[0]); 433 } 434 435 436 437 sub sendBack { 438 print <<EOF; 439 <p> 440 <A HREF="${cgiURL}profLogin.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 441 <IMG SRC="$Global::upImgUrl" BORDER=1></A> 442 EOF 443 } 444 445 446 447 sub printChangeProblemFileNamesForm { 448 449 my $delete_cached_images = 0; ## if problems are deleted or reseeded, this will mess up 450 ## the chached latex2html image. We keep track of this so 451 ## we can delete them. 452 453 # Update the database if needed 454 if ( ( defined( $inputs{'FileNameEditMode'}) && $inputs{'FileNameEditMode'} eq "ReadWrite" ) 455 || 456 ( defined( $inputs{'AddNewProblem'}) && $inputs{'AddNewProblem'} eq "Add" ) ) 457 { 458 459 # get list of changed problems submitted by the form 460 my $i; 461 my @changedProblems; 462 foreach $i ( grep(/ProblemFileName/, keys %inputs) ) { 463 464 if ( $i =~ /^ProblemFileName(.+)$/ ) { 465 push(@changedProblems, $1); 466 } 467 if ($inputs{'AddNewProblem'} eq "Add" ) { 468 if ( $i =~ /^NewProblemFileName(.+)$/ ) { 469 my $label = $1; 470 # file name cannot be blank and cannot contain a question mark. 471 if ($inputs{"NewProblemFileName$label"} =~/\w+/ && not $inputs{"NewProblemFileName$label"} =~/\?/) { 472 push(@changedProblems, $label) ; 473 $inputs{"ProblemFileName$label"}=$inputs{"NewProblemFileName$label"}; 474 $inputs{"ProblemValue$label"}=$inputs{"NewProblemValue$label"}; 475 } 476 } 477 } 478 } 479 480 ############################## 481 ### Later this program assumes that the problem numbers in @changedProblems are in ascending order, 482 ### but the validity of this assumption depends on whether the hash %inputs 483 ### preserves the order of the form variables; in particular, do the keys 484 ### ProblemFileName1, ProblemFileName2, ..., ProblemFileName(N), NewProblemFileName(N+1), etc., 485 ### occur in that order in the array keys %inputs . 486 ### On harper.ucs.indiana.edu, which is a Sun running Sun OS 5.7, 487 ### the keys do not necessarily occur in increasing order of the problem number. 488 ### For short hashes, they do. But for long hashes, they usually do not, and that causes 489 ### this program to fail. So we must have the line below to insure 490 ### that @changedProblems is ordered in ascending order. 491 ############################# 492 @changedProblems = sort {$a <=> $b} @changedProblems; 493 ############################### 494 495 496 my $psvn; 497 my @psvn = &getAllProbSetKeysForSet($setNumber); 498 srand(time); 499 foreach $psvn (@psvn) { 500 &attachProbSetRecord($psvn); 501 my $num =1; 502 # srand(time); ## Move this out of the loop as per Zig's suggestion. 503 ## Otherwise many students get the same seed - AKP 504 foreach $i (@changedProblems) { 505 506 ## chech if we should delete cached l2h images 507 if ( (defined( $inputs{"problem{$i}ReSeed"}) and ($inputs{"problem{$i}ReSeed"} eq "on")) or 508 (defined( $inputs{"problem{$i}Delete"}) and ($inputs{"problem{$i}Delete"} eq "on"))) { 509 $delete_cached_images = 1; 510 } 511 512 #ReadWrite 513 #save seed (or define it) 514 my $seed = &getProblemSeed($i,$psvn); 515 unless (defined($seed) ){ 516 print STDERR "profChangeDates.pl: Seed for problem $i is not defined<BR>"; 517 $seed = int( rand(5000) ); 518 } 519 520 #save 521 my ($filename, $status, $attempted, $pvalue, $maxNumOfIncorrectAttempts); 522 $filename = &getProblemFileName( $i,$psvn); 523 $attempted = &getProblemAttempted( $i,$psvn); 524 $status = &getProblemStatus( $i,$psvn); 525 $pvalue = &getProblemValue( $i,$psvn); 526 $maxNumOfIncorrectAttempts = &getProblemMaxNumOfIncorrectAttemps( $i,$psvn); 527 528 # delete problem names and values 529 &deleteProblemFileName( $i,$psvn); 530 &deleteProblemAttempted( $i,$psvn); 531 &deleteProblemStatus( $i,$psvn); 532 &deleteProblemValue( $i,$psvn); 533 &deleteProblemMaxNumOfIncorrectAttemps( $i,$psvn); 534 &deleteProblemSeed( $i,$psvn); 535 # recreate problem using saved seed 536 unless (defined( $inputs{"problem{$i}Delete"}) && $inputs{"problem{$i}Delete"} eq "on" ) { 537 538 if ($inputs{"ProblemFileName$i"} =~ /\w+/) {$filename = stripWhiteSpace($inputs{"ProblemFileName$i"});} 539 &putProblemFileName($filename , $num,$psvn); 540 541 if ($inputs{"ProblemAttempted$i"} =~ /\w+/) {$attempted = stripWhiteSpace($inputs{"ProblemAttempted$i"});} 542 &putProblemAttempted($attempted, $num,$psvn); 543 544 if ($inputs{"ProblemStatus$i"} =~ /\w+/) {$status = stripWhiteSpace($inputs{"ProblemStatus$i"});} 545 &putProblemStatus($status, $num,$psvn); 546 547 if ($inputs{"ProblemValue$i"} =~ /\w+/) {$pvalue = stripWhiteSpace($inputs{"ProblemValue$i"});} 548 &putProblemValue($pvalue, $num,$psvn); 549 550 if ($inputs{"ProblemMaxNumOfIncorrectAttemps$i"} =~ /\w+/) {$maxNumOfIncorrectAttempts = stripWhiteSpace($inputs{"ProblemMaxNumOfIncorrectAttemps$i"});} 551 &putProblemMaxNumOfIncorrectAttemps($maxNumOfIncorrectAttempts, $num,$psvn); 552 553 &putProblemSeed( $seed,$num,$psvn); 554 555 # Reseed if requested 556 if (( defined( $inputs{"problem{$i}ReSeed"}) && $inputs{"problem{$i}ReSeed"} eq "on") 557 # But not if we are deleting 558 and not ( defined( $inputs{"problem{$i}Delete"}) && $inputs{"problem{$i}Delete"} eq "on")) { 559 $seed = int( rand(5000) ); 560 &putProblemSeed( $seed , $num,$psvn); 561 print "Seed changed for problem number $num, psvn $psvn<BR>\n"; 562 } 563 $num++; 564 } 565 566 567 } 568 &detachProbSetRecord($psvn); 569 } 570 } # end of updating database 571 572 ## remove l2h images if necessary 573 574 if ($delete_cached_images) { 575 my $l2hDir = getCoursel2hDirectory(); 576 system ("rm -rf ${l2hDir}set$setNumber"); 577 print "\n<BR>deleting Latex2html tmp files and the directory:<BR>\n"; 578 print " ${l2hDir}set$setNumber<BR>"; 579 # Now delete dvipng images 580 $l2hDir = getCourseTempDirectory()."png/"; 581 system ("rm -rf ${l2hDir}$setNumber"); 582 print "\n<BR>deleting dvipng tmp files and the directory:<BR>\n"; 583 print " ${l2hDir}$setNumber<BR>\n"; 584 } 585 586 587 # print a new form 588 print qq!<HR NOSHADE>\n 589 <FORM method="post" action="profChangeDates.pl"> 590 !; 591 print &sessionKeyInputs(\%inputs); 592 if (defined( $inputs{"FileNameEditMode"}) && $inputs{"FileNameEditMode"} eq "ReadWrite") { 593 print "<FONT COLOR='#ff00aa'> CHANGES SAVED FOR SET $setNumber</font><BR>"; 594 } elsif ( defined( $inputs{'AddNewProblem'}) && $inputs{'AddNewProblem'} eq "Add" ) { 595 print "Problems added to SET $setNumber<BR>"; 596 } elsif ( defined( $inputs{"FileNameEditMode"}) && $inputs{"FileNameEditMode"} eq "ReadOnly") { 597 print "<FONT COLOR='#ff00aa'> ReadOnly mode -- <B>NO</B> CHANGES SAVED FOR SET $setNumber</font><BR>"; 598 } 599 my @psvn = &getAllProbSetKeysForSet($setNumber); 600 601 print qq! 602 <INPUT TYPE="HIDDEN" NAME="pCD" VALUE="1">\n 603 <INPUT TYPE="HIDDEN" NAME="setNo" VALUE="$setNumber">\n 604 605 <H3>Change problem file names, status, etc. for set $setNumber:</H3>\n 606 607 <H4>If a Filename, "Attempted", "Status", "Value", or "MaxAttmp" cell is left blank, the corresponding 608 individualized current values in the database will be maintained. If a value is 609 entered, that value will be used for every student's problem.<p>\n 610 Valid values for "Attempted" 611 are: 0 (not attempted) or 1.<br>\n 612 Valid values for "Status" are numbers in the range [0,1] where 0 represents 613 no credit and 1 full crefit.<br>\n 614 To give all students full credit for a problem, enter 1 in both the "Attempted" and "Status" cells. <br> 615 Valid values for "Value" are 616 non-negative decimal numbers with 1 (1 point) being the most common.<br>\n 617 Valid values for "MaxAttmp" 618 are -1 and non-negative integers where -1 means allow unlimited attempts.<p>\n 619 To see the actual data for any student, go back and use 620 "Modify set for Student:" 621 </H4>\n 622 623 <TABLE><TR><TD> 624 <INPUT TYPE=RADIO NAME="FileNameEditMode" VALUE="ReadOnly" CHECKED>Disable "Save Problem Changes Below" button.\n 625 </TD></TR><TR><TD> 626 <INPUT TYPE=RADIO NAME="FileNameEditMode" VALUE="ReadWrite" >Enable "Save Problem Changes Below" button.\n 627 </TD></TR><TR><TD> 628 <INPUT TYPE=SUBMIT VALUE="Save Problem Changes Below"><p>\n 629 </TD></TR></TABLE> 630 631 <TABLE BORDER="1" CELLPADDING="1" CELLSPACING="2" >\n 632 !; 633 #Re-establish the order of problems from database -- they may have changed. 634 my $psvn = $psvn[0]; 635 my $Mode = defined($inputs{'mode'}) ? $inputs{'mode'} : "HTML"; 636 my $User = $inputs{'user'}; 637 my $Key = $inputs{'key'}; 638 &attachProbSetRecord($psvn); 639 my @problems = sort {$a <=> $b} &getAllProblemsForProbSetRecord($psvn); 640 641 642 # print table listing problems 643 my $i; 644 foreach $i (@problems) { 645 print "<TR>"; 646 print &formatHeaderCell( qq! 647 <A HREF="${Global::processProblem_CGI}?probSetKey=$psvn&probNum=$i&Mode=$Mode&course=$Course&user=$User&key=$Key" TARGET="VIEW_PROBLEM"> 648 Problem $i</A> 649 ! 650 ); 651 print &formatHeaderCell( "Attempted"); 652 print &formatHeaderCell( "Status"); 653 print &formatHeaderCell( "Value"); 654 print &formatHeaderCell( "MaxAttmp"); 655 print &formatHeaderCell( "Delete" ); 656 print &formatHeaderCell( "ReSeed" ); 657 print "</TR>"; 658 659 660 print "<TR>"; 661 662 print &formatDataCell( "ProblemFileName$i" , &getProblemFileName($i,$psvn),"50" ); 663 print &formatDataCell( "ProblemAttempted$i" , '' ,"1"); 664 print &formatDataCell( "ProblemStatus$i" ,'' ,"5"); 665 print &formatDataCell( "ProblemValue$i" ,'' ,"5"); 666 print &formatDataCell( "ProblemMaxNumOfIncorrectAttemps$i" , '' ,"4"); 667 print & formatCheckboxButtonCell( "problem{$i}Delete", "5", ""); 668 print & formatCheckboxButtonCell( "problem{$i}ReSeed", "5", ""); 669 670 print "</TR>"; 671 672 } 673 674 print qq! 675 </TABLE>\n 676 <HR NOSHADE> 677 <H3>Add problem file names for set $setNumber</H3>\n 678 Off <INPUT TYPE="RADIO" NAME="AddNewProblem" VALUE="Off" CHECKED> \n 679 Add <INPUT TYPE="RADIO" NAME="AddNewProblem" VALUE="Add"> \n 680 <INPUT TYPE=SUBMIT VALUE="Add File Names to Set"><p>\n 681 <TABLE BORDER="1" CELLPADDING="1" CELLSPACING="2" >\n 682 !; 683 # print table new listing problems 684 foreach $i (101,102) { 685 print "<TR>"; 686 print &formatHeaderCell( "New File $i"); 687 print &formatHeaderCell( "Attempted"); 688 print &formatHeaderCell( "Status"); 689 print &formatHeaderCell( "Value"); 690 print &formatHeaderCell( "MaxAttmp"); 691 print "</TR>\n"; 692 693 694 print "<TR>"; 695 696 print &formatDataCell( "NewProblemFileName$i" , " " ,"30" ); 697 print &formatDataCell( "NewProblemAttempted$i" , "0" ,"1"); 698 print &formatDataCell( "NewProblemStatus$i" , "0" ,"5"); 699 print &formatDataCell( "NewProblemValue$i" , "1" ,"5"); 700 print &formatDataCell( "ProblemMaxNumOfIncorrectAttemps$i" , "-1" ,"4"); 701 702 print "</TR>\n"; 703 } 704 print qq! 705 </TABLE>\n 706 707 </FORM>\n 708 !; 709 710 print qq! 711 <FONT COLOR='#ff00aa'> IMPORTANT.</font> You should also modify the set definition file for 712 set $setNumber adding the new problem(s) at the end. Otherwise, if you later add new students 713 to the course and rebuild set $setNumber, the new students will see only the old problems, not 714 the new ones. 715 !; 716 ############################################# 717 # build a problem set 718 ############################################# 719 720 print <<EOF; 721 <P> 722 <HR NOSHADE> 723 <H4 ALIGN=LEFT> 724 <img src="$Global::bluesquareImgUrl" border=1 alt=""> 725 Build a problem set for $Course: 726 </H4> 727 EOF 728 729 print "<TD>", 730 start_form('POST', "${Global::cgiWebworkURL}profBuildProblemSetPage.pl"), 731 p,"\n", 732 hidden('course'), "\n", 733 hidden('user'), "\n", 734 hidden('key'), "\n", 735 submit("Enter Build Problem Set Page"), 736 end_form, 737 "</TD>", 738 "You can build a problem set, edit a set definition file, etc."; 739 740 # delete an entire problem set 741 print <<EOF; 742 <P> 743 <HR NOSHADE> 744 <H4 ALIGN=LEFT><A HREF="${cgiURL}profDeleteProbSet.pl?user=$inputs{'user'}&key=$inputs{'key'}&course=$inputs{'course'}"> 745 <IMG SRC="$Global::bluesquareImgUrl" 746 BORDER=1 747 ALT=""> Delete a problem set in $Course</A> 748 </H4> 749 Remove an entire problem set from the database. 750 Individual problems can be deleted from the set using the method 2. above. 751 752 EOF 753 754 } #DONE printChangeProblemFileNamesForm() 755 756 #sub printAddProblemFileNameForm { 757 # 758 # my @problems = ("new1","new2"); 759 # 760 ## updating will be done in printChangeProblemFileNamesForm() 761 # 762 ## print a new form 763 # print qq!<HR NOSHADE>\n 764 # <FORM method="post" action="profChangeDates.pl"> 765 # !; 766 # print &sessionKeyInputs(\%inputs); 767 # print qq! 768 # <INPUT TYPE="HIDDEN" NAME="pCD" VALUE="1">\n 769 # <INPUT TYPE="HIDDEN" NAME="setNumber" VALUE="$setNumber">\n 770 # <HR NOSHADE> 771 # <H3>Add problem file names for set $setNumber</H3>\n 772 # Off <INPUT TYPE="RADIO" NAME="AddNewProblem" VALUE="Off"><BR>\n 773 # Add <INPUT TYPE="RADIO" NAME="AddNewProblem" VALUE="Add"><BR>\n 774 # <INPUT TYPE=SUBMIT VALUE="Add New Problem"><p>\n 775 # <TABLE BORDER="1" CELLPADDING="1" CELLSPACING="2" >\n 776 # !; 777 ## print table new listing problems 778 # foreach $i ("9998") { 779 # print "<TR>"; 780 # print &formatHeaderCell( $i); 781 # print &formatHeaderCell( "Value" ); 782 # print "</TR>\n"; 783 # 784 # 785 # print "<TR>"; 786 # 787 # print &formatDataCell( "NewProblemFileName$i" , "???" ,"30" ); 788 # print &formatDataCell( "NewProblemValue$i" , "???" ,"5"); 789 # 790 # print "</TR>\n"; 791 # } 792 #print qq! 793 # </TABLE>\n 794 # 795 # </FORM>\n 796 # !; 797 # } 798 799 sub formatDataRow { 800 my ($pAitems,$size) =@_; 801 my $out = "<TR>\n"; 802 my $value; 803 my $i; 804 foreach $i (@$pAitems) { 805 $value = eval "\$$i=&get$i($inputs{'psvn'})"; 806 $out .= &formatDataCell($i,$value,$size); 807 } 808 $out .= "</TR>\n"; 809 } 810 sub formatHeaderRow { 811 my ( $pAitems,$options) =@_; 812 my $out = "<TR>\n"; 813 my $i; 814 foreach $i ( @$pAitems) { 815 $out .= &formatHeaderCell($i,$options); 816 } 817 $out .= "</TR>\n"; 818 } 819 sub formatDataCell { 820 my ($name,$value,$size) = @_; 821 $value = "" unless defined($value); # this value is optional 822 $size = "" unless defined($size); # this value is optional 823 my $out = qq! 824 <TD ALIGN=CENTER VALIGN=MIDDLE > 825 <INPUT TYPE="TEXT" NAME="$name" VALUE="$value", SIZE=$size> 826 </TD> 827 !; 828 $out; 829 } 830 sub formatCheckboxButtonCell { 831 my ($name,$size, $options) = @_; 832 $options = "" unless defined($options); 833 my $out = qq! 834 <TD ALIGN=CENTER VALIGN=MIDDLE > 835 <INPUT TYPE="CHECKBOX" NAME="$name" VALUE="on" SIZE="$size" $options> 836 </TD> 837 !; 838 $out; 839 } 840 sub formatHeaderCell { 841 my ($item,$options) = @_; 842 $options = "" unless defined($options); 843 my $out = qq! 844 <TH ALIGN=CENTER VALIGN=MIDDLE $options> 845 $item 846 </TH> 847 !; 848 849 }
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |