[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 36 Revision 37
67 67
68 68
69 69
70use vars qw ( $questionNumber $STRINGforOUTPUT $languageMode $ansCount $openDate $cgiURL 70use vars qw ( $questionNumber $STRINGforOUTPUT $languageMode $ansCount $openDate $cgiURL
71 $studentName $pinNumber $submittedAnswers $setNumber $answerDate $dueDate $studentLogin 71 $studentName $pinNumber $submittedAnswers $setNumber $answerDate $dueDate $studentLogin
72 $problemValue $safeCompartment $solutionExists $psvnNumber $fileName 72 $problemValue $safeCompartment $psvnNumber $fileName
73 $probNum $sectionName $sectionNumber $recitationName $recitationNumber $sessionKey 73 $probNum $sectionName $sectionNumber $recitationName $recitationNumber $sessionKey
74 $courseName $modules_to_evaluate $extra_packages_to_be_loaded 74 $courseName $modules_to_evaluate $extra_packages_to_be_loaded
75 ); 75 );
76 76
77eval { 77eval {
192 $answersRequestedQ= $inputs{'ShowAns'} if defined($inputs{'ShowAns'}); 192 $answersRequestedQ= $inputs{'ShowAns'} if defined($inputs{'ShowAns'});
193 193
194 my $solutionsRequestedQ= 0; 194 my $solutionsRequestedQ= 0;
195 $solutionsRequestedQ= $inputs{'ShowSol'} if defined($inputs{'ShowSol'}); 195 $solutionsRequestedQ= $inputs{'ShowSol'} if defined($inputs{'ShowSol'});
196 196
197 my $hintsRequestedQ= 0;
198 $hintsRequestedQ= $inputs{'ShowHint'} if defined($inputs{'ShowHint'});
199
197 my $doNotRecordAnsRequestedQ= 0; 200 my $doNotRecordAnsRequestedQ= 0;
198 $doNotRecordAnsRequestedQ= $inputs{'doNotRecordAns'} if defined($inputs{'doNotRecordAns'}); 201 $doNotRecordAnsRequestedQ= $inputs{'doNotRecordAns'} if defined($inputs{'doNotRecordAns'});
199 202
200 203
201# 204#
266 if($currentTime>$ddts) 269 if($currentTime>$ddts)
267 {$dueDateNote=" <EM>Note: it is after the due date.</EM>\n";} 270 {$dueDateNote=" <EM>Note: it is after the due date.</EM>\n";}
268 if($currentTime>$adts) 271 if($currentTime>$adts)
269 {$answerNote= " <EM>Answers available.</EM>\n";} 272 {$answerNote= " <EM>Answers available.</EM>\n";}
270 273
271
272# determine display defaults 274# determine display defaults
273 my ($displayCorrectAnswersQ,$displayShowAnswerLineQ); 275 my ($displayCorrectAnswersQ,$displayShowAnswerLineQ);
274 276
275 $displayShowAnswerLineQ = ($permissions == $Global::instructor_permissions) || ($currentTime > $adts) ; 277 $displayShowAnswerLineQ = ($permissions == $Global::instructor_permissions) || ($currentTime > $adts) ;
276 $displayCorrectAnswersQ = 1 if $answersRequestedQ && ($currentTime > $adts); 278 $displayCorrectAnswersQ = 1 if $answersRequestedQ && ($currentTime > $adts);
277 $displayCorrectAnswersQ = 1 if $answersRequestedQ && ($permissions == $Global::instructor_permissions); 279 $displayCorrectAnswersQ = 1 if $answersRequestedQ && ($permissions == $Global::instructor_permissions);
278 280
279 281
280 $main::displaySolutionsQ = 0; 282 my $displaySolutionsQ = 0;
281 $main::displaySolutionsQ = 1 if $solutionsRequestedQ && ($currentTime > $adts); 283 $displaySolutionsQ = 1 if $solutionsRequestedQ && ($currentTime > $adts);
282 $main::displaySolutionsQ = 1 if $solutionsRequestedQ && ($permissions == $Global::instructor_permissions); 284 $displaySolutionsQ = 1 if $solutionsRequestedQ && ($permissions == $Global::instructor_permissions);
283 285
286 my $displayHintsQ = 0;
287 $displayHintsQ = 1 if $hintsRequestedQ;
284 288
285#check if we need to save the updated version of the text 289#check if we need to save the updated version of the text
286my $problem_has_been_saved = ''; 290my $problem_has_been_saved = '';
287if ( defined($inputs{'action'}) && 291if ( defined($inputs{'action'}) &&
288 ( $inputs{'action'} eq 'Save updated version' ) && 292 ( $inputs{'action'} eq 'Save updated version' ) &&
427 431
428 # dereference some flags returned by createPGtext; 432 # dereference some flags returned by createPGtext;
429 if ( defined( $pt ->rh_flags ) ) { 433 if ( defined( $pt ->rh_flags ) ) {
430 $main::showPartialCorrectAnswers = $pt ->rh_flags->{'showPartialCorrectAnswers'}; 434 $main::showPartialCorrectAnswers = $pt ->rh_flags->{'showPartialCorrectAnswers'};
431 $main::recordSubmittedAnswers = $pt ->rh_flags->{'recordSubmittedAnswers'}; 435 $main::recordSubmittedAnswers = $pt ->rh_flags->{'recordSubmittedAnswers'};
432 $main::solutionExists = $pt ->rh_flags->{'solutionExists'};
433 } 436 }
434 437
435 # massage problem text if necessary. 438 # massage problem text if necessary.
436 if($mode eq "HTML" || $mode eq 'HTML_tth' || $pt ->rh_flags->{'error_flag'}) { 439 if($mode eq "HTML" || $mode eq 'HTML_tth' || $pt ->rh_flags->{'error_flag'}) {
437 @printlines=@{ $pt->ra_text() }; 440 @printlines=@{ $pt->ra_text() };
438 } 441 }
439 elsif ($mode eq 'Latex2HTML') { 442 elsif ($mode eq 'Latex2HTML') {
440 my %PG_flags = %{ $pt->rh_flags() }; 443 my %PG_flags = %{ $pt->rh_flags() };
441 $PG_flags{'refreshLatex2HTML'} = $inputs{'refreshLatex2HTML'}; 444 $PG_flags{'refreshLatex2HTML'} = $inputs{'refreshLatex2HTML'};
442 $PG_flags{'ShowHint'} = $inputs{'ShowHint'}; 445 $PG_flags{'refreshLatex2HTML'} = 1 if $displaySolutionsQ;
446 $PG_flags{'refreshLatex2HTML'} = 1 if $displayHintsQ;
443 @printlines = &createDisplayedProblem($setNumber,$probNum,$psvn,$pt->ra_text(),\%PG_flags ); 447 @printlines = &createDisplayedProblem($setNumber,$probNum,$psvn,$pt->ra_text(),\%PG_flags );
444 448
445 @printlines = &l2h_sticky_answers($envir{'inputs_ref'}, \@printlines, $pt->rh_flags() ); 449 @printlines = &l2h_sticky_answers($envir{'inputs_ref'}, \@printlines, $pt->rh_flags() );
446 450
447# @printlines = &l2h_update_keys($envir{'sessionKey'}, \@printlines); 451# @printlines = &l2h_update_keys($envir{'sessionKey'}, \@printlines);
724 -override => 1), "\n\t"; 728 -override => 1), "\n\t";
725 } else { 729 } else {
726 print $cgi -> hidden(-name=>'doNotRecordAns', 730 print $cgi -> hidden(-name=>'doNotRecordAns',
727 -value => 0,override => 1), "\n\t"; 731 -value => 0,override => 1), "\n\t";
728 } 732 }
733
734# Decide whether the showHint line is visible
735
736 if (
737 defined($pt ->rh_flags->{'hintExists'})
738 and ($pt ->rh_flags->{'hintExists'} ==1)
739 and ($numOfAttempts >= $pt ->rh_flags->{'showHintLimit'})
740 ) {
741 print $cgi -> checkbox(-name=>'ShowHint',
742 -value=>1,
743 -label=>"Show Hint",
744 -override => 1);
745 } else {
746 print $cgi -> hidden(-name=>'ShowHint', -value=>0, -override => 1), "\n\t";
747 }
748
749
750
729# Decide whether the showAnswer line is visible 751# Decide whether the showAnswer line is visible
730 752
731 if (defined($displayShowAnswerLineQ) and $displayShowAnswerLineQ) { 753 if (defined($displayShowAnswerLineQ) and $displayShowAnswerLineQ) {
732 print $cgi -> checkbox(-name=>'ShowAns', 754 print $cgi -> checkbox(-name=>'ShowAns',
733 -value=>1, 755 -value=>1,
734 -label=>"Show Correct Answer$s", 756 -label=>"Show Correct Answer$s",
735 -override => 1), "\n\t"; 757 -override => 1), "\n\t";
736 } else { 758 } else {
737 print $cgi -> hidden(-name=>'ShowAns', 759 print $cgi -> hidden(-name=>'ShowAns',
738 -value => 0,override => 1), "\n\t"; 760 -value => 0,-override => 1), "\n\t";
739 } 761 }
740 762
741 763
742 764
743# Decide whether the showSolution line is visible 765# Decide whether the showSolution line is visible
746 print $cgi -> checkbox(-name=>'ShowSol', 768 print $cgi -> checkbox(-name=>'ShowSol',
747 -value=>1, 769 -value=>1,
748 -label=>"Show Solution$s", 770 -label=>"Show Solution$s",
749 -override => 1); 771 -override => 1);
750 } else { 772 } else {
751 print $cgi -> hidden(-name=>'ShowSol', -value=>0); 773 print $cgi -> hidden(-name=>'ShowSol', -value=>0, -override => 1), "\n\t";
752 } 774 }
753 775
754 776
755## check to see if $numOfAttempts is approaching or at the limit 777## check to see if $numOfAttempts is approaching or at the limit
756## $maxNumOfIncorrectAttempts. If so, put note by 778## $maxNumOfIncorrectAttempts. If so, put note by
1493 $envir{'webworkDocsURL'} = $Global::webworkDocsURL; 1515 $envir{'webworkDocsURL'} = $Global::webworkDocsURL;
1494 1516
1495 1517
1496 $envir{'inputs_ref'} = \%inputs; 1518 $envir{'inputs_ref'} = \%inputs;
1497 $envir{'problemSeed'} = $seed; 1519 $envir{'problemSeed'} = $seed;
1520 $envir{'displaySolutionsQ'} = $displaySolutionsQ;
1521 $envir{'displayHintsQ'} = $displayHintsQ;
1498 1522
1499 # here is a way to pass environment variables defined in webworkCourse.ph 1523 # here is a way to pass environment variables defined in webworkCourse.ph
1500 my $k; 1524 my $k;
1501 foreach $k (keys %Global::PG_environment ) { 1525 foreach $k (keys %Global::PG_environment ) {
1502 $envir{$k} = $Global::PG_environment{$k}; 1526 $envir{$k} = $Global::PG_environment{$k};

Legend:
Removed from v.36  
changed lines
  Added in v.37

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9