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

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

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

Revision 20 Revision 21
10# 'course' 10# 'course'
11# 'probSetKey' and 11# 'probSetKey' and
12# 'probNum' 12# 'probNum'
13# and in addition 13# and in addition
14# 'Mode' (for either TeX mode or HTML mode or Latex2HTML mode) 14# 'Mode' (for either TeX mode or HTML mode or Latex2HTML mode)
15# 'show_old_answers' (whether or not student's old answers should be filled in)
15# 'ShowAns' (asks for answer to be shown -- only available for instructors) 16# 'ShowAns' (asks for answer to be shown -- only available for instructors)
16# 'answer$i' (the answers -- if any --provided to the questions) 17# 'answer$i' (the answers -- if any --provided to the questions)
17# 'showEdit' (checks if the ShowEditor button should be shown and clicked) 18# 'showEdit' (checks if the ShowEditor button should be shown and clicked)
18# 'showSol' (checks if the solution button ishould be shown and clicked) 19# 'showSol' (checks if the solution button ishould be shown and clicked)
19# as well as 20# as well as
108 my $previousProbNum = $probNum -1 if defined($probNum); 109 my $previousProbNum = $probNum -1 if defined($probNum);
109 my $mode = "HTML"; 110 my $mode = "HTML";
110 $mode = $inputs{'Mode'} if defined( $inputs{'Mode'} ); 111 $mode = $inputs{'Mode'} if defined( $inputs{'Mode'} );
111 $main::display_mode = $mode; # this is only used for the timing messages. 112 $main::display_mode = $mode; # this is only used for the timing messages.
112 my $showEdit = $inputs{'showEdit'}; 113 my $showEdit = $inputs{'showEdit'};
114 my $show_old_answers = 0;
115 $show_old_answers = $inputs{'show_old_answers'} if defined($inputs{'show_old_answers'});
113 116
114# verify that information has been received 117# verify that information has been received
115 unless($Course && $User && $Session_key && $psvn) { 118 unless($Course && $User && $Session_key && $psvn) {
116 my $error_msg = $cgi -> remote_host() . ' ' . 119 my $error_msg = $cgi -> remote_host() . ' ' .
117 $cgi -> user_agent() . ' ' . $cgi -> query_string(); 120 $cgi -> user_agent() . ' ' . $cgi -> query_string();
213 $setNumber = &getSetNumber($psvn); 216 $setNumber = &getSetNumber($psvn);
214 $numberOfProblems = &getAllProblemsForProbSetRecord($psvn); 217 $numberOfProblems = &getAllProblemsForProbSetRecord($psvn);
215 218
216 219
217# If answers have not been submitted and previous answers have been saved, patch them in 220# If answers have not been submitted and previous answers have been saved, patch them in
218 unless ($answers_submitted) { 221# unless $show_old_answers = 0
222
223 unless ($answers_submitted or !$show_old_answers) {
219 my $student_answers = getProblemStudentAnswer($probNum,$psvn); 224 my $student_answers = getProblemStudentAnswer($probNum,$psvn);
220 if (defined $student_answers) { 225 if (defined $student_answers) {
221 my $rh_answer_hash = decode_submitted_answers($student_answers); 226 my $rh_answer_hash = decode_submitted_answers($student_answers);
222 my %answer_hash = %$rh_answer_hash; 227 my %answer_hash = %$rh_answer_hash;
223 my ($label, $value); 228 my ($label, $value);
769 774
770############# print hidden information about problem and set 775############# print hidden information about problem and set
771 776
772 print $cgi -> hidden( -name => 'probNum', -value => $probNum ), "\n\t", 777 print $cgi -> hidden( -name => 'probNum', -value => $probNum ), "\n\t",
773 $cgi -> hidden( -name => 'probSetKey', -value => $psvn ), "\n\t", 778 $cgi -> hidden( -name => 'probSetKey', -value => $psvn ), "\n\t",
779 $cgi->hidden( -name=>'show_old_answers', -value=>$show_old_answers), "\n\t",
774 $cgi -> hidden( -name => 'answer_form_submitted', -value => 1 ); # alerts the problem to show answers. 780 $cgi -> hidden( -name => 'answer_form_submitted', -value => 1 ); # alerts the problem to show answers.
775 781
776 #sessionKeyInputs() in scripts/HTMLglue.pl 782 #sessionKeyInputs() in scripts/HTMLglue.pl
777 print &sessionKeyInputs(\%inputs), 783 print &sessionKeyInputs(\%inputs),
778 "<BR>", 784 "<BR>",
1083 <TABLE><TR><TD ALIGN=CENTER VALIGN=MIDDLE> 1089 <TABLE><TR><TD ALIGN=CENTER VALIGN=MIDDLE>
1084 }; 1090 };
1085 1091
1086 unless($previousProbNum <= 0) { 1092 unless($previousProbNum <= 0) {
1087 $navigation_bar .= $cgi->startform(-method=>'POST', -action=>"$Global::processProblem_CGI"). "\n". 1093 $navigation_bar .= $cgi->startform(-method=>'POST', -action=>"$Global::processProblem_CGI"). "\n".
1088 $cgi->input({-type=>'IMAGE', -src=>"$Global::previousImgUrl", -alt=>'<--Previous Problem'}). "\n". 1094 $cgi->input({-type=>'IMAGE', -src=>"$Global::previousImgUrl", -alt=>'<--Previous Problem'}). "\n".
1089 $cgi->hidden(-name=>'probSetKey', -value=>"$inputs{probSetKey}"). "\n". 1095 $cgi->hidden(-name=>'probSetKey', -value=>"$inputs{probSetKey}"). "\n".
1090 $cgi->hidden(-name=>'probNum', -value=>"$previousProbNum", -override=>1). "\n". 1096 $cgi->hidden(-name=>'probNum', -value=>"$previousProbNum", -override=>1). "\n".
1091 $cgi->hidden(-name=>'Mode', -value=>"$inputs{Mode}"). "\n". 1097 $cgi->hidden(-name=>'Mode', -value=>"$inputs{Mode}"). "\n".
1098 $cgi->hidden(-name=>'show_old_answers', -value=>$show_old_answers). "\n".
1092 $cgi->hidden(-name=>'user', -value=>"$inputs{user}"). "\n". 1099 $cgi->hidden(-name=>'user', -value=>"$inputs{user}"). "\n".
1093 $cgi->hidden(-name=>'key', -value=>"$inputs{key}"). "\n". 1100 $cgi->hidden(-name=>'key', -value=>"$inputs{key}"). "\n".
1094 $cgi->hidden(-name=>'course', -value=>"$inputs{course}"). "\n". 1101 $cgi->hidden(-name=>'course', -value=>"$inputs{course}"). "\n".
1095 $cgi->endform(). "\n"; 1102 $cgi->endform(). "\n";
1096 1103
1097# $navigation_bar .= qq{ 1104# $navigation_bar .= qq{
1098# <A HREF="$Global::processProblem_CGI?probSetKey=$inputs{'probSetKey'}&probNum=$previousProbNum&Mode=$inputs{'Mode'}&course=$inputs{'course'}&user=$inputs{'user'}&key=$inputs{'key'}"> 1105# <A HREF="$Global::processProblem_CGI?probSetKey=$inputs{'probSetKey'}&probNum=$previousProbNum&Mode=$inputs{'Mode'}&course=$inputs{'course'}&user=$inputs{'user'}&key=$inputs{'key'}">
1099# <IMG SRC="$Global::previousImgUrl" ALT="&lt;--Previous Problem"></A> 1106# <IMG SRC="$Global::previousImgUrl" ALT="&lt;--Previous Problem"></A>
1100# }; 1107# };
1125 <TD ALIGN=CENTER VALIGN=MIDDLE> 1132 <TD ALIGN=CENTER VALIGN=MIDDLE>
1126 }; 1133 };
1127 1134
1128 unless($nextProbNum > $numberOfProblems) { 1135 unless($nextProbNum > $numberOfProblems) {
1129 1136
1130 $navigation_bar .= $cgi->startform(-method=>'POST', -action=>"$Global::processProblem_CGI"). "\n". 1137 $navigation_bar .= $cgi->startform(-method=>'POST', -action=>"$Global::processProblem_CGI"). "\n".
1131 $cgi->input({-type=>'IMAGE', -src=>"$Global::nextImgUrl", -alt=>'Next Problem-->'}). "\n". 1138 $cgi->input({-type=>'IMAGE', -src=>"$Global::nextImgUrl", -alt=>'Next Problem-->'}). "\n".
1132 $cgi->hidden(-name=>'probSetKey', -value=>"$inputs{probSetKey}"). "\n". 1139 $cgi->hidden(-name=>'probSetKey', -value=>"$inputs{probSetKey}"). "\n".
1133 $cgi->hidden(-name=>'probNum', -value=>"$nextProbNum", -override=>1). "\n". 1140 $cgi->hidden(-name=>'probNum', -value=>"$nextProbNum", -override=>1). "\n".
1134 $cgi->hidden(-name=>'Mode', -value=>"$inputs{Mode}"). "\n". 1141 $cgi->hidden(-name=>'Mode', -value=>"$inputs{Mode}"). "\n".
1142 $cgi->hidden(-name=>'show_old_answers', -value=>$show_old_answers). "\n".
1135 $cgi->hidden(-name=>'user', -value=>"$inputs{user}"). "\n". 1143 $cgi->hidden(-name=>'user', -value=>"$inputs{user}"). "\n".
1136 $cgi->hidden(-name=>'key', -value=>"$inputs{key}"). "\n". 1144 $cgi->hidden(-name=>'key', -value=>"$inputs{key}"). "\n".
1137 $cgi->hidden(-name=>'course', -value=>"$inputs{course}"). "\n". 1145 $cgi->hidden(-name=>'course', -value=>"$inputs{course}"). "\n".
1138 $cgi->endform(). "\n"; 1146 $cgi->endform(). "\n";
1139 1147
1140# $navigation_bar .= qq{ 1148# $navigation_bar .= qq{
1141# <A HREF="$Global::processProblem_CGI?probSetKey=$inputs{'probSetKey'}&probNum=$nextProbNum&Mode=$inputs{'Mode'}&course=$inputs{'course'}&user=$inputs{'user'}&key=$inputs{'key'}"> 1149# <A HREF="$Global::processProblem_CGI?probSetKey=$inputs{'probSetKey'}&probNum=$nextProbNum&Mode=$inputs{'Mode'}&course=$inputs{'course'}&user=$inputs{'user'}&key=$inputs{'key'}">
1142# <IMG SRC="$Global::nextImgUrl" ALT="Next Problem--&gt;"></A> 1150# <IMG SRC="$Global::nextImgUrl" ALT="Next Problem--&gt;"></A>
1143# }; 1151# };
1177 $navigation_bar .= $cgi->startform(-method=>'POST', -action=>"$Global::processProblem_CGI"). "\n". 1185 $navigation_bar .= $cgi->startform(-method=>'POST', -action=>"$Global::processProblem_CGI"). "\n".
1178 $cgi->input({-type=>'IMAGE', -src=>"$Global::currentImgUrl", -alt=>'Current Problem'}). "\n". 1186 $cgi->input({-type=>'IMAGE', -src=>"$Global::currentImgUrl", -alt=>'Current Problem'}). "\n".
1179 $cgi->hidden(-name=>'probSetKey', -value=>"$inputs{probSetKey}"). "\n". 1187 $cgi->hidden(-name=>'probSetKey', -value=>"$inputs{probSetKey}"). "\n".
1180 $cgi->hidden(-name=>'probNum', -value=>"$curentProbNum", -override=>1). "\n". 1188 $cgi->hidden(-name=>'probNum', -value=>"$curentProbNum", -override=>1). "\n".
1181 $cgi->hidden(-name=>'Mode', -value=>"$inputs{Mode}"). "\n". 1189 $cgi->hidden(-name=>'Mode', -value=>"$inputs{Mode}"). "\n".
1190 $cgi->hidden(-name=>'show_old_answers', -value=>$show_old_answers). "\n".
1182 $cgi->hidden(-name=>'user', -value=>"$inputs{user}"). "\n". 1191 $cgi->hidden(-name=>'user', -value=>"$inputs{user}"). "\n".
1183 $cgi->hidden(-name=>'key', -value=>"$inputs{key}"). "\n". 1192 $cgi->hidden(-name=>'key', -value=>"$inputs{key}"). "\n".
1184 $cgi->hidden(-name=>'course', -value=>"$inputs{course}"). "\n". 1193 $cgi->hidden(-name=>'course', -value=>"$inputs{course}"). "\n".
1185 $cgi->endform(). "\n"; 1194 $cgi->endform(). "\n";
1186 1195
1346 $s = ''; 1355 $s = '';
1347 if( $expected_answer_count > 1) {$s = 's'; } 1356 if( $expected_answer_count > 1) {$s = 's'; }
1348 print $cgi -> hidden(-name=>'probNum', -value=>$probNum), 1357 print $cgi -> hidden(-name=>'probNum', -value=>$probNum),
1349 $cgi -> hidden(-name=>'probSetKey', -value=>$psvn), 1358 $cgi -> hidden(-name=>'probSetKey', -value=>$psvn),
1350 $cgi -> hidden(-name=>'answer_form_submitted', -value=>1), # alerts the problem to show answers. 1359 $cgi -> hidden(-name=>'answer_form_submitted', -value=>1), # alerts the problem to show answers.
1351 $cgi -> hidden(-name=>'Mode', -value=>$mode); 1360 $cgi -> hidden(-name=>'Mode', -value=>$mode);
1352 1361 $cgi -> hidden(-name=>'show_old_answers', -value=>$show_old_answers);
1353 print &sessionKeyInputs(\%inputs), 1362 print &sessionKeyInputs(\%inputs),
1354 '<BR>', 1363 '<BR>',
1355 $cgi -> submit( -name => 'action', -value=>"Submit Answer$s" ),' ', 1364 $cgi -> submit( -name => 'action', -value=>"Submit Answer$s" ),' ',
1356 $cgi -> submit( -name => 'action', -value=>"Preview Again" ),"\n"; 1365 $cgi -> submit( -name => 'action', -value=>"Preview Again" ),"\n";
1357 1366

Legend:
Removed from v.20  
changed lines
  Added in v.21

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9