[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 1128 Revision 1131
236 $self->{will} = \%will; 236 $self->{will} = \%will;
237 237
238 $self->{pg} = $pg; 238 $self->{pg} = $pg;
239} 239}
240 240
241sub if_warnings($$) { 241#sub if_warnings($$) {
242 my ($self, $arg) = @_; 242# my ($self, $arg) = @_;
243 return 0 unless $self->{isOpen}; 243# return 0 unless $self->{isOpen};
244 return $self->{pg}->{warnings} ne ""; 244# return $self->{pg}->{warnings} ne "";
245} 245#}
246 246
247sub if_errors($$) { 247sub if_errors($$) {
248 my ($self, $arg) = @_; 248 my ($self, $arg) = @_;
249 return 0 unless $self->{isOpen}; 249 return 0 unless $self->{isOpen};
250 return $self->{pg}->{flags}->{error_flag}; 250 return $self->{pg}->{flags}->{error_flag};
252 252
253sub head { 253sub head {
254 my $self = shift; 254 my $self = shift;
255 return "" unless $self->{isOpen}; 255 return "" unless $self->{isOpen};
256 return $self->{pg}->{head_text} if $self->{pg}->{head_text}; 256 return $self->{pg}->{head_text} if $self->{pg}->{head_text};
257}
258
259sub options {
260 my $self = shift;
261 return join("",
262 CGI::start_form("POST", $self->{r}->uri),
263 $self->hidden_authen_fields,
264 CGI::hr(),
265 CGI::start_div({class=>"viewOptions"}),
266 $self->viewOptions(),
267 CGI::end_div(),
268 CGI::end_form()
269 );
257} 270}
258 271
259sub path { 272sub path {
260 my $self = shift; 273 my $self = shift;
261 my $args = $_[-1]; 274 my $args = $_[-1];
450 463
451 } 464 }
452 # end logging student answers 465 # end logging student answers
453 466
454 ##### output ##### 467 ##### output #####
468
455 print CGI::start_div({class=>"problemHeader"}); 469 print CGI::start_div({class=>"problemHeader"});
470
456 # attempt summary 471 # attempt summary
457 if ($submitAnswers or $will{showCorrectAnswers}) { 472 if ($submitAnswers or $will{showCorrectAnswers}) {
458 # print this if user submitted answers OR requested correct answers 473 # print this if user submitted answers OR requested correct answers
459 print $self->attemptResults($pg, $submitAnswers, 474 print $self->attemptResults($pg, $submitAnswers,
460 $will{showCorrectAnswers}, 475 $will{showCorrectAnswers},
476 } 491 }
477 492
478 print CGI::end_div(); 493 print CGI::end_div();
479 494
480 print CGI::start_div({class=>"problem"}); 495 print CGI::start_div({class=>"problem"});
481 #print CGI::hr(); 496
482 # main form 497 # main form
483 print 498 print
484 CGI::startform("POST", $r->uri), 499 CGI::startform("POST", $r->uri),
485 $self->hidden_authen_fields, 500 $self->hidden_authen_fields,
486 CGI::p($pg->{body_text}), 501 CGI::p($pg->{body_text}),
498 -label=>"Preview Answers"), 513 -label=>"Preview Answers"),
499 ); 514 );
500 print CGI::end_div(); 515 print CGI::end_div();
501 516
502 print CGI::start_div({class=>"scoreSummary"}); 517 print CGI::start_div({class=>"scoreSummary"});
518
503 # score summary 519 # score summary
504 my $attempts = $problem->num_correct + $problem->num_incorrect; 520 my $attempts = $problem->num_correct + $problem->num_incorrect;
505 my $attemptsNoun = $attempts != 1 ? "times" : "time"; 521 my $attemptsNoun = $attempts != 1 ? "times" : "time";
506 my $lastScore = sprintf("%.0f%%", $problem->status * 100); # Round to whole number 522 my $lastScore = sprintf("%.0f%%", $problem->status * 100); # Round to whole number
507 my ($attemptsLeft, $attemptsLeftNoun); 523 my ($attemptsLeft, $attemptsLeftNoun);
518 my $setClosedMessage; 534 my $setClosedMessage;
519 if (time < $set->open_date or time > $set->due_date) { 535 if (time < $set->open_date or time > $set->due_date) {
520 $setClosed = 1; 536 $setClosed = 1;
521 $setClosedMessage = "This problem set is closed."; 537 $setClosedMessage = "This problem set is closed.";
522 if ($permissionLevel > 0) { 538 if ($permissionLevel > 0) {
523 $setClosedMessage .= " Since you are a privileged user, additional attempts will be recorded."; 539 $setClosedMessage .= " However, since you are a privileged user, additional attempts will be recorded.";
524 } else { 540 } else {
525 $setClosedMessage .= " Additional attempts will not be recorded."; 541 $setClosedMessage .= " Additional attempts will not be recorded.";
526 } 542 }
527 } 543 }
528 print CGI::p( 544 print CGI::p(
531 ? "Your recorded score is $lastScore." . CGI::br() 547 ? "Your recorded score is $lastScore." . CGI::br()
532 : "", 548 : "",
533 $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining." 549 $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining."
534 ); 550 );
535 print CGI::end_div(); 551 print CGI::end_div();
536# print CGI::hr(), CGI::start_div({class=>"viewOptions"}); 552
537# print $self->viewOptions(),CGI::end_div(),
538# save state for viewOptions 553 # save state for viewOptions
539 print CGI::hidden(-name => "showOldAnswers", 554 print CGI::hidden(
555 -name => "showOldAnswers",
540 -value => $will{showOldAnswers}, 556 -value => $will{showOldAnswers}
541 ), 557 ),
558 CGI::hidden(
542 CGI::hidden(-name => "showCorrectAnswers", 559 -name => "showCorrectAnswers",
543 -value => $will{showCorrectAnswers}, 560 -value => $will{showCorrectAnswers}
544 ), 561 ),
545 CGI::hidden(-name => "showHints", 562 CGI::hidden(
563 -name => "showHints",
546 -value => $will{showHints}, 564 -value => $will{showHints}),
547 ), 565 CGI::hidden(
548 CGI::hidden(-name => "showSolutions", 566 -name => "showSolutions",
549 -value => $will{showSolutions}, 567 -value => $will{showSolutions},
550 ), 568 ),
569 CGI::hidden(
551 CGI::hidden(-name => "displayMode", 570 -name => "displayMode",
552 -value => $self->{displayMode} 571 -value => $self->{displayMode}
553 ); 572 );
573
574 # end of main form
554 print CGI::endform(); 575 print CGI::endform();
555 576
556 print CGI::start_div({class=>"problemFooter"}); 577 # stuff we need below (pull these out at the beginning?)
557 # feedback form
558 my $ce = $self->{ce}; 578 my $ce = $self->{ce};
559 my $root = $ce->{webworkURLs}->{root}; 579 my $root = $ce->{webworkURLs}->{root};
560 my $courseName = $ce->{courseName}; 580 my $courseName = $ce->{courseName};
561 my $feedbackURL = "$root/$courseName/feedback/"; 581
582 print CGI::start_div({class=>"problemFooter"});
562 583
563 # arguments for answer inspection button 584 # arguments for answer inspection button
564 my $prof_url = $ce->{webworkURLs}->{oldProf}; 585 my $prof_url = $ce->{webworkURLs}->{oldProf};
565 my $cgi_url = $prof_url; 586 my $cgi_url = $prof_url;
566 $cgi_url=~ s|/[^/]*$||; # clip profLogin.pl 587 $cgi_url=~ s|/[^/]*$||; # clip profLogin.pl
567 my $authen_args = $self->url_authen_args(); 588 my $authen_args = $self->url_authen_args();
568 my $showPastAnswersURL = "$cgi_url/showPastAnswers.pl"; 589 my $showPastAnswersURL = "$cgi_url/showPastAnswers.pl";
569 590
570
571 print CGI::end_div();
572 print CGI::start_div();
573 # print answer inspection button 591 # print answer inspection button
574 if ($self->{permissionLevel} >0) { 592 if ($self->{permissionLevel} > 0) {
575
576
577 print "\n", 593 print "\n",
578 CGI::start_form(-method=>"POST",-action=>$showPastAnswersURL,-target=>"information"),"\n", 594 CGI::start_form(-method=>"POST",-action=>$showPastAnswersURL,-target=>"information"),"\n",
579 $self->hidden_authen_fields,"\n", 595 $self->hidden_authen_fields,"\n",
580 CGI::hidden(-name => 'course', -value=>$courseName), "\n", 596 CGI::hidden(-name => 'course', -value=>$courseName), "\n",
581 CGI::hidden(-name => 'probNum', -value=>$problem->problem_id), "\n", 597 CGI::hidden(-name => 'probNum', -value=>$problem->problem_id), "\n",
582 CGI::hidden(-name => 'setNum', -value=>$problem->set_id), "\n", 598 CGI::hidden(-name => 'setNum', -value=>$problem->set_id), "\n",
583 CGI::hidden(-name => 'User', -value=>$problem->user_id), "\n", 599 CGI::hidden(-name => 'User', -value=>$problem->user_id), "\n",
584 CGI::p( {-align=>"left"}, 600 CGI::p( {-align=>"left"},
585 CGI::submit(-name => 'action', -value=>'Show Past Answers') 601 CGI::submit(-name => 'action', -value=>'Show Past Answers')
586 ), "\n", 602 ), "\n",
587 CGI::endform(); 603 CGI::endform();
604 }
588 605
606 #print CGI::end_div();
607 #
608 #print CGI::start_div();
589 609
610 # arguments for feedback form
611 my $feedbackURL = "$root/$courseName/feedback/";
590 612
591 } #print feedback form 613 #print feedback form
592
593
594 print 614 print
595 CGI::start_form(-method=>"POST", -action=>$feedbackURL),"\n", 615 CGI::start_form(-method=>"POST", -action=>$feedbackURL),"\n",
596 $self->hidden_authen_fields,"\n", 616 $self->hidden_authen_fields,"\n",
597 CGI::hidden("module", __PACKAGE__),"\n", 617 CGI::hidden("module", __PACKAGE__),"\n",
598 CGI::hidden("set", $set->set_id),"\n", 618 CGI::hidden("set", $set->set_id),"\n",
612 if ($self->{permissionLevel}>=10 and ( (not defined($self->{edit_mode})) or $self->{edit_mode} eq 'savedFile') ) { 632 if ($self->{permissionLevel}>=10 and ( (not defined($self->{edit_mode})) or $self->{edit_mode} eq 'savedFile') ) {
613 print CGI::a({-href=>$ce->{webworkURLs}->{root}."/$courseName/instructor/pgProblemEditor/".$set->set_id. 633 print CGI::a({-href=>$ce->{webworkURLs}->{root}."/$courseName/instructor/pgProblemEditor/".$set->set_id.
614 '/'.$problem->problem_id.'?'.$self->url_authen_args},'Edit this problem'); 634 '/'.$problem->problem_id.'?'.$self->url_authen_args},'Edit this problem');
615 } 635 }
616 636
617 print CGI::end_div(); 637 print CGI::end_div();
618 638
619 # end answer inspection button
620 # warning output 639 # warning output
621 if ($pg->{warnings} ne "") { 640 #if ($pg->{warnings} ne "") {
622 print CGI::hr(), $self->warningOutput($pg->{warnings}); 641 # print CGI::hr(), $self->warningOutput($pg->{warnings});
623 } 642 #}
624 643
625 # debugging stuff 644 # debugging stuff
626 if (0) { 645 if (0) {
627 print 646 print
628 CGI::hr(), 647 CGI::hr(),
811 return "<b>[math2img failed]</b>"; 830 return "<b>[math2img failed]</b>";
812 } 831 }
813 } 832 }
814} 833}
815 834
816sub options {
817 my $self=shift;
818 my $out;
819 $out .=join("",
820 CGI::start_form("POST", $self->{r}->uri),
821 $self->hidden_authen_fields,
822 CGI::hr(),
823 CGI::start_div({class=>"viewOptions"}),
824 $self->viewOptions(),CGI::end_div(),
825 CGI::end_form()
826 );
827return $out;
828
829}
830##### logging subroutine #### 835##### logging subroutine ####
831 836
832 837
833 838
834##### permission queries ##### 839##### permission queries #####

Legend:
Removed from v.1128  
changed lines
  Added in v.1131

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9