[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 683 Revision 685
101 101
102 # final values for options 102 # final values for options
103 my %will; 103 my %will;
104 foreach (keys %must) { 104 foreach (keys %must) {
105 $will{$_} = $can{$_} && ($want{$_} || $must{$_}); 105 $will{$_} = $can{$_} && ($want{$_} || $must{$_});
106 #warn "$_: can? $can{$_} want? $want{$_} must? $must{$_} will? $will{$_}\n";
107 } 106 }
108 107
109 ##### sticky answers ##### 108 ##### sticky answers #####
110 109
111 if (not $submitAnswers and $will{showOldAnswers}) { 110 if (not $submitAnswers and $will{showOldAnswers}) {
127 { # translation options 126 { # translation options
128 displayMode => $displayMode, 127 displayMode => $displayMode,
129 showHints => $will{showHints}, 128 showHints => $will{showHints},
130 showSolutions => $will{showSolutions}, 129 showSolutions => $will{showSolutions},
131 refreshMath2img => $will{showHints} || $will{showSolutions}, 130 refreshMath2img => $will{showHints} || $will{showSolutions},
132 # try leaving processAnswers on all the time? 131 processAnswers => 1,
133 processAnswers => 1, #$submitAnswers ? 1 : 0,
134 }, 132 },
135 ); 133 );
134
135 ##### fix hint/solution options #####
136
137 $can{showHints} &&= $pg->{flags}->{hintExists};
138 $can{showSolutions} &&= $pg->{flags}->{solutionExists};
136 139
137 ##### store fields ##### 140 ##### store fields #####
138 141
139 $self->{cldb} = $cldb; 142 $self->{cldb} = $cldb;
140 $self->{wwdb} = $wwdb; 143 $self->{wwdb} = $wwdb;
393 if ($pg->{warnings} ne "") { 396 if ($pg->{warnings} ne "") {
394 print CGI::hr(), warningOutput($pg->{warnings}); 397 print CGI::hr(), warningOutput($pg->{warnings});
395 } 398 }
396 399
397 # debugging stuff 400 # debugging stuff
398 #print 401 print
399 # CGI::hr(), 402 CGI::hr(),
400 # CGI::h2("debugging information"), 403 CGI::h2("debugging information"),
401 # CGI::h3("form fields"), 404 CGI::h3("form fields"),
402 # ref2string($self->{formFields}), 405 ref2string($self->{formFields}),
403 # CGI::h3("user object"), 406 CGI::h3("user object"),
404 # ref2string($self->{user}), 407 ref2string($self->{user}),
405 # CGI::h3("set object"), 408 CGI::h3("set object"),
406 # ref2string($set), 409 ref2string($set),
407 # CGI::h3("problem object"), 410 CGI::h3("problem object"),
408 # ref2string($problem), 411 ref2string($problem),
409 # CGI::h3("PG object"), 412 CGI::h3("PG object"),
410 # ref2string($pg, {'WeBWorK::PG::Translator' => 1}); 413 ref2string($pg, {'WeBWorK::PG::Translator' => 1});
411 414
412 return ""; 415 return "";
413} 416}
414 417
415##### output utilities ##### 418##### output utilities #####
454 my $showAttemptResults = $showAttemptAnswers && shift; 457 my $showAttemptResults = $showAttemptAnswers && shift;
455 my $showAttemptPreview = shift || 0; 458 my $showAttemptPreview = shift || 0;
456 my $problemResult = $pg->{result}; # the overall result of the problem 459 my $problemResult = $pg->{result}; # the overall result of the problem
457 my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; 460 my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} };
458 461
462 my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames;
463
459 my $header = CGI::th("answer"); 464 my $header = CGI::th("part");
460 $header .= $showAttemptAnswers ? CGI::th("attempt") : ""; 465 $header .= $showAttemptAnswers ? CGI::th("entered") : "";
461 $header .= $showAttemptPreview ? CGI::th("preview") : ""; 466 $header .= $showAttemptPreview ? CGI::th("preview") : "";
462 $header .= $showCorrectAnswers ? CGI::th("correct") : ""; 467 $header .= $showCorrectAnswers ? CGI::th("correct") : "";
463 $header .= $showAttemptResults ? CGI::th("result") : ""; 468 $header .= $showAttemptResults ? CGI::th("result") : "";
464 $header .= $showAttemptAnswers ? CGI::th("messages") : ""; 469 $header .= $showMessages ? CGI::th("messages") : "";
465 my @tableRows = ( $header ); 470 my @tableRows = ( $header );
466 my $numCorrect; 471 my $numCorrect;
467 foreach my $name (@answerNames) { 472 foreach my $name (@answerNames) {
468 my $answerResult = $pg->{answers}->{$name}; 473 my $answerResult = $pg->{answers}->{$name};
469 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans 474 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans
470 my $preview = ($showAttemptPreview 475 my $preview = ($showAttemptPreview
471 ? $self->previewAnswer($answerResult) 476 ? $self->previewAnswer($answerResult)
472 : ""); 477 : "");
473 my $correctAnswer = $answerResult->{correct_ans}; 478 my $correctAnswer = $answerResult->{correct_ans};
474 my $answerScore = $answerResult->{score}; 479 my $answerScore = $answerResult->{score};
475 my $answerMessage = $showAttemptAnswers ? $answerResult->{ans_message} : ""; 480 my $answerMessage = $showMessages ? $answerResult->{ans_message} : "";
476 481
477 $numCorrect += $answerScore > 0; 482 $numCorrect += $answerScore > 0;
478 my $resultString = $answerScore ? "correct" : "incorrect"; 483 my $resultString = $answerScore ? "correct" : "incorrect";
479 484
480 # get rid of the goofy prefix on the answer names (supposedly, the format 485 # get rid of the goofy prefix on the answer names (supposedly, the format

Legend:
Removed from v.683  
changed lines
  Added in v.685

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9