| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.29 2004/10/11 13:32:01 gage Exp $ |
4 | # $CVSHeader$ |
| 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. |
| … | |
… | |
| 252 | ##### Version 2 is local problem sets |
252 | ##### Version 2 is local problem sets |
| 253 | sub browse_mysets_panel { |
253 | sub browse_mysets_panel { |
| 254 | my $self = shift; |
254 | my $self = shift; |
| 255 | my $library_selected = shift; |
255 | my $library_selected = shift; |
| 256 | my $list_of_local_sets = shift; |
256 | my $list_of_local_sets = shift; |
| 257 | my $default_value = "Select a Problem Set"; |
257 | my $default_value = "Select a Homework Set"; |
| 258 | |
258 | |
| 259 | if(scalar(@$list_of_local_sets) == 0) { |
259 | if(scalar(@$list_of_local_sets) == 0) { |
| 260 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
260 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
| 261 | } elsif (not $library_selected or $library_selected eq $default_value) { |
261 | } elsif (not $library_selected or $library_selected eq $default_value) { |
| 262 | unshift @{$list_of_local_sets}, $default_value; |
262 | unshift @{$list_of_local_sets}, $default_value; |
| … | |
… | |
| 412 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
412 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
| 413 | |
413 | |
| 414 | if($have_local_sets ==0) { |
414 | if($have_local_sets ==0) { |
| 415 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
415 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
| 416 | } elsif (not $set_selected or $set_selected eq SELECT_SET_STRING) { |
416 | } elsif (not $set_selected or $set_selected eq SELECT_SET_STRING) { |
| 417 | if ($list_of_local_sets->[0] eq "Select a Problem Set") { |
417 | if ($list_of_local_sets->[0] eq "Select a Homework Set") { |
| 418 | shift @{$list_of_local_sets}; |
418 | shift @{$list_of_local_sets}; |
| 419 | } |
419 | } |
| 420 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
420 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
| 421 | $set_selected = SELECT_SET_STRING; |
421 | $set_selected = SELECT_SET_STRING; |
| 422 | } |
422 | } |
| … | |
… | |
| 432 | CGI::br(), |
432 | CGI::br(), |
| 433 | CGI::br(), |
433 | CGI::br(), |
| 434 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
434 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
| 435 | -onclick=>$myjs |
435 | -onclick=>$myjs |
| 436 | ), |
436 | ), |
| 437 | " ", |
437 | " ", |
| 438 | CGI::textfield(-name=>"new_set_name", |
438 | CGI::textfield(-name=>"new_set_name", |
| 439 | -default=>"Name for new set here", |
439 | -default=>"Name for new set here", |
| 440 | -override=>1, -size=>30), |
440 | -override=>1, -size=>30), |
| 441 | CGI::br(), |
441 | CGI::br(), |
| 442 | )); |
442 | )); |
| … | |
… | |
| 460 | CGI::submit(-name=>"cleardisplay", |
460 | CGI::submit(-name=>"cleardisplay", |
| 461 | -style=>$these_widths, |
461 | -style=>$these_widths, |
| 462 | -value=>"Clear Problem Display") |
462 | -value=>"Clear Problem Display") |
| 463 | )), |
463 | )), |
| 464 | CGI::end_table())); |
464 | CGI::end_table())); |
| 465 | |
|
|
| 466 | } |
465 | } |
| 467 | |
466 | |
| 468 | sub make_data_row { |
467 | sub make_data_row { |
| 469 | my $self = shift; |
468 | my $self = shift; |
| 470 | my $sourceFileName = shift; |
469 | my $sourceFileName = shift; |
| … | |
… | |
| 656 | |
655 | |
| 657 | } elsif ($r->param('view_mysets_set')) { |
656 | } elsif ($r->param('view_mysets_set')) { |
| 658 | |
657 | |
| 659 | my $set_to_display = $r->param('library_sets'); |
658 | my $set_to_display = $r->param('library_sets'); |
| 660 | if (not defined($set_to_display) |
659 | if (not defined($set_to_display) |
| 661 | or $set_to_display eq "Select a Problem Set" |
660 | or $set_to_display eq "Select a Homework Set" |
| 662 | or $set_to_display eq NO_LOCAL_SET_STRING) { |
661 | or $set_to_display eq NO_LOCAL_SET_STRING) { |
| 663 | $self->addbadmessage("You need to select a set from this course to view."); |
662 | $self->addbadmessage("You need to select a set from this course to view."); |
| 664 | } else { |
663 | } else { |
| 665 | my @problemList = $db->listGlobalProblems($set_to_display); |
664 | my @problemList = $db->listGlobalProblems($set_to_display); |
| 666 | my $problem; |
665 | my $problem; |
| … | |
… | |
| 704 | |
703 | |
| 705 | ##### Make a new local problem set |
704 | ##### Make a new local problem set |
| 706 | |
705 | |
| 707 | } elsif ($r->param('new_local_set')) { |
706 | } elsif ($r->param('new_local_set')) { |
| 708 | if ($r->param('new_set_name') !~ /^[\w.-]*$/) { |
707 | if ($r->param('new_set_name') !~ /^[\w.-]*$/) { |
| 709 | $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."); |
708 | $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."); |
| 710 | } else { |
709 | } else { |
| 711 | my $newSetName = $r->param('new_set_name'); |
710 | my $newSetName = $r->param('new_set_name'); |
| 712 | $newSetName =~ s/^set//; |
711 | # if we want to munge the input set name, do it here |
| 713 | $newSetName =~ s/\.def$//; |
|
|
| 714 | $r->param('local_sets',$newSetName); |
712 | $r->param('local_sets',$newSetName); |
| 715 | my $newSetRecord = $db->getGlobalSet($newSetName); |
713 | my $newSetRecord = $db->getGlobalSet($newSetName); |
| 716 | if (defined($newSetRecord)) { |
714 | if (defined($newSetRecord)) { |
| 717 | $self->addbadmessage("The set name $newSetName is already in use. Pick a different name if you would like to start a new set."); |
715 | $self->addbadmessage("The set name $newSetName is already in use. Pick a different name if you would like to start a new set."); |
| 718 | } else { # Do it! |
716 | } else { # Do it! |
| 719 | $newSetRecord = $db->{set}->{record}->new(); |
717 | $newSetRecord = $db->{set}->{record}->new(); |
| 720 | $newSetRecord->set_id($newSetName); |
718 | $newSetRecord->set_id($newSetName); |
| 721 | $newSetRecord->set_header(""); |
719 | $newSetRecord->set_header(""); |
| 722 | $newSetRecord->hardcopy_header(""); |
720 | $newSetRecord->hardcopy_header(""); |
| … | |
… | |
| 754 | if (not defined($localSet) or |
752 | if (not defined($localSet) or |
| 755 | $localSet eq SELECT_SET_STRING or |
753 | $localSet eq SELECT_SET_STRING or |
| 756 | $localSet eq NO_LOCAL_SET_STRING) { |
754 | $localSet eq NO_LOCAL_SET_STRING) { |
| 757 | $self->addbadmessage('You are trying to add problems to something, but you did not select a "Target Set" name as a target.'); |
755 | $self->addbadmessage('You are trying to add problems to something, but you did not select a "Target Set" name as a target.'); |
| 758 | } else { |
756 | } else { |
| 759 | my $newSetRecord = $db->getGlobalSet($localSet); |
757 | my $newSetRecord = $db->getGlobalSet($localSet); |
| 760 | if (not defined($newSetRecord)) { |
758 | if (not defined($newSetRecord)) { |
| 761 | $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."); |
759 | $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."); |
| 762 | } else { |
760 | } else { |
| 763 | my $addcount = add_selected($self, $db, $localSet); |
761 | my $addcount = add_selected($self, $db, $localSet); |
| 764 | if($addcount > 0) { |
762 | if($addcount > 0) { |
| 765 | $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':''). |
763 | $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':''). |
| 766 | " to $localSet."); |
764 | " to $localSet."); |
| … | |
… | |
| 830 | |
828 | |
| 831 | } |
829 | } |
| 832 | |
830 | |
| 833 | |
831 | |
| 834 | sub title { |
832 | sub title { |
| 835 | return "Problem Set Maker"; |
833 | return "Homework Set Maker"; |
| 836 | } |
834 | } |
| 837 | |
835 | |
| 838 | sub body { |
836 | sub body { |
| 839 | my ($self) = @_; |
837 | my ($self) = @_; |
| 840 | |
838 | |
| … | |
… | |
| 860 | } |
858 | } |
| 861 | |
859 | |
| 862 | ########## Extract information computed in pre_header_initialize |
860 | ########## Extract information computed in pre_header_initialize |
| 863 | |
861 | |
| 864 | my $first_shown = $self->{first_shown}; |
862 | my $first_shown = $self->{first_shown}; |
| 865 | my $last_shown = $self->{last_shown}; |
863 | my $last_shown = $self->{last_shown}; |
| 866 | my $browse_which = $self->{browse_which}; |
864 | my $browse_which = $self->{browse_which}; |
| 867 | my $problem_seed = $self->{problem_seed}; |
865 | my $problem_seed = $self->{problem_seed}; |
| 868 | my @pg_files = @{$self->{pg_files}}; |
866 | my @pg_files = @{$self->{pg_files}}; |
| 869 | my @all_set_defs = @{$self->{all_set_defs}}; |
867 | my @all_set_defs = @{$self->{all_set_defs}}; |
| 870 | |
868 | |