[system] / branches / rel-2-3-dev / webwork-modperl / lib / WeBWorK / ContentGenerator / Instructor / SetMaker.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-3-dev/webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm

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

Revision 3427 Revision 3431
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.42 2005/07/26 22:28:56 jj Exp $ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/SetMaker.pm,v 1.46 2005/07/29 20:45:38 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.
44use constant CREATE_SET_BUTTON => 'Create New Set'; 44use constant CREATE_SET_BUTTON => 'Create New Set';
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
50#use constant LIB2_DATA => [
51 #[qw(dbchapter library_chapters), ALL_CHAPTERS],
52 #[qw(dbsection library_sections), ALL_SECTIONS],
53 #[qw(dbsubject library_subjects), ALL_SUBJECT],
54 #[qw(textbook library_textbook), ALL_TEXTBOOKS],
55 #];
49 56
50## Flags for operations on files 57## Flags for operations on files
51 58
52use constant ADDED => 1; 59use constant ADDED => 1;
53use constant HIDDEN => (1 << 1); 60use constant HIDDEN => (1 << 1);
504 my $r = $self->r; 511 my $r = $self->r;
505 my $ce = $r->ce; 512 my $ce = $r->ce;
506 my $right_button_style = "width: 18ex"; 513 my $right_button_style = "width: 18ex";
507 514
508 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r); 515 my @subjs = WeBWorK::Utils::ListingDB::getAllDBsubjects($r);
516 if(! grep { $_ eq $r->param('library_subjects') } @subjs) {
517 $r->param('library_subjects', '');
518 }
509 unshift @subjs, ALL_SUBJECTS; 519 unshift @subjs, ALL_SUBJECTS;
510 520
511 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r); 521 my @chaps = WeBWorK::Utils::ListingDB::getAllDBchapters($r);
522 if(! grep { $_ eq $r->param('library_chapters') } @chaps) {
523 $r->param('library_chapters', '');
524 }
512 unshift @chaps, ALL_CHAPTERS; 525 unshift @chaps, ALL_CHAPTERS;
513 526
514 my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r); 527 my @sects = WeBWorK::Utils::ListingDB::getAllDBsections($r);
528 if(! grep { $_ eq $r->param('library_sections') } @sects) {
529 $r->param('library_sections', '');
530 }
515 unshift @sects, ALL_SECTIONS; 531 unshift @sects, ALL_SECTIONS;
516 532
517 my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r); 533 my $texts = WeBWorK::Utils::ListingDB::getDBTextbooks($r);
518 my @textarray = map { $_->[0] } @{$texts}; 534 my @textarray = map { $_->[0] } @{$texts};
519 my %textlabels = (); 535 my %textlabels = ();
520 for my $ta (@{$texts}) { 536 for my $ta (@{$texts}) {
521 $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")"; 537 $textlabels{$ta->[0]} = $ta->[1]." by ".$ta->[2]." (edition ".$ta->[3].")";
538 }
539 if(! grep { $_ eq $r->param('library_textbook') } @textarray) {
540 $r->param('library_textbook', '');
522 } 541 }
523 unshift @textarray, ALL_TEXTBOOKS; 542 unshift @textarray, ALL_TEXTBOOKS;
524 my $atb = ALL_TEXTBOOKS; $textlabels{$atb} = ALL_TEXTBOOKS; 543 my $atb = ALL_TEXTBOOKS; $textlabels{$atb} = ALL_TEXTBOOKS;
525 544
526 my $section_selected = $r->param('library_sections') || ALL_SECTIONS; 545 my $section_selected = $r->param('library_sections') || ALL_SECTIONS;
791 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName]). 810 CGI::hidden(-name=>"filetrial$cnt", -default=>[$sourceFileName]).
792 CGI::p($problem_output), 811 CGI::p($problem_output),
793 )); 812 ));
794} 813}
795 814
815sub clear_default {
816 my $r = shift;
817 my $param = shift;
818 my $default = shift;
819 my $newvalue = $r->param($param) || '';
820 $newvalue = '' if($newvalue eq $default);
821 $r->param($param, $newvalue);
822}
796 823
797sub pre_header_initialize { 824sub pre_header_initialize {
798 my ($self) = @_; 825 my ($self) = @_;
799 my $r = $self->r; 826 my $r = $self->r;
800 ## For all cases, lets set some things 827 ## For all cases, lets set some things
804 my $maxShown = $r->param('max_shown') || MAX_SHOW_DEFAULT; 831 my $maxShown = $r->param('max_shown') || MAX_SHOW_DEFAULT;
805 $maxShown = 10000000 if($maxShown eq 'All'); # let's hope there aren't more 832 $maxShown = 10000000 if($maxShown eq 'All'); # let's hope there aren't more
806 my $library_basic = $r->param('library_is_basic') || 1; 833 my $library_basic = $r->param('library_is_basic') || 1;
807 834
808 ## Fix some parameters 835 ## Fix some parameters
809 $r->param('library_subjects', '') if($r->param('library_subjects') eq ALL_SUBJECTS); 836 clear_default($r,'library_subjects', ALL_SUBJECTS);
810 $r->param('library_chapters', '') if($r->param('library_chapters') eq ALL_CHAPTERS); 837 clear_default($r,'library_chapters', ALL_CHAPTERS);
811 $r->param('library_sections', '') if($r->param('library_sections') eq ALL_SECTIONS); 838 clear_default($r,'library_sections', ALL_SECTIONS);
812 $r->param('library_textbook', '') if($r->param('library_textbook') eq ALL_TEXTBOOKS); 839 clear_default($r,'library_textbook', ALL_TEXTBOOKS);
813 840
814 ## These directories will have individual buttons 841 ## These directories will have individual buttons
815 %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs}; 842 %problib = %{$ce->{courseFiles}{problibs}} if $ce->{courseFiles}{problibs};
816 843
817 my $userName = $r->param('user'); 844 my $userName = $r->param('user');

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9