| 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: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.16 2004/05/28 23:15:44 jj Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.17 2004/05/31 02:20:27 jj 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. |
| … | |
… | |
| 142 | my $j; |
142 | my $j; |
| 143 | for ($j=0; $j<scalar(@all_problem_directories); $j++) { |
143 | for ($j=0; $j<scalar(@all_problem_directories); $j++) { |
| 144 | $all_problem_directories[$j] =~ s|^$ce->{courseDirs}->{templates}/?||; |
144 | $all_problem_directories[$j] =~ s|^$ce->{courseDirs}->{templates}/?||; |
| 145 | } |
145 | } |
| 146 | @all_problem_directories = sort @all_problem_directories; |
146 | @all_problem_directories = sort @all_problem_directories; |
| 147 | unshift @all_problem_directories, ' -- Top -- ' if($includetop); |
147 | unshift @all_problem_directories, ' My Problems ' if($includetop); |
| 148 | return (\@all_problem_directories); |
148 | return (\@all_problem_directories); |
| 149 | } |
149 | } |
| 150 | |
150 | |
| 151 | ############# Everyone has a view problems line. Abstract it |
151 | ############# Everyone has a view problems line. Abstract it |
| 152 | sub view_problems_line { |
152 | sub view_problems_line { |
| … | |
… | |
| 359 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
359 | unshift @{$list_of_local_sets}, SELECT_SET_STRING; |
| 360 | $set_selected = SELECT_SET_STRING; |
360 | $set_selected = SELECT_SET_STRING; |
| 361 | } |
361 | } |
| 362 | |
362 | |
| 363 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Adding Problems to ", |
363 | print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, "Adding Problems to ", |
| 364 | CGI::b("Current Set: "), |
364 | CGI::b("Target Set: "), |
| 365 | CGI::popup_menu(-name=> 'local_sets', |
365 | CGI::popup_menu(-name=> 'local_sets', |
| 366 | -values=>$list_of_local_sets, |
366 | -values=>$list_of_local_sets, |
| 367 | -default=> $set_selected), |
367 | -default=> $set_selected), |
| 368 | CGI::submit(-name=>"edit_local", -value=>"Edit Current Set"), |
368 | CGI::submit(-name=>"edit_local", -value=>"Edit Target Set"), |
| 369 | CGI::br(), |
369 | CGI::br(), |
| 370 | CGI::br(), |
370 | CGI::br(), |
| 371 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
371 | CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", |
| 372 | #-onclick=>$myjs |
372 | #-onclick=>$myjs |
| 373 | ), |
373 | ), |
| … | |
… | |
| 487 | my $urlpath = $r->urlpath; |
487 | my $urlpath = $r->urlpath; |
| 488 | my $db = $r->db; |
488 | my $db = $r->db; |
| 489 | my $checkset = $db->getGlobalSet($r->param('local_sets')); |
489 | my $checkset = $db->getGlobalSet($r->param('local_sets')); |
| 490 | if (not defined($checkset)) { |
490 | if (not defined($checkset)) { |
| 491 | $self->{error} = 1; |
491 | $self->{error} = 1; |
| 492 | $self->addbadmessage('You need to select a "Current Set" before you can edit it.'); |
492 | $self->addbadmessage('You need to select a "Target Set" before you can edit it.'); |
| 493 | } else { |
493 | } else { |
| 494 | my $page = $urlpath->newFromModule('WeBWorK::ContentGenerator::Instructor::ProblemSetEditor', setID=>$r->param('local_sets'), courseID=>$urlpath->arg("courseID")); |
494 | my $page = $urlpath->newFromModule('WeBWorK::ContentGenerator::Instructor::ProblemSetEditor', setID=>$r->param('local_sets'), courseID=>$urlpath->arg("courseID")); |
| 495 | my $url = $self->systemLink($page); |
495 | my $url = $self->systemLink($page); |
| 496 | $self->reply_with_redirect($url); |
496 | $self->reply_with_redirect($url); |
| 497 | } |
497 | } |
| … | |
… | |
| 560 | |
560 | |
| 561 | my $set_to_display = $r->param('library_sets'); |
561 | my $set_to_display = $r->param('library_sets'); |
| 562 | if (not defined($set_to_display) or $set_to_display eq SELECT_LOCAL_STRING or $set_to_display eq "Found no directories containing problems") { |
562 | if (not defined($set_to_display) or $set_to_display eq SELECT_LOCAL_STRING or $set_to_display eq "Found no directories containing problems") { |
| 563 | $self->addbadmessage('You need to select a set to view.'); |
563 | $self->addbadmessage('You need to select a set to view.'); |
| 564 | } else { |
564 | } else { |
| 565 | $set_to_display = '.' if $set_to_display eq ' -- Top -- '; |
565 | $set_to_display = '.' if $set_to_display eq ' My Problems '; |
| 566 | @pg_files = list_pg_files($ce->{courseDirs}->{templates}, |
566 | @pg_files = list_pg_files($ce->{courseDirs}->{templates}, |
| 567 | "$set_to_display"); |
567 | "$set_to_display"); |
| 568 | $use_previous_problems=0; |
568 | $use_previous_problems=0; |
| 569 | } |
569 | } |
| 570 | |
570 | |
| … | |
… | |
| 661 | if (scalar(@selected)>0) { # if some are to be added, they need a place to go |
661 | if (scalar(@selected)>0) { # if some are to be added, they need a place to go |
| 662 | $localSet = $r->param('local_sets'); |
662 | $localSet = $r->param('local_sets'); |
| 663 | if (not defined($localSet) or |
663 | if (not defined($localSet) or |
| 664 | $localSet eq SELECT_SET_STRING or |
664 | $localSet eq SELECT_SET_STRING or |
| 665 | $localSet eq NO_LOCAL_SET_STRING) { |
665 | $localSet eq NO_LOCAL_SET_STRING) { |
| 666 | $self->addbadmessage('You are trying to add problems to something, but you did not select a "Current Set" name as a target.'); |
666 | $self->addbadmessage('You are trying to add problems to something, but you did not select a "Target Set" name as a target.'); |
| 667 | } else { |
667 | } else { |
| 668 | my $newSetRecord = $db->getGlobalSet($localSet); |
668 | my $newSetRecord = $db->getGlobalSet($localSet); |
| 669 | if (not defined($newSetRecord)) { |
669 | if (not defined($newSetRecord)) { |
| 670 | $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."); |
670 | $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."); |
| 671 | } else { |
671 | } else { |