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

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm

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

Revision 2944 Revision 2959
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: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.32 2004/10/21 01:22:51 sh002i 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.
75## pg file. 75## pg file.
76## 76##
77 77
78sub get_library_sets { 78sub get_library_sets {
79 my $top = shift; my $dir = shift; 79 my $top = shift; my $dir = shift;
80 my @lis = readDirectory($dir); my @pgdirs; 80 # ignore directories that give us an error
81 my @lis = eval { readDirectory($dir) };
82 if ($@) {
83 warn $@;
84 return (0);
85 }
81 return (0) if grep /^=library-ignore$/, @lis; 86 return (0) if grep /^=library-ignore$/, @lis;
82 87
88 my @pgdirs;
89
83 my $pgcount = scalar(grep { m/\.pg$/ and (not m/(Header|-text)\.pg$/) and -f "$dir/$_"} @lis); 90 my $pgcount = scalar(grep { m/\.pg$/ and (not m/(Header|-text)\.pg$/) and -f "$dir/$_"} @lis);
84 my $others = scalar(grep { (!m/\.pg$/ || m/(Header|-text)\.pg$/) && 91 my $others = scalar(grep { (!m/\.pg$/ || m/(Header|-text)\.pg$/) &&
85 !m/(\.(tmp|bak)|~)$/ && -f "$dir/$_" } @lis); 92 !m/(\.(tmp|bak)|~)$/ && -f "$dir/$_" } @lis);
86 93
87 my @dirs = grep {!$ignoredir{$_} and -d "$dir/$_"} @lis; 94 my @dirs = grep {!$ignoredir{$_} and -d "$dir/$_"} @lis;
425 CGI::br(), 432 CGI::br(),
426 CGI::br(), 433 CGI::br(),
427 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:",
428 -onclick=>$myjs 435 -onclick=>$myjs
429 ), 436 ),
430 " ", 437 " ",
431 CGI::textfield(-name=>"new_set_name", 438 CGI::textfield(-name=>"new_set_name",
432 -default=>"Name for new set here", 439 -default=>"Name for new set here",
433 -override=>1, -size=>30), 440 -override=>1, -size=>30),
434 CGI::br(), 441 CGI::br(),
435 )); 442 ));
697 704
698 ##### Make a new local problem set 705 ##### Make a new local problem set
699 706
700 } elsif ($r->param('new_local_set')) { 707 } elsif ($r->param('new_local_set')) {
701 if ($r->param('new_set_name') !~ /^[\w.-]*$/) { 708 if ($r->param('new_set_name') !~ /^[\w.-]*$/) {
702 $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."); 709 $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and .");
703 } else { 710 } else {
704 my $newSetName = $r->param('new_set_name'); 711 my $newSetName = $r->param('new_set_name');
705 $newSetName =~ s/^set//; 712 $newSetName =~ s/^set//;
706 $newSetName =~ s/\.def$//; 713 $newSetName =~ s/\.def$//;
707 $r->param('local_sets',$newSetName); 714 $r->param('local_sets',$newSetName);
708 my $newSetRecord = $db->getGlobalSet($newSetName); 715 my $newSetRecord = $db->getGlobalSet($newSetName);
709 if (defined($newSetRecord)) { 716 if (defined($newSetRecord)) {
710 $self->addbadmessage("The set name $newSetName is already in use. Pick a different name if you would like to start a new set."); 717 $self->addbadmessage("The set name $newSetName is already in use. Pick a different name if you would like to start a new set.");
711 } else { # Do it! 718 } else { # Do it!
712 $newSetRecord = $db->{set}->{record}->new(); 719 $newSetRecord = $db->{set}->{record}->new();
713 $newSetRecord->set_id($newSetName); 720 $newSetRecord->set_id($newSetName);
714 $newSetRecord->set_header(""); 721 $newSetRecord->set_header("");
715 $newSetRecord->hardcopy_header(""); 722 $newSetRecord->hardcopy_header("");
747 if (not defined($localSet) or 754 if (not defined($localSet) or
748 $localSet eq SELECT_SET_STRING or 755 $localSet eq SELECT_SET_STRING or
749 $localSet eq NO_LOCAL_SET_STRING) { 756 $localSet eq NO_LOCAL_SET_STRING) {
750 $self->addbadmessage('You are trying to add problems to something, but you did not select a "Target Set" name as a target.'); 757 $self->addbadmessage('You are trying to add problems to something, but you did not select a "Target Set" name as a target.');
751 } else { 758 } else {
752 my $newSetRecord = $db->getGlobalSet($localSet); 759 my $newSetRecord = $db->getGlobalSet($localSet);
753 if (not defined($newSetRecord)) { 760 if (not defined($newSetRecord)) {
754 $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."); 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.");
755 } else { 762 } else {
756 my $addcount = add_selected($self, $db, $localSet); 763 my $addcount = add_selected($self, $db, $localSet);
757 if($addcount > 0) { 764 if($addcount > 0) {
758 $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':''). 765 $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':'').
759 " to $localSet."); 766 " to $localSet.");
853 } 860 }
854 861
855 ########## Extract information computed in pre_header_initialize 862 ########## Extract information computed in pre_header_initialize
856 863
857 my $first_shown = $self->{first_shown}; 864 my $first_shown = $self->{first_shown};
858 my $last_shown = $self->{last_shown}; 865 my $last_shown = $self->{last_shown};
859 my $browse_which = $self->{browse_which}; 866 my $browse_which = $self->{browse_which};
860 my $problem_seed = $self->{problem_seed}; 867 my $problem_seed = $self->{problem_seed};
861 my @pg_files = @{$self->{pg_files}}; 868 my @pg_files = @{$self->{pg_files}};
862 my @all_set_defs = @{$self->{all_set_defs}}; 869 my @all_set_defs = @{$self->{all_set_defs}};
863 870

Legend:
Removed from v.2944  
changed lines
  Added in v.2959

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9