| … | |
… | |
| 545 | # srand(time); ## Move this out of the loop as per Zig's suggestion. |
545 | # srand(time); ## Move this out of the loop as per Zig's suggestion. |
| 546 | ## Otherwise many students get the same seed - AKP |
546 | ## Otherwise many students get the same seed - AKP |
| 547 | foreach $i (@changedProblems) { |
547 | foreach $i (@changedProblems) { |
| 548 | |
548 | |
| 549 | ## chech if we should delete cached l2h images |
549 | ## chech if we should delete cached l2h images |
| 550 | if ( defined( $inputs{"problem{$i}EditMode"}) and |
550 | if ( (defined( $inputs{"problem{$i}ReSeed"}) and ($inputs{"problem{$i}ReSeed"} eq "on")) or |
| 551 | (($inputs{"problem{$i}EditMode"} eq "ReSeed") or ($inputs{"problem{$i}EditMode"} eq "Delete"))) { |
551 | (defined( $inputs{"problem{$i}Delete"}) and ($inputs{"problem{$i}Delete"} eq "on"))) { |
| 552 | $delete_cached_l2h_images = 1; |
552 | $delete_cached_l2h_images = 1; |
| 553 | } |
553 | } |
| 554 | |
554 | |
| 555 | #ReadWrite |
555 | #ReadWrite |
| 556 | #save seed (or define it) |
556 | #save seed (or define it) |
| … | |
… | |
| 574 | &deleteProblemStatus( $i,$psvn); |
574 | &deleteProblemStatus( $i,$psvn); |
| 575 | &deleteProblemValue( $i,$psvn); |
575 | &deleteProblemValue( $i,$psvn); |
| 576 | &deleteProblemMaxNumOfIncorrectAttemps( $i,$psvn); |
576 | &deleteProblemMaxNumOfIncorrectAttemps( $i,$psvn); |
| 577 | &deleteProblemSeed( $i,$psvn); |
577 | &deleteProblemSeed( $i,$psvn); |
| 578 | # recreate problem using saved seed |
578 | # recreate problem using saved seed |
| 579 | unless (defined( $inputs{"problem{$i}EditMode"}) && $inputs{"problem{$i}EditMode"} eq "Delete" ) { |
579 | unless (defined( $inputs{"problem{$i}Delete"}) && $inputs{"problem{$i}Delete"} eq "on" ) { |
| 580 | |
580 | |
| 581 | if ($inputs{"ProblemFileName$i"} =~ /\w+/) {$filename = stripWhiteSpace($inputs{"ProblemFileName$i"});} |
581 | if ($inputs{"ProblemFileName$i"} =~ /\w+/) {$filename = stripWhiteSpace($inputs{"ProblemFileName$i"});} |
| 582 | &putProblemFileName($filename , $num,$psvn); |
582 | &putProblemFileName($filename , $num,$psvn); |
| 583 | |
583 | |
| 584 | if ($inputs{"ProblemAttempted$i"} =~ /\w+/) {$attempted = stripWhiteSpace($inputs{"ProblemAttempted$i"});} |
584 | if ($inputs{"ProblemAttempted$i"} =~ /\w+/) {$attempted = stripWhiteSpace($inputs{"ProblemAttempted$i"});} |
| … | |
… | |
| 594 | &putProblemMaxNumOfIncorrectAttemps($maxNumOfIncorrectAttempts, $num,$psvn); |
594 | &putProblemMaxNumOfIncorrectAttemps($maxNumOfIncorrectAttempts, $num,$psvn); |
| 595 | |
595 | |
| 596 | &putProblemSeed( $seed,$num,$psvn); |
596 | &putProblemSeed( $seed,$num,$psvn); |
| 597 | |
597 | |
| 598 | # Reseed if requested |
598 | # Reseed if requested |
| 599 | if ( defined( $inputs{"problem{$i}EditMode"}) && $inputs{"problem{$i}EditMode"} eq "ReSeed" ) { |
599 | if (( defined( $inputs{"problem{$i}ReSeed"}) && $inputs{"problem{$i}ReSeed"} eq "on") |
|
|
600 | # But not if we are deleting |
|
|
601 | and not ( defined( $inputs{"problem{$i}Delete"}) && $inputs{"problem{$i}Delete"} eq "on")) { |
| 600 | $seed = int( rand(5000) ); |
602 | $seed = int( rand(5000) ); |
| 601 | &putProblemSeed( $seed , $num,$psvn); |
603 | &putProblemSeed( $seed , $num,$psvn); |
| 602 | print "Seed changed for problem number $num, psvn $psvn<BR>\n"; |
604 | print "Seed changed for problem number $num, psvn $psvn<BR>\n"; |
| 603 | } |
605 | } |
| 604 | $num++; |
606 | $num++; |
| … | |
… | |
| 608 | } |
610 | } |
| 609 | &detachProbSetRecord($psvn); |
611 | &detachProbSetRecord($psvn); |
| 610 | } |
612 | } |
| 611 | } # end of updating database |
613 | } # end of updating database |
| 612 | |
614 | |
| 613 | ## remobe l2h images if necessary |
615 | ## remove l2h images if necessary |
| 614 | |
616 | |
| 615 | if ($delete_cached_l2h_images) { |
617 | if ($delete_cached_l2h_images) { |
| 616 | my $l2hDir = getCoursel2hDirectory(); |
618 | my $l2hDir = getCoursel2hDirectory(); |
| 617 | system ("rm -rf ${l2hDir}set$setNumber"); |
619 | system ("rm -rf ${l2hDir}set$setNumber"); |
| 618 | print "\n<BR>deleting Latex2html tmp files and the directory:<BR>\n"; |
620 | print "\n<BR>deleting Latex2html tmp files and the directory:<BR>\n"; |
| … | |
… | |
| 692 | print &formatDataCell( "ProblemFileName$i" , &getProblemFileName($i,$psvn),"50" ); |
694 | print &formatDataCell( "ProblemFileName$i" , &getProblemFileName($i,$psvn),"50" ); |
| 693 | print &formatDataCell( "ProblemAttempted$i" , '' ,"1"); |
695 | print &formatDataCell( "ProblemAttempted$i" , '' ,"1"); |
| 694 | print &formatDataCell( "ProblemStatus$i" ,'' ,"5"); |
696 | print &formatDataCell( "ProblemStatus$i" ,'' ,"5"); |
| 695 | print &formatDataCell( "ProblemValue$i" ,'' ,"5"); |
697 | print &formatDataCell( "ProblemValue$i" ,'' ,"5"); |
| 696 | print &formatDataCell( "ProblemMaxNumOfIncorrectAttemps$i" , '' ,"4"); |
698 | print &formatDataCell( "ProblemMaxNumOfIncorrectAttemps$i" , '' ,"4"); |
| 697 | print & formatRadioButtonCell( "problem{$i}EditMode", "Delete" ,"5", ""); |
699 | print & formatCheckboxButtonCell( "problem{$i}Delete", "5", ""); |
| 698 | print & formatRadioButtonCell( "problem{$i}EditMode", "ReSeed" ,"5", ""); |
700 | print & formatCheckboxButtonCell( "problem{$i}ReSeed", "5", ""); |
| 699 | |
701 | |
| 700 | print "</TR>"; |
702 | print "</TR>"; |
| 701 | |
703 | |
| 702 | } |
704 | } |
| 703 | |
705 | |
| … | |
… | |
| 848 | <INPUT TYPE="TEXT" NAME="$name" VALUE="$value", SIZE=$size> |
850 | <INPUT TYPE="TEXT" NAME="$name" VALUE="$value", SIZE=$size> |
| 849 | </TD> |
851 | </TD> |
| 850 | !; |
852 | !; |
| 851 | $out; |
853 | $out; |
| 852 | } |
854 | } |
| 853 | sub formatRadioButtonCell { |
855 | sub formatCheckboxButtonCell { |
| 854 | my ($name,$value,$size, $options) = @_; |
856 | my ($name,$size, $options) = @_; |
| 855 | $options = "" unless defined($options); |
857 | $options = "" unless defined($options); |
| 856 | my $out = qq! |
858 | my $out = qq! |
| 857 | <TD ALIGN=CENTER VALIGN=MIDDLE > |
859 | <TD ALIGN=CENTER VALIGN=MIDDLE > |
| 858 | <INPUT TYPE="RADIO" NAME="$name" VALUE="$value" SIZE="$size" $options> |
860 | <INPUT TYPE="CHECKBOX" NAME="$name" VALUE="on" SIZE="$size" $options> |
| 859 | </TD> |
861 | </TD> |
| 860 | !; |
862 | !; |
| 861 | $out; |
863 | $out; |
| 862 | } |
864 | } |
| 863 | sub formatHeaderCell { |
865 | sub formatHeaderCell { |