| 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$ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.37 2005/07/14 16:23:11 glarose 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. |
| … | |
… | |
| 33 | use WeBWorK::Utils::Tasks qw(renderProblems); |
33 | use WeBWorK::Utils::Tasks qw(renderProblems); |
| 34 | |
34 | |
| 35 | require WeBWorK::Utils::ListingDB; |
35 | require WeBWorK::Utils::ListingDB; |
| 36 | |
36 | |
| 37 | use constant MAX_SHOW_DEFAULT => 20; |
37 | use constant MAX_SHOW_DEFAULT => 20; |
| 38 | use constant NO_LOCAL_SET_STRING => 'There are no local sets yet'; |
38 | use constant NO_LOCAL_SET_STRING => 'No sets in this course yet'; |
| 39 | use constant SELECT_SET_STRING => 'Select a Set for This Course'; |
39 | use constant SELECT_SET_STRING => 'Select a Set for This Course'; |
| 40 | use constant SELECT_LOCAL_STRING => 'Select a Problem Collection'; |
40 | use constant SELECT_LOCAL_STRING => 'Select a Problem Collection'; |
| 41 | use constant MY_PROBLEMS => ' My Problems '; |
41 | use constant MY_PROBLEMS => ' My Problems '; |
| 42 | use constant MAIN_PROBLEMS => ' Main Problems '; |
42 | use constant MAIN_PROBLEMS => ' Main Problems '; |
|
|
43 | use constant CREATE_SET_BUTTON => 'Create New Set'; |
| 43 | |
44 | |
| 44 | ## Flags for operations on files |
45 | ## Flags for operations on files |
| 45 | |
46 | |
| 46 | use constant ADDED => 1; |
47 | use constant ADDED => 1; |
| 47 | use constant HIDDEN => (1 << 1); |
48 | use constant HIDDEN => (1 << 1); |
| … | |
… | |
| 386 | ($browse_which eq "browse_$lib")? '-disabled': '') |
387 | ($browse_which eq "browse_$lib")? '-disabled': '') |
| 387 | if (-d "$ce->{courseDirs}{templates}/$lib"); |
388 | if (-d "$ce->{courseDirs}{templates}/$lib"); |
| 388 | } |
389 | } |
| 389 | $libs = CGI::br()."or Problems from".$libs if $libs ne ''; |
390 | $libs = CGI::br()."or Problems from".$libs if $libs ne ''; |
| 390 | |
391 | |
| 391 | my $these_widths = "width: 20ex"; |
392 | my $these_widths = "width: 23ex"; |
| 392 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, |
|
|
| 393 | "Browse ", |
|
|
| 394 | CGI::submit(-name=>"browse_library", -value=>"Problem Library", -style=>$these_widths, $dis1), |
|
|
| 395 | CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, $dis2), |
|
|
| 396 | CGI::submit(-name=>"browse_mysets", -value=>"From This Course", -style=>$these_widths, $dis3), |
|
|
| 397 | $libs, |
|
|
| 398 | )); |
|
|
| 399 | |
|
|
| 400 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
| 401 | |
|
|
| 402 | if ($browse_which eq 'browse_local') { |
|
|
| 403 | $self->browse_local_panel($library_selected); |
|
|
| 404 | } elsif ($browse_which eq 'browse_mysets') { |
|
|
| 405 | $self->browse_mysets_panel($library_selected, $list_of_local_sets); |
|
|
| 406 | } elsif ($browse_which eq 'browse_library') { |
|
|
| 407 | $self->browse_library_panel(); |
|
|
| 408 | } else { ## handle other problem libraries |
|
|
| 409 | $self->browse_local_panel($library_selected,$browse_which); |
|
|
| 410 | } |
|
|
| 411 | |
|
|
| 412 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
| 413 | |
393 | |
| 414 | if($have_local_sets ==0) { |
394 | if($have_local_sets ==0) { |
| 415 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
395 | $list_of_local_sets = [NO_LOCAL_SET_STRING]; |
| 416 | } elsif (not $set_selected or $set_selected eq SELECT_SET_STRING) { |
396 | } elsif (not $set_selected or $set_selected eq SELECT_SET_STRING) { |
| 417 | if ($list_of_local_sets->[0] eq "Select a Homework Set") { |
397 | if ($list_of_local_sets->[0] eq "Select a Homework Set") { |
| … | |
… | |
| 420 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
400 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
| 421 | $set_selected = SELECT_SET_STRING; |
401 | $set_selected = SELECT_SET_STRING; |
| 422 | } |
402 | } |
| 423 | my $myjs = 'document.mainform.selfassign.value=confirm("Should I assign the new set to you now?\nUse OK for yes and Cancel for no.");true;'; |
403 | my $myjs = 'document.mainform.selfassign.value=confirm("Should I assign the new set to you now?\nUse OK for yes and Cancel for no.");true;'; |
| 424 | |
404 | |
| 425 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Adding Problems to ", |
405 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Add problems to ", |
| 426 | CGI::b("Target Set: "), |
406 | CGI::b("Target Set: "), |
| 427 | CGI::popup_menu(-name=> 'local_sets', |
407 | CGI::popup_menu(-name=> 'local_sets', |
| 428 | -values=>$list_of_local_sets, |
408 | -values=>$list_of_local_sets, |
| 429 | -default=> $set_selected), |
409 | -default=> $set_selected), |
| 430 | CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"), |
410 | CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"), |
| … | |
… | |
| 436 | ), |
416 | ), |
| 437 | " ", |
417 | " ", |
| 438 | CGI::textfield(-name=>"new_set_name", |
418 | CGI::textfield(-name=>"new_set_name", |
| 439 | -default=>"Name for new set here", |
419 | -default=>"Name for new set here", |
| 440 | -override=>1, -size=>30), |
420 | -override=>1, -size=>30), |
| 441 | CGI::br(), |
|
|
| 442 | )); |
421 | )); |
|
|
422 | |
|
|
423 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
424 | |
|
|
425 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, |
|
|
426 | "Browse ", |
|
|
427 | CGI::submit(-name=>"browse_library", -value=>"Problem Library", -style=>$these_widths, $dis1), |
|
|
428 | CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, $dis2), |
|
|
429 | CGI::submit(-name=>"browse_mysets", -value=>"From This Course", -style=>$these_widths, $dis3), |
|
|
430 | $libs, |
|
|
431 | )); |
|
|
432 | |
|
|
433 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
|
|
434 | |
|
|
435 | if ($browse_which eq 'browse_local') { |
|
|
436 | $self->browse_local_panel($library_selected); |
|
|
437 | } elsif ($browse_which eq 'browse_mysets') { |
|
|
438 | $self->browse_mysets_panel($library_selected, $list_of_local_sets); |
|
|
439 | } elsif ($browse_which eq 'browse_library') { |
|
|
440 | $self->browse_library_panel(); |
|
|
441 | } else { ## handle other problem libraries |
|
|
442 | $self->browse_local_panel($library_selected,$browse_which); |
|
|
443 | } |
| 443 | |
444 | |
| 444 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
445 | print CGI::Tr(CGI::td({-bgcolor=>"black"})); |
| 445 | |
446 | |
| 446 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, |
447 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, |
| 447 | CGI::start_table({-border=>"0"}), |
448 | CGI::start_table({-border=>"0"}), |
| … | |
… | |
| 451 | CGI::submit(-name=>"select_none", -style=>$these_widths, |
452 | CGI::submit(-name=>"select_none", -style=>$these_widths, |
| 452 | -value=>"Clear All Marks"), |
453 | -value=>"Clear All Marks"), |
| 453 | )), |
454 | )), |
| 454 | CGI::Tr(CGI::td( |
455 | CGI::Tr(CGI::td( |
| 455 | CGI::submit(-name=>"update", -style=>$these_widths. "; font-weight:bold", |
456 | CGI::submit(-name=>"update", -style=>$these_widths. "; font-weight:bold", |
| 456 | -value=>"Update"), |
457 | -value=>"Update Set"), |
| 457 | CGI::submit(-name=>"rerandomize", |
458 | CGI::submit(-name=>"rerandomize", |
| 458 | -style=>$these_widths, |
459 | -style=>$these_widths, |
| 459 | -value=>"Rerandomize"), |
460 | -value=>"Rerandomize"), |
| 460 | CGI::submit(-name=>"cleardisplay", |
461 | CGI::submit(-name=>"cleardisplay", |
| 461 | -style=>$these_widths, |
462 | -style=>$these_widths, |
| … | |
… | |
| 828 | |
829 | |
| 829 | } |
830 | } |
| 830 | |
831 | |
| 831 | |
832 | |
| 832 | sub title { |
833 | sub title { |
| 833 | return "Homework Set Maker"; |
834 | return "Library Browser"; |
| 834 | } |
835 | } |
| 835 | |
836 | |
| 836 | sub body { |
837 | sub body { |
| 837 | my ($self) = @_; |
838 | my ($self) = @_; |
| 838 | |
839 | |