--- loncom/interface/courseclassifier.pm 2010/07/08 23:19:19 1.9 +++ loncom/interface/courseclassifier.pm 2013/07/15 14:32:45 1.15 @@ -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.15 2013/07/15 14:32:45 bisitz 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". - '