Parent Directory
|
Revision Log
added the grid and preview features to library browser 2
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.85 2008/07/01 13:18:52 glarose Exp $ 5 # 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 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. 10 # 11 # This program is distributed in the hope that it will be useful, but WITHOUT 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the 14 # Artistic License for more details. 15 ################################################################################ 16 17 18 package WeBWorK::ContentGenerator::Instructor::SetMaker2; 19 use base qw(WeBWorK::ContentGenerator::Instructor); 20 21 =head1 NAME 22 23 WeBWorK::ContentGenerator::Instructor::SetMaker2 - Make homework sets. 24 25 =cut 26 27 use strict; 28 use warnings; 29 30 31 #use CGI qw(-nosticky); 32 use WeBWorK::CGI; 33 use WeBWorK::Debug; 34 use WeBWorK::Form; 35 use WeBWorK::Utils qw(readDirectory max sortByName); 36 use WeBWorK::Utils::Tasks qw(renderProblems); 37 use File::Find; 38 39 require WeBWorK::Utils::ListingDB; 40 41 use constant SHOW_HINTS_DEFAULT => 0; 42 use constant SHOW_SOLUTIONS_DEFAULT => 0; 43 use constant MAX_SHOW_DEFAULT => 20; 44 use constant NO_LOCAL_SET_STRING => 'No sets in this course yet'; 45 use constant SELECT_SET_STRING => 'Select a Set from this Course'; 46 use constant SELECT_LOCAL_STRING => 'Select a Problem Collection'; 47 use constant MY_PROBLEMS => ' My Problems '; 48 use constant MAIN_PROBLEMS => ' Unclassified Problems '; 49 use constant CREATE_SET_BUTTON => 'Create New Set'; 50 use constant ALL_CHAPTERS => 'All Chapters'; 51 use constant ALL_SUBJECTS => 'All Subjects'; 52 use constant ALL_SECTIONS => 'All Sections'; 53 use constant ALL_TEXTBOOKS => 'All Textbooks'; 54 55 use constant LIB2_DATA => { 56 'dbchapter' => {name => 'library_chapters', all => 'All Chapters'}, 57 'dbsection' => {name => 'library_sections', all =>'All Sections' }, 58 'dbsubject' => {name => 'library_subjects', all => 'All Subjects' }, 59 'textbook' => {name => 'library_textbook', all => 'All Textbooks'}, 60 'textchapter' => {name => 'library_textchapter', all => 'All Chapters'}, 61 'textsection' => {name => 'library_textsection', all => 'All Sections'}, 62 'keywords' => {name => 'library_keywords', all => '' }, 63 }; 64 65 ## Flags for operations on files 66 67 use constant ADDED => 1; 68 use constant HIDDEN => (1 << 1); 69 use constant SUCCESS => (1 << 2); 70 use constant DELETED => (1 << 3); 71 use constant MOVED => (1 << 4); 72 73 ## for additional problib buttons 74 my %problib; ## filled in in global.conf 75 my %ignoredir = ( 76 '.' => 1, '..' => 1, 'Library' => 1, 'CVS' => 1, 'tmpEdit' => 1, 77 'headers' => 1, 'macros' => 1, 'email' => 1, '.svn' => 1, 78 ); 79 80 sub prepare_activity_entry { 81 my $self=shift; 82 my $r = $self->r; 83 my $user = $self->r->param('user') || 'NO_USER'; 84 return("In SetMaker as user $user"); 85 } 86 87 ## This is for searching the disk for directories containing pg files. 88 ## to make the recursion work, this returns an array where the first 89 ## item is the number of pg files in the directory. The second is a 90 ## list of directories which contain pg files. 91 ## 92 ## If a directory contains only one pg file and the directory name 93 ## is the same as the file name, then the directory is considered 94 ## to be part of the parent directory (it is probably in a separate 95 ## directory only because it has auxiliary files that want to be 96 ## kept together with the pg file). 97 ## 98 ## If a directory has a file named "=library-ignore", it is never 99 ## included in the directory menu. If a directory contains a file 100 ## called "=library-combine-up", then its pg are included with those 101 ## in the parent directory (and the directory does not appear in the 102 ## menu). If it has a file called "=library-no-combine" then it is 103 ## always listed as a separate directory even if it contains only one 104 ## pg file. 105 106 sub get_library_sets { 107 my $top = shift; my $dir = shift; 108 # ignore directories that give us an error 109 my @lis = eval { readDirectory($dir) }; 110 if ($@) { 111 warn $@; 112 return (0); 113 } 114 return (0) if grep /^=library-ignore$/, @lis; 115 116 my @pgfiles = grep { m/\.pg$/ and (not m/(Header|-text)\.pg$/) and -f "$dir/$_"} @lis; 117 my $pgcount = scalar(@pgfiles); 118 my $pgname = $dir; $pgname =~ s!.*/!!; $pgname .= '.pg'; 119 my $combineUp = ($pgcount == 1 && $pgname eq $pgfiles[0] && !(grep /^=library-no-combine$/, @lis)); 120 121 my @pgdirs; 122 my @dirs = grep {!$ignoredir{$_} and -d "$dir/$_"} @lis; 123 if ($top == 1) {@dirs = grep {!$problib{$_}} @dirs} 124 foreach my $subdir (@dirs) { 125 my @results = get_library_sets(0, "$dir/$subdir"); 126 $pgcount += shift @results; push(@pgdirs,@results); 127 } 128 129 return ($pgcount, @pgdirs) if $top || $combineUp || grep /^=library-combine-up$/, @lis; 130 return (0,@pgdirs,$dir); 131 } 132 133 sub get_library_pgs { 134 my $top = shift; my $base = shift; my $dir = shift; 135 my @lis = readDirectory("$base/$dir"); 136 return () if grep /^=library-ignore$/, @lis; 137 return () if !$top && grep /^=library-no-combine$/, @lis; 138 139 my @pgs = grep { m/\.pg$/ and (not m/(Header|-text)\.pg$/) and -f "$base/$dir/$_"} @lis; 140 my $others = scalar(grep { (!m/\.pg$/ || m/(Header|-text)\.pg$/) && 141 !m/(\.(tmp|bak)|~)$/ && -f "$base/$dir/$_" } @lis); 142 143 my @dirs = grep {!$ignoredir{$_} and -d "$base/$dir/$_"} @lis; 144 if ($top == 1) {@dirs = grep {!$problib{$_}} @dirs} 145 foreach my $subdir (@dirs) {push(@pgs, get_library_pgs(0,"$base/$dir",$subdir))} 146 147 return () unless $top || (scalar(@pgs) == 1 && $others) || grep /^=library-combine-up$/, @lis; 148 return (map {"$dir/$_"} @pgs); 149 } 150 151 sub list_pg_files { 152 my ($templates,$dir) = @_; 153 my $top = ($dir eq '.')? 1 : 2; 154 my @pgs = get_library_pgs($top,$templates,$dir); 155 return sortByName(undef,@pgs); 156 } 157 158 ## Search for set definition files 159 160 sub get_set_defs { 161 my $topdir = shift; 162 my @found_set_defs; 163 # get_set_defs_wanted is a closure over @found_set_defs 164 my $get_set_defs_wanted = sub { 165 #my $fn = $_; 166 #my $fdir = $File::Find::dir; 167 #return() if($fn !~ /^set.*\.def$/); 168 ##return() if(not -T $fn); 169 #push @found_set_defs, "$fdir/$fn"; 170 push @found_set_defs, $_ if m|/set[^/]*\.def$|; 171 }; 172 find({ wanted => $get_set_defs_wanted, follow_fast=>1, no_chdir=>1}, $topdir); 173 map { $_ =~ s|^$topdir/?|| } @found_set_defs; 174 return @found_set_defs; 175 } 176 177 ## Try to make reading of set defs more flexible. Additional strategies 178 ## for fixing a path can be added here. 179 180 sub munge_pg_file_path { 181 my $self = shift; 182 my $pg_path = shift; 183 my $path_to_set_def = shift; 184 my $end_path = $pg_path; 185 # if the path is ok, don't fix it 186 return($pg_path) if(-e $self->r->ce->{courseDirs}{templates}."/$pg_path"); 187 # if we have followed a link into a self contained course to get 188 # to the set.def file, we need to insert the start of the path to 189 # the set.def file 190 $end_path = "$path_to_set_def/$pg_path"; 191 return($end_path) if(-e $self->r->ce->{courseDirs}{templates}."/$end_path"); 192 # if we got this far, this path is bad, but we let it produce 193 # an error so the user knows there is a troublesome path in the 194 # set.def file. 195 return($pg_path); 196 } 197 198 ## Read a set definition file. This could be abstracted since it happens 199 ## elsewhere. Here we don't have to process so much of the file. 200 201 sub read_set_def { 202 my $self = shift; 203 my $r = $self->r; 204 my $filePathOrig = shift; 205 my $filePath = $r->ce->{courseDirs}{templates}."/$filePathOrig"; 206 $filePathOrig =~ s/set.*\.def$//; 207 $filePathOrig =~ s|/$||; 208 $filePathOrig = "." if ($filePathOrig !~ /\S/); 209 my @pg_files = (); 210 my ($line, $got_to_pgs, $name, @rest) = ("", 0, ""); 211 if ( open (SETFILENAME, "$filePath") ) { 212 while($line = <SETFILENAME>) { 213 chomp($line); 214 $line =~ s|(#.*)||; # don't read past comments 215 if($got_to_pgs) { 216 unless ($line =~ /\S/) {next;} # skip blank lines 217 ($name,@rest) = split (/\s*,\s*/,$line); 218 $name =~ s/\s*//g; 219 push @pg_files, $name; 220 } else { 221 $got_to_pgs = 1 if ($line =~ /problemList\s*=/); 222 } 223 } 224 } else { 225 $self->addbadmessage("Cannot open $filePath"); 226 } 227 # This is where we would potentially munge the pg file paths 228 # One possibility 229 @pg_files = map { $self->munge_pg_file_path($_, $filePathOrig) } @pg_files; 230 return(@pg_files); 231 } 232 233 ## go through past page getting a list of identifiers for the problems 234 ## and whether or not they are selected, and whether or not they should 235 ## be hidden 236 237 sub get_past_problem_files { 238 my $r = shift; 239 my @found=(); 240 my $count =1; 241 while (defined($r->param("filetrial$count"))) { 242 my $val = 0; 243 $val |= ADDED if($r->param("trial$count")); 244 $val |= HIDDEN if($r->param("hideme$count")); 245 $val |= MOVED if($r->param("moved$count")); 246 push @found, [$r->param("filetrial$count"), $val]; 247 $count++; 248 } 249 $count = 1; 250 while (defined($r->param("mysetfiletrial$count"))) { 251 my $val = 0; 252 $val |= DELETED if($r->param("deleted$count")); 253 push @found, [$r->param("mysetfiletrial$count"), $val]; 254 $count++; 255 } 256 return(\@found); 257 } 258 259 #### For adding new problems 260 261 sub add_selected { 262 my $self = shift; 263 my $db = shift; 264 my $setName = shift; 265 my @past_problems = @{$self->{past_problems}}; 266 my @selected = @past_problems; 267 my (@path, $file, $selected, $freeProblemID); 268 # DBFIXME count would work just as well 269 $freeProblemID = max($db->listGlobalProblems($setName)) + 1; 270 my $addedcount=0; 271 272 for $selected (@selected) { 273 if($selected->[1] & ADDED || $selected->[1] & MOVED) { 274 $file = $selected->[0]; 275 #print "$file"; 276 my $problemRecord = $self->addProblemToSet(setName => $setName, 277 sourceFile => $file, problemID => $freeProblemID); 278 $freeProblemID++; 279 $self->assignProblemToAllSetUsers($problemRecord); 280 if(!($selected->[1] & MOVED)){ 281 $selected->[1] |= SUCCESS; 282 } 283 $addedcount++; 284 } 285 } 286 return($addedcount); 287 } 288 289 sub delete_selected { 290 my $self = shift; 291 my $db = shift; 292 my $setName = shift; 293 my @past_problems = @{$self->{past_problems}}; 294 my @selected = @past_problems; 295 my (@path, $file, $selected); 296 # DBFIXME count would work just as well 297 my $deletedcount=0; 298 299 for $selected (@selected) { 300 if($selected->[1] & DELETED || $selected->[1] & MOVED) { 301 foreach my $problem ($db->listGlobalProblems($setName)) { 302 my $problemRecord = $db->getGlobalProblem($setName, $problem); 303 if($problemRecord->source_file eq $selected->[0]){ 304 $db->deleteGlobalProblem($setName, $problemRecord->problem_id); 305 } 306 } 307 if(!($selected->[1] & MOVED)){ 308 $selected->[1] |= SUCCESS; 309 } 310 $deletedcount++; 311 } 312 } 313 return($deletedcount); 314 } 315 316 317 ############# List of sets of problems in templates directory 318 319 sub get_problem_directories { 320 my $ce = shift; 321 my $lib = shift; 322 my $source = $ce->{courseDirs}{templates}; 323 my $main = MY_PROBLEMS; my $isTop = 1; 324 if ($lib) {$source .= "/$lib"; $main = MAIN_PROBLEMS; $isTop = 2} 325 my @all_problem_directories = get_library_sets($isTop, $source); 326 my $includetop = shift @all_problem_directories; 327 my $j; 328 for ($j=0; $j<scalar(@all_problem_directories); $j++) { 329 $all_problem_directories[$j] =~ s|^$ce->{courseDirs}->{templates}/?||; 330 } 331 @all_problem_directories = sortByName(undef, @all_problem_directories); 332 unshift @all_problem_directories, $main if($includetop); 333 return (\@all_problem_directories); 334 } 335 336 ############# Everyone has a view problems line. Abstract it 337 sub view_problems_line { 338 my $internal_name = shift; 339 my $label = shift; 340 my $r = shift; # so we can get parameter values 341 my $result = CGI::submit(-name=>"$internal_name", -value=>$label); 342 343 my %display_modes = %{WeBWorK::PG::DISPLAY_MODES()}; 344 my @active_modes = grep { exists $display_modes{$_} } 345 @{$r->ce->{pg}->{displayModes}}; 346 push @active_modes, 'None'; 347 # We have our own displayMode since its value may be None, which is illegal 348 # in other modules. 349 my $mydisplayMode = $r->param('mydisplayMode') || $r->ce->{pg}->{options}->{displayMode}; 350 $result .= ' Display Mode: '.CGI::popup_menu(-name=> 'mydisplayMode', 351 -values=>\@active_modes, 352 -default=> $mydisplayMode); 353 # Now we give a choice of the number of problems to show 354 my $defaultMax = $r->param('max_shown') || MAX_SHOW_DEFAULT; 355 $result .= ' Max. Shown: '. 356 CGI::popup_menu(-name=> 'max_shown', 357 -values=>[5,10,15,20,25,30,50,'All'], 358 -default=> $defaultMax); 359 # Option of whether to show hints and solutions 360 my $defaultHints = $r->param('showHints') || SHOW_HINTS_DEFAULT; 361 $result .= " ".CGI::checkbox(-name=>"showHints",-checked=>$defaultHints,-label=>"Hints"); 362 my $defaultSolutions = $r->param('showSolutions') || SHOW_SOLUTIONS_DEFAULT; 363 $result .= " ".CGI::checkbox(-name=>"showSolutions",-checked=>$defaultSolutions,-label=>"Solutions"); 364 365 return($result); 366 } 367 368 369 ### The browsing panel has three versions 370 ##### Version 1 is local problems 371 sub browse_local_panel { 372 my $self = shift; 373 my $library_selected = shift; 374 my $lib = shift || ''; $lib =~ s/^browse_//; 375 my $name = ($lib eq '')? 'Local' : $problib{$lib}; 376 377 my $list_of_prob_dirs= get_problem_directories($self->r->ce,$lib); 378 if(scalar(@$list_of_prob_dirs) == 0) { 379 $library_selected = "Found no directories containing problems"; 380 unshift @{$list_of_prob_dirs}, $library_selected; 381 } else { 382 my $default_value = SELECT_LOCAL_STRING; 383 if (not $library_selected or $library_selected eq $default_value) { 384 unshift @{$list_of_prob_dirs}, $default_value; 385 $library_selected = $default_value; 386 } 387 } 388 debug("library is $lib and sets are $library_selected"); 389 my $view_problem_line = view_problems_line('view_local_set', 'View Problems', $self->r); 390 my @popup_menu_args = ( 391 -name => 'library_sets', 392 -values => $list_of_prob_dirs, 393 -default => $library_selected, 394 ); 395 # make labels without the $lib prefix -- reduces the width of the popup menu 396 if (length($lib)) { 397 my %labels = map { my($l)=$_=~/^$lib\/(.*)$/;$_=>$l } @$list_of_prob_dirs; 398 push @popup_menu_args, -labels => \%labels; 399 } 400 print CGI::div({-class=>"InfoPanel", -align=>"left"}, "$name Problems: ", 401 CGI::popup_menu(@popup_menu_args), 402 CGI::br(), 403 $view_problem_line, 404 ); 405 } 406 407 ##### Version 2 is local homework sets 408 sub browse_mysets_panel { 409 my $self = shift; 410 my $library_selected = shift; 411 my $list_of_local_sets = shift; 412 my $remember_local_set = shift; 413 my $default_value = "Select a Homework Set"; 414 415 if(scalar(@$list_of_local_sets) == 0) { 416 $list_of_local_sets = [NO_LOCAL_SET_STRING]; 417 } elsif (not $library_selected or $library_selected eq $default_value) { 418 unshift @{$list_of_local_sets}, $default_value; 419 $library_selected = $default_value; 420 } 421 422 #my $view_problem_line = view_problems_line('view_mysets_set', 'View Problems', $self->r); 423 print CGI::div({-class=>"InfoPanel", -align=>"left"}, 424 CGI::submit(-name=>"update", -style=>"width: 25ex; font-weight:bold;", 425 -value=>"Update Set"), 426 CGI::popup_menu(-name=> 'myset_sets', 427 -values=>$list_of_local_sets, 428 -default=> $library_selected), 429 CGI::hidden(-name=> 'local_sets', -value=>$remember_local_set), 430 CGI::br(), 431 CGI::submit(-name=>"view_mysets_set", -value=>"View Set"), 432 ); 433 } 434 435 ##### Version 2.1 is local homework sets 436 sub edit_mysets_panel { 437 my $self = shift; 438 my $library_selected = shift; 439 my $list_of_local_sets = shift; 440 my $default_value = "Select a Homework Set"; 441 442 if(scalar(@$list_of_local_sets) == 0) { 443 $list_of_local_sets = [NO_LOCAL_SET_STRING]; 444 } elsif (not $library_selected or $library_selected eq $default_value) { 445 unshift @{$list_of_local_sets}, $default_value; 446 $library_selected = $default_value; 447 } 448 449 my $view_problem_line = view_problems_line('edit_mysets_set', 'View Problems', $self->r); 450 print CGI::Tr({}, 451 CGI::td({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", 452 CGI::popup_menu(-name=> 'library_sets', 453 -values=>$list_of_local_sets, 454 -default=> $library_selected), 455 CGI::br(), 456 $view_problem_line 457 )); 458 } 459 460 ##### Version 3 is the problem library 461 # 462 # This comes in 3 forms, problem library version 1, and for version 2 there 463 # is the basic, and the advanced interfaces. This function checks what we are 464 # supposed to do, or aborts if the problem library has not been installed. 465 466 sub browse_library_panel { 467 my $self=shift; 468 my $r = $self->r; 469 my $ce = $r->ce; 470 471 # See if the problem library is installed 472 my $libraryRoot = $r->{ce}->{problemLibrary}->{root}; 473 474 unless($libraryRoot) { 475 print CGI::div({class=>'ResultsWithError', align=>"center"}, 476 "The problem library has not been installed."); 477 return; 478 } 479 # Test if the Library directory link exists. If not, try to make it 480 unless(-d "$ce->{courseDirs}->{templates}/Library") { 481 unless(symlink($libraryRoot, "$ce->{courseDirs}->{templates}/Library")) { 482 my $msg = <<"HERE"; 483 You are missing the directory <code>templates/Library</code>, which is needed 484 for the Problem Library to function. It should be a link pointing to 485 <code>$libraryRoot</code>, which you set in <code>conf/global.conf</code>. 486 I tried to make the link for you, but that failed. Check the permissions 487 in your <code>templates</code> directory. 488 HERE 489 $self->addbadmessage($msg); 490 } 491 } 492 493 # Now check what version we are supposed to use 494 my $libraryVersion = $r->{ce}->{problemLibrary}->{version} || 1; 495 if($libraryVersion == 1) { 496 return $self->browse_library_panel1; 497 } elsif($libraryVersion == 2) { 498 return $self->browse_library_panel2 if($self->{library_basic}==1); 499 return $self->browse_library_panel2adv; 500 } else { 501 print CGI::div({class=>'ResultsWithError', align=>"center"}, 502 "The problem library version is set to an illegal value."); 503 return; 504 } 505 } 506 507 sub browse_library_panel1 { 508 my $self = shift; 509 my $r = $self->r; 510 my $ce = $r->ce; 511 512 my @chaps = WeBWorK::Utils::ListingDB::getAllChapters($r->{ce}); 513 unshift @chaps, LIB2_DATA->{dbchapter}{all}; 514 my $chapter_selected = $r->param('library_chapters') || LIB2_DATA->{dbchapter}->{all}; 515 516 my @sects=(); 517 if ($chapter_selected ne LIB2_DATA->{dbchapter}{all}) { 518 @sects = WeBWorK::Utils::ListingDB::getAllSections($r->{ce}, $chapter_selected); 519 } 520 521 unshift @sects, ALL_SECTIONS; 522 my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; 523 524 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 525 526 print CGI::div({-class=>"InfoPanel", -align=>"left"}, 527 CGI::div(["Chapter:", 528 CGI::popup_menu(-name=> 'library_chapters', 529 -values=>\@chaps, 530 -default=> $chapter_selected, 531 -onchange=>"submit();return true" 532 ), 533 CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")]), 534 CGI::div("Section:", 535 CGI::popup_menu(-name=> 'library_sections', 536 -values=>\@sects, 537 -default=> $section_selected 538 )), 539 CGI::div($view_problem_line) 540 ); 541 } 542 543 sub browse_library_panel2 { 544 my $self = shift; 545 my $r = $self->r; 546 my $ce = $r->ce; 547 548 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); 549 unshift @subjs, LIB2_DATA->{dbsubject}{all}; 550 551 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); 552 unshift @chaps, LIB2_DATA->{dbchapter}{all}; 553 554 my @sects=(); 555 @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); 556 unshift @sects, LIB2_DATA->{dbsection}{all}; 557 558 my $subject_selected = $r->param('library_subjects') || LIB2_DATA->{dbsubject}{all}; 559 my $chapter_selected = $r->param('library_chapters') || LIB2_DATA->{dbchapter}{all}; 560 my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all}; 561 562 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 563 564 my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); 565 if($count_line==0) { 566 $count_line = "There are no matching pg files"; 567 } else { 568 $count_line = "There are $count_line matching WeBWorK problem files"; 569 } 570 571 print CGI::div({-class=>"InfoPanel", -align=>"left"}, 572 CGI::hidden(-name=>"library_is_basic", -default=>1,-override=>1), 573 CGI::div({-style=>"float:left;"},["Subject:", 574 CGI::popup_menu(-name=> 'library_subjects', 575 -values=>\@subjs, 576 -default=> $subject_selected, 577 -onchange=>"submit();return true;" 578 )]), 579 CGI::div({-style=>"float:left;"},["Chapter:", 580 CGI::popup_menu(-name=> 'library_chapters', 581 -values=>\@chaps, 582 -default=> $chapter_selected, 583 -onchange=>"submit();return true;" 584 )]), 585 CGI::div({-style=>"float:left;"},["Section:", 586 CGI::popup_menu(-name=> 'library_sections', 587 -values=>\@sects, 588 -default=> $section_selected, 589 -onchange=>"submit();return true" 590 )]), 591 CGI::div({-colspan=>2, -align=>"right"}, 592 CGI::submit(-name=>"library_advanced", -value=>"Advanced Search")), 593 CGI::div({-colspan=>2, -align=>"right"}, 594 CGI::submit(-name=>"lib_select_subject", -value=>"Update Chapter/Section Lists")), 595 CGI::div({-colspan=>3}, $view_problem_line), 596 CGI::div({-colspan=>3, -align=>"center"}, $count_line) 597 ); 598 599 } 600 601 sub browse_library_panel2adv { 602 my $self = shift; 603 my $r = $self->r; 604 my $ce = $r->ce; 605 my $right_button_style = "width: 18ex"; 606 607 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); 608 if(! grep { $_ eq $r->param('library_subjects') } @subjs) { 609 $r->param('library_subjects', ''); 610 } 611 unshift @subjs, LIB2_DATA->{dbsubject}{all}; 612 613 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); 614 if(! grep { $_ eq $r->param('library_chapters') } @chaps) { 615 $r->param('library_chapters', ''); 616 } 617 unshift @chaps, LIB2_DATA->{dbchapter}{all}; 618 619 my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); 620 if(! grep { $_ eq $r->param('library_sections') } @sects) { 621 $r->param('library_sections', ''); 622 } 623 unshift @sects, LIB2_DATA->{dbsection}{all}; 624 625 my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r); 626 my @textarray = map { $_->[0] } @{$texts}; 627 my %textlabels = (); 628 for my $ta (@{$texts}) { 629 $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")"; 630 } 631 if(! grep { $_ eq $r->param('library_textbook') } @textarray) { 632 $r->param('library_textbook', ''); 633 } 634 unshift @textarray, LIB2_DATA->{textbook}{all}; 635 my $atb = LIB2_DATA->{textbook}{all}; $textlabels{$atb} = LIB2_DATA->{textbook}{all}; 636 637 my $textchap_ref = WeBWorK::Utils::ListingDB::getDBTextbooks($r, 'textchapter'); 638 my @textchaps = map { $_->[0] } @{$textchap_ref}; 639 if(! grep { $_ eq $r->param('library_textchapter') } @textchaps) { 640 $r->param('library_textchapter', ''); 641 } 642 unshift @textchaps, LIB2_DATA->{textchapter}{all}; 643 644 my $textsec_ref = WeBWorK::Utils::ListingDB::getDBTextbooks($r, 'textsection'); 645 my @textsecs = map { $_->[0] } @{$textsec_ref}; 646 if(! grep { $_ eq $r->param('library_textsection') } @textsecs) { 647 $r->param('library_textsection', ''); 648 } 649 unshift @textsecs, LIB2_DATA->{textsection}{all}; 650 651 my %selected = (); 652 for my $j (qw( dbsection dbchapter dbsubject textbook textchapter textsection )) { 653 $selected{$j} = $r->param(LIB2_DATA->{$j}{name}) || LIB2_DATA->{$j}{all}; 654 } 655 656 my $text_popup = CGI::popup_menu(-name => 'library_textbook', 657 -values =>\@textarray, 658 -labels => \%textlabels, 659 -default=>$selected{textbook}, 660 -onchange=>"submit();return true"); 661 662 663 my $library_keywords = $r->param('library_keywords') || ''; 664 665 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 666 667 my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r); 668 if($count_line==0) { 669 $count_line = "There are no matching pg files"; 670 } else { 671 $count_line = "There are $count_line matching WeBWorK problem files"; 672 } 673 674 print CGI::div({-class=>"InfoPanel", -align=>"left"}, 675 CGI::hidden(-name=>"library_is_basic", -default=>2,-override=>1), 676 # Html done by hand since it is temporary 677 CGI::div({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"'), 678 CGI::div(["Subject:", 679 CGI::popup_menu(-name=> 'library_subjects', 680 -values=>\@subjs, 681 -default=> $selected{dbsubject}, 682 -onchange=>"submit();return true" 683 )]), 684 CGI::div({-colspan=>2, -align=>"right"}, 685 CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus", 686 -style=> $right_button_style)), 687 CGI::div(["Chapter:", 688 CGI::popup_menu(-name=> 'library_chapters', 689 -values=>\@chaps, 690 -default=> $selected{dbchapter}, 691 -onchange=>"submit();return true" 692 )]), 693 CGI::div({-colspan=>2, -align=>"right"}, 694 CGI::submit(-name=>"library_reset", -value=>"Reset", 695 -style=>$right_button_style)), 696 CGI::div(["Section:", 697 CGI::popup_menu(-name=> 'library_sections', 698 -values=>\@sects, 699 -default=> $selected{dbsection}, 700 -onchange=>"submit();return true" 701 )]), 702 CGI::div({-colspan=>2, -align=>"right"}, 703 CGI::submit(-name=>"library_basic", -value=>"Basic Search", 704 -style=>$right_button_style)), 705 CGI::div(["Textbook:", $text_popup]), 706 CGI::div(["Text chapter:", 707 CGI::popup_menu(-name=> 'library_textchapter', 708 -values=>\@textchaps, 709 -default=> $selected{textchapter}, 710 -onchange=>"submit();return true" 711 )]), 712 CGI::div(["Text section:", 713 CGI::popup_menu(-name=> 'library_textsection', 714 -values=>\@textsecs, 715 -default=> $selected{textsection}, 716 -onchange=>"submit();return true" 717 )]), 718 CGI::div("Keywords:"),CGI::div({-colspan=>2}, 719 CGI::textfield(-name=>"library_keywords", 720 -default=>$library_keywords, 721 -override=>1, 722 -size=>40)), 723 CGI::div({-colspan=>3}, $view_problem_line), 724 CGI::div({-colspan=>3, -align=>"center"}, $count_line) 725 ); 726 727 } 728 729 730 ##### Version 4 is the set definition file panel 731 732 sub browse_setdef_panel { 733 my $self = shift; 734 my $r = $self->r; 735 my $ce = $r->ce; 736 my $library_selected = shift; 737 my $default_value = "Select a Set Definition File"; 738 # in the following line, the parens after sort are important. if they are 739 # omitted, sort will interpret get_set_defs as the name of the comparison 740 # function, and ($ce->{courseDirs}{templates}) as a single element list to 741 # be sorted. *barf* 742 my @list_of_set_defs = sort(get_set_defs($ce->{courseDirs}{templates})); 743 if(scalar(@list_of_set_defs) == 0) { 744 @list_of_set_defs = (NO_LOCAL_SET_STRING); 745 } elsif (not $library_selected or $library_selected eq $default_value) { 746 unshift @list_of_set_defs, $default_value; 747 $library_selected = $default_value; 748 } 749 my $view_problem_line = view_problems_line('view_setdef_set', 'View Problems', $self->r); 750 my $popupetc = CGI::popup_menu(-name=> 'library_sets', 751 -values=>\@list_of_set_defs, 752 -default=> $library_selected). 753 CGI::br(). $view_problem_line; 754 if($list_of_set_defs[0] eq NO_LOCAL_SET_STRING) { 755 $popupetc = "there are no set definition files in this course to look at." 756 } 757 print CGI::div({-class=>"InfoPanel", -align=>"left"}, "Browse from: ", 758 $popupetc 759 ); 760 } 761 762 sub make_mysets_row { 763 my $self = shift; 764 my $r = $self->r; 765 my $ce = $r->ce; 766 my %data = @_; 767 768 my $list_of_local_sets = $data{all_db_sets}; 769 my $have_local_sets = scalar(@$list_of_local_sets); 770 my $browse_which = 'browse_mysets'; 771 my $library_selected = $self->{current_myset_set}; 772 my $set_selected = $r->param('myset_sets'); 773 my $remember_local_set = $r->param('local_sets'); 774 775 ## Make buttons for additional problem libraries 776 #my $libs = ''; 777 #foreach my $lib (sort(keys(%problib))) { 778 # $libs .= ' '. CGI::submit(-name=>"browse_$lib", -value=>$problib{$lib}, 779 # ($browse_which eq "browse_$lib")? (-disabled=>1): ()) 780 # if (-d "$ce->{courseDirs}{templates}/$lib"); 781 #} 782 #$libs = CGI::br()."or Problems from".$libs if $libs ne ''; 783 784 my $these_widths = "width: 25ex"; 785 786 if($have_local_sets ==0) { 787 $list_of_local_sets = [NO_LOCAL_SET_STRING]; 788 } elsif (not defined($set_selected) or $set_selected eq "" 789 or $set_selected eq SELECT_SET_STRING) { 790 unshift @{$list_of_local_sets}, SELECT_SET_STRING; 791 $set_selected = SELECT_SET_STRING; 792 } 793 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;'; 794 795 # Tidy this list up since it is used in two different places 796 if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { 797 shift @{$list_of_local_sets}; 798 } 799 800 #print CGI::div(CGI::div({-bgcolor=>"black"})); 801 #print CGI::hr(); 802 803 $self->browse_mysets_panel($library_selected, $list_of_local_sets, $remember_local_set); 804 } 805 806 sub make_top_row { 807 my $self = shift; 808 my $r = $self->r; 809 my $ce = $r->ce; 810 my %data = @_; 811 812 my $list_of_local_sets = $data{all_db_sets}; 813 my $have_local_sets = scalar(@$list_of_local_sets); 814 my $browse_which = $data{browse_which}; 815 my $library_selected = $self->{current_library_set}; 816 my $set_selected = $r->param('local_sets'); 817 my (@dis1, @dis2, @dis3, @dis4) = (); 818 @dis1 = (-disabled=>1) if($browse_which eq 'browse_npl_library'); 819 @dis2 = (-disabled=>1) if($browse_which eq 'browse_local'); 820 @dis3 = (-disabled=>1) if($browse_which eq 'edit_mysets'); 821 @dis4 = (-disabled=>1) if($browse_which eq 'browse_setdefs'); 822 823 ## Make buttons for additional problem libraries 824 my $libs = ''; 825 foreach my $lib (sort(keys(%problib))) { 826 $libs .= ' '. CGI::submit(-name=>"browse_$lib", -value=>$problib{$lib}, 827 ($browse_which eq "browse_$lib")? (-disabled=>1): ()) 828 if (-d "$ce->{courseDirs}{templates}/$lib"); 829 } 830 $libs = CGI::br()."or Problems from".$libs if $libs ne ''; 831 832 my $these_widths = "width: 25ex"; 833 834 if($have_local_sets ==0) { 835 $list_of_local_sets = [NO_LOCAL_SET_STRING]; 836 } elsif (not defined($set_selected) or $set_selected eq "" 837 or $set_selected eq SELECT_SET_STRING) { 838 unshift @{$list_of_local_sets}, SELECT_SET_STRING; 839 $set_selected = SELECT_SET_STRING; 840 } 841 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;'; 842 ## edited this, as a demo for the current set problem list 843 print CGI::div({-class=>"InfoPanel"}, 844 CGI::submit(-name=>"new_local_set", -value=>"Create a New Set in This Course:", 845 -onclick=>$myjs 846 ), 847 " ", 848 CGI::textfield(-name=>"new_set_name", 849 -default=>"Name for new set here", 850 -override=>1, -size=>30), 851 ); 852 853 # Tidy this list up since it is used in two different places 854 if ($list_of_local_sets->[0] eq SELECT_SET_STRING) { 855 shift @{$list_of_local_sets}; 856 } 857 858 print CGI::div({-class=>"InfoPanel"}, 859 "Browse ", 860 CGI::submit(-name=>"browse_npl_library", -value=>"National Problem Library", -style=>$these_widths, @dis1), 861 CGI::submit(-name=>"browse_local", -value=>"Local Problems", -style=>$these_widths, @dis2), 862 CGI::submit(-name=>"edit_mysets", -value=>"From This Course", -style=>$these_widths, @dis3), 863 CGI::submit(-name=>"browse_setdefs", -value=>"Set Definition Files", -style=>$these_widths, @dis4), 864 $libs, 865 ); 866 867 if ($browse_which eq 'browse_local') { 868 $self->browse_local_panel($library_selected); 869 } elsif ($browse_which eq 'edit_mysets') { 870 $self->edit_mysets_panel($library_selected, $list_of_local_sets); 871 } elsif ($browse_which eq 'browse_npl_library') { 872 $self->browse_library_panel(); 873 } elsif ($browse_which eq 'browse_setdefs') { 874 $self->browse_setdef_panel($library_selected); 875 } else { ## handle other problem libraries 876 $self->browse_local_panel($library_selected,$browse_which); 877 } 878 879 print CGI::div({-class=>"InfoPanel"}, 880 CGI::submit(-name=>"select_all", -style=>$these_widths, 881 -value=>"Mark All For Adding"), 882 CGI::submit(-name=>"select_none", -style=>$these_widths, 883 -value=>"Clear All Marks"), 884 ), 885 CGI::div({}, 886 CGI::submit(-name=>"rerandomize", 887 -style=>$these_widths, 888 -value=>"Rerandomize"), 889 CGI::submit(-name=>"cleardisplay", 890 -style=>$these_widths, 891 -value=>"Clear Problem Display") 892 ); 893 } 894 895 sub make_data_row { 896 my $self = shift; 897 my $sourceFileName = shift; 898 my $pg = shift; 899 my $cnt = shift; 900 my $mark = shift || 0; 901 902 $sourceFileName =~ s|^./||; # clean up top ugliness 903 904 my $urlpath = $self->r->urlpath; 905 my $db = $self->r->db; 906 907 ## to set up edit and try links elegantly we want to know if 908 ## any target set is a gateway assignment or not 909 my $localSet = $self->r->param('local_sets'); 910 my $setRecord; 911 if ( defined($localSet) && $localSet ne SELECT_SET_STRING && 912 $localSet ne NO_LOCAL_SET_STRING ) { 913 $setRecord = $db->getGlobalSet( $localSet ); 914 } 915 my $isGatewaySet = ( defined($setRecord) && 916 $setRecord->assignment_type =~ /gateway/ ); 917 918 my $problem_output = $pg->{flags}->{error_flag} ? 919 CGI::div({class=>"ResultsWithError"}, CGI::em("This problem produced an error")) 920 : CGI::div({class=>"RenderSolo"}, $pg->{body_text}); 921 $problem_output .= $pg->{flags}->{comment} if($pg->{flags}->{comment}); 922 923 924 #if($self->{r}->param('browse_which') ne 'browse_npl_library') { 925 my $problem_seed = $self->{'problem_seed'} || 1234; 926 my $edit_link = CGI::a({href=>$self->systemLink( 927 $urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::PGProblemEditor", 928 courseID =>$urlpath->arg("courseID"), 929 setID=>"Undefined_Set", 930 problemID=>"1"), 931 params=>{sourceFilePath => "$sourceFileName", problemSeed=> $problem_seed} 932 ), target=>"WW_Editor"}, "Edit it" ); 933 934 my $displayMode = $self->r->param("mydisplayMode"); 935 $displayMode = $self->r->ce->{pg}->{options}->{displayMode} 936 if not defined $displayMode or $displayMode eq "None"; 937 my $module = ( $isGatewaySet ) ? "GatewayQuiz" : "Problem"; 938 my %pathArgs = ( courseID =>$urlpath->arg("courseID"), 939 setID=>"Undefined_Set" ); 940 $pathArgs{problemID} = "1" if ( ! $isGatewaySet ); 941 942 my $try_link = CGI::a({href=>$self->systemLink( 943 $urlpath->newFromModule("WeBWorK::ContentGenerator::$module", 944 %pathArgs ), 945 params =>{ 946 effectiveUser => scalar($self->r->param('user')), 947 editMode => "SetMaker", 948 problemSeed=> $problem_seed, 949 sourceFilePath => "$sourceFileName", 950 displayMode => $displayMode, 951 } 952 ), target=>"WW_View"}, "Try it"); 953 954 my %add_box_data = ( -id=>"trial$cnt" ,-name=>"trial$cnt",-value=>1,-label=>"Add this problem to the target set on the next update"); 955 #allow for a move command from one problem set to anoter 956 my $move_box_data; 957 if($self->r->param('edit_mysets_set')){ 958 $move_box_data = CGI::checkbox( -id=>"moved$cnt" ,-name=>"moved$cnt",-value=>1,,-override=>1,-label=>"Move this problem from this set to the target set on the next update"); 959 } 960 else{ 961 $move_box_data = ""; 962 } 963 if($mark & SUCCESS) { 964 $add_box_data{ -label } .= " (just added this problem)"; 965 } elsif($mark & ADDED) { 966 $add_box_data{ -checked } = 1; 967 } 968 969 if(!($self->{isInSet}{$sourceFileName})){ 970 971 print CGI::div({-class=>"problem libraryProblem", -align=>"left", -draggable=>"true", -href=>"#", -id=>"$cnt"}, 972 CGI::p({},"File name: $sourceFileName "), 973 CGI::p({}, $edit_link, " ", $try_link), 974 CGI::p(CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1)), 975 CGI::p(CGI::checkbox((%add_box_data),-override=>1)), 976 CGI::p($move_box_data), 977 CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). 978 CGI::p($problem_output) 979 ); 980 } 981 else{ 982 print CGI::div({-class=>"problem libraryProblem used", -align=>"left", -draggable=>"true", -href=>"#", -id=>"$cnt"}, 983 CGI::p({},"File name: $sourceFileName "), 984 CGI::p({}, $edit_link, " ", $try_link), 985 CGI::p(CGI::checkbox(-id=>"hideme$cnt", -name=>"hideme$cnt",-value=>1,-label=>"Don't show this problem on the next update",-override=>1)), 986 CGI::p(CGI::checkbox((%add_box_data),-override=>1)), 987 CGI::p($move_box_data), 988 CGI::hidden(-name=>"filetrial$cnt", -default=>$sourceFileName,-override=>1). 989 CGI::p($problem_output), 990 CGI::b("(This problem is in the target set)") 991 ); 992 } 993 } 994 995 sub make_myset_data_row { 996 my $self = shift; 997 my $sourceFileName = shift; 998 my $pg = shift; 999 my $cnt = shift; 1000 my $mark = shift || 0; 1001 1002 $sourceFileName =~ s|^./||; # clean up top ugliness 1003 1004 my $urlpath = $self->r->urlpath; 1005 my $db = $self->r->db; 1006 1007 ## to set up edit and try links elegantly we want to know if 1008 ## any target set is a gateway assignment or not 1009 my $localSet = $self->r->param('local_sets'); 1010 my $setRecord; 1011 if ( defined($localSet) && $localSet ne SELECT_SET_STRING && 1012 $localSet ne NO_LOCAL_SET_STRING ) { 1013 $setRecord = $db->getGlobalSet( $localSet ); 1014 } 1015 my $isGatewaySet = ( defined($setRecord) && 1016 $setRecord->assignment_type =~ /gateway/ ); 1017 1018 my $problem_output = $pg->{flags}->{error_flag} ? 1019 CGI::div({class=>"ResultsWithError"}, CGI::em("This problem produced an error")) 1020 : CGI::div({class=>"RenderSolo"}, $pg->{body_text}); 1021 $problem_output .= $pg->{flags}->{comment} if($pg->{flags}->{comment}); 1022 1023 1024 #if($self->{r}->param('browse_which') ne 'browse_npl_library') { 1025 my $problem_seed = $self->{'problem_seed'} || 1234; 1026 my $edit_link = CGI::a({href=>$self->systemLink( 1027 $urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::PGProblemEditor", 1028 courseID =>$urlpath->arg("courseID"), 1029 setID=>"Undefined_Set", 1030 problemID=>"1"), 1031 params=>{sourceFilePath => "$sourceFileName", problemSeed=> $problem_seed} 1032 ), target=>"WW_Editor"}, "Edit it" ); 1033 1034 my %delete_box_data = ( -id=>"deleted$cnt".'myset' ,-name=>"deleted$cnt",-value=>1,-label=>"Delete this problem from the target set on the next update"); 1035 1036 my $displayMode = $self->r->param("mydisplayMode"); 1037 $displayMode = $self->r->ce->{pg}->{options}->{displayMode} 1038 if not defined $displayMode or $displayMode eq "None"; 1039 my $module = ( $isGatewaySet ) ? "GatewayQuiz" : "Problem"; 1040 my %pathArgs = ( courseID =>$urlpath->arg("courseID"), 1041 setID=>"Undefined_Set" ); 1042 $pathArgs{problemID} = "1" if ( ! $isGatewaySet ); 1043 1044 my $try_link = CGI::a({href=>$self->systemLink( 1045 $urlpath->newFromModule("WeBWorK::ContentGenerator::$module", 1046 %pathArgs ), 1047 params =>{ 1048 effectiveUser => scalar($self->r->param('user')), 1049 editMode => "SetMaker", 1050 problemSeed=> $problem_seed, 1051 sourceFilePath => "$sourceFileName", 1052 displayMode => $displayMode, 1053 } 1054 ), target=>"WW_View"}, "Try it"); 1055 1056 print CGI::div({-class=>"problem myProblem", -draggable=>"true", -href=>"#", -id=>("$cnt".'myset')}, 1057 CGI::p({},"File name: $sourceFileName "), 1058 CGI::p({}, $edit_link, " ", $try_link), 1059 CGI::p(CGI::checkbox((%delete_box_data),-override=>1)), 1060 CGI::hidden(-name=>"mysetfiletrial$cnt", -default=>$sourceFileName,-override=>1). 1061 CGI::p($problem_output), 1062 ); 1063 } 1064 1065 sub clear_default { 1066 my $r = shift; 1067 my $param = shift; 1068 my $default = shift; 1069 my $newvalue = $r->param($param) || ''; 1070 $newvalue = '' if($newvalue eq $default); 1071 $r->param($param, $newvalue); 1072 } 1073 1074 sub pre_header_initialize { 1075 my ($self) = @_; 1076 my $r = $self->r; 1077 ## For all cases, lets set some things 1078 $self->{error}=0; 1079 my $ce = $r->ce; 1080 my $db = $r->db; 1081 my $maxShown = $r->param('max_shown') || MAX_SHOW_DEFAULT; 1082 $maxShown = 10000000 if($maxShown eq 'All'); # let's hope there aren't more 1083 my $library_basic = $r->param('library_is_basic') || 1; 1084 $self->{problem_seed} = $r->param('problem_seed') || 1234; 1085 ## Fix some parameters 1086 for my $key (keys(%{ LIB2_DATA() })) { 1087 clear_default($r, LIB2_DATA->{$key}->{name}, LIB2_DATA->{$key}->{all} ); 1088 } 1089 ## Grab library sets to display from parameters list. We will modify this 1090 ## as we go through the if/else tree 1091 $self->{current_library_set} = $r->param('library_sets'); 1092 $self->{current_myset_set} = $r->param('myset_sets'); 1093 if (not defined($self->{current_myset_set}) 1094 or $self->{current_myset_set} eq "Select a Homework Set" 1095 or $self->{current_myset_set} eq NO_LOCAL_SET_STRING) { 1096 my @all_db_sets = $db->listGlobalSets; 1097 @all_db_sets = sortByName(undef, @all_db_sets); 1098 $self->{current_myset_set} = shift(@all_db_sets); 1099 } 1100 1101 ## These directories will have individual buttons 1102 %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs}; 1103 1104 my $userName = $r->param('user'); 1105 my $user = $db->getUser($userName); # checked 1106 die "record for user $userName (real user) does not exist." 1107 unless defined $user; 1108 my $authz = $r->authz; 1109 unless ($authz->hasPermissions($userName, "modify_problem_sets")) { 1110 return(""); # Error message already produced in the body 1111 } 1112 1113 ## Now one action we have to deal with here 1114 if ($r->param('edit_local')) { 1115 my $urlpath = $r->urlpath; 1116 my $db = $r->db; 1117 my $checkset = $db->getGlobalSet($r->param('local_sets')); 1118 if (not defined($checkset)) { 1119 $self->{error} = 1; 1120 $self->addbadmessage('You need to select a "Target Set" before you can edit it.'); 1121 } else { 1122 my $page = $urlpath->newFromModule('WeBWorK::ContentGenerator::Instructor::ProblemSetDetail', setID=>$r->param('local_sets'), courseID=>$urlpath->arg("courseID")); 1123 my $url = $self->systemLink($page); 1124 $self->reply_with_redirect($url); 1125 } 1126 } 1127 1128 ## Next, lots of set up so that errors can be reported with message() 1129 1130 ############# List of problems we have already printed 1131 1132 $self->{past_problems} = get_past_problem_files($r); 1133 # if we don't end up reusing problems, this will be wiped out 1134 # if we do redisplay the same problems, we must adjust this accordingly 1135 my @past_marks = map {$_->[1]} @{$self->{past_problems}}; 1136 my $none_shown = scalar(@{$self->{past_problems}})==0; 1137 my @pg_files=(); 1138 my @myset_files=(); 1139 my $use_previous_problems = 1; 1140 my $first_shown = $r->param('first_shown') || 0; 1141 my $last_shown = $r->param('last_shown'); 1142 if (not defined($last_shown)) { 1143 $last_shown = -1; 1144 } 1145 my @all_past_list = (); # these are include requested, but not shown 1146 my $j = 0; 1147 while (defined($r->param("all_past_list$j"))) { 1148 push @all_past_list, $r->param("all_past_list$j"); 1149 $j++; 1150 } 1151 1152 ############# Default of which problem selector to display 1153 1154 my $browse_which = $r->param('browse_which') || 'browse_npl_library'; 1155 1156 1157 1158 ## check for problem lib buttons 1159 my $browse_lib = ''; 1160 foreach my $lib (keys %problib) { 1161 if ($r->param("browse_$lib")) { 1162 $browse_lib = "browse_$lib"; 1163 last; 1164 } 1165 } 1166 1167 1168 ########### Start the logic through if elsif elsif ... 1169 debug("browse_lib", $r->param("$browse_lib")); 1170 debug("browse_npl_library", $r->param("browse_npl_library")); 1171 debug("edit_mysets", $r->param("edit_mysets")); 1172 debug("browse_setdefs", $r->param("browse_setdefs")); 1173 ##### Asked to browse certain problems 1174 if ($browse_lib ne '') { 1175 $browse_which = $browse_lib; 1176 $self->{current_library_set} = ""; 1177 $use_previous_problems = 0; @pg_files = (); ## clear old problems 1178 } elsif ($r->param('browse_npl_library')) { 1179 $browse_which = 'browse_npl_library'; 1180 $self->{current_library_set} = ""; 1181 $use_previous_problems = 0; @pg_files = (); ## clear old problems 1182 } elsif ($r->param('browse_local')) { 1183 $browse_which = 'browse_local'; 1184 #$self->{current_library_set} = ""; 1185 $use_previous_problems = 0; @pg_files = (); ## clear old problems 1186 } elsif ($r->param('edit_mysets')) { 1187 $browse_which = 'edit_mysets'; 1188 $self->{current_library_set} = ""; 1189 $use_previous_problems = 0; @pg_files = (); ## clear old problems 1190 } elsif ($r->param('browse_setdefs')) { 1191 $browse_which = 'browse_setdefs'; 1192 $self->{current_library_set} = ""; 1193 $use_previous_problems = 0; @pg_files = (); ## clear old problems 1194 1195 ##### Change the seed value 1196 1197 } elsif ($r->param('rerandomize')) { 1198 $self->{problem_seed}= 1+$self->{problem_seed}; 1199 #$r->param('problem_seed', $problem_seed); 1200 $self->addbadmessage('Changing the problem seed for display, but there are no problems showing.') if $none_shown; 1201 1202 ##### Clear the display 1203 1204 } elsif ($r->param('cleardisplay')) { 1205 @pg_files = (); 1206 $use_previous_problems=0; 1207 $self->addbadmessage('The display was already cleared.') if $none_shown; 1208 1209 ##### View problems selected from the local list 1210 1211 } elsif ($r->param('view_local_set')) { 1212 1213 my $set_to_display = $self->{current_library_set}; 1214 if (not defined($set_to_display) or $set_to_display eq SELECT_LOCAL_STRING or $set_to_display eq "Found no directories containing problems") { 1215 $self->addbadmessage('You need to select a set to view.'); 1216 } else { 1217 $set_to_display = '.' if $set_to_display eq MY_PROBLEMS; 1218 $set_to_display = substr($browse_which,7) if $set_to_display eq MAIN_PROBLEMS; 1219 @pg_files = list_pg_files($ce->{courseDirs}->{templates}, 1220 "$set_to_display"); 1221 $use_previous_problems=0; 1222 } 1223 1224 ##### View problems selected from the a set in this course 1225 } elsif ($r->param('edit_mysets_set')){ 1226 1227 my $set_to_display = $self->{current_library_set}; 1228 debug("set_to_display is $set_to_display"); 1229 if (not defined($set_to_display) 1230 or $set_to_display eq "Select a Homework Set" 1231 or $set_to_display eq NO_LOCAL_SET_STRING) { 1232 $self->addbadmessage("You need to select a set from this course to view."); 1233 } else { 1234 # DBFIXME don't use ID list, use an iterator 1235 my @problemList = $db->listGlobalProblems($set_to_display); 1236 my $problem; 1237 @pg_files=(); 1238 for $problem (@problemList) { 1239 my $problemRecord = $db->getGlobalProblem($set_to_display, $problem); # checked 1240 die "global $problem for set $set_to_display not found." unless 1241 $problemRecord; 1242 push @pg_files, $problemRecord->source_file; 1243 1244 } 1245 @pg_files = sortByName(undef,@pg_files); 1246 $use_previous_problems=0; 1247 } 1248 1249 ##### View from the library database 1250 1251 } elsif ($r->param('lib_view')) { 1252 @pg_files=(); 1253 my @dbsearch = WeBWorK::Utils::ListingDB::getSectionListings($r); 1254 my ($result, $tolibpath); 1255 for $result (@dbsearch) { 1256 $tolibpath = "Library/$result->{path}/$result->{filename}"; 1257 1258 ## Too clunky!!!! 1259 push @pg_files, $tolibpath; 1260 } 1261 $use_previous_problems=0; 1262 1263 ##### View a set from a set*.def 1264 1265 } elsif ($r->param('view_setdef_set')) { 1266 1267 my $set_to_display = $self->{current_library_set}; 1268 debug("set_to_display is $set_to_display"); 1269 if (not defined($set_to_display) 1270 or $set_to_display eq "Select a Set Definition File" 1271 or $set_to_display eq NO_LOCAL_SET_STRING) { 1272 $self->addbadmessage("You need to select a set definition file to view."); 1273 } else { 1274 @pg_files= $self->read_set_def($set_to_display); 1275 } 1276 $use_previous_problems=0; 1277 1278 ##### Edit the current local homework set 1279 1280 } elsif ($r->param('edit_local')) { ## Jump to set edit page 1281 1282 ; # already handled 1283 1284 1285 ##### Make a new local homework set 1286 1287 } elsif ($r->param('new_local_set')) { 1288 if ($r->param('new_set_name') !~ /^[\w .-]*$/) { 1289 $self->addbadmessage("The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."); 1290 } else { 1291 my $newSetName = $r->param('new_set_name'); 1292 # if we want to munge the input set name, do it here 1293 $newSetName =~ s/\s/_/g; 1294 debug("local_sets was ", $r->param('local_sets')); 1295 $r->param('local_sets',$newSetName); ## use of two parameter param 1296 debug("new value of local_sets is ", $r->param('local_sets')); 1297 my $newSetRecord = $db->getGlobalSet($newSetName); 1298 if (defined($newSetRecord)) { 1299 $self->addbadmessage("The set name $newSetName is already in use. 1300 Pick a different name if you would like to start a new set."); 1301 } else { # Do it! 1302 # DBFIXME use $db->newGlobalSet 1303 $newSetRecord = $db->{set}->{record}->new(); 1304 $newSetRecord->set_id($newSetName); 1305 $newSetRecord->set_header(""); 1306 $newSetRecord->hardcopy_header(""); 1307 $newSetRecord->open_date(time()+60*60*24*7); # in one week 1308 $newSetRecord->due_date(time()+60*60*24*7*2); # in two weeks 1309 $newSetRecord->answer_date(time()+60*60*24*7*3); # in three weeks 1310 eval {$db->addGlobalSet($newSetRecord)}; 1311 if ($@) { 1312 $self->addbadmessage("Problem creating set $newSetName<br> $@"); 1313 } else { 1314 $self->addgoodmessage("Set $newSetName has been created."); 1315 my $selfassign = $r->param('selfassign') || ""; 1316 $selfassign = "" if($selfassign =~ /false/i); # deal with javascript false 1317 if($selfassign) { 1318 $self->assignSetToUser($userName, $newSetRecord); 1319 $self->addgoodmessage("Set $newSetName was assigned to $userName."); 1320 } 1321 } 1322 } 1323 } 1324 1325 ##### Add selected problems to the current local set 1326 1327 } elsif ($r->param('update')) { 1328 ## first handle problems to be added before we hide them 1329 my($localSet, @selected); 1330 1331 my @add_pg_files = grep {(($_->[1] & ADDED)) != 0 } @{$self->{past_problems}}; 1332 my @add_selected = map {$_->[0]} @add_pg_files; 1333 1334 my @delete_pg_files = grep {(($_->[1] & DELETED)) != 0} @{$self->{past_problems}}; 1335 my @delete_selected = map {$_->[0]} @delete_pg_files; 1336 1337 my @move_pg_files = grep {(($_->[1] & MOVED)) != 0} @{$self->{past_problems}}; 1338 my @move_selected = map {$_->[0]} @move_pg_files; 1339 1340 my @action_files = grep {$_->[1] > 0 } @{$self->{past_problems}}; 1341 # There are now good reasons to do an update without selecting anything. 1342 #if(scalar(@action_files) == 0) { 1343 # $self->addbadmessage('Update requested, but no problems were marked.'); 1344 #} 1345 1346 if (scalar(@add_selected)>0) { # if some are to be added, they need a place to go 1347 $localSet = $r->param('myset_sets'); 1348 if (not defined($localSet) or 1349 $localSet eq SELECT_SET_STRING or 1350 $localSet eq NO_LOCAL_SET_STRING) { 1351 $self->addbadmessage('You are trying to add problems to something, 1352 but you did not select a "Target Set" name as a target.'); 1353 } else { 1354 my $newSetRecord = $db->getGlobalSet($localSet); 1355 if (not defined($newSetRecord)) { 1356 $self->addbadmessage("You are trying to add problems to $localSet, 1357 but that set does not seem to exist! I bet you used your \"Back\" button."); 1358 } else { 1359 my $addcount = add_selected($self, $db, $localSet); 1360 if($addcount > 0) { 1361 $self->addgoodmessage("Added $addcount problem".(($addcount>1)?'s':''). 1362 " to $localSet."); 1363 } 1364 } 1365 } 1366 } 1367 if (scalar(@delete_selected)>0) { # if some are to be added, they need a place to go 1368 $localSet = $r->param('myset_sets'); 1369 if (not defined($localSet) or 1370 $localSet eq SELECT_SET_STRING or 1371 $localSet eq NO_LOCAL_SET_STRING) { 1372 $self->addbadmessage('You are trying to add problems to something, 1373 but you did not select a "Target Set" name as a target.'); 1374 } else { 1375 my $newSetRecord = $db->getGlobalSet($localSet); 1376 if (not defined($newSetRecord)) { 1377 $self->addbadmessage("You are trying to delete problems to $localSet, 1378 but that set does not seem to exist! I bet you used your \"Back\" button."); 1379 } else { 1380 my $deletecount = delete_selected($self, $db, $localSet); 1381 if($deletecount > 0) { 1382 $self->addgoodmessage("Deleted $deletecount problem".(($deletecount>1)?'s':''). 1383 " to $localSet."); 1384 } 1385 } 1386 } 1387 } 1388 if (scalar(@move_selected)>0) { # if some are to be added, they need a place to go 1389 $localSet = $r->param('myset_sets'); 1390 my $otherSet = $self->{current_library_set}; 1391 if (not defined($localSet) or not defined($otherSet) or 1392 $localSet eq SELECT_SET_STRING or 1393 $localSet eq NO_LOCAL_SET_STRING) { 1394 $self->addbadmessage('You are trying to add problems to something, 1395 but you did not select a "Target Set" name as a target.'); 1396 } else { 1397 my $newSetRecord = $db->getGlobalSet($localSet); 1398 my $otherNewSetRecord = $db->getGlobalSet($otherSet); 1399 if (not defined($newSetRecord) or not defined($otherNewSetRecord)) { 1400 $self->addbadmessage("You are trying to move problems from $otherNewSetRecord to $localSet, 1401 but that set does not seem to exist! I bet you used your \"Back\" button."); 1402 } else { 1403 my $addcount = add_selected($self, $db, $localSet); 1404 my $deletecount = delete_selected($self, $db, $otherSet); 1405 if($addcount > 0 && $deletecount > 0) { 1406 $self->addgoodmessage("Moved $addcount problem".(($addcount>1)?'s':''). 1407 " from $otherSet to $localSet."); 1408 } 1409 } 1410 } 1411 } 1412 ## now handle problems to be hidden 1413 1414 ## only keep the ones which are not hidden 1415 @pg_files = grep {($_->[1] & HIDDEN) ==0 } @{$self->{past_problems}}; 1416 @pg_files = grep {(($_->[1] & DELETED)) != 0 } @pg_files; 1417 @past_marks = map {$_->[1]} @pg_files; 1418 @pg_files = map {$_->[0]} @pg_files; 1419 @all_past_list = (@all_past_list[0..($first_shown-1)], 1420 @pg_files, 1421 @all_past_list[($last_shown+1)..(scalar(@all_past_list)-1)]); 1422 $last_shown = $first_shown+$maxShown -1; debug("last_shown 3: ", $last_shown); 1423 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 4: ", $last_shown); 1424 1425 } elsif ($r->param('next_page')) { 1426 $first_shown = $last_shown+1; 1427 $last_shown = $first_shown+$maxShown-1; debug("last_shown 5: ", $last_shown); 1428 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); debug("last_shown 6: ", $last_shown); 1429 @past_marks = (); 1430 } elsif ($r->param('prev_page')) { 1431 $last_shown = $first_shown-1; 1432 $first_shown = $last_shown - $maxShown+1; 1433 1434 $first_shown = 0 if($first_shown<0); 1435 @past_marks = (); 1436 1437 } elsif ($r->param('select_all')) { 1438 @past_marks = map {1} @past_marks; 1439 } elsif ($r->param('library_basic')) { 1440 $library_basic = 1; 1441 for my $jj (qw(textchapter textsection textbook)) { 1442 $r->param('library_'.$jj,''); 1443 } 1444 } elsif ($r->param('library_advanced')) { 1445 $library_basic = 2; 1446 } elsif ($r->param('library_reset')) { 1447 for my $jj (qw(chapters sections subjects textbook keywords)) { 1448 $r->param('library_'.$jj,''); 1449 } 1450 } elsif ($r->param('select_none')) { 1451 @past_marks = (); 1452 } else { 1453 #nothing 1454 } ##### end of the if elsif ... 1455 1456 my $default_set = $self->{current_myset_set}; 1457 #debug("set_to_display is $default_set"); 1458 if (not defined($default_set) 1459 or $default_set eq "Select a Homework Set" 1460 or $default_set eq NO_LOCAL_SET_STRING) { 1461 $self->addbadmessage("You need to select a set from this course to view."); 1462 } else { 1463 # DBFIXME don't use ID list, use an iterator 1464 my @problemList = $db->listGlobalProblems($default_set); 1465 my $problem; 1466 @myset_files=(); 1467 for $problem (@problemList) { 1468 my $problemRecord = $db->getGlobalProblem($default_set, $problem); # checked 1469 die "global $problem for set $default_set not found." unless 1470 $problemRecord; 1471 push @myset_files, $problemRecord->source_file; 1472 1473 } 1474 @myset_files = sortByName(undef,@myset_files); 1475 $use_previous_problems=0; 1476 } 1477 1478 ############# List of local sets 1479 1480 # DBFIXME sorting in database, please! 1481 my @all_db_sets = $db->listGlobalSets; 1482 @all_db_sets = sortByName(undef, @all_db_sets); 1483 1484 if ($use_previous_problems) { 1485 @pg_files = @all_past_list; 1486 } else { 1487 $first_shown = 0; 1488 $last_shown = scalar(@pg_files)<$maxShown ? scalar(@pg_files) : $maxShown; 1489 $last_shown--; # to make it an array index 1490 @past_marks = (); 1491 } 1492 ############# Now store data in self for retreival by body 1493 $self->{first_shown} = $first_shown; 1494 $self->{last_shown} = $last_shown; 1495 $self->{browse_which} = $browse_which; 1496 #$self->{problem_seed} = $problem_seed; 1497 $self->{pg_files} = \@pg_files; 1498 $self->{myset_files} = \@myset_files; 1499 $self->{past_marks} = \@past_marks; 1500 $self->{all_db_sets} = \@all_db_sets; 1501 $self->{library_basic} = $library_basic; 1502 debug("past_marks is ", join(" ", @{$self->{past_marks}})); 1503 } 1504 1505 1506 sub title { 1507 return "Library Browser v2"; 1508 } 1509 1510 # hide view options panel since it distracts from SetMaker's built-in view options 1511 sub options { 1512 return ""; 1513 } 1514 1515 sub head { 1516 print '<script src="/webwork2_files/js/dnd.js"></script>'; 1517 print '<script src="/webwork2_files/js/problem_grid.js"></script>'; 1518 print '<link rel="stylesheet" type="text/css" href="/webwork2_files/css/setmaker2.css" />'; 1519 print '<script>window.addEventListener("load", setup, false);</script>'; 1520 return ""; 1521 } 1522 1523 sub body { 1524 my ($self) = @_; 1525 1526 my $r = $self->r; 1527 my $ce = $r->ce; # course environment 1528 my $db = $r->db; # database 1529 my $j; # garden variety counter 1530 1531 my $userName = $r->param('user'); 1532 1533 my $user = $db->getUser($userName); # checked 1534 die "record for user $userName (real user) does not exist." 1535 unless defined $user; 1536 1537 ### Check that this is a professor 1538 my $authz = $r->authz; 1539 unless ($authz->hasPermissions($userName, "modify_problem_sets")) { 1540 print "User $userName returned " . 1541 $authz->hasPermissions($user, "modify_problem_sets") . 1542 " for permission"; 1543 return(CGI::div({class=>'ResultsWithError'}, 1544 CGI::em("You are not authorized to access the Instructor tools."))); 1545 } 1546 1547 my $showHints = $r->param('showHints'); 1548 my $showSolutions = $r->param('showSolutions'); 1549 1550 ########## Extract information computed in pre_header_initialize 1551 1552 my $first_shown = $self->{first_shown}; 1553 my $last_shown = $self->{last_shown}; 1554 my $browse_which = $self->{browse_which}; 1555 my $problem_seed = $self->{problem_seed}||1234; 1556 my @pg_files = @{$self->{pg_files}}; 1557 my @myset_files =@{$self->{myset_files}}; 1558 my @all_db_sets = @{$self->{all_db_sets}}; 1559 1560 my @pg_html; 1561 if ($last_shown >= $first_shown) { 1562 @pg_html = renderProblems( 1563 r=> $r, 1564 user => $user, 1565 problem_list => [@pg_files[$first_shown..$last_shown]], 1566 displayMode => 'images', 1567 showHints => $showHints, 1568 showSolutions => $showSolutions, 1569 ); 1570 } 1571 my @myset_html; 1572 my $displayModePlaceholder; 1573 if (not defined($r->param('mydisplayMode'))){ 1574 $displayModePlaceholder = "None"; 1575 } 1576 else{ 1577 $displayModePlaceholder = $r->param('mydisplayMode'); 1578 } 1579 if (scalar(@myset_files) >= $first_shown) { 1580 @myset_html = renderProblems( 1581 r=> $r, 1582 user => $user, 1583 problem_list => [@myset_files[$first_shown..(scalar(@myset_files)-1)]], 1584 displayMode => 'images', 1585 showHints => $showHints, 1586 showSolutions => $showSolutions, 1587 ); 1588 } 1589 1590 my %isInSet; 1591 my $setName = $r->param("myset_sets"); 1592 if ($setName) { 1593 # DBFIXME where clause, iterator 1594 # DBFIXME maybe instead of hashing here, query when checking source files? 1595 # DBFIXME definitely don't need to be making full record objects 1596 # DBFIXME SELECT source_file FROM whatever_problem WHERE set_id=? GROUP BY source_file ORDER BY NULL; 1597 # DBFIXME (and stick result directly into hash) 1598 foreach my $problem ($db->listGlobalProblems($setName)) { 1599 my $problemRecord = $db->getGlobalProblem($setName, $problem); 1600 $isInSet{$problemRecord->source_file} = 1; 1601 } 1602 } 1603 $self->{isInSet} = \%isInSet; 1604 my $jj; 1605 ########## Top part 1606 print '<button id="gridifyButton" onclick="gridify();">Gridify!!</button>'; 1607 print '<div id="editor-form">'; 1608 print CGI::start_form({-method=>"POST", -action=>$r->uri, -name=>'mainform'}), 1609 $self->hidden_authen_fields; 1610 print '<div id="control_panel">'; 1611 print '<div id="myset_control" class="mysets control">'; 1612 $self->make_mysets_row('all_db_sets'=>\@all_db_sets); 1613 print '</div>'; 1614 print '<div id="library_control" class="setmaker_library control">'; 1615 $self->make_top_row('all_db_sets'=>\@all_db_sets, 'browse_which'=> $browse_which); 1616 print '</div>'; 1617 print '</div>'; 1618 print '<div style="clear:both;padding:0px;margin:0px;"></div>'; 1619 ######### Table of mysets problems 1620 print '<div id="problem_container">'; 1621 print '<div id="mysets_problems" class="problemList mysets">'; 1622 for ($jj=0; $jj<scalar(@myset_html); $jj++) { 1623 $myset_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; 1624 $self->make_myset_data_row($myset_files[$jj+$first_shown], $myset_html[$jj], $jj+1, $self->{past_marks}->[$jj]); 1625 } 1626 print '</div>'; 1627 1628 print '<div class="setmaker_library">'; 1629 print CGI::hidden(-name=>'browse_which', -value=>$browse_which,-override=>1), 1630 CGI::hidden(-name=>'problem_seed', -value=>$problem_seed, -override=>1); 1631 for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { 1632 print CGI::hidden(-name=>"all_past_list$j", -value=>$pg_files[$j],-override=>1); 1633 } 1634 print CGI::hidden(-name=>'first_shown', -value=>$first_shown,-override=>1); 1635 print CGI::hidden(-name=>'last_shown', -value=>$last_shown, -override=>1); 1636 print '<div id="setmaker_library_problems" class="problemList">'; 1637 ########## Now print problems 1638 for ($jj=0; $jj<scalar(@pg_html); $jj++) { 1639 $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; 1640 $self->make_data_row($pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1, $self->{past_marks}->[$jj]); 1641 } 1642 print '</div>'; 1643 ########## Finish things off 1644 my ($next_button, $prev_button) = ("", ""); 1645 if ($first_shown > 0) { 1646 $prev_button = CGI::submit(-name=>"prev_page", -style=>"width:15ex", -value=>"Previous page"); 1647 } 1648 if ((1+$last_shown)<scalar(@pg_files)) { 1649 $next_button = CGI::submit(-name=>"next_page", -style=>"width:15ex", -value=>"Next page"); 1650 } 1651 if (scalar(@pg_files)>0) { 1652 print CGI::p(($first_shown+1)."-".($last_shown+1)." of ".scalar(@pg_files)." shown.", $prev_button, " ", $next_button, 1653 CGI::submit(-name=>"update", -style=>"width:15ex; font-weight:bold", -value=>"Update Set")); 1654 } 1655 #close setmaker_library 1656 print '</div>'; 1657 #close problem_container 1658 print '</div>'; 1659 print CGI::endform(), "\n"; 1660 #close form-editor 1661 print '</div>'; 1662 print '<div style="clear:both;"></div>'; 1663 # if($first_shown>0 or (1+$last_shown)<scalar(@pg_files)) { 1664 1665 # } 1666 1667 1668 return ""; 1669 } 1670 1671 =head1 AUTHOR 1672 1673 Written by John Jones, jj (at) asu.edu. 1674 Edited by David Gage 1675 1676 =cut 1677 1678 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |