From: jj v. a. <we...@ma...> - 2005-07-26 22:27:53
|
Log Message: ----------- Initial support for version 2 of the problem library. Modified Files: -------------- webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor: SetMaker.pm Revision Data ------------- Index: SetMaker.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v retrieving revision 1.41 retrieving revision 1.42 diff -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -Llib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm -u -r1.41 -r1.42 --- lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm +++ lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm @@ -56,7 +56,6 @@ 'headers' => 1, 'macros' => 1, 'email' => 1, ); -## ## This is for searching the disk for directories containing pg files. ## to make the recursion work, this returns an array where the first ## item is the number of pg files in the directory. The second is a @@ -75,7 +74,6 @@ ## menu). If it has a file called "=library-no-combine" then it is ## always listed as a separate directory even if it contains only one ## pg file. -## sub get_library_sets { my $top = shift; my $dir = shift; @@ -360,10 +358,11 @@ # # Incoming data - current chapter, current section sub browse_library_panel { - my $self = shift; + my $self=shift; my $r = $self->r; my $ce = $r->ce; - + + # See if the problem library is installed my $libraryRoot = $r->{ce}->{problemLibrary}->{root}; unless($libraryRoot) { @@ -371,7 +370,7 @@ "The problem library has not been installed."))); return; } - # Test if the Library directory exists. If not, try to make it + # Test if the Library directory link exists. If not, try to make it unless(-d "$ce->{courseDirs}->{templates}/Library") { unless(symlink($libraryRoot, "$ce->{courseDirs}->{templates}/Library")) { my $msg = <<"HERE"; @@ -385,6 +384,25 @@ } } + + # Now check what version we are supposed to use + my $libraryVersion = $r->{ce}->{problemLibrary}->{version} || 1; + if($libraryVersion == 1) { + return $self->browse_library_panel1; + } elsif($libraryVersion == 2) { + return $self->browse_library_panel2; + } else { + print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, + "The problem library version is set to an illegal value."))); + return; + } +} + +sub browse_library_panel1 { + my $self = shift; + my $r = $self->r; + my $ce = $r->ce; + my $default_chap = "All Chapters"; my $default_sect = "All Sections"; @@ -441,6 +459,51 @@ )); } +sub browse_library_panel2 { + my $self = shift; + my $r = $self->r; + my $ce = $r->ce; + + my $default_chap = "All Chapters"; + my $default_sect = "All Sections"; + + my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($ce); + unshift @chaps, $default_chap; + my $chapter_selected = $r->param('library_chapters') || $default_chap; + + my @sects=(); + if ($chapter_selected ne $default_chap) { + @sects = WeBWorK::Utils::ListingDB::getAllDBsections($ce, $chapter_selected); + } + unshift @sects, $default_sect; + my $section_selected = $r->param('library_sections') || $default_sect; + my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); + + print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, + CGI::start_table(), + CGI::Tr( + CGI::td(["Chapter:", + CGI::popup_menu(-name=> 'library_chapters', + -values=>\@chaps, + -default=> $chapter_selected, + -onchange=>"submit();return true" + ), + CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")])), + CGI::Tr( + CGI::td("Section:"), + CGI::td({-colspan=>2}, + CGI::popup_menu(-name=> 'library_sections', + -values=>\@sects, + -default=> $section_selected + ))), + CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), + CGI::end_table(), + )); + + +} + + ##### Version 4 is the set definition file panel sub browse_setdef_panel { |