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

Diff of /trunk/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm

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

Revision 3431 Revision 3449
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.46 2005/07/29 20:45:38 jj Exp $ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.47 2005/07/30 00:13:44 jj Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
45use constant ALL_CHAPTERS => 'All Chapters'; 45use constant ALL_CHAPTERS => 'All Chapters';
46use constant ALL_SUBJECTS => 'All Subjects'; 46use constant ALL_SUBJECTS => 'All Subjects';
47use constant ALL_SECTIONS => 'All Sections'; 47use constant ALL_SECTIONS => 'All Sections';
48use constant ALL_TEXTBOOKS => 'All Textbooks'; 48use constant ALL_TEXTBOOKS => 'All Textbooks';
49 49
50#use constant LIB2_DATA => [ 50use constant LIB2_DATA => {
51 #[qw(dbchapter library_chapters), ALL_CHAPTERS], 51 'dbchapter' => {name => 'library_chapters', all => 'All Chapters'},
52 #[qw(dbsection library_sections), ALL_SECTIONS], 52 'dbsection' => {name => 'library_sections', all =>'All Sections' },
53 #[qw(dbsubject library_subjects), ALL_SUBJECT], 53 'dbsubject' => {name => 'library_subjects', all => 'All Subjects' },
54 #[qw(textbook library_textbook), ALL_TEXTBOOKS], 54 'textbook' => {name => 'library_textbook', all => 'All Textbooks'},
55 #]; 55 'textchapter' => {name => 'library_textchapter', all => 'All Chapters'},
56 'textsection' => {name => 'library_textsection', all => 'All Sections'},
57 'keywords' => {name => 'library_keywords', all => '' },
58 };
56 59
57## Flags for operations on files 60## Flags for operations on files
58 61
59use constant ADDED => 1; 62use constant ADDED => 1;
60use constant HIDDEN => (1 << 1); 63use constant HIDDEN => (1 << 1);
412 my $self = shift; 415 my $self = shift;
413 my $r = $self->r; 416 my $r = $self->r;
414 my $ce = $r->ce; 417 my $ce = $r->ce;
415 418
416 my @chaps = WeBWorK::Utils::ListingDB::getAllChapters($r->{ce}); 419 my @chaps = WeBWorK::Utils::ListingDB::getAllChapters($r->{ce});
417 unshift @chaps, ALL_CHAPTERS; 420 unshift @chaps, LIB2_DATA->{dbchapter}{all};
418 my $chapter_selected = $r->param('library_chapters') || ALL_CHAPTERS; 421 my $chapter_selected = $r->param('library_chapters') || LIB2_DATA->{dbchapter}->{all};
419 422
420 my @sects=(); 423 my @sects=();
421 if ($chapter_selected ne ALL_CHAPTERS) { 424 if ($chapter_selected ne LIB2_DATA->{dbchapter}{all}) {
422 @sects = WeBWorK::Utils::ListingDB::getAllSections($r->{ce}, $chapter_selected); 425 @sects = WeBWorK::Utils::ListingDB::getAllSections($r->{ce}, $chapter_selected);
423 } 426 }
424 427
425 unshift @sects, ALL_SECTIONS; 428 unshift @sects, ALL_SECTIONS;
426 my $section_selected = $r->param('library_sections') || ALL_SECTIONS; 429 my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all};
430
427 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 431 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r);
428 432
429 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, 433 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"},
430 CGI::start_table(), 434 CGI::start_table(),
431 CGI::Tr( 435 CGI::Tr(
453 my $self = shift; 457 my $self = shift;
454 my $r = $self->r; 458 my $r = $self->r;
455 my $ce = $r->ce; 459 my $ce = $r->ce;
456 460
457 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); 461 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r);
458 unshift @subjs, ALL_SUBJECTS; 462 unshift @subjs, LIB2_DATA->{dbsubject}{all};
459 463
460 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); 464 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r);
461 unshift @chaps, ALL_CHAPTERS; 465 unshift @chaps, LIB2_DATA->{dbchapter}{all};
462 466
463 my @sects=(); 467 my @sects=();
464 @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); 468 @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r);
465 unshift @sects, ALL_SECTIONS; 469 unshift @sects, LIB2_DATA->{dbsection}{all};
466 470
467 my $subject_selected = $r->param('library_subjects') || ALL_SUBJECTS; 471 my $subject_selected = $r->param('library_subjects') || LIB2_DATA->{dbsubject}{all};
468 my $chapter_selected = $r->param('library_chapters') || ALL_CHAPTERS; 472 my $chapter_selected = $r->param('library_chapters') || LIB2_DATA->{dbchapter}{all};
469 my $section_selected = $r->param('library_sections') || ALL_SECTIONS; 473 my $section_selected = $r->param('library_sections') || LIB2_DATA->{dbsection}{all};
470 474
471 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 475 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r);
476
477 my $count_line = WeBWorK::Utils::ListingDB::countDBListings($r);
478 if($count_line==0) {
479 $count_line = "There are no matching pg files";
480 } else {
481 $count_line = "There are $count_line matching WeBWorK problem files";
482 }
472 483
473 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"}, 484 print CGI::Tr(CGI::td({-class=>"InfoPanel", -align=>"left"},
474 CGI::hidden(-name=>"library_is_basic", -default=>[1]), 485 CGI::hidden(-name=>"library_is_basic", -default=>[1]),
475 CGI::start_table({-width=>"100%"}), 486 CGI::start_table({-width=>"100%"}),
476 CGI::Tr( 487 CGI::Tr(
495 ), 506 ),
496 CGI::Tr( 507 CGI::Tr(
497 CGI::td(["Section:", 508 CGI::td(["Section:",
498 CGI::popup_menu(-name=> 'library_sections', 509 CGI::popup_menu(-name=> 'library_sections',
499 -values=>\@sects, 510 -values=>\@sects,
500 -default=> $section_selected 511 -default=> $section_selected,
512 -onchange=>"submit();return true"
501 )]), 513 )]),
502 ), 514 ),
503 CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)), 515 CGI::Tr(CGI::td({-colspan=>3}, $view_problem_line)),
516 CGI::Tr(CGI::td({-colspan=>3, -align=>"center"}, $count_line)),
504 CGI::end_table(), 517 CGI::end_table(),
505 )); 518 ));
506 519
507} 520}
508 521
514 527
515 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); 528 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r);
516 if(! grep { $_ eq $r->param('library_subjects') } @subjs) { 529 if(! grep { $_ eq $r->param('library_subjects') } @subjs) {
517 $r->param('library_subjects', ''); 530 $r->param('library_subjects', '');
518 } 531 }
519 unshift @subjs, ALL_SUBJECTS; 532 unshift @subjs, LIB2_DATA->{dbsubject}{all};
520 533
521 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); 534 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r);
522 if(! grep { $_ eq $r->param('library_chapters') } @chaps) { 535 if(! grep { $_ eq $r->param('library_chapters') } @chaps) {
523 $r->param('library_chapters', ''); 536 $r->param('library_chapters', '');
524 } 537 }
525 unshift @chaps, ALL_CHAPTERS; 538 unshift @chaps, LIB2_DATA->{dbchapter}{all};
526 539
527 my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); 540 my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r);
528 if(! grep { $_ eq $r->param('library_sections') } @sects) { 541 if(! grep { $_ eq $r->param('library_sections') } @sects) {
529 $r->param('library_sections', ''); 542 $r->param('library_sections', '');
530 } 543 }
531 unshift @sects, ALL_SECTIONS; 544 unshift @sects, LIB2_DATA->{dbsection}{all};
532 545
533 my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r); 546 my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r);
534 my @textarray = map { $_->[0] } @{$texts}; 547 my @textarray = map { $_->[0] } @{$texts};
535 my %textlabels = (); 548 my %textlabels = ();
536 for my $ta (@{$texts}) { 549 for my $ta (@{$texts}) {
537 $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")"; 550 $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")";
538 } 551 }
539 if(! grep { $_ eq $r->param('library_textbook') } @textarray) { 552 if(! grep { $_ eq $r->param('library_textbook') } @textarray) {
540 $r->param('library_textbook', ''); 553 $r->param('library_textbook', '');
541 } 554 }
542 unshift @textarray, ALL_TEXTBOOKS; 555 unshift @textarray, LIB2_DATA->{textbook}{all};
543 my $atb = ALL_TEXTBOOKS; $textlabels{$atb} = ALL_TEXTBOOKS; 556 my $atb = LIB2_DATA->{textbook}{all}; $textlabels{$atb} = LIB2_DATA->{textbook}{all};
544 557
545 my $section_selected = $r->param('library_sections') || ALL_SECTIONS; 558 my $textchap_ref = WeBWorK::Utils::ListingDB::getDBTextbooks($r, 'textchapter');
546 my $chapter_selected = $r->param('library_chapters') || ALL_CHAPTERS; 559 my @textchaps = map { $_->[0] } @{$textchap_ref};
547 my $subject_selected = $r->param('library_subjects') || ALL_SUBJECTS; 560 if(! grep { $_ eq $r->param('library_textchapter') } @textchaps) {
548 my $textbook_selected = $r->param('library_textbook') || ALL_TEXTBOOKS; 561 $r->param('library_textchapter', '');
562 }
563 unshift @textchaps, LIB2_DATA->{textchapter}{all};
564
565 my $textsec_ref = WeBWorK::Utils::ListingDB::getDBTextbooks($r, 'textsection');
566 my @textsecs = map { $_->[0] } @{$textsec_ref};
567 if(! grep { $_ eq $r->param('library_textsection') } @textsecs) {
568 $r->param('library_textsection', '');
569 }
570 unshift @textsecs, LIB2_DATA->{textsection}{all};
571
572 my %selected = ();
573 for my $j (qw( dbsection dbchapter dbsubject textbook textchapter textsection )) {
574 $selected{$j} = $r->param(LIB2_DATA->{$j}{name}) || LIB2_DATA->{$j}{all};
575 }
549 576
550 my $text_popup = CGI::popup_menu(-name => 'library_textbook', 577 my $text_popup = CGI::popup_menu(-name => 'library_textbook',
551 -values =>\@textarray, 578 -values =>\@textarray,
552 -labels => \%textlabels, 579 -labels => \%textlabels,
553 -default=>$textbook_selected, 580 -default=>$selected{textbook},
554 -onchange=>"submit();return true"); 581 -onchange=>"submit();return true");
582
555 583
556 my $library_keywords = $r->param('library_keywords') || ''; 584 my $library_keywords = $r->param('library_keywords') || '';
557 585
558 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r); 586 my $view_problem_line = view_problems_line('lib_view', 'View Problems', $self->r);
559 587
571 CGI::Tr(CGI::td({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"')), 599 CGI::Tr(CGI::td({-colspan=>4, -align=>"center"}, 'All Selected Constraints Joined by "And"')),
572 CGI::Tr( 600 CGI::Tr(
573 CGI::td(["Subject:", 601 CGI::td(["Subject:",
574 CGI::popup_menu(-name=> 'library_subjects', 602 CGI::popup_menu(-name=> 'library_subjects',
575 -values=>\@subjs, 603 -values=>\@subjs,
576 -default=> $subject_selected, 604 -default=> $selected{dbsubject},
577 -onchange=>"submit();return true" 605 -onchange=>"submit();return true"
578 )]), 606 )]),
579 CGI::td({-colspan=>2, -align=>"right"}, 607 CGI::td({-colspan=>2, -align=>"right"},
580 CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus", 608 CGI::submit(-name=>"lib_select_subject", -value=>"Update Menus",
581 -style=> $right_button_style))), 609 -style=> $right_button_style))),
582 CGI::Tr( 610 CGI::Tr(
583 CGI::td(["Chapter:", 611 CGI::td(["Chapter:",
584 CGI::popup_menu(-name=> 'library_chapters', 612 CGI::popup_menu(-name=> 'library_chapters',
585 -values=>\@chaps, 613 -values=>\@chaps,
586 -default=> $chapter_selected, 614 -default=> $selected{dbchapter},
587 -onchange=>"submit();return true" 615 -onchange=>"submit();return true"
588 )]), 616 )]),
589 CGI::td({-colspan=>2, -align=>"right"}, 617 CGI::td({-colspan=>2, -align=>"right"},
590 CGI::submit(-name=>"library_reset", -value=>"Reset", 618 CGI::submit(-name=>"library_reset", -value=>"Reset",
591 -style=>$right_button_style)) 619 -style=>$right_button_style))
592 ), 620 ),
593 CGI::Tr( 621 CGI::Tr(
594 CGI::td(["Section:", 622 CGI::td(["Section:",
595 CGI::popup_menu(-name=> 'library_sections', 623 CGI::popup_menu(-name=> 'library_sections',
596 -values=>\@sects, 624 -values=>\@sects,
597 -default=> $section_selected, 625 -default=> $selected{dbsection},
598 -onchange=>"submit();return true" 626 -onchange=>"submit();return true"
599 )]), 627 )]),
600 CGI::td({-colspan=>2, -align=>"right"}, 628 CGI::td({-colspan=>2, -align=>"right"},
601 CGI::submit(-name=>"library_basic", -value=>"Basic Search", 629 CGI::submit(-name=>"library_basic", -value=>"Basic Search",
602 -style=>$right_button_style)) 630 -style=>$right_button_style))
603 ), 631 ),
604 CGI::Tr( 632 CGI::Tr(
605 CGI::td(["Textbook:", $text_popup]), 633 CGI::td(["Textbook:", $text_popup]),
634 ),
635 CGI::Tr(
636 CGI::td(["Text chapter:",
637 CGI::popup_menu(-name=> 'library_textchapter',
638 -values=>\@textchaps,
639 -default=> $selected{textchapter},
640 -onchange=>"submit();return true"
641 )]),
642 ),
643 CGI::Tr(
644 CGI::td(["Text section:",
645 CGI::popup_menu(-name=> 'library_textsection',
646 -values=>\@textsecs,
647 -default=> $selected{textsection},
648 -onchange=>"submit();return true"
649 )]),
606 ), 650 ),
607 CGI::Tr(CGI::td("Keywords:"),CGI::td({-colspan=>2}, 651 CGI::Tr(CGI::td("Keywords:"),CGI::td({-colspan=>2},
608 CGI::textfield(-name=>"library_keywords", 652 CGI::textfield(-name=>"library_keywords",
609 -default=>$library_keywords, 653 -default=>$library_keywords,
610 -override=>1, 654 -override=>1,
1112 1156
1113 } elsif ($r->param('select_all')) { 1157 } elsif ($r->param('select_all')) {
1114 @past_marks = map {1} @past_marks; 1158 @past_marks = map {1} @past_marks;
1115 } elsif ($r->param('library_basic')) { 1159 } elsif ($r->param('library_basic')) {
1116 $library_basic = 1; 1160 $library_basic = 1;
1161 for my $jj (qw(textchapter textsection textbook)) {
1162 $r->param('library_'.$jj,'');
1163 }
1117 } elsif ($r->param('library_advanced')) { 1164 } elsif ($r->param('library_advanced')) {
1118 $library_basic = 2; 1165 $library_basic = 2;
1166 } elsif ($r->param('library_reset')) {
1167 for my $jj (qw(chapters sections subjects textbook keywords)) {
1168 $r->param('library_'.$jj,'');
1169 }
1119 } elsif ($r->param('select_none')) { 1170 } elsif ($r->param('select_none')) {
1120 @past_marks = (); 1171 @past_marks = ();
1121 1172
1122 ##### No action requested, probably our first time here 1173 ##### No action requested, probably our first time here
1123 1174

Legend:
Removed from v.3431  
changed lines
  Added in v.3449

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9