Parent Directory
|
Revision Log
Removed hard-wired path.
1 ################################################################################ 2 # WeBWorK Online Homework Delivery System 3 # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 4 # $CVSHeader: $ 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::SetMaker; 19 use base qw(WeBWorK::ContentGenerator::Instructor); 20 21 =head1 NAME 22 23 WeBWorK::ContentGenerator::Instructor::SetMaker - Make problem sets. 24 25 =cut 26 27 use strict; 28 use warnings; 29 30 use CGI::Pretty qw(); 31 use WeBWorK::Form; 32 use WeBWorK::Utils qw(readDirectory max); 33 use WeBWorK::Utils::Tasks qw(renderProblems); 34 35 require WeBWorK::Utils::ListingDB; 36 37 38 use constant MAX_SHOW => 20; 39 40 ## to make the recursion work, this returns an array where the first 41 ## item is 1 or 0 depending on whether or not the current 42 ## directory has any pg files. The second is a list of directories 43 ## which contain pg files. 44 sub get_library_sets { 45 my $topdir = shift; 46 my @lis = readDirectory($topdir); 47 my @pgs = grep { m/\.pg$/ and (not m/Header\.pg/) and -f "$topdir/$_"} @lis; 48 my $havepg = scalar(@pgs)>0 ? 1 : 0; 49 my @mdirs = grep {$_ ne "." and $_ ne ".." and $_ ne "Library" 50 and -d "$topdir/$_"} @lis; 51 my ($adir, @results, @thisresult); 52 for $adir (@mdirs) { 53 @results = get_library_sets("$topdir/$adir"); 54 my $isadirok = shift @results; 55 @thisresult = (@thisresult, @results); 56 if ($isadirok) { 57 @thisresult = ("$topdir/$adir", @thisresult); 58 } 59 } 60 return(($havepg, @thisresult)); 61 } 62 63 ## List all the pg files in the requested directory 64 sub list_pg_files { 65 my $templatedir = shift; 66 my $topdir = shift; 67 68 my @lis = readDirectory("$templatedir/$topdir"); 69 my @pgs = grep { m/\.pg$/ and (not m/Header\.pg/) and -f "$templatedir/$topdir/$_"} @lis; 70 @pgs = map { "$topdir/$_" } @pgs; 71 return(@pgs); 72 } 73 74 ## Maybe I should use this instead, returns a list 75 sub get_global_set_defs { 76 my $db = shift; 77 78 my @globalSetIDs = $db->listGlobalSets; 79 return(@globalSetIDs); 80 } 81 82 ## go through past page getting a list of identifiers for the problems 83 ## and whether or not they are selected, and whether or not they should 84 ## be hidden 85 86 sub get_past_problem_files { 87 my $r = shift; 88 my @found=(); 89 my $count =1; 90 while (defined($r->param("filetrial$count"))) { 91 push @found, [$r->param("filetrial$count"), 92 defined($r->param("trial$count")) ? $r->param("trial$count"):0, 93 defined($r->param("hideme$count")) ?$r->param("hideme$count"):0]; 94 $count++; 95 } 96 return(@found); 97 } 98 99 #### For adding new problems 100 101 sub add_selected { 102 my $self = shift; 103 my $db = shift; 104 my $setName = shift; 105 my @selected = @_; 106 my (@path, $file, $selected, $freeProblemID); 107 $freeProblemID = max($db->listGlobalProblems($setName)) + 1; 108 109 for $selected (@selected) { 110 $file = $selected; 111 @path = split "/", $selected; 112 pop @path; # Remove the file name from the path 113 shift @path if $path[0] eq ""; # remove the null element from the begining 114 my $problemRecord = $db->newGlobalProblem(); 115 $problemRecord->problem_id($freeProblemID++); 116 $problemRecord->set_id($setName); 117 $problemRecord->source_file($file); 118 $problemRecord->value("1"); 119 $problemRecord->max_attempts("-1"); 120 $db->addGlobalProblem($problemRecord); 121 $self->assignProblemToAllSetUsers($problemRecord); 122 } 123 } 124 125 126 ############# List of library sets 127 128 sub getalllibsets { 129 my $ce = shift; 130 my @all_library_sets = get_library_sets($ce->{courseDirs}->{templates}); 131 shift @all_library_sets; 132 my $j; 133 for ($j=0; $j<scalar(@all_library_sets); $j++) { 134 $all_library_sets[$j] =~ s|^$ce->{courseDirs}->{templates}/?||; 135 } 136 @all_library_sets = sort @all_library_sets; 137 return (\@all_library_sets); 138 } 139 140 ### The browsing panel has three versions 141 ##### Version 1 is local problems 142 sub browse_local_panel { 143 my $self = shift; 144 my $library_selected = shift; 145 146 my $list_of_sets= getalllibsets($self->r->ce); 147 my $libstr = ""; 148 my $default_value = "Select a Local Problem Collection"; 149 $libstr = CGI::br() . CGI::em($self->{libmsg}) if($self->{libmsg}); 150 151 if (not $library_selected or $library_selected eq $default_value) { 152 unshift @{$list_of_sets}, $default_value; 153 $library_selected = $default_value; 154 } 155 156 157 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, "Local Problems: ", 158 CGI::popup_menu(-name=> 'library_sets', 159 -values=>$list_of_sets, 160 -default=> $library_selected), 161 CGI::br(), 162 CGI::submit(-name=>"view_local_set", -value=>"View Problems"), 163 $libstr 164 )); 165 } 166 167 ##### Version 2 is local problem sets 168 sub browse_mysets_panel { 169 my $self = shift; 170 my $library_selected = shift; 171 my $list_of_local_sets = shift; 172 my $default_value = "Select a Problem Set"; 173 174 my $libstr = CGI::br() . CGI::em($self->{libmsg}) if($self->{libmsg}); 175 176 if (not $library_selected or $library_selected eq $default_value) { 177 unshift @{$list_of_local_sets}, $default_value; 178 $library_selected = $default_value; 179 } 180 181 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, "Browse from: ", 182 CGI::popup_menu(-name=> 'library_sets', 183 -values=>$list_of_local_sets, 184 -default=> $library_selected), 185 CGI::br(), 186 CGI::submit(-name=>"view_mysets_set", -value=>"View This Set"), 187 $libstr 188 )); 189 } 190 191 ##### Version 3 is the problem library 192 193 194 # There a different levels, and you can pick a new chapter, 195 # pick a new section, pick all from chapter, pick all from section 196 # 197 # Incoming data - current chapter, current section 198 sub browse_library_panel { 199 my $self = shift; 200 my $r = $self->r; 201 202 my $libraryRoot = $r->{ce}->{webworkDirs}->{libraryRoot}; 203 204 unless($libraryRoot) { 205 print CGI::Tr(CGI::td(CGI::div({class=>'ResultsWithError', align=>"center"}, 206 "The problem library has not been installed."))); 207 return; 208 } 209 210 my $default_chap = "All Chapters"; 211 my $default_sect = "All Sections"; 212 213 my $libstr = CGI::br() . CGI::em($self->{libmsg}) if($self->{libmsg}); 214 215 my @chaps = WeBWorK::Utils::ListingDB::getAllChapters($r->{ce}); 216 unshift @chaps, $default_chap; 217 my $chapter_selected = $r->param('library_chapters') || $default_chap; 218 219 my @sects=(); 220 if ($chapter_selected ne $default_chap) { 221 @sects = WeBWorK::Utils::ListingDB::getAllSections($r->{ce}, $chapter_selected); 222 } 223 224 my @textbooks = ('Textbook info not ready'); 225 226 unshift @sects, $default_sect; 227 my $section_selected = $r->param('library_sections') || $default_sect; 228 229 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, 230 CGI::start_table(), 231 CGI::Tr( 232 CGI::td(["Chapter:", 233 CGI::popup_menu(-name=> 'library_chapters', 234 -values=>\@chaps, 235 -default=> $chapter_selected, 236 -onchange=>"submit();return true" 237 ), 238 CGI::submit(-name=>"lib_select_chapter", -value=>"Update Section List")])), 239 CGI::Tr( 240 CGI::td("Section:"), 241 CGI::td({-colspan=>2}, 242 CGI::popup_menu(-name=> 'library_sections', 243 -values=>\@sects, 244 -default=> $section_selected 245 ))), 246 247 CGI::Tr( 248 CGI::td("Textbook:"), 249 CGI::td({-colspan=>2}, 250 CGI::popup_menu(-name=> 'library_textbooks', 251 -values=>\@textbooks, 252 # -default=> $section_selected 253 ))), 254 255 CGI::Tr( 256 CGI::td("Keywords:"), 257 CGI::td({-colspan=>2}, CGI::textfield(-name=>"keywords", 258 -default=>"Keywords not implemented yet", 259 -override=>1, -size=>60))), 260 CGI::Tr(CGI::td({-colspan=>3},CGI::submit(-name=>"lib_view", -value=>"View Problems"))), 261 CGI::end_table(), 262 $libstr 263 )); 264 } 265 266 sub make_top_row { 267 my $self = shift; 268 my $r = $self->r; 269 my %data = @_; 270 271 my $list_of_local_sets = $data{all_set_defs}; 272 my $browse_which = $data{browse_which}; 273 my $library_selected = $r->param('library_sets'); 274 my $set_selected = $r->param('local_sets'); 275 276 my $list_of_sets; 277 my ($dis1, $dis2, $dis3) = ("","",""); 278 $dis1 = '-disabled' if($browse_which eq 'browse_library'); 279 $dis2 = '-disabled' if($browse_which eq 'browse_local'); 280 $dis3 = '-disabled' if($browse_which eq 'browse_mysets'); 281 282 my $locstr = ""; 283 $locstr = CGI::br() . CGI::em($self->{localmsg}) if($self->{localmsg}); 284 285 my $these_widths = "width: 27ex"; 286 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, 287 CGI::submit(-name=>"browse_library", -value=>"Browse Problem Library", -style=>$these_widths, $dis1), 288 CGI::submit(-name=>"browse_local", -value=>"Browse Local Problems", -style=>$these_widths, $dis2), 289 CGI::submit(-name=>"browse_mysets", -value=>"Browse From This Course", -style=>$these_widths, $dis3), 290 )); 291 292 print CGI::Tr(CGI::td({-bgcolor=>"black"})); 293 294 if ($browse_which eq 'browse_local') { 295 browse_local_panel($self, $library_selected); 296 } elsif ($browse_which eq 'browse_mysets') { 297 browse_mysets_panel($self, $library_selected, $list_of_local_sets); 298 } else { 299 browse_library_panel($self); 300 } 301 302 print CGI::Tr(CGI::td({-bgcolor=>"black"})); 303 304 if (not $set_selected or $set_selected eq "Select a Set for This Course") { 305 if ($list_of_local_sets->[0] eq "Select a Problem Set") { 306 shift @{$list_of_local_sets}; 307 } 308 unshift @{$list_of_local_sets}, "Select a Set for This Course"; 309 $set_selected = "Select a Set for This Course"; 310 } 311 312 print CGI::Tr(CGI::td({-class=>"InfoPanel"}, "Current Set: ", 313 CGI::popup_menu(-name=> 'local_sets', 314 -values=>$list_of_local_sets, 315 -default=> $set_selected), 316 CGI::submit(-name=>"edit_local", -value=>"Edit Current Set"), 317 CGI::br(), 318 CGI::br(), 319 CGI::submit(-name=>"new_local_set", -value=>"Create New Local Set:"), 320 " ", 321 CGI::textfield(-name=>"new_set_name", 322 -default=>"Name for new set here", 323 -override=>1, -size=>30), 324 CGI::br(), 325 $locstr 326 )); 327 328 print CGI::Tr(CGI::td({-bgcolor=>"black"})); 329 330 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"center"}, 331 CGI::submit(-name=>"update", -style=>$these_widths, 332 -value=>"Act on Marked Problems"), 333 CGI::submit(-name=>"rerandomize", 334 -style=>$these_widths, 335 -value=>"Rerandomize"), 336 CGI::submit(-name=>"cleardisplay", 337 -style=>$these_widths, 338 -value=>"Clear Problem Display"))); 339 340 } 341 342 sub make_data_row { 343 my $self = shift; 344 my $sourceFileName = shift; 345 my $pg = shift; 346 my $cnt = shift; 347 348 my $urlpath = $self->r->urlpath; 349 my $problem_output = $pg->{flags}->{error_flag} ? 350 CGI::em("This problem produced an error") : CGI::div({class=>"RenderSolo"}, $pg->{body_text}); 351 352 353 my $edit_link = CGI::a({href=>$self->systemLink( 354 $urlpath->new(type=>'instructor_problem_editor_withset_withproblem', 355 args=>{courseID =>$urlpath->arg("courseID"), 356 setID=>"Undefined_Set", problemID=>"1" } 357 ), params=>{sourceFilePath => "$sourceFileName"} 358 )}, "Edit it" ); 359 360 my $try_link = CGI::a({href=>$self->systemLink( $urlpath->new(type=>'problem_detail', 361 args=>{courseID =>$urlpath->arg("courseID"), 362 setID=>"Undefined_Set", problemID=>"1"} 363 ), 364 params =>{effectiveUser => $self->r->param('user'), editMode => "temporaryFile", sourceFilePath => $self->r->ce->{courseDirs}->{templates}."/$sourceFileName"} )}, "Try it"); 365 366 367 368 print CGI::Tr({-align=>"left"}, CGI::td( 369 370 CGI::div({-style=>"background-color: #DDDDDD"},"File name: $sourceFileName ", 371 # $edit_link, " ", $try_link 372 ), 373 374 375 376 377 CGI::checkbox(-name=>"hideme$cnt",-value=>1,-label=>"Don't show me on the next update"), 378 CGI::br(), 379 CGI::checkbox(-name=>"trial$cnt",-value=>1,-label=>"Add me to the current set on the next update"), 380 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName]). 381 CGI::p($problem_output), 382 )); 383 } 384 385 sub title { 386 return "Problem Set Maker"; 387 } 388 389 sub body { 390 my ($self) = @_; 391 392 my $r = $self->r; 393 my $ce = $r->ce; # course environment 394 my $db = $r->db; # database 395 my $j; # garden variety counter 396 397 my $userName = $r->param('user'); 398 399 my $user = $db->getUser($userName); # checked 400 die "record for user $userName (real user) does not exist." 401 unless defined $user; 402 403 ### Check that this is a professor 404 my $authz = $r->authz; 405 unless ($authz->hasPermissions($userName, "modify_problem_sets")) { 406 print "User $userName returned " . 407 $authz->hasPermissions($user, "modify_problem_sets") . 408 " for permission"; 409 return(CGI::em("You are not authorized to access the Instructor tools.")); 410 } 411 412 413 ############# List of problems we have already printed 414 415 my @past_problems = get_past_problem_files($r); 416 my (@pg_files, @pg_html); 417 my $use_previous_problems = 1; 418 my $first_shown = $r->param('first_shown') || 0; 419 my $last_shown = $r->param('last_shown'); 420 if (not defined($last_shown)) { 421 $last_shown = -1; 422 } 423 my @all_past_list = (); # these are include requested, but not shown 424 $j = 0; 425 while (defined($r->param("all_past_list$j"))) { 426 push @all_past_list, $r->param("all_past_list$j"); 427 $j++; 428 } 429 430 ############# Default of which problem selector to display 431 432 my $browse_which = 'browse_local'; 433 $browse_which = $r->param('browse_which') if defined($r->param('browse_which')); 434 435 my $problem_seed = $r->param('problem_seed') || 0; 436 $r->param('problem_seed', $problem_seed); # if it wasn't defined before 437 438 ########### Start the logic through if elsif elsif ... 439 440 ##### Asked to browse certain problems 441 if ($r->param('browse_library')) { 442 $browse_which = 'browse_library'; 443 $r->param('library_sets', ""); 444 } elsif ($r->param('browse_local')) { 445 $browse_which = 'browse_local'; 446 $r->param('library_sets', ""); 447 } elsif ($r->param('browse_mysets')) { 448 $browse_which = 'browse_mysets'; 449 $r->param('library_sets', ""); 450 451 ##### Change the seed value 452 453 } elsif ($r->param('rerandomize')) { 454 $problem_seed++; 455 $r->param('problem_seed', $problem_seed); 456 457 ##### Clear the display 458 459 } elsif ($r->param('cleardisplay')) { 460 @pg_files = (); 461 $use_previous_problems=0; 462 463 ##### View problems selected from the local list 464 465 } elsif ($r->param('view_local_set')) { 466 467 my $set_to_display = $r->param('library_sets'); 468 if (not defined($set_to_display) or $set_to_display eq "Select a Local Problem Collection") { 469 $self->{libmsg} = "You need to select a set to view."; 470 } else { 471 @pg_files = list_pg_files($ce->{courseDirs}->{templates}, 472 "$set_to_display"); 473 $use_previous_problems=0; 474 } 475 476 ##### View problems selected from the a set in this course 477 478 } elsif ($r->param('view_mysets_set')) { 479 480 my $set_to_display = $r->param('library_sets'); 481 if (not defined($set_to_display) or $set_to_display eq "Select a Problem Set") { 482 $self->{libmsg} = "You need to select a set from this course to view."; 483 } else { 484 my @problemList = $db->listGlobalProblems($set_to_display); 485 my $problem; 486 @pg_files=(); 487 for $problem (@problemList) { 488 my $problemRecord = $db->getGlobalProblem($set_to_display, $problem); # checked 489 die "global $problem for set $set_to_display not found." unless 490 $problemRecord; 491 push @pg_files, $problemRecord->source_file; 492 493 } 494 $use_previous_problems=0; 495 } 496 497 ##### View whole chapter from the library 498 ## This will change somewhat later 499 500 } elsif ($r->param('lib_view')) { 501 502 @pg_files=(); 503 my $chap = $r->param('library_chapters') || ""; 504 $chap = "" if($chap eq "All Chapters"); 505 my $sect = $r->param('library_sections') || ""; 506 $sect = "" if($sect eq "All Sections"); 507 my @dbsearch = WeBWorK::Utils::ListingDB::getSectionListings($r->{ce}, "$chap", "$sect"); 508 my ($result, $tolibpath); 509 for $result (@dbsearch) { 510 $tolibpath = "Library/$result->{path}/$result->{filename}"; 511 512 ## Too clunky!!!! 513 push @pg_files, $tolibpath; 514 } 515 $use_previous_problems=0; 516 517 ##### Edit the current local problem set 518 519 } elsif ($r->param('edit_local')) { ## Jump to set edit page 520 # This is handled in pre_header_initialize -- it redirects 521 # If there is an error, so no redirect, we want to be ready 522 # and do something here 523 524 ##### Make a new local problem set 525 526 } elsif ($r->param('new_local_set')) { 527 if ($r->param('new_set_name') !~ /^[\w.-]*$/) { 528 $self->{localmsg} = "The name ".$r->param('new_set_name')." is not a valid set name. Use only letters, digits, -, _, and ."; 529 } else { 530 my $newSetName = $r->param('new_set_name'); 531 $newSetName =~ s/^set//; 532 $newSetName =~ s/\.def$//; 533 my $newSetRecord = $db->getGlobalSet($newSetName); 534 if (defined($newSetRecord)) { 535 $self->{localmsg} = "The set name $newSetName is already in use. Pick a different name if you would like to start a new set."; 536 } else { # Do it! 537 $newSetRecord = $db->{set}->{record}->new(); 538 $newSetRecord->set_id($newSetName); 539 $newSetRecord->set_header(""); 540 $newSetRecord->problem_header(""); 541 $newSetRecord->open_date(time()+60*60*24*7); # in one week 542 $newSetRecord->due_date(time()+60*60*24*7*2); # in two weeks 543 $newSetRecord->answer_date(time()+60*60*24*7*3); # in three weeks 544 eval {$db->addGlobalSet($newSetRecord)}; 545 } 546 } 547 548 ##### Add selected problems to the current local set 549 550 } elsif ($r->param('update')) { 551 ## first handle problems to be added before we hide them 552 my($localSet, @selected); 553 554 @pg_files = grep {$_->[1] != 0 } @past_problems; 555 @selected = map {$_->[0]} @pg_files; 556 557 if (scalar(@selected)>0) { # if some are to be added, they need a place to go 558 $localSet = $r->param('local_sets'); 559 if (not defined($localSet)) { 560 $self->{localmsg} = "Trying to add problems to something, you did not select a current set name as a target."; 561 } else { 562 my $newSetRecord = $db->getGlobalSet($localSet); 563 if (not defined($newSetRecord)) { 564 $self->{localmsg} = "You need to select a local problem set to add the problems to."; 565 } else { 566 add_selected($self, $db, $localSet, @selected); 567 } 568 } 569 } 570 ## now handle problems to be hidden 571 572 @pg_files = grep {$_->[2]==0 } @past_problems; 573 @pg_files = map {$_->[0]} @pg_files; 574 @all_past_list = (@all_past_list[0..($first_shown-1)], 575 @pg_files, 576 @all_past_list[($last_shown+1)..(scalar(@all_past_list)-1)]); 577 $last_shown = $first_shown+MAX_SHOW -1; 578 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); 579 580 ## FIXME: you should say something if no problems are selected 581 ## maybe the add button should be disabled if there are no problems 582 ## showing 583 584 585 } elsif ($r->param('next_page')) { 586 $first_shown = $last_shown+1; 587 $last_shown = $first_shown+MAX_SHOW-1; 588 $last_shown = (scalar(@all_past_list)-1) if($last_shown>=scalar(@all_past_list)); 589 } elsif ($r->param('prev_page')) { 590 $last_shown = $first_shown-1; 591 $first_shown = $last_shown - MAX_SHOW+1; 592 593 $first_shown = 0 if($first_shown<0); 594 595 ##### No action requested, probably our first time here 596 597 } else { 598 #my $c = $r->connection; 599 #print "Debug info: ". $r->get_remote_host ."<p>". $c->remote_ip ; 600 ; 601 } ##### end of the if elsif ... 602 603 604 ############# List of local sets 605 606 my @all_set_defs = get_global_set_defs($db); 607 for ($j=0; $j<scalar(@all_set_defs); $j++) { 608 $all_set_defs[$j] =~ s|^set||; 609 $all_set_defs[$j] =~ s|\.def||; 610 } 611 612 if ($use_previous_problems) { 613 @pg_files = @all_past_list; 614 } else { 615 $first_shown = 0; 616 $last_shown = scalar(@pg_files)<MAX_SHOW ? scalar(@pg_files) : MAX_SHOW; 617 $last_shown--; # to make it an array index 618 } 619 620 @pg_html=($last_shown>=$first_shown) ? 621 renderProblems($r,$user, @pg_files[$first_shown..$last_shown]) : (); 622 623 ########## Top part 624 print CGI::startform({-method=>"POST", -action=>$r->uri}), 625 $self->hidden_authen_fields, 626 '<div align="center">', 627 CGI::start_table({-border=>2}); 628 make_top_row($self, 'all_set_defs'=>\@all_set_defs, 629 'browse_which'=> $browse_which); 630 print CGI::hidden(-name=>'browse_which', -default=>[$browse_which]), 631 CGI::hidden(-name=>'problem_seed', -default=>[$problem_seed]); 632 for ($j = 0 ; $j < scalar(@pg_files) ; $j++) { 633 print CGI::hidden(-name=>"all_past_list$j", -default=>$pg_files[$j]); 634 } 635 636 print CGI::hidden(-name=>'first_shown', -default=>[$first_shown]); 637 print CGI::hidden(-name=>'last_shown', -default=>[$last_shown]); 638 639 640 ########## Now print problems 641 my $jj; 642 for ($jj=0; $jj<scalar(@pg_html); $jj++) { 643 $pg_files[$jj] =~ s|^$ce->{courseDirs}->{templates}/?||; 644 make_data_row($self, $pg_files[$jj+$first_shown], $pg_html[$jj], $jj+1); 645 } 646 647 ########## Finish things off 648 print CGI::end_table(); 649 print '</div>'; 650 # if($first_shown>0 or (1+$last_shown)<scalar(@pg_files)) { 651 my ($next_button, $prev_button) = ("", ""); 652 if ($first_shown > 0) { 653 $prev_button = CGI::submit(-name=>"prev_page", -style=>"width:15ex", 654 -value=>"Previous page"); 655 } 656 if ((1+$last_shown)<scalar(@pg_files)) { 657 $next_button = CGI::submit(-name=>"next_page", -style=>"width:15ex", 658 -value=>"Next page"); 659 } 660 if (scalar(@pg_files)>0) { 661 print CGI::p(($first_shown+1)."-".($last_shown+1)." of ".scalar(@pg_files). 662 " shown.", $prev_button, " ", $next_button); 663 } 664 # } 665 print CGI::endform(), "\n"; 666 667 return ""; 668 } 669 670 ############################################## End of Body 671 672 sub pre_header_initialize { 673 my ($self) = @_; 674 my $r = $self->r; 675 ## For all cases, lets set some things 676 $self->{error}=0; 677 $self->{libmsg}=""; 678 $self->{localmsg}=""; 679 680 681 ### Maybe FIXME: this needs to check permissions before doing anything 682 683 ## Now one action we have to deal with here 684 if ($r->param('edit_local')) { 685 my $urlpath = $r->urlpath; 686 my $db = $r->db; 687 my $checkset = $db->getGlobalSet($r->param('local_sets')); 688 if (not defined($checkset)) { 689 $self->{error} = 1; 690 $self->{localmsg} = "You need to select a local set before you can edit it."; 691 return(); 692 } 693 my $page = $urlpath->newFromModule('WeBWorK::ContentGenerator::Instructor::ProblemSetEditor', setID=>$r->param('local_sets'), courseID=>$urlpath->arg("courseID")); 694 my $url = $self->systemLink($page); 695 $self->reply_with_redirect($url); 696 } 697 } 698 699 700 # SKEL: To emit your own HTTP header, uncomment this: 701 # 702 #sub header { 703 # my ($self) = @_; 704 # 705 # # Generate your HTTP header here. 706 # 707 # # If you return something, it will be used as the HTTP status code for this 708 # # request. The Apache::Constants module might be useful for gerating status 709 # # codes. If you don't return anything, the status code "OK" will be used. 710 # return ""; 711 #} 712 713 # SKEL: If you need to do any processing after the HTTP header is sent, but before 714 # any template processing occurs, or you need to calculate values that will be 715 # used in multiple methods, do it in this method: 716 # 717 #sub initialize { 718 #my ($self) = @_; 719 #} 720 721 # SKEL: If you need to add tags to the document <HEAD>, uncomment this method: 722 # 723 #sub head { 724 # my ($self) = @_; 725 # 726 # # You can print head tags here, like <META>, <SCRIPT>, etc. 727 # 728 # return ""; 729 #} 730 731 # SKEL: To fill in the "info" box (to the right of the main body), use this 732 # method: 733 # 734 #sub info { 735 # my ($self) = @_; 736 # 737 # # Print HTML here. 738 # 739 # return ""; 740 #} 741 742 # SKEL: To provide navigation links, use this method: 743 # 744 #sub nav { 745 # my ($self, $args) = @_; 746 # 747 # # See the documentation of path() and pathMacro() in 748 # # WeBWorK::ContentGenerator for more information. 749 # 750 # return ""; 751 #} 752 753 # SKEL: For a little box for display options, etc., use this method: 754 # 755 #sub options { 756 # my ($self) = @_; 757 # 758 # # Print HTML here. 759 # 760 # return ""; 761 #} 762 763 # SKEL: For a list of sibling objects, use this method: 764 # 765 #sub siblings { 766 # my ($self, $args) = @_; 767 # 768 # # See the documentation of siblings() and siblingsMacro() in 769 # # WeBWorK::ContentGenerator for more information. 770 # # 771 # # Refer to implementations in ProblemSet and Problem. 772 # 773 # return ""; 774 #} 775 776 =head1 AUTHOR 777 778 Written by John Jones, jj (at) asu.edu. 779 780 =cut 781 782 783 784 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |