[system] / trunk / webwork / system / cgi / cgi-scripts / welcomeAction.pl Repository:
ViewVC logotype

Diff of /trunk/webwork/system/cgi/cgi-scripts/welcomeAction.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 114 Revision 115
35 } 35 }
36 # end Timing code 36 # end Timing code
37 37
38# ## Setting these time out comstants to zeros removes the time constraint completely. (zero = infinity :=) ) 38# ## Setting these time out comstants to zeros removes the time constraint completely. (zero = infinity :=) )
39 $main::TIME_OUT_CONSTANT = 60; # one minute wait for on screen problems 39 $main::TIME_OUT_CONSTANT = 60; # one minute wait for on screen problems
40 $main::DOWNLOAD_TIME_OUT_CONSTANT = 300; # give it five minutes 40# $main::DOWNLOAD_TIME_OUT_CONSTANT = 300; # give it five minutes
41 $main::CLASS_DOWNLOAD_TIME_OUT_CONSTANT = 1200; #twenty minutes 41 $main::CLASS_DOWNLOAD_TIME_OUT_CONSTANT = 1200; #twenty minutes
42 $main::DOWNLOAD_NICE = 2; 42# $main::DOWNLOAD_NICE = 2;
43 $main::CLASS_DOWNLOAD_NICE = 5; # higher numbers indicated lower priorities 43 $main::CLASS_DOWNLOAD_NICE = 5; # higher numbers indicated lower priorities
44 44
45# ## ATTENTION: The handlers PG_floating_point_exception_handler and PG_warnings_handler 45# ## ATTENTION: The handlers PG_floating_point_exception_handler and PG_warnings_handler
46# ## have to be installed after CGI::Carp is called since it also 46# ## have to be installed after CGI::Carp is called since it also
47# ## modifes the die and warn labels. Finding the right warning mechanism using these two 47# ## modifes the die and warn labels. Finding the right warning mechanism using these two
132attachCLRecord($login_name_for_psvn); 132attachCLRecord($login_name_for_psvn);
133 133
134my $setNumber=&getSetNumber($psvn); 134my $setNumber=&getSetNumber($psvn);
135$setNumber = $inputs{'setNo'} if defined $inputs{'setNo'}; ## script called from profChangeDates.pl 135$setNumber = $inputs{'setNo'} if defined $inputs{'setNo'}; ## script called from profChangeDates.pl
136 136
137 137# keep strict happy
138my $tempTexFileBaseName;
138 139
139###### check to see that it is after the open date 140###### check to see that it is after the open date
140my ($currentTime,$odts,$ddts,$remainingTime, $TimeString); 141my ($currentTime,$odts,$ddts,$remainingTime, $TimeString);
141$currentTime = time; 142$currentTime = time;
142$odts=&getOpenDate($psvn); 143$odts=&getOpenDate($psvn);
480# $PG_ANSWER_HASH_REF = $pt->rh_correct_answers; 481# $PG_ANSWER_HASH_REF = $pt->rh_correct_answers;
481 $PG_EVALUATED_ANSWERS_REF = $pt->process_answers; 482 $PG_EVALUATED_ANSWERS_REF = $pt->process_answers;
482 $PG_FLAGS_REF = $pt ->rh_flags; 483 $PG_FLAGS_REF = $pt ->rh_flags;
483 484
484 485
485 print OUTPUT @{$PG_PROBLEM_TEXT_REF}; 486# print OUTPUT @{$PG_PROBLEM_TEXT_REF};
486 $texSource .= join '', @{$PG_PROBLEM_TEXT_REF}; 487 $texSource .= join '', @{$PG_PROBLEM_TEXT_REF};
487 488
488 if (defined($PG_FLAGS_REF->{'error_flag'}) and $PG_FLAGS_REF->{'error_flag'} ==1) { 489 if (defined($PG_FLAGS_REF->{'error_flag'}) and $PG_FLAGS_REF->{'error_flag'} ==1) {
489 push(@PG_COMPILE_ERRORS, qq{<A HREF="#problem$probNum">$probNum</A>} ); 490 push(@PG_COMPILE_ERRORS, qq{<A HREF="#problem$probNum">$probNum</A>} );
490 } 491 }
535 return \$texSource, \@PG_COMPILE_ERRORS; 536 return \$texSource, \@PG_COMPILE_ERRORS;
536} 537}
537 538
538################### END main routine ################################## 539################### END main routine ##################################
539 540
540# sub downloadPS { 541sub downloadAllSets {
541# my $psvn = shift; 542 system("/usr/bin/renice +$main::CLASS_DOWNLOAD_NICE -p $$ 1>/dev/null") && warn "Could not renice process. pid $$";
542# my $texFile = shift; 543 alarm( $main::CLASS_DOWNLOAD_TIME_OUT_CONSTANT);
543# 544
544# my ($texSourceRef, $errorRef) = &createTexSource($psvn); 545 my $downloadMulti = "unknown";
545# 546 $downloadMulti = "multistudent" if $action eq "Get_all_copies";
546# 547 $downloadMulti = "multiset" if $action eq "Get_hard_copy";
547# open(OUTPUT, ">${tempDirectory}${texFile}${psvn}.tex") 548
548# || wwerror("Can't create $tempDirectory${texFile}$psvn.tex\n"); 549 my @psvns_to_download = $query->param('local_psvns');
549# print OUTPUT $$texSourceRef; 550 my $num_psvns_to_download = @psvns_to_download;
550# close OUTPUT; 551 my $max_psvns_to_download = $Global::max_num_of_ps_downloads_allowed;
551# 552
552# 553 if($num_psvns_to_download > 1 and $permissions != $Global::instructor_permissions) {
553# print STDERR "Finished making tex file $tempDirectory${texFile}$psvn.tex <br>\n\n" if $debugON; 554 wwerror("Non-professors are not permitted to download more than one problem set at a time.");
555 }
556
557 if(@psvns_to_download > $Global::max_num_of_ps_downloads_allowed) {
558 my $tooManyWhat = $downloadMulti eq "multiset" ? "problem sets" : "students";
559 wwerror("Too many $tooManyWhat are selected for download.",
560 "The maximum number of $tooManyWhat which can be downloaded at one time is $Global::max_num_of_ps_downloads_allowed."
561 ." You selected $num_psvns_to_download. Go back and select fewer $tooManyWhat."
562 ." (This maximun is set by the variable \$max_num_of_ps_downloads_allowed in Global.pm.)");
563 }
564
565 my ($cumulativeTexSource, $currentTexSourceRef, $currentTexSource, $currentTexErrorRef);
566
567 # this could be used when eliminating pre-foreach createTexSourceHandleErrors call
568 # s/\\end\{document\}.*?\\begin\{document\}/\n\\newpage\n/s;
569
570 $tempTexFileBaseName = "$tempDirectory$User\_$Course";
571 my $first_psvn = $psvns_to_download[0];
572
573 my $current_psvn = shift @psvns_to_download;
574 ($currentTexSourceRef, $currentTexErrorRef) = createTexSource($current_psvn);
575 @psvns_to_download = () if(@$currentTexErrorRef);
576 $currentTexSource = $$currentTexSourceRef;
577 $currentTexSource =~ s|\\end\{document\}\s$|\n|s;
578 $cumulativeTexSource .= $currentTexSource;
579
580 foreach $current_psvn (@psvns_to_download) {
581 ($currentTexSourceRef, $currentTexErrorRef) = createTexSource($current_psvn);
582 @psvns_to_download = () if(@$currentTexErrorRef);
583 $currentTexSource = $$currentTexSourceRef;
584 $currentTexSource =~ s|^.*?\\begin\{document\}|\n\\newpage\n|s;
585 $currentTexSource =~ s|\\end\{document\}\s$|\n|s;
586 $cumulativeTexSource .= $currentTexSource;
587 }
588
589 $cumulativeTexSource .= "\n\\end{document}\n";
590
591 open TEXOUTPUT, ">$tempTexFileBaseName.tex"
592 or wwerror("Can't open $tempTexFileBaseName.tex for output.");
593 print TEXOUTPUT $cumulativeTexSource;
594 close TEXOUTPUT;
595
596 if(@$currentTexErrorRef) {
597 PG_error_print($tempTexFileBaseName, $current_psvn, @$currentTexErrorRef);
598 } else {
599 $downloadType = lc $downloadType;
600 my $mimeType = prepareHardcopy($tempTexFileBaseName, $downloadType);
601
602 my ($setName, $userName);
603 &attachProbSetRecord($first_psvn);
604 if($downloadMulti eq "multistudent") {
605 if($num_psvns_to_download == 1) {
606 $setName = getSetNumber($first_psvn);
607 $userName = getStudentLogin($first_psvn);
608 } else {
609 $setName = getSetNumber($first_psvn);
610 $userName = "multistudent";
611 }
612 } elsif($downloadMulti eq "multiset") {
613 if($num_psvns_to_download == 1) {
614 $setName = getSetNumber($first_psvn);
615 $userName = getStudentLogin($first_psvn);
616 } else {
617 $setName = "multiset";
618 $userName = getStudentLogin($first_psvn);
619 }
620 }
621 my $hardCopyName = "$Course.$userName.$setName.$downloadType";
622
623 open(TEXINPUT, "$tempTexFileBaseName.$downloadType")
624 or wwerror($0, "Can't open $tempTexFileBaseName.$downloadType: $!\n");
625 print "Content-type: $mimeType\n";
626 print "Content-disposition: attachment; filename=\"$hardCopyName\"\n\n";
627 print while (<TEXINPUT>);
628 close TEXINPUT;
629 }
630}
631
632sub prepareHardcopy
633{
634 my ($texFileBaseName, $targetFormat) = @_;
635 my $mimeType;
636
554# # chdir "$tempDirectory"; 637 chdir $tempDirectory;
555# # umask(022); 638
556# 639 my $dviCommandLine = "$Global::$Global::externalLatexPath $texFileBaseName.tex >/dev/null 2>/dev/null";
557# # Now that the complete TeX version of the problem set has been 640 my $psCommandLine = "$Global::externalDvipsPath -o $texFileBaseName.ps $texFileBaseName.dvi >/dev/null 2>/dev/null";
558# # constructed in the $tempDirectory We first attempt to convert it to 641 my $pdfCommandLine = "$Global::externalPs2pdfPath $texFileBaseName.ps $texFileBaseName.pdf";
559# # postscript, first running TeX and then running dvips The system commands 642
560# # for this are located in the file makePS which is in the script directory. 643 if($targetFormat eq "pdf") {
561# # If this command fails then an error is reported, otherwise &psPrint 644 system($dviCommandLine) and die "dvi generation failed.";
562# # ships the postscript file off to the client which requested the download. 645 system($psCommandLine) and die "ps generation failed.";
563# my @PG_COMPILE_ERRORS = @$errorRef; 646 system($pdfCommandLine) and die "pdf generation failed.";
564# if ( @PG_COMPILE_ERRORS ) { 647 $mimeType = "application/pdf";
565# &PG_error_print(@PG_COMPILE_ERRORS); 648 } elsif($targetFormat eq "ps") {
566# # $PG_COMPILE_ERRORS contains the number of the first problem with an error. 649 system($dviCommandLine) and die "dvi generation failed.";
567# return 'errors'; 650 system($psCommandLine) and die "ps generation failed.";
568# } 651 $mimeType = "application/postscript";
569# else {return 'no_errors';} 652 } elsif($targetFormat eq "dvi") {
570# } 653 system($dviCommandLine) and die "dvi generation failed.";
654 $mimeType = "application/x-dvi";
655 } elsif($targetFormat eq "tex") {
656 $mimeType = "application/tex";
657 } else {
658 die "unrecognized format: $targetFormat";
659 }
660
661 return $mimeType;
662}
571 663
664sub PG_error_print
665{
666 my ($tempTexFileBaseName, $current_psvn, @errors) = @_;
667
668 # get set name and student name from psvn
669 &attachProbSetRecord($current_psvn);
670 my $userName = &getStudentLogin($current_psvn);
671 my $setName = &getSetNumber($current_psvn);
672
673 # print error page header
674 print &htmlTOP("PG compile error");
675 print "<H3>PG error while compiling problem number", (@errors>1) ? 's ' : ' ',
676 join(', ', @errors), " in problem set $setName for $userName.</H3>";
677 print "<h3>TeX source file:</h3>";
678
679 # open temp tex file
680 if(open TEXINPUT, "$tempTexFileBaseName.tex") {
681 print "<pre>\n";
682 my $lineNumber = 1;
683 while(<TEXINPUT>) {
684 if(/<A NAME/) { print $_; }
685 else { print protect_HTML("$lineNumber $_"), "\n"; }
686 $lineNumber++;
687 }
688 print "</pre>\n";
689 close TEXINPUT;
690 } else {
691 print "<p>Unable to open TeX source file:<br><tt>$tempTexFileBaseName.tex</tt></p>";
692 }
693
694 # print page footer
695 print &htmlBOTTOM("welcomeAction.pl", \%inputs);
696 exit;
697}
572 698
573# sub psPrint { 699# -----
574# open(INPUT, "$tempDirectory${texFile}$psvn.ps")
575# or wwerror( $0, "Can't open $tempDirectory${texFile}$psvn.ps: $!\n", "", "");
576#
577# print "Content-disposition: attachment; filename= \"${login_name_for_psvn}_Set${setNumber}.ps\"\n";
578# print "Content-type: application/postscript\n\n";
579# while (<INPUT>) {
580# print;
581# }
582# close INPUT;
583# print STDERR "Finished TeX $texFile for $login_name_for_psvn in $Course\n" if $debugON;
584#
585# }
586#
587# sub pdfPrint {
588#
589# system( "${scriptDirectory}makePDF $tempDirectory ${texFile}$psvn 1>&2" ) == 0
590# or wwerror("$0", "Unable to create PDF output using makePDF file:<BR> ${scriptDirectory}makePDF $tempDirectory ${texFile}$psvn 1>&2<BR>Error is: $!", "", "");
591# open(INPUT, "$tempDirectory${texFile}$psvn.pdf")
592# || wwerror("$0", "Can't open $tempDirectory${texFile}$psvn.pdf: $!\n","","");
593#
594# print "Content-type: application/pdf\n\n" ;
595# print "Content-disposition: attachment; filename= \"${login_name_for_psvn}_Set${setNumber}.pdf\"\n";
596# #print "Content-type: application/pdf\n\n" ;
597# while (<INPUT>) {
598# print;
599# }
600# close INPUT;
601# print STDERR "Finished TeX $texFile for $login_name_for_psvn in $Course\n" if $debugON;
602#
603# }
604#
605# sub texPrint {
606# open(INPUT, "$tempDirectory${texFile}$psvn.tex") ||
607# wwerror("$0", "Can't open $tempDirectory${texFile}$psvn.tex:<BR> $!\n", "", "");
608#
609# print "Content-disposition: attachment; filename= \"${login_name_for_psvn}_Set${setNumber}.tex\"\n";
610# print "Content-type: application/tex\n\n";
611#
612# while (<INPUT>) {
613# print;
614# }
615# close INPUT;
616# }
617#
618# sub dviPrint {
619# open(INPUT, "$tempDirectory${texFile}$psvn.dvi") ||
620# wwerror("$0", "Can't open $tempDirectory${texFile}$psvn.dvi:<BR> $!\n", "", "");
621#
622# print "Content-disposition: attachment; filename= \"${login_name_for_psvn}_Set${setNumber}.dvi\"\n";
623# print "Content-type: application/x-dvi\n\n" ;
624# while (<INPUT>) {
625# print;
626# }
627# close INPUT;
628# }
629 700
630sub logPrint { 701sub logPrint {
631 print &htmlTOP("TeX Error or error in creating PostScript file"); 702 print &htmlTOP("TeX Error or error in creating PostScript file");
632 open (LOGFILE, " $tempDirectory$texFile$psvn.log") 703 open (LOGFILE, " $tempDirectory$texFile$psvn.log")
633 || print "<H3>Can't open log file:</H3> path= $tempDirectory$texFile$psvn.log<BR>$!<BR><BR>" ; 704 || print "<H3>Can't open log file:</H3> path= $tempDirectory$texFile$psvn.log<BR>$!<BR><BR>" ;
667 $line =~s/\&/&amp;/g; 738 $line =~s/\&/&amp;/g;
668 $line =~s/</&lt;/g; 739 $line =~s/</&lt;/g;
669 $line =~s/>/&gt;/g; 740 $line =~s/>/&gt;/g;
670 $line; 741 $line;
671} 742}
672sub PG_error_print {
673 my @probNums = @_;
674 my $dummy_psvn = -1;
675 &attachProbSetRecord($psvn);
676 my $userName = &getStudentLogin($psvn);
677 my $setName = &getSetNumber($psvn);
678 print &htmlTOP("PG compile error");
679 print "<H3>PG error while compiling problem number",
680 (@probNums>1) ? 's ' : ' ',
681 join(',', @probNums),
682 " in problem set $setName for $userName",
683 "</H3>";
684 print "(Search for &quot;ERROR&quot; to find the line where the error occurs.)";
685 print "<H3>TeX Source File:</H3>";
686 print "<PRE>";
687# print "openedFile = ${tempDirectory}${texFile}${dummy_psvn}.tex\n",
688# "userName = $userName\n",
689# "setName = $setName\n";
690
691 open (TEXFILE, "${tempDirectory}${texFile}${dummy_psvn}.tex")
692 or print STDERR "Can't open $tempDirectory$texFile$dummy_psvn.tex\n";
693 my $lineNumber = 1;
694 local($/) = "\n";
695 while (<TEXFILE>) {
696 if ( $_ =~/^<A NAME/ ) { # skip lines starting with a destination anchor
697 print $_;
698 } else {
699 print protect_HTML("$lineNumber $_")."\n";
700 }
701 $lineNumber++;
702 }
703 close(TEXFILE);
704 print &htmlBOTTOM("downloadPS.pl", \%inputs);
705}
706
707sub selectionError { 743sub selectionError {
708 print &htmlTOP("Selection error"); 744 print &htmlTOP("Selection error");
709 print"<H2>Error:</H2> You must first select a problem set in order to download a hard copy!\n"; 745 print"<H2>Error:</H2> You must first select a problem set in order to download a hard copy!\n";
710 print "<FORM METHOD=POST ACTION=\"${Global::cgiWebworkURL}welcome.pl\"><P>"; 746 print "<FORM METHOD=POST ACTION=\"${Global::cgiWebworkURL}welcome.pl\"><P>";
711 print &sessionKeyInputs(\%inputs); 747 print &sessionKeyInputs(\%inputs);
764 </FORM> 800 </FORM>
765 </TD> 801 </TD>
766 </TABLE> 802 </TABLE>
767 }; 803 };
768 $title_bar; 804 $title_bar;
769}
770
771# sub downloadIndividualSet {
772# system("/usr/bin/renice +$main::DOWNLOAD_NICE -p $$ 1>/dev/null") && warn "Could not renice process. pid $$";
773# alarm( $main::DOWNLOAD_TIME_OUT_CONSTANT);
774# my $return_status='';
775# eval {$return_status = downloadPS($psvn,$texFile)}; ## trap any errors
776# $save_errors=$@; ## errors will be printed out by END
777# if ($return_status eq 'errors') {exit;}
778# elsif ($return_status eq 'no_errors') {
779# if ($downloadType eq "TeX" ) {
780# &texPrint;
781# }
782# elsif (system( "${scriptDirectory}makePS $tempDirectory $texFile$psvn 1>&2" )) {
783# &logPrint;
784# # wwerror("$0", "downloadPS: Error in creating postscript file. <BR>
785# # System command ${scriptDirectory}makePS $tempDirectory $texFile$psvn 1>&2", "", "");
786# }
787# else { # tex file has been processed successfully
788# if ($downloadType eq 'pdf') {&pdfPrint;}
789# elsif ($downloadType eq 'dvi') {&dviPrint;}
790# else {&psPrint;}
791# }
792# }
793# else {wwerror($0, "The subroutine downloadPS returned an unknown status");}
794# }
795
796sub downloadAllSets {
797 system("/usr/bin/renice +$main::CLASS_DOWNLOAD_NICE -p $$ 1>/dev/null") && warn "Could not renice process. pid $$";
798 alarm( $main::CLASS_DOWNLOAD_TIME_OUT_CONSTANT);
799 my $localpsvn; ## psvn numbers for individual students
800 my $return_status='';
801 my $texSource ='';
802 my $individualTexSource ='';
803 my ($texSourceRef, $errorRef);
804
805 my @local_psvns = $query -> param('local_psvns');
806
807 my $max = $Global::max_num_of_ps_downloads_allowed;
808
809 ## make sure non professors can not download more than one set by submitting an altered form
810 @local_psvns = ($local_psvns[0]) unless $permissions == $Global::instructor_permissions;
811
812 my $length = @local_psvns;
813
814 if ($length > $max) {
815 wwerror ("Too many students selected", "The maximun number of sets which can be downloaded at one time is $max. You selected $length.
816Go back and select fewer students. This maximun is set by the variable
817\$max_num_of_ps_downloads_allowed in Global.pm.");
818 }
819 $localpsvn = shift @local_psvns; ## get first set which will contain TeX header info
820# attachProbSetRecord($localpsvn);
821 ($texSourceRef, $errorRef) = &createTexSourceHandleErrors($localpsvn);
822 ## don't do anything with $errorRef at this time
823 ## only contains prob numbers of bad problems
824 $texSource = $$texSourceRef; ## contains initial header info
825 $texSource =~ s|\\end\{document\}\s$|\n|s; ## remove end{document} statement
826
827 foreach $localpsvn (@local_psvns) { ## get the rest of the sets and strip TeX header info
828# attachProbSetRecord($localpsvn);
829 ($texSourceRef, $errorRef) = &createTexSourceHandleErrors($localpsvn);
830 ## don't do anything with $errorRef at this time
831 ## only contains prob numbers of bad problems
832 $individualTexSource = $$texSourceRef;
833 $individualTexSource =~ s|^.*?\\begin\{document\}|\n\\newpage\n|s; ## remove header material and start new page
834 $individualTexSource =~ s|\\end\{document\}\s$|\n|s; ## remove end{document} statement
835 $texSource .= $individualTexSource;
836 }
837 $texSource .= "\n\\end{document}\n"; ## append end{document} statement
838
839 $psvn = -1;
840 $texFile = "set${setNumber}.tempTex-CGIscript";
841 $login_name_for_psvn = 'all_students';
842
843 open(OUTPUT, ">${tempDirectory}${texFile}${psvn}.tex")
844 || wwerror("Can't create $tempDirectory${texFile}$psvn.tex\n");
845 print OUTPUT $texSource;
846 close OUTPUT;
847
848 # This code replaces the psPrint, pdfPrint, dviPrint, texPrint, subs
849 # and the scripts/makePS and scripts/makePDF files
850
851 $downloadType = lc $downloadType;
852 my $texFileBaseName = "${tempDirectory}${texFile}${psvn}";
853 my $mimeType = prepareHardcopy($texFileBaseName, $downloadType);
854
855 open(INPUT, "$texFileBaseName.$downloadType")
856 or wwerror($0, "Can't open $texFileBaseName.$downloadType: $!\n");
857 print "Content-type: $mimeType\n";
858 print "Content-disposition: attachment; filename=\"${login_name_for_psvn}_Set${setNumber}.$downloadType\"\n\n";
859 print while (<INPUT>);
860 close INPUT;
861}
862
863sub createTexSourceHandleErrors {
864 # wraps call to createTexSource to handle PGtranslator errors
865 # if an error is found, &PG_error_print is called
866
867 my $psvn = shift;
868
869 my ($texSourceRef, $errorRef) = &createTexSource($psvn);
870
871 my @errors = @$errorRef;
872 if(@errors) {
873 PG_error_print(@errors);
874 }
875
876 return ($texSourceRef, $errorRef);
877}
878
879sub prepareHardcopy
880{
881 my ($texFileBaseName, $targetFormat) = @_;
882 my $mimeType;
883
884 chdir $tempDirectory;
885
886 my $dviCommandLine = "$Global::$Global::externalLatexPath $texFileBaseName.tex >/dev/null 2>/dev/null";
887 my $psCommandLine = "$Global::externalDvipsPath -o $texFileBaseName.ps $texFileBaseName.dvi";
888 my $pdfCommandLine = "$Global::externalPs2pdfPath $texFileBaseName.ps $texFileBaseName.pdf";
889
890 if($targetFormat eq "pdf") {
891 system($dviCommandLine) and die "dvi generation failed.";
892 system($psCommandLine) and die "ps generation failed.";
893 system($pdfCommandLine) and die "pdf generation failed.";
894 $mimeType = "application/pdf";
895 } elsif($targetFormat eq "ps") {
896 system($dviCommandLine) and die "dvi generation failed.";
897 system($psCommandLine) and die "ps generation failed.";
898 $mimeType = "application/postscript";
899 } elsif($targetFormat eq "dvi") {
900 system($dviCommandLine) and die "dvi generation failed.";
901 $mimeType = "application/x-dvi";
902 } elsif($targetFormat eq "tex") {
903 $mimeType = "application/tex";
904 } else {
905 die "unrecognized format: $targetFormat";
906 }
907
908 return $mimeType;
909} 805}
910 806
911sub hackerError { ## prints hacker error message 807sub hackerError { ## prints hacker error message
912 808
913 my $msg = "Attempt to hack into WeBWorK \n Remote Host is: ". remote_host()."\n"; 809 my $msg = "Attempt to hack into WeBWorK \n Remote Host is: ". remote_host()."\n";
1041 unless (defined($action ) and ($action eq 'Do problem set' or $action eq 'Do_problem_set')) { 937 unless (defined($action ) and ($action eq 'Do problem set' or $action eq 'Do_problem_set')) {
1042 my $ERRORS = $save_errors; 938 my $ERRORS = $save_errors;
1043 unless ($debugON) { #clean up the directory 939 unless ($debugON) { #clean up the directory
1044 eval { 940 eval {
1045 chdir $tempDirectory; 941 chdir $tempDirectory;
1046 unlink("$texFile$psvn.dvi", "$texFile$psvn.ps","$texFile$psvn.pdf", 942 unlink(
1047 "$texFile$psvn.log", "$texFile$psvn.aux", 943 "#tempTexFileBaseName.dvi",
944 "$tempTexFileBaseName.ps",
945 "$tempTexFileBaseName.pdf",
946 "$tempTexFileBaseName.log",
947 "$tempTexFileBaseName.aux",
1048 "$texFile$psvn.tex",); 948 "$tempTexFileBaseName.tex"
949 );
1049 unlink("${tempDirectory}eps/${login_name_for_psvn}*.eps"); 950 unlink("${tempDirectory}eps/${login_name_for_psvn}*.eps");
1050 }; # clean up 951 }; # clean up
1051 $ERRORS .= $ERRORS . $@; 952 $ERRORS .= $ERRORS . $@;
1052 } 953 }
1053 my $query = query_string(); 954 my $query = query_string();
1123 } 1024 }
1124 # end Timing code 1025 # end Timing code
1125 cleanup_downloadPS(); 1026 cleanup_downloadPS();
1126} 1027}
1127 1028
1128
1129######## DEBUGGING TOOLS
1130
1131# sub downloadPS_dumpvar {
1132# my ($packageName) = @_;
1133#
1134# local(*alias);
1135#
1136#
1137# *stash = *{"${packageName}::"};
1138# $, = " ";
1139#
1140# print OUTPUT "Content-type: text/html\n\n<PRE>\n";
1141#
1142#
1143# while ( ($varName, $globValue) = each %stash) {
1144# print OUTPUT "$varName =================================\n";
1145#
1146# *alias = $globValue;
1147# next if $varName=~/main/;
1148# next unless $varName =~/::/;
1149#
1150# if (defined($alias) ) {
1151# print OUTPUT "\t \$$varName $alias \n";
1152# }
1153#
1154# if ( defined(@alias) ) {
1155# print OUTPUT "\t \@$varName @alias \n";
1156# }
1157# if (defined(%alias) ) {
1158# print OUTPUT "\t \%$varName \n";
1159# foreach $key (keys %alias) {
1160# print OUTPUT "\t\t $key => $alias{$key}\n";
1161# }
1162#
1163#
1164# }
1165# }
1166#
1167#
1168#
1169# }
1170
1171
11721; 10291;

Legend:
Removed from v.114  
changed lines
  Added in v.115

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9