From: Sam H. v. a. <we...@ma...> - 2007-08-25 18:30:15
|
Log Message: ----------- backport (jj): Textbook chapters and sections will now include their numbers in the library browser, and be sorted accordingly. Tags: ---- rel-2-4-dev Modified Files: -------------- webwork2/lib/WeBWorK/Utils: ListingDB.pm Revision Data ------------- Index: ListingDB.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/Utils/ListingDB.pm,v retrieving revision 1.15.2.3 retrieving revision 1.15.2.4 diff -Llib/WeBWorK/Utils/ListingDB.pm -Llib/WeBWorK/Utils/ListingDB.pm -u -r1.15.2.3 -r1.15.2.4 --- lib/WeBWorK/Utils/ListingDB.pm +++ lib/WeBWorK/Utils/ListingDB.pm @@ -23,9 +23,9 @@ use constant LIBRARY_STRUCTURE => { textbook => { select => 'tbk.textbook_id,tbk.title,tbk.author,tbk.edition', name => 'library_textbook', where => 'tbk.textbook_id'}, - textchapter => { select => 'tc.name', name=>'library_textchapter', + textchapter => { select => 'tc.number,tc.name', name=>'library_textchapter', where => 'tc.name'}, - textsection => { select => 'ts.name', name=>'library_textsection', + textsection => { select => 'ts.number,ts.name', name=>'library_textsection', where => 'ts.name'}, problem => { select => 'prob.name' }, }; @@ -137,6 +137,7 @@ } my $textchap = $r->param('library_textchapter') || ''; + $textchap =~ s/^\s*\d+\.\s*//; if($textchap and $thing eq 'textsection') { $textextrawhere .= " AND tc.name=\"$textchap\" "; } else { @@ -169,9 +170,10 @@ @texts = indirectSortByName( \@sortarray, @texts ); return(\@texts); } else { - @texts = grep { $_->[0] =~ /\S/ } @texts; - my @sortarray = map { $_->[0] } @texts; - @texts = indirectSortByName( \@sortarray, @texts ); + @texts = grep { $_->[1] =~ /\S/ } @texts; + my @sortarray = map { $_->[0] .". " . $_->[1] } @texts; + @texts = map { [ $_ ] } @sortarray; + @texts = indirectSortByName(\@sortarray, @texts); return(\@texts); } } @@ -268,8 +270,7 @@ $kw1 = ", `NPL-keyword` kw, `NPL-pgfile-keyword` pgkey"; $kw2 = " AND kw.keyword_id=pgkey.keyword_id AND pgkey.pgfile_id=pgf.pgfile_id ". - makeKeywordWhere($keywords) - ; + makeKeywordWhere($keywords) ; } my $dbh = getDB($ce); @@ -291,6 +292,7 @@ my $haveTextInfo=0; for my $j (qw( textbook textchapter textsection )) { my $foo = $r->param(LIBRARY_STRUCTURE->{$j}{name}) || ''; + $foo =~ s/^\s*\d+\.\s*//; if($foo) { $haveTextInfo=1; $foo =~ s/'/\\'/g; |