--- loncom/interface/courseclassifier.pm 2010/07/08 23:19:19 1.9 +++ loncom/interface/courseclassifier.pm 2014/03/11 21:42:18 1.16 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utilities for classifying courses based on institutional code # -# $Id: courseclassifier.pm,v 1.9 2010/07/08 23:19:19 raeburn Exp $ +# $Id: courseclassifier.pm,v 1.16 2014/03/11 21:42:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,6 +30,7 @@ package Apache::courseclassifier; use strict; use lib '/home/httpd/lib/perl/'; use Apache::lonnet; +use Apache::loncommon; use Apache::lonlocal; use LONCAPA; @@ -39,8 +40,10 @@ sub retrieve_instcodes { my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.', undef,undef,'Course'); foreach my $course (keys(%courses)) { if (ref($courses{$course}) eq 'HASH') { - $$coursecodes{$course} = $courses{$course}{'inst_code'}; - $totcodes ++; + if ($courses{$course}{'inst_code'} ne '') { + $$coursecodes{$course} = $courses{$course}{'inst_code'}; + $totcodes ++; + } } } return $totcodes; @@ -52,7 +55,7 @@ sub sort_cats { if (defined($$cat_order{$$codetitles[$num]})) { foreach my $item (@{$$cat_order{$$codetitles[$num]}}) { if (grep/^\Q$item\E$/,@unsorted) { - push @{$sorted}, $item; + push(@{$sorted},$item); } } } else { @@ -258,12 +261,16 @@ sub build_code_selections { sub javascript_code_selections { my ($formname,@codetitles) = @_; my $numtitles = @codetitles; + my %lt = &Apache::lonlocal::texthash( + Select => 'Select', + Pick => 'Pick', + ); my $output = (<[$i]} = $standardnames[$i]; + } + } $jscript .= ' function setElements() { '; for (my $i=0; $i<@{$codetitles}-1; $i++) { - if ($env{'form.'.$codetitles->[$i]} != -1) { + my $item = $local_to_standard{$codetitles->[$i]}; + if ($env{'form.'.$item} != -1) { $jscript .= ' - for (var j=0; j[$i].'.length; j++) { - if (document.'.$formname.'.'.$codetitles->[$i].'[j].value == "'.$env{'form.'.$codetitles->[$i]}.'") { - document.'.$formname.'.'.$codetitles->[$i].'.selectedIndex = j; + for (var j=0; j[-1]} != -1) { + my $lastcodetitle = $local_to_standard{$codetitles->[-1]}; + if ($env{'form.'.$lastcodetitle} != -1) { $jscript .= ' - for (var j=0; j[-1].'.length; j++) { - if (document.'.$formname.'.'.$codetitles->[-1].'[j].value == "'.$env{'form.'.$codetitles->[-1]}.'") { - document.'.$formname.'.'.$codetitles->[-1].'.selectedIndex = j; + for (var j=0; j 0) { $output .= ''; for (my $k=0; $k<$lasttitle-1; $k++) { @@ -563,7 +579,7 @@ sub build_instcode_selectors { @longitems = @items; } $output .= '
'.$codetitles->[$k].'
'."\n". - ''. + &mt('Yes').''.(' 'x3).'
'. + &build_instcode_selectors($numtitles,$lasttitle,\%cat_items,$codetitles, + \%cat_titles,\%cat_order)."\n". + ''."\n". + ''."\n"; + } + return ($output,$jscript,$numtitles); +} + sub recurse_options { my ($currkey,$currlist,$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept) = @_; if (ref($currlist) eq 'HASH') { @@ -672,6 +714,8 @@ sub build_javascript { sub javascript_select_filler { my ($formname,$scripttext,$codetitles,$longtitles_str,$allidlist,$officialjs) = @_; + my $all = &mt('All'); + my $nocrs = &mt('No courses'); my $output = < -1) { - document.$formname.Number.options[0] = new Option('All','0',false,false); + document.$formname.Number.options[0] = new Option('$all','0',false,false); for (var k=0; k