[system] / trunk / webwork-modperl / lib / WeBWorK / ContentGenerator / Instructor / SetMaker.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 4205 Revision 4206
322sub browse_local_panel { 322sub browse_local_panel {
323 my $self = shift; 323 my $self = shift;
324 my $library_selected = shift; 324 my $library_selected = shift;
325 my $lib = shift || ''; $lib =~ s/^browse_//; 325 my $lib = shift || ''; $lib =~ s/^browse_//;
326 my $name = ($lib eq '')? 'Local' : $problib{$lib}; 326 my $name = ($lib eq '')? 'Local' : $problib{$lib};
327 327 debug("library is $lib and sets are $library_selected");
328 my $list_of_prob_dirs= get_problem_directories($self->r->ce,$lib); 328 my $list_of_prob_dirs= get_problem_directories($self->r->ce,$lib);
329 if(scalar(@$list_of_prob_dirs) == 0) { 329 if(scalar(@$list_of_prob_dirs) == 0) {
330 $library_selected = "Found no directories containing problems"; 330 $library_selected = "Found no directories containing problems";
331 unshift @{$list_of_prob_dirs}, $library_selected; 331 unshift @{$list_of_prob_dirs}, $library_selected;
332 } else { 332 } else {
486 } else { 486 } else {
487 $count_line = "There are $count_line matching WeBWorK problem files"; 487 $count_line = "There are $count_line matching WeBWorK problem files";
488 } 488 }
489 489
490 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, 490 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"},
491 CGI::hidden(-name=>"library_is_basic", -default=>[1]), 491 CGI::hidden(-name=>"library_is_basic", -default=>[1],-override=>1),
492 CGI::start_table({-width=>"100%"}), 492 CGI::start_table({-width=>"100%"}),
493 CGI::Tr( 493 CGI::Tr(
494 CGI::td(["Subject:", 494 CGI::td(["Subject:",
495 CGI::popup_menu(-name=> 'library_subjects', 495 CGI::popup_menu(-name=> 'library_subjects',
496 -values=>\@subjs, 496 -values=>\@subjs,
597 } else { 597 } else {
598 $count_line = "There are $count_line matching WeBWorK problem files"; 598 $count_line = "There are $count_line matching WeBWorK problem files";
599 } 599 }
600 600
601 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, 601 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"},
602 CGI::hidden(-name=>"library_is_basic", -default=>[2]), 602 CGI::hidden(-name=>"library_is_basic", -default=>[2],-override=>1),
603 CGI::start_table({-width=>"100%"}), 603 CGI::start_table({-width=>"100%"}),
604 # Html done by hand since it is temporary 604 # Html done by hand since it is temporary
605 CGI::Tr(CGI::td({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"')), 605 CGI::Tr(CGI::td({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"')),
606 CGI::Tr( 606 CGI::Tr(
607 CGI::td(["Subject:", 607 CGI::td(["Subject:",
706 my %data = @_; 706 my %data = @_;
707 707
708 my $list_of_local_sets = $data{all_db_sets}; 708 my $list_of_local_sets = $data{all_db_sets};
709 my $have_local_sets = scalar(@$list_of_local_sets); 709 my $have_local_sets = scalar(@$list_of_local_sets);
710 my $browse_which = $data{browse_which}; 710 my $browse_which = $data{browse_which};
711 my $library_selected = $r->param('library_sets'); 711 my $library_selected = $self->{current_library_set};
712 debug("library_sets parameter is now ", $library_selected);
712 my $set_selected = $r->param('local_sets'); 713 my $set_selected = $r->param('local_sets');
713 714 debug("local_sets parameter is now ", $set_selected);
714 my ($dis1, $dis2, $dis3, $dis4) = ("","","", ""); 715 my ($dis1, $dis2, $dis3, $dis4) = ("","","", "");
715 $dis1 = '-disabled' if($browse_which eq 'browse_library'); 716 $dis1 = '-disabled' if($browse_which eq 'browse_library');
716 $dis2 = '-disabled' if($browse_which eq 'browse_local'); 717 $dis2 = '-disabled' if($browse_which eq 'browse_local');
717 $dis3 = '-disabled' if($browse_which eq 'browse_mysets'); 718 $dis3 = '-disabled' if($browse_which eq 'browse_mysets');
718 $dis4 = '-disabled' if($browse_which eq 'browse_setdefs'); 719 $dis4 = '-disabled' if($browse_which eq 'browse_setdefs');
741 CGI::b("Target Set: "), 742 CGI::b("Target Set: "),
742 CGI::popup_menu(-name=> 'local_sets', 743 CGI::popup_menu(-name=> 'local_sets',
743 -values=>$list_of_local_sets, 744 -values=>$list_of_local_sets,
744 -default=> $set_selected), 745 -default=> $set_selected),
745 CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"), 746 CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"),
746 CGI::hidden(-name=>"selfassign", -default=>[0]). 747 CGI::hidden(-name=>"selfassign", -default=>[0],-override=>1).
747 CGI::br(), 748 CGI::br(),
748 CGI::br(), 749 CGI::br(),
749 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:",
750 -onclick=>$myjs 751 -onclick=>$myjs
751 ), 752 ),
870 ), CGI::br(), 871 ), CGI::br(),
871 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"),
872 CGI::br(), 873 CGI::br(),
873 $inSet, 874 $inSet,
874 CGI::checkbox((%add_box_data)), 875 CGI::checkbox((%add_box_data)),
875 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName]). 876 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName],-override=>1).
876 CGI::p($problem_output), 877 CGI::p($problem_output),
877 )); 878 ));
878} 879}
879 880
880sub clear_default { 881sub clear_default {
899 900
900 ## Fix some parameters 901 ## Fix some parameters
901 for my $key (keys(%{ LIB2_DATA() })) { 902 for my $key (keys(%{ LIB2_DATA() })) {
902 clear_default($r, LIB2_DATA->{$key}->{name}, LIB2_DATA->{$key}->{all} ); 903 clear_default($r, LIB2_DATA->{$key}->{name}, LIB2_DATA->{$key}->{all} );
903 } 904 }
904 905 ## Grab library sets to display from parameters list. We will modify this
906 ## as we go through the if/else tree
907 $self->{current_library_set} = $r->param('library_sets');
908
905 ## These directories will have individual buttons 909 ## These directories will have individual buttons
906 %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs}; 910 %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs};
907 911
908 my $userName = $r->param('user'); 912 my $userName = $r->param('user');
909 my $user = $db->getUser($userName); # checked 913 my $user = $db->getUser($userName); # checked
967 last; 971 last;
968 } 972 }
969 } 973 }
970 974
971 ########### Start the logic through if elsif elsif ... 975 ########### Start the logic through if elsif elsif ...
972 976 debug("browse_lib", $r->param("$browse_lib"));
977 debug("browse_library", $r->param("browse_library"));
978 debug("browse_mysets", $r->param("browse_mysets"));
979 debug("browse_setdefs", $r->param("browse_setdefs"));
973 ##### Asked to browse certain problems 980 ##### Asked to browse certain problems
974 if ($browse_lib ne '') { 981 if ($browse_lib ne '') {
975 $browse_which = $browse_lib; 982 $browse_which = $browse_lib;
976 $r->param('library_sets', ""); 983 $self->{current_library_sets} = "";
977 $use_previous_problems = 0; @pg_files = (); ## clear old problems 984 $use_previous_problems = 0; @pg_files = (); ## clear old problems
978 } elsif ($r->param('browse_library')) { 985 } elsif ($r->param('browse_library')) {
979 $browse_which = 'browse_library'; 986 $browse_which = 'browse_library';
980 $r->param('library_sets', ""); 987 $self->{current_library_sets} = "";
981 $use_previous_problems = 0; @pg_files = (); ## clear old problems 988 $use_previous_problems = 0; @pg_files = (); ## clear old problems
982 } elsif ($r->param('browse_local')) { 989 } elsif ($r->param('browse_local')) {
983 $browse_which = 'browse_local'; 990 $browse_which = 'browse_local';
984 $r->param('library_sets', ""); 991 $self->{current_library_sets} = "";
985 $use_previous_problems = 0; @pg_files = (); ## clear old problems 992 $use_previous_problems = 0; @pg_files = (); ## clear old problems
986 } elsif ($r->param('browse_mysets')) { 993 } elsif ($r->param('browse_mysets')) {
987 $browse_which = 'browse_mysets'; 994 $browse_which = 'browse_mysets';
988 $r->param('library_sets', ""); 995 $self->{current_library_sets} = "";
989 $use_previous_problems = 0; @pg_files = (); ## clear old problems 996 $use_previous_problems = 0; @pg_files = (); ## clear old problems
990 } elsif ($r->param('browse_setdefs')) { 997 } elsif ($r->param('browse_setdefs')) {
991 $browse_which = 'browse_setdefs'; 998 $browse_which = 'browse_setdefs';
992 $r->param('library_sets', ""); 999 $self->{current_library_sets} = "";
993 $use_previous_problems = 0; @pg_files = (); ## clear old problems 1000 $use_previous_problems = 0; @pg_files = (); ## clear old problems
994 1001
995 ##### Change the seed value 1002 ##### Change the seed value
996 1003
997 } elsif ($r->param('rerandomize')) { 1004 } elsif ($r->param('rerandomize')) {
1008 1015
1009 ##### View problems selected from the local list 1016 ##### View problems selected from the local list
1010 1017
1011 } elsif ($r->param('view_local_set')) { 1018 } elsif ($r->param('view_local_set')) {
1012 1019
1013 my $set_to_display = $r->param('library_sets'); 1020 my $set_to_display = $self->{current_library_sets};
1014 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") {
1015 $self->addbadmessage('You need to select a set to view.'); 1022 $self->addbadmessage('You need to select a set to view.');
1016 } else { 1023 } else {
1017 $set_to_display = '.' if $set_to_display eq MY_PROBLEMS; 1024 $set_to_display = '.' if $set_to_display eq MY_PROBLEMS;
1018 $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;
1023 1030
1024 ##### View problems selected from the a set in this course 1031 ##### View problems selected from the a set in this course
1025 1032
1026 } elsif ($r->param('view_mysets_set')) { 1033 } elsif ($r->param('view_mysets_set')) {
1027 1034
1028 my $set_to_display = $r->param('library_sets'); 1035 my $set_to_display = $self->{current_library_sets};
1029 if (not defined($set_to_display) 1036 if (not defined($set_to_display)
1030 or $set_to_display eq "Select a Homework Set" 1037 or $set_to_display eq "Select a Homework Set"
1031 or $set_to_display eq NO_LOCAL_SET_STRING) { 1038 or $set_to_display eq NO_LOCAL_SET_STRING) {
1032 $self->addbadmessage("You need to select a set from this course to view."); 1039 $self->addbadmessage("You need to select a set from this course to view.");
1033 } else { 1040 } else {
1062 1069
1063 ##### View a set from a set*.def 1070 ##### View a set from a set*.def
1064 1071
1065 } elsif ($r->param('view_setdef_set')) { 1072 } elsif ($r->param('view_setdef_set')) {
1066 1073
1067 my $set_to_display = $r->param('library_sets'); 1074 my $set_to_display = $self->{current_library_sets};
1068 if (not defined($set_to_display) 1075 if (not defined($set_to_display)
1069 or $set_to_display eq "Select a Set Definition File" 1076 or $set_to_display eq "Select a Set Definition File"
1070 or $set_to_display eq NO_LOCAL_SET_STRING) { 1077 or $set_to_display eq NO_LOCAL_SET_STRING) {
1071 $self->addbadmessage("You need to select a set from this course to view."); 1078 $self->addbadmessage("You need to select a set from this course to view.");
1072 } else { 1079 } else {
1091 # if we want to munge the input set name, do it here 1098 # if we want to munge the input set name, do it here
1092 $newSetName =~ s/\s/_/g; 1099 $newSetName =~ s/\s/_/g;
1093 $r->param('local_sets',$newSetName); 1100 $r->param('local_sets',$newSetName);
1094 my $newSetRecord = $db->getGlobalSet($newSetName); 1101 my $newSetRecord = $db->getGlobalSet($newSetName);
1095 if (defined($newSetRecord)) { 1102 if (defined($newSetRecord)) {
1096 $self->addbadmessage("The set name $newSetName is already in use. Pick a different name if you would like to start a new set."); 1103 $self->addbadmessage("The set name $newSetName is already in use.
1104 Pick a different name if you would like to start a new set.");
1097 } else { # Do it! 1105 } else { # Do it!
1098 $newSetRecord = $db->{set}->{record}->new(); 1106 $newSetRecord = $db->{set}->{record}->new();
1099 $newSetRecord->set_id($newSetName); 1107 $newSetRecord->set_id($newSetName);
1100 $newSetRecord->set_header(""); 1108 $newSetRecord->set_header("");
1101 $newSetRecord->hardcopy_header(""); 1109 $newSetRecord->hardcopy_header("");
1134 1142
1135 if (scalar(@selected)>0) { # if some are to be added, they need a place to go 1143 if (scalar(@selected)>0) { # if some are to be added, they need a place to go
1136 $localSet = $r->param('local_sets'); 1144 $localSet = $r->param('local_sets');
1137 if (not defined($localSet) or 1145 if (not defined($localSet) or
1138 $localSet eq SELECT_SET_STRING or 1146 $localSet eq SELECT_SET_STRING or
1139 $localSet eq NO_LOCAL_SET_STRING) { 1147 $localSet eq NO_LOCAL_SET_STRING) {
1140 $self->addbadmessage('You are trying to add problems to something, but you did not select a "Target Set" name as a target.'); 1148 $self->addbadmessage('You are trying to add problems to something,
1149 but you did not select a "Target Set" name as a target.');
1141 } else { 1150 } else {
1142 my $newSetRecord = $db->getGlobalSet($localSet); 1151 my $newSetRecord = $db->getGlobalSet($localSet);
1143 if (not defined($newSetRecord)) { 1152 if (not defined($newSetRecord)) {
1144 $self->addbadmessage("You are trying to add problems to $localSet, but that set does not seem to exist! I bet you used your \"Back\" button."); 1153 $self->addbadmessage("You are trying to add problems to $localSet,
1154 but that set does not seem to exist! I bet you used your \"Back\" button.");
1145 } else { 1155 } else {
1146 my $addcount = add_selected($self, $db, $localSet); 1156 my $addcount = add_selected($self, $db, $localSet);
1147 if($addcount > 0) { 1157 if($addcount > 0) {
1148 $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':''). 1158 $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':'').
1149 " to $localSet."); 1159 " to $localSet.");
1160 }
1150 } 1161 }
1151 }
1152 } 1162 }
1153 } 1163 }
1154 ## now handle problems to be hidden 1164 ## now handle problems to be hidden
1155 1165
1156 ## only keep the ones which are not hidden 1166 ## only keep the ones which are not hidden
1197 #my $c = $r->connection; 1207 #my $c = $r->connection;
1198 #print "Debug info: ". $r->get_remote_host ."<p>". $c->remote_ip ; 1208 #print "Debug info: ". $r->get_remote_host ."<p>". $c->remote_ip ;
1199 ; 1209 ;
1200 } ##### end of the if elsif ... 1210 } ##### end of the if elsif ...
1201 1211
1202 1212
1203 ############# List of local sets 1213 ############# List of local sets
1204 1214
1205 my @all_db_sets = $db->listGlobalSets; 1215 my @all_db_sets = $db->listGlobalSets;
1206 @all_db_sets = sortByName(undef, @all_db_sets); 1216 @all_db_sets = sortByName(undef, @all_db_sets);
1207 1217
1288 $self->hidden_authen_fields, 1298 $self->hidden_authen_fields,
1289 '<div align="center">', 1299 '<div align="center">',
1290 CGI::start_table({-border=>2}); 1300 CGI::start_table({-border=>2});
1291 $self->make_top_row('all_db_sets'=>\@all_db_sets, 1301 $self->make_top_row('all_db_sets'=>\@all_db_sets,
1292 'browse_which'=> $browse_which); 1302 'browse_which'=> $browse_which);
1293 print CGI::hidden(-name=>'browse_which', -value=>[$browse_which]), 1303 print CGI::hidden(-name=>'browse_which', -value=>[$browse_which],-override=>1),
1294 CGI::hidden(-name=>'problem_seed', -value=>[$problem_seed]); 1304 CGI::hidden(-name=>'problem_seed', -value=>[$problem_seed], -override=>1);
1295 for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { 1305 for ($j = 0 ; $j < scalar(@pg_files) ; $j++) {
1296 print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j]); 1306 print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j],-override=>1);
1297 } 1307 }
1298 1308
1299 print CGI::hidden(-name=>'first_shown', -value=>[$first_shown]); 1309 print CGI::hidden(-name=>'first_shown', -value=>[$first_shown],-override=>1);
1300 debug("last_shown 11: ", $last_shown); 1310 debug("last_shown 11: ", $last_shown);
1301 1311
1302 debug("last_shown hidden field: ", CGI::hidden(-name=>'last_shown', -value=>$last_shown, -override=>1)); 1312 debug("last_shown hidden field: ", CGI::hidden(-name=>'last_shown', -value=>$last_shown, -override=>1));
1303 print CGI::hidden(-name=>'last_shown', -value=>[$last_shown], -override=>1); 1313 print CGI::hidden(-name=>'last_shown', -value=>[$last_shown], -override=>1);
1304 1314

Legend:
Removed from v.4205  
changed lines
  Added in v.4206

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9