[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator / Problem.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm

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

Revision 387 Revision 388
1package WeBWorK::ContentGenerator::Problem; 1package WeBWorK::ContentGenerator::Problem;
2our @ISA = qw(WeBWorK::ContentGenerator); 2our @ISA = qw(WeBWorK::ContentGenerator);
3 3use lib '/Users/gage/webwork/xmlrpc/daemon';
4use lib '/Users/gage/webwork-modperl/lib';
5use PGtranslator5;
4use WeBWorK::ContentGenerator; 6use WeBWorK::ContentGenerator;
5use Apache::Constants qw(:common); 7use Apache::Constants qw(:common);
6 8
7sub title { 9sub title {
8 my ($self, $problem_set, $problem) = @_; 10 my ($self, $problem_set, $problem) = @_;
15 my ($self, $problem_set, $problem) = @_; 17 my ($self, $problem_set, $problem) = @_;
16 my $r = $self->{r}; 18 my $r = $self->{r};
17 my $courseEnvironment = $self->{courseEnvironment}; 19 my $courseEnvironment = $self->{courseEnvironment};
18 my $user = $r->param('user'); 20 my $user = $r->param('user');
19 21
20 print "Problem goes here"; 22 print "Problem goes here<p>\n";
21 23
24 print "<P>Request item<P>\n\n";
25 print "<TABLE border=\"3\">";
26 print $self->print_form_data('<tr><td>','</td><td>','</td></tr>');
27 print "</table>\n";
28 print "<P>\n\ncourseEnvironment<P>\n\n";
29 print pretty_print_rh($courseEnvironment);
30
31 ###########################################################################
32 # The pg problem class should have a method for installing it's problemEnvironment
33 ###########################################################################
34
35 $problemEnvir_rh = defineProblemEnvir($self);
36
37 print "<P>\n\nproblemEnvironment<P>\n\n";
38 print pretty_print_rh($problemEnvir_rh);
39# my $sig = do "pgGenerator.pl" ;
40# print "File not found $1" unless defined(sig);
41# print "Errors $@";
42# print pgHTML();
43
22 ""; 44 "";
23} 45}
24 46
47
48########################################################################################
49# This is the structure that needs to be filled out in order to call PGtranslator;
50########################################################################################
51
52sub defineProblemEnvir {
53 my $self = shift;
54 my $r = $self->{r};
55 my $courseEnvironment = $self->{courseEnvironment};
56 my %envir=();
57# $envir{'refSubmittedAnswers'} = $refSubmittedAnswers if defined($refSubmittedAnswers);
58 $envir{'psvnNumber'} = 123456789;
59 $envir{'psvn'} = 123456789;
60 $envir{'studentName'} = 'Jane Doe';
61 $envir{'studentLogin'} = 'jd001m';
62 $envir{'studentID'} = 'xxx-xx-4321';
63 $envir{'sectionName'} = 'gage';
64 $envir{'sectionNumber'} = '111foobar';
65 $envir{'recitationName'} = 'gage_recitation';
66 $envir{'recitationNumber'} = '11_foobar recitation';
67 $envir{'setNumber'} = 'setAlgebraicGeometry';
68 $envir{'questionNumber'} = 43;
69 $envir{'probNum'} = 43;
70 $envir{'openDate'} = 3014438528;
71 $envir{'formattedOpenDate'} = '3/4/02';
72 $envir{'dueDate'} = 4014438528;
73 $envir{'formattedDueDate'} = '10/4/04';
74 $envir{'answerDate'} = 4014438528;
75 $envir{'formattedAnswerDate'} = '10/4/04';
76 $envir{'problemValue'} = 1;
77 $envir{'fileName'} = 'problem1';
78 $envir{'probFileName'} = 'problem1';
79 $envir{'languageMode'} = 'HTML_tth';
80 $envir{'displayMode'} = 'HTML_tth';
81 $envir{'outputMode'} = 'HTML_tth';
82 $envir{'courseName'} = $courseEnvironment ->{courseName};
83 $envir{'sessionKey'} = 'asdf';
84
85# initialize constants for PGanswermacros.pl
86 $envir{'numRelPercentTolDefault'} = .1;
87 $envir{'numZeroLevelDefault'} = 1E-14;
88 $envir{'numZeroLevelTolDefault'} = 1E-12;
89 $envir{'numAbsTolDefault'} = .001;
90 $envir{'numFormatDefault'} = '';
91 $envir{'functRelPercentTolDefault'} = .1;
92 $envir{'functZeroLevelDefault'} = 1E-14;
93 $envir{'functZeroLevelTolDefault'} = 1E-12;
94 $envir{'functAbsTolDefault'} = .001;
95 $envir{'functNumOfPoints'} = 3;
96 $envir{'functVarDefault'} = 'x';
97 $envir{'functLLimitDefault'} = .0000001;
98 $envir{'functULimitDefault'} = .9999999;
99 $envir{'functMaxConstantOfIntegration'} = 1E8;
100# kludge check definition of number of attempts again. The +1 is because this is used before the current answer is evaluated.
101 $envir{'numOfAttempts'} = 2; #&getProblemNumOfCorrectAns($probNum,$psvn)
102 # &getProblemNumOfIncorrectAns($probNum,$psvn)+1;
103
104#
105#
106# defining directorys and URLs
107 $envir{'templateDirectory'} = $courseEnvironment ->{courseDirs}->{templates};
108############ $envir{'classDirectory'} = $Global::classDirectory;
109# $envir{'cgiDirectory'} = $Global::cgiDirectory;
110# $envir{'cgiURL'} = getWebworkCgiURL();
111# $envir{'macroDirectory'} = getCourseMacroDirectory();
112# $envir{'courseScriptsDirectory'} = getCourseScriptsDirectory();
113 $envir{'htmlDirectory'} = $courseEnvironment ->{courseDirectory}->{html};
114# $envir{'htmlURL'} = getCourseHtmlURL();
115# $envir{'tempDirectory'} = getCourseTempDirectory();
116# $envir{'tempURL'} = getCourseTempURL();
117# $envir{'scriptDirectory'} = $Global::scriptDirectory;##omit
118 $envir{'webworkDocsURL'} = 'http://webwork.math.rochester.edu';
119 $envir{'externalTTHPath'} = '/usr/local/bin/tth';
120
121
122#
123 $envir{'inputs_ref'} = $r->param;
124 $envir{'problemSeed'} = 3245;
125 $envir{'displaySolutionsQ'} = 1;
126 $envir{'displayHintsQ'} = 1;
127
128 # here is a way to pass environment variables defined in webworkCourse.ph
129# my $k;
130# foreach $k (keys %Global::PG_environment ) {
131# $envir{$k} = $Global::PG_environment{$k};
132# }
133 \%envir;
134}
135
136########################################################################################
137# This recursive pretty_print function will print a hash and its sub hashes.
138########################################################################################
139sub pretty_print_rh {
140 my $r_input = shift;
141 my $out = '';
142 if ( not ref($r_input) ) {
143 $out = $r_input; # not a reference
144 } elsif (is_hash_ref($r_input)) {
145 local($^W) = 0;
146 $out .= "<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">";
147 foreach my $key (sort keys %$r_input ) {
148 $out .= "<tr><TD> $key</TD><TD>=&gt;</td><td>&nbsp;".pretty_print_rh($r_input->{$key}) . "</td></tr>";
149 }
150 $out .="</table>";
151 } elsif (is_array_ref($r_input) ) {
152 my @array = @$r_input;
153 $out .= "( " ;
154 while (@array) {
155 $out .= pretty_print_rh(shift @array) . " , ";
156 }
157 $out .= " )";
158 } elsif (ref($r_input) eq 'CODE') {
159 $out = "$r_input";
160 } else {
161 $out = $r_input;
162 }
163 $out;
164}
165
166sub is_hash_ref {
167 my $in =shift;
168 my $save_SIG_die_trap = $SIG{__DIE__};
169 $SIG{__DIE__} = sub {CORE::die(@_) };
170 my $out = eval{ %{ $in } };
171 $out = ($@ eq '') ? 1 : 0;
172 $@='';
173 $SIG{__DIE__} = $save_SIG_die_trap;
174 $out;
175}
176sub is_array_ref {
177 my $in =shift;
178 my $save_SIG_die_trap = $SIG{__DIE__};
179 $SIG{__DIE__} = sub {CORE::die(@_) };
180 my $out = eval{ @{ $in } };
181 $out = ($@ eq '') ? 1 : 0;
182 $@='';
183 $SIG{__DIE__} = $save_SIG_die_trap;
184 $out;
185}
251; 1861;

Legend:
Removed from v.387  
changed lines
  Added in v.388

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9