| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.66 2006/07/08 14:07:35 gage Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.70 2006/07/08 17:29:16 gage Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 708 | |
708 | |
| 709 | my $list_of_local_sets = $data{all_db_sets}; |
709 | my $list_of_local_sets = $data{all_db_sets}; |
| 710 | my $have_local_sets = scalar(@$list_of_local_sets); |
710 | my $have_local_sets = scalar(@$list_of_local_sets); |
| 711 | my $browse_which = $data{browse_which}; |
711 | my $browse_which = $data{browse_which}; |
| 712 | my $library_selected = $self->{current_library_set}; |
712 | my $library_selected = $self->{current_library_set}; |
| 713 | debug("library_sets parameter is now ", $library_selected); |
|
|
| 714 | my $set_selected = $r->param('local_sets'); |
713 | my $set_selected = $r->param('local_sets'); |
| 715 | debug("local_sets parameter is now ", $set_selected); |
|
|
| 716 | my ($dis1, $dis2, $dis3, $dis4) = ("","","", ""); |
714 | my ($dis1, $dis2, $dis3, $dis4) = ("","","", ""); |
| 717 | $dis1 = '-disabled' if($browse_which eq 'browse_library'); |
715 | $dis1 = '-disabled' if($browse_which eq 'browse_library'); |
| 718 | $dis2 = '-disabled' if($browse_which eq 'browse_local'); |
716 | $dis2 = '-disabled' if($browse_which eq 'browse_local'); |
| 719 | $dis3 = '-disabled' if($browse_which eq 'browse_mysets'); |
717 | $dis3 = '-disabled' if($browse_which eq 'browse_mysets'); |
| 720 | $dis4 = '-disabled' if($browse_which eq 'browse_setdefs'); |
718 | $dis4 = '-disabled' if($browse_which eq 'browse_setdefs'); |
| … | |
… | |
| 741 | |
739 | |
| 742 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Add problems to ", |
740 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Add problems to ", |
| 743 | CGI::b("Target Set: "), |
741 | CGI::b("Target Set: "), |
| 744 | CGI::popup_menu(-name=> 'local_sets', |
742 | CGI::popup_menu(-name=> 'local_sets', |
| 745 | -values=>$list_of_local_sets, |
743 | -values=>$list_of_local_sets, |
| 746 | -default=> $set_selected), |
744 | -default=> $set_selected, |
|
|
745 | -override=>1), |
| 747 | CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"), |
746 | CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"), |
| 748 | CGI::hidden(-name=>"selfassign", -default=>[0],-override=>1). |
747 | CGI::hidden(-name=>"selfassign", -default=>[0],-override=>1). |
| 749 | CGI::br(), |
748 | CGI::br(), |
| 750 | CGI::br(), |
749 | CGI::br(), |
| 751 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
750 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
| … | |
… | |
| 868 | print CGI::Tr({-align=>"left"}, CGI::td( |
867 | print CGI::Tr({-align=>"left"}, CGI::td( |
| 869 | CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, |
868 | CGI::div({-style=>"background-color: #DDDDDD; margin: 0px auto"}, |
| 870 | CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), |
869 | CGI::span({-style=>"float:left ; text-align: left"},"File name: $sourceFileName "), |
| 871 | CGI::span({-style=>"float:right ; text-align: right"}, $edit_link, " ", $try_link) |
870 | CGI::span({-style=>"float:right ; text-align: right"}, $edit_link, " ", $try_link) |
| 872 | ), CGI::br(), |
871 | ), CGI::br(), |
| 873 | CGI::checkbox(-name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update"), |
872 | CGI::checkbox(-name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1), |
| 874 | CGI::br(), |
873 | CGI::br(), |
| 875 | $inSet, |
874 | $inSet, |
| 876 | CGI::checkbox((%add_box_data)), |
875 | CGI::checkbox((%add_box_data),-override=>1), |
| 877 | CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName],-override=>1). |
876 | CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName],-override=>1). |
| 878 | CGI::p($problem_output), |
877 | CGI::p($problem_output), |
| 879 | )); |
878 | )); |
| 880 | } |
879 | } |
| 881 | |
880 | |
| … | |
… | |
| 944 | my @past_marks = map {$_->[1]} @{$self->{past_problems}}; |
943 | my @past_marks = map {$_->[1]} @{$self->{past_problems}}; |
| 945 | my $none_shown = scalar(@{$self->{past_problems}})==0; |
944 | my $none_shown = scalar(@{$self->{past_problems}})==0; |
| 946 | my @pg_files=(); |
945 | my @pg_files=(); |
| 947 | my $use_previous_problems = 1; |
946 | my $use_previous_problems = 1; |
| 948 | my $first_shown = $r->param('first_shown') || 0; |
947 | my $first_shown = $r->param('first_shown') || 0; |
| 949 | my $last_shown = $r->param('last_shown'); debug("last_shown 1: ", $last_shown); |
948 | my $last_shown = $r->param('last_shown'); |
| 950 | if (not defined($last_shown)) { |
949 | if (not defined($last_shown)) { |
| 951 | $last_shown = -1; debug("last_shown 2: ", $last_shown); |
950 | $last_shown = -1; |
| 952 | } |
951 | } |
| 953 | my @all_past_list = (); # these are include requested, but not shown |
952 | my @all_past_list = (); # these are include requested, but not shown |
| 954 | my $j = 0; |
953 | my $j = 0; |
| 955 | while (defined($r->param("all_past_list$j"))) { |
954 | while (defined($r->param("all_past_list$j"))) { |
| 956 | push @all_past_list, $r->param("all_past_list$j"); |
955 | push @all_past_list, $r->param("all_past_list$j"); |
| … | |
… | |
| 1017 | ##### View problems selected from the local list |
1016 | ##### View problems selected from the local list |
| 1018 | |
1017 | |
| 1019 | } elsif ($r->param('view_local_set')) { |
1018 | } elsif ($r->param('view_local_set')) { |
| 1020 | |
1019 | |
| 1021 | my $set_to_display = $self->{current_library_set}; |
1020 | my $set_to_display = $self->{current_library_set}; |
| 1022 | debug("display local sets", $r->param('local_sets'), "or library sets", $set_to_display); |
|
|
| 1023 | if (not defined($set_to_display) or $set_to_display eq SELECT_LOCAL_STRING or $set_to_display eq "Found no directories containing problems") { |
1021 | if (not defined($set_to_display) or $set_to_display eq SELECT_LOCAL_STRING or $set_to_display eq "Found no directories containing problems") { |
| 1024 | $self->addbadmessage('You need to select a set to view.'); |
1022 | $self->addbadmessage('You need to select a set to view.'); |
| 1025 | } else { |
1023 | } else { |
| 1026 | $set_to_display = '.' if $set_to_display eq MY_PROBLEMS; |
1024 | $set_to_display = '.' if $set_to_display eq MY_PROBLEMS; |
| 1027 | $set_to_display = substr($browse_which,7) if $set_to_display eq MAIN_PROBLEMS; |
1025 | $set_to_display = substr($browse_which,7) if $set_to_display eq MAIN_PROBLEMS; |
| … | |
… | |
| 1099 | $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."); |
1097 | $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."); |
| 1100 | } else { |
1098 | } else { |
| 1101 | my $newSetName = $r->param('new_set_name'); |
1099 | my $newSetName = $r->param('new_set_name'); |
| 1102 | # if we want to munge the input set name, do it here |
1100 | # if we want to munge the input set name, do it here |
| 1103 | $newSetName =~ s/\s/_/g; |
1101 | $newSetName =~ s/\s/_/g; |
| 1104 | $r->param('local_sets',$newSetName); |
1102 | debug("local_sets was ", $r->param('local_sets')); |
|
|
1103 | $r->param('local_sets',$newSetName); ## use of two parameter param |
|
|
1104 | debug("new value of local_sets is ", $r->param('local_sets')); |
| 1105 | my $newSetRecord = $db->getGlobalSet($newSetName); |
1105 | my $newSetRecord = $db->getGlobalSet($newSetName); |
| 1106 | if (defined($newSetRecord)) { |
1106 | if (defined($newSetRecord)) { |
| 1107 | $self->addbadmessage("The set name $newSetName is already in use. |
1107 | $self->addbadmessage("The set name $newSetName is already in use. |
| 1108 | Pick a different name if you would like to start a new set."); |
1108 | Pick a different name if you would like to start a new set."); |
| 1109 | } else { # Do it! |
1109 | } else { # Do it! |
| … | |
… | |
| 1181 | $first_shown = $last_shown+1; |
1181 | $first_shown = $last_shown+1; |
| 1182 | $last_shown = $first_shown+$maxShown-1; debug("last_shown 5: ", $last_shown); |
1182 | $last_shown = $first_shown+$maxShown-1; debug("last_shown 5: ", $last_shown); |
| 1183 | $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 6: ", $last_shown); |
1183 | $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 6: ", $last_shown); |
| 1184 | @past_marks = (); |
1184 | @past_marks = (); |
| 1185 | } elsif ($r->param('prev_page')) { |
1185 | } elsif ($r->param('prev_page')) { |
| 1186 | $last_shown = $first_shown-1; debug("last_shown 7: ", $last_shown); |
1186 | $last_shown = $first_shown-1; |
| 1187 | $first_shown = $last_shown - $maxShown+1; |
1187 | $first_shown = $last_shown - $maxShown+1; |
| 1188 | |
1188 | |
| 1189 | $first_shown = 0 if($first_shown<0); |
1189 | $first_shown = 0 if($first_shown<0); |
| 1190 | @past_marks = (); |
1190 | @past_marks = (); |
| 1191 | |
1191 | |
| … | |
… | |
| 1221 | |
1221 | |
| 1222 | if ($use_previous_problems) { |
1222 | if ($use_previous_problems) { |
| 1223 | @pg_files = @all_past_list; |
1223 | @pg_files = @all_past_list; |
| 1224 | } else { |
1224 | } else { |
| 1225 | $first_shown = 0; |
1225 | $first_shown = 0; |
| 1226 | $last_shown = scalar(@pg_files)<$maxShown ? scalar(@pg_files) : $maxShown; debug("last_shown 8: ", $last_shown); |
1226 | $last_shown = scalar(@pg_files)<$maxShown ? scalar(@pg_files) : $maxShown; |
| 1227 | $last_shown--; debug("last_shown 9: ", $last_shown); # to make it an array index |
1227 | $last_shown--; # to make it an array index |
| 1228 | @past_marks = (); |
1228 | @past_marks = (); |
| 1229 | } |
1229 | } |
| 1230 | ############# Now store data in self for retreival by body |
1230 | ############# Now store data in self for retreival by body |
| 1231 | $self->{first_shown} = $first_shown; |
1231 | $self->{first_shown} = $first_shown; |
| 1232 | $self->{last_shown} = $last_shown; |
1232 | $self->{last_shown} = $last_shown; |
| … | |
… | |
| 1234 | $self->{problem_seed} = $problem_seed; |
1234 | $self->{problem_seed} = $problem_seed; |
| 1235 | $self->{pg_files} = \@pg_files; |
1235 | $self->{pg_files} = \@pg_files; |
| 1236 | $self->{past_marks} = \@past_marks; |
1236 | $self->{past_marks} = \@past_marks; |
| 1237 | $self->{all_db_sets} = \@all_db_sets; |
1237 | $self->{all_db_sets} = \@all_db_sets; |
| 1238 | $self->{library_basic} = $library_basic; |
1238 | $self->{library_basic} = $library_basic; |
|
|
1239 | debug("past_marks is ", join(" ", @{$self->{past_marks}})); |
| 1239 | } |
1240 | } |
| 1240 | |
1241 | |
| 1241 | |
1242 | |
| 1242 | sub title { |
1243 | sub title { |
| 1243 | return "Library Browser"; |
1244 | return "Library Browser"; |
| … | |
… | |
| 1273 | } |
1274 | } |
| 1274 | |
1275 | |
| 1275 | ########## Extract information computed in pre_header_initialize |
1276 | ########## Extract information computed in pre_header_initialize |
| 1276 | |
1277 | |
| 1277 | my $first_shown = $self->{first_shown}; |
1278 | my $first_shown = $self->{first_shown}; |
| 1278 | my $last_shown = $self->{last_shown}; debug("last_shown 10: ", $last_shown); |
1279 | my $last_shown = $self->{last_shown}; |
| 1279 | my $browse_which = $self->{browse_which}; |
1280 | my $browse_which = $self->{browse_which}; |
| 1280 | my $problem_seed = $self->{problem_seed}; |
1281 | my $problem_seed = $self->{problem_seed}; |
| 1281 | my @pg_files = @{$self->{pg_files}}; |
1282 | my @pg_files = @{$self->{pg_files}}; |
| 1282 | my @all_db_sets = @{$self->{all_db_sets}}; |
1283 | my @all_db_sets = @{$self->{all_db_sets}}; |
| 1283 | |
1284 | |
| … | |
… | |
| 1309 | for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { |
1310 | for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { |
| 1310 | print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j],-override=>1); |
1311 | print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j],-override=>1); |
| 1311 | } |
1312 | } |
| 1312 | |
1313 | |
| 1313 | print CGI::hidden(-name=>'first_shown', -value=>[$first_shown],-override=>1); |
1314 | print CGI::hidden(-name=>'first_shown', -value=>[$first_shown],-override=>1); |
| 1314 | debug("last_shown 11: ", $last_shown); |
1315 | |
| 1315 | |
|
|
| 1316 | debug("last_shown hidden field: ", CGI::hidden(-name=>'last_shown', -value=>$last_shown, -override=>1)); |
|
|
| 1317 | print CGI::hidden(-name=>'last_shown', -value=>[$last_shown], -override=>1); |
1316 | print CGI::hidden(-name=>'last_shown', -value=>[$last_shown], -override=>1); |
| 1318 | |
1317 | |
| 1319 | |
1318 | |
| 1320 | ########## Now print problems |
1319 | ########## Now print problems |
| 1321 | my $jj; |
1320 | my $jj; |
| 1322 | for ($jj=0; $jj<scalar(@pg_html); $jj++) { |
1321 | for ($jj=0; $jj<scalar(@pg_html); $jj++) { |
| 1323 | $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
1322 | $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; |
| 1324 | $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
1323 | $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); |
|
|
1324 | #$self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj+$first_shown]); #MEG |
| 1325 | } |
1325 | } |
| 1326 | |
1326 | |
| 1327 | ########## Finish things off |
1327 | ########## Finish things off |
| 1328 | print CGI::end_table(); |
1328 | print CGI::end_table(); |
| 1329 | print '</div>'; |
1329 | print '</div>'; |