| … | |
… | |
| 73 | my $submitAnswers = $r->param("submitAnswers"); |
73 | my $submitAnswers = $r->param("submitAnswers"); |
| 74 | my $checkAnswers = $r->param("checkAnswers"); |
74 | my $checkAnswers = $r->param("checkAnswers"); |
| 75 | my $previewAnswers = $r->param("previewAnswers"); |
75 | my $previewAnswers = $r->param("previewAnswers"); |
| 76 | |
76 | |
| 77 | # fields which may be defined when using Problem Editor |
77 | # fields which may be defined when using Problem Editor |
| 78 | my $override_seed = ($permissionLevel>=10) ? $r->param('seed') : undef; |
78 | my $override_seed = ($permissionLevel>=10) ? $r->param('problemSeed') : undef; |
| 79 | my $override_problem_source = ($permissionLevel>=10) ? $r->param('sourceFilePath') : undef; |
79 | my $override_problem_source = ($permissionLevel>=10) ? $r->param('sourceFilePath') : undef; |
| 80 | my $editMode = undef; |
80 | my $editMode = undef; |
| 81 | my $submit_button = $r->param('submit_button'); |
81 | my $submit_button = $r->param('submit_button'); |
| 82 | if ( defined($submit_button ) ) { |
82 | if ( defined($submit_button ) ) { |
| 83 | $editMode = "temporaryFile" if $submit_button eq 'Refresh'; |
83 | $editMode = "temporaryFile" if $submit_button eq 'Refresh'; |
| … | |
… | |
| 392 | # attempt summary |
392 | # attempt summary |
| 393 | if ($submitAnswers or $will{showCorrectAnswers}) { |
393 | if ($submitAnswers or $will{showCorrectAnswers}) { |
| 394 | # print this if user submitted answers OR requested correct answers |
394 | # print this if user submitted answers OR requested correct answers |
| 395 | print $self->attemptResults($pg, $submitAnswers, |
395 | print $self->attemptResults($pg, $submitAnswers, |
| 396 | $will{showCorrectAnswers}, |
396 | $will{showCorrectAnswers}, |
| 397 | $pg->{flags}->{showPartialCorrectAnswers}, 1, 0); |
397 | $pg->{flags}->{showPartialCorrectAnswers}, 1, 1); |
| 398 | } elsif ($checkAnswers) { |
398 | } elsif ($checkAnswers) { |
| 399 | # print this if user previewed answers |
399 | # print this if user previewed answers |
| 400 | print $self->attemptResults($pg, 1, 0, 1, 1, 0); |
400 | print $self->attemptResults($pg, 1, 0, 1, 1, 1); |
| 401 | # show attempt answers |
401 | # show attempt answers |
| 402 | # don't show correct answers |
402 | # don't show correct answers |
| 403 | # show attempt results (correctness) |
403 | # show attempt results (correctness) |
| 404 | # don't show attempt previews |
404 | # don't show attempt previews |
| 405 | } elsif ($previewAnswers) { |
405 | } elsif ($previewAnswers) { |
| … | |
… | |
| 467 | ? "Your recorded score is $lastScore." . CGI::br() |
467 | ? "Your recorded score is $lastScore." . CGI::br() |
| 468 | : "", |
468 | : "", |
| 469 | $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining." |
469 | $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining." |
| 470 | ); |
470 | ); |
| 471 | print CGI::end_div(); |
471 | print CGI::end_div(); |
| 472 | print CGI::hr(), CGI::start_div({class=>"viewOptions"}); |
472 | # print CGI::hr(), CGI::start_div({class=>"viewOptions"}); |
| 473 | print |
|
|
| 474 | $self->viewOptions(),CGI::end_div(), |
473 | # print $self->viewOptions(),CGI::end_div(), |
| 475 | CGI::endform(); |
474 | print CGI::endform(); |
| 476 | |
475 | |
| 477 | print CGI::start_div({class=>"problemFooter"}); |
476 | print CGI::start_div({class=>"problemFooter"}); |
| 478 | # feedback form |
477 | # feedback form |
| 479 | my $ce = $self->{ce}; |
478 | my $ce = $self->{ce}; |
| 480 | my $root = $ce->{webworkURLs}->{root}; |
479 | my $root = $ce->{webworkURLs}->{root}; |
| … | |
… | |
| 486 | my $cgi_url = $prof_url; |
485 | my $cgi_url = $prof_url; |
| 487 | $cgi_url=~ s|/[^/]*$||; # clip profLogin.pl |
486 | $cgi_url=~ s|/[^/]*$||; # clip profLogin.pl |
| 488 | my $authen_args = $self->url_authen_args(); |
487 | my $authen_args = $self->url_authen_args(); |
| 489 | my $showPastAnswersURL = "$cgi_url/showPastAnswers.pl"; |
488 | my $showPastAnswersURL = "$cgi_url/showPastAnswers.pl"; |
| 490 | |
489 | |
|
|
490 | |
|
|
491 | print CGI::end_div(); |
|
|
492 | print CGI::start_div(); |
|
|
493 | # print answer inspection button |
|
|
494 | if ($self->{permissionLevel} >0) { |
|
|
495 | |
|
|
496 | |
|
|
497 | print "\n", |
|
|
498 | CGI::start_form(-method=>"POST",-action=>$showPastAnswersURL,-target=>"information"),"\n", |
|
|
499 | $self->hidden_authen_fields,"\n", |
|
|
500 | CGI::hidden(-name => 'course', -value=>$courseName), "\n", |
|
|
501 | CGI::hidden(-name => 'probNum', -value=>$problem->problem_id), "\n", |
|
|
502 | CGI::hidden(-name => 'setNum', -value=>$problem->set_id), "\n", |
|
|
503 | CGI::hidden(-name => 'User', -value=>$problem->user_id), "\n", |
|
|
504 | CGI::p( {-align=>"left"}, |
|
|
505 | CGI::submit(-name => 'action', -value=>'Show Past Answers') |
|
|
506 | ), "\n", |
|
|
507 | CGI::endform(); |
|
|
508 | |
|
|
509 | |
|
|
510 | |
| 491 | #print feedback form |
511 | } #print feedback form |
|
|
512 | |
|
|
513 | |
| 492 | print |
514 | print |
| 493 | CGI::start_form(-method=>"POST", -action=>$feedbackURL),"\n", |
515 | CGI::start_form(-method=>"POST", -action=>$feedbackURL),"\n", |
| 494 | $self->hidden_authen_fields,"\n", |
516 | $self->hidden_authen_fields,"\n", |
| 495 | CGI::hidden("module", __PACKAGE__),"\n", |
517 | CGI::hidden("module", __PACKAGE__),"\n", |
| 496 | CGI::hidden("set", $set->set_id),"\n", |
518 | CGI::hidden("set", $set->set_id),"\n", |
| … | |
… | |
| 498 | CGI::hidden("displayMode", $self->{displayMode}),"\n", |
520 | CGI::hidden("displayMode", $self->{displayMode}),"\n", |
| 499 | CGI::hidden("showOldAnswers", $will{showOldAnswers}),"\n", |
521 | CGI::hidden("showOldAnswers", $will{showOldAnswers}),"\n", |
| 500 | CGI::hidden("showCorrectAnswers", $will{showCorrectAnswers}),"\n", |
522 | CGI::hidden("showCorrectAnswers", $will{showCorrectAnswers}),"\n", |
| 501 | CGI::hidden("showHints", $will{showHints}),"\n", |
523 | CGI::hidden("showHints", $will{showHints}),"\n", |
| 502 | CGI::hidden("showSolutions", $will{showSolutions}),"\n", |
524 | CGI::hidden("showSolutions", $will{showSolutions}),"\n", |
| 503 | CGI::p({-align=>"right"}, |
525 | CGI::p({-align=>"left"}, |
| 504 | CGI::submit(-name=>"feedbackForm", -label=>"Send Feedback") |
526 | CGI::submit(-name=>"feedbackForm", -label=>"Contact instructor") |
| 505 | ), |
527 | ), |
| 506 | CGI::endform(),"\n"; |
528 | CGI::endform(),"\n"; |
| 507 | # print answer inspection button |
529 | |
| 508 | if ($self->{permissionLevel} >0) { |
|
|
| 509 | |
|
|
| 510 | |
|
|
| 511 | print "\n", |
|
|
| 512 | CGI::start_form(-method=>"POST",-action=>$showPastAnswersURL,-target=>"information"),"\n", |
|
|
| 513 | $self->hidden_authen_fields,"\n", |
|
|
| 514 | CGI::hidden(-name => 'course', -value=>$courseName), "\n", |
|
|
| 515 | CGI::hidden(-name => 'probNum', -value=>$problem->problem_id), "\n", |
|
|
| 516 | CGI::hidden(-name => 'setNum', -value=>$problem->set_id), "\n", |
|
|
| 517 | CGI::hidden(-name => 'User', -value=>$problem->user_id), "\n", |
|
|
| 518 | CGI::submit(-name => 'action', -value=>'Show Past Answers'), "\n", |
|
|
| 519 | CGI::endform(); |
|
|
| 520 | |
|
|
| 521 | |
|
|
| 522 | |
|
|
| 523 | } |
|
|
| 524 | # FIXME print editor link |
530 | # FIXME print editor link |
| 525 | # print editor link if the user is an instructor AND the file is not in temporary editing mode |
531 | # print editor link if the user is an instructor AND the file is not in temporary editing mode |
| 526 | if ($self->{permissionLevel}>=10 and ( (not defined($self->{edit_mode})) or $self->{edit_mode} eq 'savedFile') ) { |
532 | if ($self->{permissionLevel}>=10 and ( (not defined($self->{edit_mode})) or $self->{edit_mode} eq 'savedFile') ) { |
| 527 | print CGI::a({-href=>"/webwork/$courseName/instructor/pgProblemEditor/".$set->set_id. |
533 | print CGI::a({-href=>"/webwork/$courseName/instructor/pgProblemEditor/".$set->set_id. |
| 528 | '/'.$problem->problem_id.'?'.$self->url_authen_args},'Edit this problem'); |
534 | '/'.$problem->problem_id.'?'.$self->url_authen_args},'Edit this problem'); |
| 529 | } |
535 | } |
|
|
536 | |
| 530 | print CGI::end_div(); |
537 | print CGI::end_div(); |
| 531 | |
538 | |
| 532 | # end answer inspection button |
539 | # end answer inspection button |
| 533 | # warning output |
540 | # warning output |
| 534 | if ($pg->{warnings} ne "") { |
541 | if ($pg->{warnings} ne "") { |
| 535 | print CGI::hr(), $self->warningOutput($pg->{warnings}); |
542 | print CGI::hr(), $self->warningOutput($pg->{warnings}); |
| … | |
… | |
| 618 | my %can = %{ $self->{can} }; |
625 | my %can = %{ $self->{can} }; |
| 619 | my %will = %{ $self->{will} }; |
626 | my %will = %{ $self->{will} }; |
| 620 | |
627 | |
| 621 | my $optionLine; |
628 | my $optionLine; |
| 622 | $can{showOldAnswers} and $optionLine .= join "", |
629 | $can{showOldAnswers} and $optionLine .= join "", |
| 623 | "Show: ", |
630 | "Show: ".CGI::br(), |
| 624 | CGI::checkbox( |
631 | CGI::checkbox( |
| 625 | -name => "showOldAnswers", |
632 | -name => "showOldAnswers", |
| 626 | -checked => $will{showOldAnswers}, |
633 | -checked => $will{showOldAnswers}, |
| 627 | -label => "Saved answers", |
634 | -label => "Saved answers", |
| 628 | ), " "; |
635 | ), " ".CGI::br(); |
| 629 | $can{showCorrectAnswers} and $optionLine .= join "", |
636 | $can{showCorrectAnswers} and $optionLine .= join "", |
| 630 | CGI::checkbox( |
637 | CGI::checkbox( |
| 631 | -name => "showCorrectAnswers", |
638 | -name => "showCorrectAnswers", |
| 632 | -checked => $will{showCorrectAnswers}, |
639 | -checked => $will{showCorrectAnswers}, |
| 633 | -label => "Correct answers", |
640 | -label => "Correct answers", |
| 634 | ), " "; |
641 | ), " ".CGI::br(); |
| 635 | $can{showHints} and $optionLine .= join "", |
642 | $can{showHints} and $optionLine .= join "", |
| 636 | CGI::checkbox( |
643 | CGI::checkbox( |
| 637 | -name => "showHints", |
644 | -name => "showHints", |
| 638 | -checked => $will{showHints}, |
645 | -checked => $will{showHints}, |
| 639 | -label => "Hints", |
646 | -label => "Hints", |
| 640 | ), " "; |
647 | ), " ".CGI::br(); |
| 641 | $can{showSolutions} and $optionLine .= join "", |
648 | $can{showSolutions} and $optionLine .= join "", |
| 642 | CGI::checkbox( |
649 | CGI::checkbox( |
| 643 | -name => "showSolutions", |
650 | -name => "showSolutions", |
| 644 | -checked => $will{showSolutions}, |
651 | -checked => $will{showSolutions}, |
| 645 | -label => "Solutions", |
652 | -label => "Solutions", |
| 646 | ), " "; |
653 | ), " ".CGI::br(); |
| 647 | $optionLine and $optionLine .= join "", CGI::br(); |
654 | $optionLine and $optionLine .= join "", CGI::br(); |
| 648 | |
655 | |
| 649 | return CGI::div({-style=>"border: thin groove; padding: 1ex; margin: 2ex"}, |
656 | return CGI::div({-style=>"border: thin groove; padding: 1ex; margin: 2ex align: left"}, |
| 650 | "View equations as: ", |
657 | "View equations as: ".CGI::br(), |
| 651 | CGI::radio_group( |
658 | CGI::radio_group( |
| 652 | -name => "displayMode", |
659 | -name => "displayMode", |
| 653 | -values => ['plainText', 'formattedText', 'images'], |
660 | -values => ['plainText', 'formattedText', 'images'], |
| 654 | -default => $displayMode, |
661 | -default => $displayMode, |
|
|
662 | -linebreak=>'true', |
| 655 | -labels => { |
663 | -labels => { |
| 656 | plainText => "plain text", |
664 | plainText => "plain", |
| 657 | formattedText => "formatted text", |
665 | formattedText => "formatted", |
| 658 | images => "images", |
666 | images => "images", |
| 659 | } |
667 | } |
| 660 | ), CGI::br(), |
668 | ), CGI::br(),CGI::hr(), |
| 661 | $optionLine, |
669 | $optionLine, |
| 662 | CGI::submit(-name=>"redisplay", -label=>"Redisplay Problem"), |
670 | CGI::submit(-name=>"redisplay", -label=>"Redisplay"), |
| 663 | ); |
671 | ); |
| 664 | } |
672 | } |
| 665 | |
673 | |
| 666 | sub previewAnswer($$) { |
674 | sub previewAnswer($$) { |
| 667 | my ($self, $answerResult) = @_; |
675 | my ($self, $answerResult) = @_; |
| … | |
… | |
| 719 | } else { |
727 | } else { |
| 720 | return "<b>[math2img failed]</b>"; |
728 | return "<b>[math2img failed]</b>"; |
| 721 | } |
729 | } |
| 722 | } |
730 | } |
| 723 | } |
731 | } |
|
|
732 | |
|
|
733 | sub options { |
|
|
734 | my $self=shift; |
|
|
735 | my $out; |
|
|
736 | $out .=join("", |
|
|
737 | CGI::startform("POST", $self->{r}->uri), |
|
|
738 | $self->hidden_authen_fields, |
|
|
739 | CGI::hr(), |
|
|
740 | CGI::start_div({class=>"viewOptions"}), |
|
|
741 | $self->viewOptions(),CGI::end_div(), |
|
|
742 | ); |
|
|
743 | return $out; |
|
|
744 | |
|
|
745 | } |
| 724 | ##### logging subroutine #### |
746 | ##### logging subroutine #### |
| 725 | |
747 | |
| 726 | |
748 | |
| 727 | |
749 | |
| 728 | ##### permission queries ##### |
750 | ##### permission queries ##### |