--- loncom/interface/courseclassifier.pm 2010/07/08 23:19:19 1.9 +++ loncom/interface/courseclassifier.pm 2010/07/09 14:40:20 1.10 @@ -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.10 2010/07/09 14:40:20 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; @@ -258,12 +259,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 = (< 0) { $output .= ''; for (my $k=0; $k<$lasttitle-1; $k++) { @@ -821,7 +826,7 @@ sub instcode_search_str { my $defaults_result = &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults, \@code_order); - my @standardnames = &get_standard_codeitems(); + my @standardnames = &Apache::loncommon::get_standard_codeitems(); my %local_to_standard; if (ref($codetitles) eq 'ARRAY') { for (my $i=0; $i<@{$codetitles}; $i++) { @@ -850,8 +855,38 @@ sub instcode_search_str { return $instcode; } -sub get_standard_codeitems { - return ('Year','Semester','Department','Number'); +sub instcode_from_selectors { + my ($cdom) = @_; + my $instcode; + my $caller = 'global'; + my (%coursecodes,%codes,@codetitles,%cat_titles,%cat_order, + %codedefaults,@code_order); + my $format_reply = + &Apache::lonnet::auto_instcode_format($caller,$cdom,\%coursecodes, + \%codes,\@codetitles,\%cat_titles,\%cat_order); + my $defaults_result = + &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults, + \@code_order); + if (($defaults_result eq 'ok') && ($format_reply eq 'ok')) { + my @standardnames = &Apache::loncommon::get_standard_codeitems(); + my %local_to_standard; + for (my $i=0; $i<@codetitles; $i++) { + $local_to_standard{$codetitles[$i]} = $standardnames[$i]; + } + foreach my $loctitle (@code_order) { + my $category = $local_to_standard{$loctitle}; + if ($category ne '') { + if ($env{'form.'.$category} eq '-1' ) { + $instcode .= $codedefaults{$category}; + } else { + $instcode .= $env{'form.'.$category}; + } + } else { + $instcode .= '.+'; + } + } + } + return $instcode; } 1;