| … | |
… | |
| 750 | |
750 | |
| 751 | return "" if ( $self->{invalidSet} ); |
751 | return "" if ( $self->{invalidSet} ); |
| 752 | return $self->{pg}->{head_text} if $self->{pg}->{head_text}; |
752 | return $self->{pg}->{head_text} if $self->{pg}->{head_text}; |
| 753 | } |
753 | } |
| 754 | |
754 | |
|
|
755 | sub post_header_text { |
|
|
756 | my ($self) = @_; |
|
|
757 | return "" if ( $self->{invalidSet} ); |
|
|
758 | return $self->{pg}->{post_header_text} if $self->{pg}->{post_header_text}; |
|
|
759 | } |
|
|
760 | |
| 755 | sub options { |
761 | sub options { |
| 756 | my ($self) = @_; |
762 | my ($self) = @_; |
| 757 | #warn "doing options in Problem"; |
763 | #warn "doing options in Problem"; |
| 758 | |
764 | |
| 759 | # don't show options if we don't have anything to show |
765 | # don't show options if we don't have anything to show |
| … | |
… | |
| 879 | return $r->maketext("[_1]: Problem [_2]",$setID, $problemID); |
885 | return $r->maketext("[_1]: Problem [_2]",$setID, $problemID); |
| 880 | } |
886 | } |
| 881 | |
887 | |
| 882 | |
888 | |
| 883 | # now altered to outsource most output operations to the template, main functions now are simply error checking and answer processing - ghe3 |
889 | # now altered to outsource most output operations to the template, main functions now are simply error checking and answer processing - ghe3 |
| 884 | sub body { |
890 | # sub body { |
| 885 | my $self = shift; |
891 | # my $self = shift; |
| 886 | my $set = $self->{set}; |
892 | # my $set = $self->{set}; |
| 887 | my $problem = $self->{problem}; |
893 | # my $problem = $self->{problem}; |
| 888 | my $pg = $self->{pg}; |
894 | # my $pg = $self->{pg}; |
| 889 | |
895 | # print "this is data from the old body function"; |
| 890 | my $valid = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::check_invalid($self); |
896 | # my $valid = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::check_invalid($self); |
| 891 | unless($valid eq "valid"){ |
897 | # unless($valid eq "valid"){ |
| 892 | return $valid; |
898 | # return $valid; |
| 893 | } |
899 | # } |
| 894 | |
900 | # |
| 895 | # my $editorLink = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::process_editorLink($self); |
901 | # # my $editorLink = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::process_editorLink($self); |
| 896 | # if($editorLink eq "permission_error"){ |
902 | # # if($editorLink eq "permission_error"){ |
| 897 | # return ""; |
903 | # # return ""; |
| 898 | # } |
904 | # # } |
| 899 | |
905 | # |
| 900 | ##### answer processing ##### |
906 | # ##### answer processing ##### |
| 901 | debug("begin answer processing"); |
907 | # debug("begin answer processing"); |
| 902 | # if answers were submitted: |
908 | # # if answers were submitted: |
| 903 | my $scoreRecordedMessage = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::process_and_log_answer($self); |
909 | # my $scoreRecordedMessage = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::process_and_log_answer($self); |
| 904 | debug("end answer processing"); |
910 | # debug("end answer processing"); |
| 905 | |
911 | # |
| 906 | ##### javaScripts ############# |
912 | # ##### javaScripts ############# |
| 907 | # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_JS($self); |
913 | # # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_JS($self); |
| 908 | |
914 | # |
| 909 | ##### output ##### |
915 | # ##### output ##### |
| 910 | # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_summary($self); |
916 | # # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_summary($self); |
| 911 | |
917 | # |
| 912 | ########################### |
918 | # ########################### |
| 913 | # print style sheet for correct and incorrect answers |
919 | # # print style sheet for correct and incorrect answers |
| 914 | ########################### |
920 | # ########################### |
| 915 | |
921 | # |
| 916 | # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_CSS($self); |
922 | # # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_CSS($self); |
| 917 | |
923 | # |
| 918 | ########################### |
924 | # ########################### |
| 919 | # main form |
925 | # # main form |
| 920 | ########################### |
926 | # ########################### |
| 921 | |
927 | # |
| 922 | # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_main_form($self,$editorLink); |
928 | # # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_main_form($self,$editorLink); |
| 923 | |
929 | # |
| 924 | # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_footer($self); |
930 | # # WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::output_footer($self); |
| 925 | |
931 | # print "end of old body function"; |
| 926 | # debugging stuff |
932 | # # debugging stuff |
| 927 | if (0) { |
933 | # if (0) { |
| 928 | print |
934 | # print |
| 929 | CGI::hr(), |
935 | # CGI::hr(), |
| 930 | CGI::h2("debugging information"), |
936 | # CGI::h2("debugging information"), |
| 931 | CGI::h3("form fields"), |
937 | # CGI::h3("form fields"), |
| 932 | ref2string($self->{formFields}), |
938 | # ref2string($self->{formFields}), |
| 933 | CGI::h3("user object"), |
939 | # CGI::h3("user object"), |
| 934 | ref2string($self->{user}), |
940 | # ref2string($self->{user}), |
| 935 | CGI::h3("set object"), |
941 | # CGI::h3("set object"), |
| 936 | ref2string($set), |
942 | # ref2string($set), |
| 937 | CGI::h3("problem object"), |
943 | # CGI::h3("problem object"), |
| 938 | ref2string($problem), |
944 | # ref2string($problem), |
| 939 | CGI::h3("PG object"), |
945 | # CGI::h3("PG object"), |
| 940 | ref2string($pg, {'WeBWorK::PG::Translator' => 1}); |
946 | # ref2string($pg, {'WeBWorK::PG::Translator' => 1}); |
| 941 | } |
947 | # } |
| 942 | debug("leaving body of Problem.pm"); |
948 | # debug("leaving body of Problem.pm"); |
| 943 | return ""; |
949 | # return ""; |
| 944 | } |
950 | # } |
| 945 | |
951 | |
| 946 | # output_form_start subroutine |
952 | # output_form_start subroutine |
| 947 | |
953 | |
| 948 | # prints out the beginning of the main form, and the necessary hidden authentication fields |
954 | # prints out the beginning of the main form, and the necessary hidden authentication fields |
| 949 | |
955 | |
| … | |
… | |
| 953 | print CGI::start_form(-method=>"POST", -action=> $r->uri,-name=>"problemMainForm", onsubmit=>"submitAction()"); |
959 | print CGI::start_form(-method=>"POST", -action=> $r->uri,-name=>"problemMainForm", onsubmit=>"submitAction()"); |
| 954 | print $self->hidden_authen_fields; |
960 | print $self->hidden_authen_fields; |
| 955 | return ""; |
961 | return ""; |
| 956 | } |
962 | } |
| 957 | |
963 | |
|
|
964 | |
| 958 | # output_problem_body subroutine |
965 | # output_problem_body subroutine |
| 959 | |
966 | |
| 960 | # prints out the body of the current problem |
967 | # prints out the body of the current problem |
| 961 | |
968 | |
| 962 | sub output_problem_body{ |
969 | sub output_problem_body{ |
| … | |
… | |
| 986 | # processes and prints out the correct link to the editor of the current problem |
993 | # processes and prints out the correct link to the editor of the current problem |
| 987 | |
994 | |
| 988 | sub output_editorLink{ |
995 | sub output_editorLink{ |
| 989 | |
996 | |
| 990 | my $self = shift; |
997 | my $self = shift; |
| 991 | |
998 | |
| 992 | my $set = $self->{set}; |
999 | my $set = $self->{set}; |
| 993 | my $problem = $self->{problem}; |
1000 | my $problem = $self->{problem}; |
| 994 | my $pg = $self->{pg}; |
1001 | my $pg = $self->{pg}; |
| 995 | |
1002 | |
| 996 | my $r = $self->r; |
1003 | my $r = $self->r; |
| 997 | |
1004 | |
| 998 | my $authz = $r->authz; |
1005 | my $authz = $r->authz; |
| 999 | my $urlpath = $r->urlpath; |
1006 | my $urlpath = $r->urlpath; |
| … | |
… | |
| 1072 | -checked => "checked", |
1079 | -checked => "checked", |
| 1073 | -value => 1, |
1080 | -value => 1, |
| 1074 | } |
1081 | } |
| 1075 | : |
1082 | : |
| 1076 | { |
1083 | { |
| 1077 | -name => "showCorrectAnswers", |
1084 | -name => "showHints", |
| 1078 | -value => 1, |
1085 | -value => 1, |
| 1079 | } |
1086 | } |
| 1080 | ) |
1087 | ) |
| 1081 | ); |
1088 | ); |
| 1082 | } |
1089 | } |
| … | |
… | |
| 1091 | -checked => "checked", |
1098 | -checked => "checked", |
| 1092 | -value => 1, |
1099 | -value => 1, |
| 1093 | } |
1100 | } |
| 1094 | : |
1101 | : |
| 1095 | { |
1102 | { |
| 1096 | -name => "showCorrectAnswers", |
1103 | -name => "showSolutions", |
| 1097 | -value => 1, |
1104 | -value => 1, |
| 1098 | } |
1105 | } |
| 1099 | ); |
1106 | ); |
| 1100 | } |
1107 | } |
| 1101 | |
1108 | |
| 1102 | if ($can{showCorrectAnswers} or $can{showHints} or $can{showSolutions}) { |
1109 | if ($can{showCorrectAnswers} or $can{showHints} or $can{showSolutions}) { |
| … | |
… | |
| 1146 | my $self = shift; |
1153 | my $self = shift; |
| 1147 | my $r = $self->r; |
1154 | my $r = $self->r; |
| 1148 | my $problem = $self->{problem}; |
1155 | my $problem = $self->{problem}; |
| 1149 | my $set = $self->{set}; |
1156 | my $set = $self->{set}; |
| 1150 | my $pg = $self->{pg}; |
1157 | my $pg = $self->{pg}; |
| 1151 | my $scoreRecordedMessage = ""; |
1158 | my $scoreRecordedMessage = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::process_and_log_answer($self) || ""; |
| 1152 | unless(defined $self->{scoreRecordedMessage}){ |
|
|
| 1153 | $scoreRecordedMessage = $self->{scoreRecordedMessage}; |
|
|
| 1154 | } |
|
|
| 1155 | my $submitAnswers = $self->{submitAnswers}; |
1159 | my $submitAnswers = $self->{submitAnswers}; |
| 1156 | |
1160 | |
| 1157 | # score summary |
1161 | # score summary |
|
|
1162 | warn "num_correct =", $problem->num_correct,"num_incorrect=",$problem->num_incorrect |
|
|
1163 | unless defined($problem->num_correct) and defined($problem->num_incorrect) ; |
| 1158 | my $attempts = $problem->num_correct + $problem->num_incorrect; |
1164 | my $attempts = $problem->num_correct + $problem->num_incorrect; |
| 1159 | #my $attemptsNoun = $attempts != 1 ? $r->maketext("times") : $r->maketext("time"); |
1165 | #my $attemptsNoun = $attempts != 1 ? $r->maketext("times") : $r->maketext("time"); |
| 1160 | my $problem_status = $problem->status || 0; |
1166 | my $problem_status = $problem->status || 0; |
| 1161 | my $lastScore = sprintf("%.0f%%", $problem_status * 100); # Round to whole number |
1167 | my $lastScore = sprintf("%.0f%%", $problem_status * 100); # Round to whole number |
| 1162 | #my ($attemptsLeft, $attemptsLeftNoun); |
1168 | #my ($attemptsLeft, $attemptsLeftNoun); |
| … | |
… | |
| 1196 | $r->maketext("You have attempted this problem [quant,_1,time,times].",$attempts), CGI::br(), |
1202 | $r->maketext("You have attempted this problem [quant,_1,time,times].",$attempts), CGI::br(), |
| 1197 | $submitAnswers ? $r->maketext("You received a score of [_1] for this attempt.",sprintf("%.0f%%", $pg->{result}->{score} * 100)) . CGI::br():'', |
1203 | $submitAnswers ? $r->maketext("You received a score of [_1] for this attempt.",sprintf("%.0f%%", $pg->{result}->{score} * 100)) . CGI::br():'', |
| 1198 | $problem->attempted |
1204 | $problem->attempted |
| 1199 | ? $r->maketext("Your overall recorded score is [_1]. [_2]",$lastScore,$notCountedMessage) . CGI::br() |
1205 | ? $r->maketext("Your overall recorded score is [_1]. [_2]",$lastScore,$notCountedMessage) . CGI::br() |
| 1200 | : "", |
1206 | : "", |
| 1201 | # $setClosed ? $setClosedMessage : $r->maketext("You have [_1] [_2] remaining.",$attemptsLeft,$attemptsLeftNoun) |
|
|
| 1202 | $setClosed ? $setClosedMessage : $r->maketext("You have [negquant,_1,unlimited attempts,attempt,attempts] remaining.",$attemptsLeft) |
1207 | $setClosed ? $setClosedMessage : $r->maketext("You have [negquant,_1,unlimited attempts,attempt,attempts] remaining.",$attemptsLeft) |
| 1203 | )); |
1208 | )); |
| 1204 | }else { |
1209 | }else { |
| 1205 | print CGI::p($pg->{state}->{state_summary_msg}); |
1210 | print CGI::p($pg->{state}->{state_summary_msg}); |
| 1206 | } |
1211 | } |
| 1207 | |
1212 | |
| 1208 | return ""; |
1213 | return ""; |
| 1209 | } |
1214 | } |
| 1210 | |
1215 | |
| 1211 | # output_misc subroutine |
1216 | # output_misc subroutine |
| 1212 | |
1217 | |
| … | |
… | |
| 1262 | |
1267 | |
| 1263 | print( CGI::hidden( |
1268 | print( CGI::hidden( |
| 1264 | -name => 'problemSeed', |
1269 | -name => 'problemSeed', |
| 1265 | -value => $r->param("problemSeed") |
1270 | -value => $r->param("problemSeed") |
| 1266 | )) if defined($r->param("problemSeed")) and $permissionLevel>= $professorPermissionLevel; # only allow this for professors |
1271 | )) if defined($r->param("problemSeed")) and $permissionLevel>= $professorPermissionLevel; # only allow this for professors |
| 1267 | |
1272 | print CGI::end_div(); |
| 1268 | return ""; |
1273 | return ""; |
| 1269 | } |
1274 | } |
| 1270 | |
1275 | |
| 1271 | # output_summary subroutine |
1276 | # output_summary subroutine |
| 1272 | |
1277 | |