[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 1499 Revision 1507
439 # store answers in DB for sticky answers 439 # store answers in DB for sticky answers
440 my %answersToStore; 440 my %answersToStore;
441 my %answerHash = %{ $pg->{answers} }; 441 my %answerHash = %{ $pg->{answers} };
442 $answersToStore{$_} = $answerHash{$_}->{original_student_ans} 442 $answersToStore{$_} = $answerHash{$_}->{original_student_ans}
443 foreach (keys %answerHash); 443 foreach (keys %answerHash);
444 # There may be some more answers to store -- one which are auxiliary entries to a primary answer. Evaluating
445 # matrices works in this way, only the first answer triggers an answer evaluator, the rest are just inputs
446 # however we need to store them. Fortunately they are still in the input form.
447 my @extra_answer_names = @{ $pg->{flags}->{KEPT_EXTRA_ANSWERS}};
448
449 $answersToStore{$_} = $r->param($_) foreach (@extra_answer_names);
450
451 # Now let's encode these answers to store them -- append the extra answers to the end of answer entry order
452 my @answer_order = (@{$pg->{flags}->{ANSWER_ENTRY_ORDER}}, @extra_answer_names);
444 my $answerString = encodeAnswers(%answersToStore, 453 my $answerString = encodeAnswers(%answersToStore,
445 @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }); 454 @answer_order);
446 455
447 # store last answer to database 456 # store last answer to database
448 $problem->last_answer($answerString); 457 $problem->last_answer($answerString);
449 $pureProblem->last_answer($answerString); 458 $pureProblem->last_answer($answerString);
450 $db->putUserProblem($pureProblem); 459 $db->putUserProblem($pureProblem);
531 } 540 }
532 541
533 # attempt summary 542 # attempt summary
534 #FIXME -- the following is a kludge: if showPartialCorrectAnswers is negative don't show anything. 543 #FIXME -- the following is a kludge: if showPartialCorrectAnswers is negative don't show anything.
535 # until after the due date 544 # until after the due date
545 # do I need to check $wills{howCorrectAnswers} to make preflight work??
536 if (($pg->{flags}->{showPartialCorrectAnswers}>= 0 and $submitAnswers) or $will{showCorrectAnswers}) { 546 if (($pg->{flags}->{showPartialCorrectAnswers}>= 0 and $submitAnswers) ) {
537 # print this if user submitted answers OR requested correct answers 547 # print this if user submitted answers OR requested correct answers
538 548
539 print $self->attemptResults($pg, $submitAnswers, 549 print $self->attemptResults($pg, 1,
540 $will{showCorrectAnswers}, 550 $will{showCorrectAnswers},
541 $pg->{flags}->{showPartialCorrectAnswers}, 1, 1); 551 $pg->{flags}->{showPartialCorrectAnswers}, 1, 1);
542 } elsif ($checkAnswers) { 552 } elsif ($checkAnswers) {
543 # print this if user previewed answers 553 # print this if user previewed answers
544 print "ANSWERS ONLY CHECKED -- ",CGI::br(),"ANSWERS NOT RECORDED", CGI::br(); 554 print "ANSWERS ONLY CHECKED -- ",CGI::br(),"ANSWERS NOT RECORDED", CGI::br();
545 print $self->attemptResults($pg, 1, 0, 1, 1, 1); 555 print $self->attemptResults($pg, 1, $will{showCorrectAnswers}, 1, 1, 1);
546 # show attempt answers 556 # show attempt answers
547 # don't show correct answers 557 # show correct answers if asked
548 # show attempt results (correctness) 558 # show attempt results (correctness)
549 # don't show attempt previews 559 # show attempt previews
550 } elsif ($previewAnswers) { 560 } elsif ($previewAnswers) {
551 # print this if user previewed answers 561 # print this if user previewed answers
552 print "PREVIEW ONLY -- NOT RECORDED",CGI::br(),$self->attemptResults($pg, 1, 0, 0, 0, 1); 562 print "PREVIEW ONLY -- NOT RECORDED",CGI::br(),$self->attemptResults($pg, 1, 0, 0, 0, 1);
553 # show attempt answers 563 # show attempt answers
554 # don't show correct answers 564 # don't show correct answers

Legend:
Removed from v.1499  
changed lines
  Added in v.1507

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9