Diff for /loncom/interface/courseclassifier.pm between versions 1.13 and 1.18

version 1.13, 2011/02/25 02:40:42 version 1.18, 2014/03/17 02:33:32
Line 37  use LONCAPA; Line 37  use LONCAPA;
 sub retrieve_instcodes {  sub retrieve_instcodes {
     my ($coursecodes,$codedom) = @_;      my ($coursecodes,$codedom) = @_;
     my $totcodes;      my $totcodes;
     my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.',                                                undef,undef,'Course');      my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.',
                                                   undef,undef,'Course');
     foreach my $course (keys(%courses)) {      foreach my $course (keys(%courses)) {
         if (ref($courses{$course}) eq 'HASH') {          if (ref($courses{$course}) eq 'HASH') {
             if ($courses{$course}{'inst_code'} ne '') {              if ($courses{$course}{'inst_code'} ne '') {
Line 488  sub instcode_selectors_data { Line 489  sub instcode_selectors_data {
                 if ($officialjs) {                  if ($officialjs) {
                     $jscript .= '                      $jscript .= '
   
 function toggleOfficial() {';  function toggleOfficial() {
      var choice; 
      for (var i=0; i<document.'.$formname.'.official.length; i++) {
          if (document.'.$formname.'.official[i].checked) {
              choice = document.'.$formname.'.official[i].value;
          }
      }
      if (choice == "off") {
          if (document.getElementById("instcodes")) {
              document.getElementById("instcodes").style.display = "none";
          }';
                     for (my $i=0; $i<@{$codetitles}-1; $i++) {                      for (my $i=0; $i<@{$codetitles}-1; $i++) {
                         $jscript .= '                          $jscript .= '
             document.'.$formname.'.'.$codetitles->[$i].'.selectedIndex = 0;';         document.'.$formname.'.'.$codetitles->[$i].'.selectedIndex = 0;';
                     }                      }
     $jscript .=  '      $jscript .= '
      } else {
          if (document.getElementById("instcodes")) { 
              document.getElementById("instcodes").style.display = "block";
          }
      }
 }  }
   
 function setOfficial(caller) {  function setOfficial(caller) {
Line 563  sub build_instcode_selectors { Line 579  sub build_instcode_selectors {
     my $output;      my $output;
     my @standardnames = &Apache::loncommon::get_standard_codeitems();      my @standardnames = &Apache::loncommon::get_standard_codeitems();
     if ($numtitles > 0) {      if ($numtitles > 0) {
         $output .= '<table><tr>';          my $style;
           if ($env{'form.official'} eq 'off') {
               $style = ' style="display: none"';
           }
           $output .= '<div id="instcodes"'.$style.'><table><tr>';
         for (my $k=0; $k<$lasttitle-1; $k++) {          for (my $k=0; $k<$lasttitle-1; $k++) {
             my (@items,@unsorted);              my (@items,@unsorted);
             if (ref($cat_items->{$codetitles->[$k]}) eq 'ARRAY') {              if (ref($cat_items->{$codetitles->[$k]}) eq 'ARRAY') {
Line 579  sub build_instcode_selectors { Line 599  sub build_instcode_selectors {
                 @longitems = @items;                  @longitems = @items;
             }              }
             $output .= '<td align="center">'.$codetitles->[$k].'<br />'."\n".              $output .= '<td align="center">'.$codetitles->[$k].'<br />'."\n".
                        '<select name="'.$standardnames[$k].'" onChange="courseSet(this)"'.                         '<select name="'.$standardnames[$k].'" onchange="courseSet(this)"'.
                        '>'."\n".'<option value="0">'.&mt('All').'</option>'."\n";                         '>'."\n".'<option value="0">'.&mt('All').'</option>'."\n";
             for (my $i=0; $i<@items; $i++) {              for (my $i=0; $i<@items; $i++) {
                 if ($longitems[$i] eq '') {                  if ($longitems[$i] eq '') {
Line 599  sub build_instcode_selectors { Line 619  sub build_instcode_selectors {
                        '<input type="text" name="'.$standardnames[$numtitles-1].                         '<input type="text" name="'.$standardnames[$numtitles-1].
                        '" /><br />'."\n";                         '" /><br />'."\n";
         }          }
         $output .= '<br />';          $output .= '</div>';
     }      }
     return $output;      return $output;
 }  }
   
   sub instcode_selectors {
       my ($codedom,$formname,$officialjs,$codetitles) = @_;
       my ($output,%cat_titles,%cat_order,%cat_items);
       my ($jscript,$totcodes,$numtitles,$lasttitle) =
           &instcode_selectors_data($codedom,$formname,\%cat_items,$codetitles,
                                    \%cat_titles,\%cat_order,$officialjs);
       if ($numtitles > 0) {
           my $official = ' checked="checked" ';
           my $unofficial = '';
           if (($formname eq 'filterpicker') && ($env{'form.official'} eq 'off')) {
               $unofficial = $official;
               $official = '';
           }
           $output .= '<span class="LC_nobreak">'.&mt('Official course:').'&nbsp;<label>'.
                      '<input type="radio" name="official" value="on"'.$official.
                      ' onclick="toggleOfficial();" />'.&mt('Yes').'</label>'.
                      ('&nbsp;'x3).'<label>'.
                      '<input type="radio" name="official" value="off"'.$unofficial.
                      ' onclick="toggleOfficial();" />'.&mt('No').'</label></span><br />'.
                      &build_instcode_selectors($numtitles,$lasttitle,\%cat_items,$codetitles,
                                                \%cat_titles,\%cat_order)."\n".
                      '<input type="hidden" name="numtitles" value="'.$numtitles.'" />'."\n".
                      '<input type="hidden" name="state" value="listing" />'."\n";
       }
       return ($output,$jscript,$numtitles);
   }
   
 sub recurse_options {  sub recurse_options {
     my ($currkey,$currlist,$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept) = @_;      my ($currkey,$currlist,$level,$cat,$cat_options,$data,$by_year,$by_sem,$by_dept) = @_;
     if (ref($currlist) eq 'HASH') {      if (ref($currlist) eq 'HASH') {
Line 802  function courseSet(caller) { Line 849  function courseSet(caller) {
                     }                      }
                 }                  }
                 if (iddept != -1) {                  if (iddept != -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 i=0; i<idcourses[idyr][idsem][iddept].length; i++) {                      for (var i=0; i<idcourses[idyr][idsem][iddept].length; i++) {
                         var display = idcourses[idyr][idsem][iddept][i];                          var display = idcourses[idyr][idsem][iddept][i];
                         if (longtitles[3] == 1) {                          if (longtitles[3] == 1) {
Line 869  sub instcode_search_str { Line 916  sub instcode_search_str {
 }  }
   
 sub instcode_from_selectors {  sub instcode_from_selectors {
     my ($cdom) = @_;      my ($cdom,$noregexps) = @_;
     my $instcode;      my $instcode;
     my $caller = 'global';      my $caller = 'global';
     my (%coursecodes,%codes,@codetitles,%cat_titles,%cat_order,      my (%coursecodes,%codes,@codetitles,%cat_titles,%cat_order,
Line 890  sub instcode_from_selectors { Line 937  sub instcode_from_selectors {
             my $category = $local_to_standard{$loctitle};              my $category = $local_to_standard{$loctitle};
             if ($category ne '') {              if ($category ne '') {
                 if ($env{'form.'.$category} eq '-1' ) {                  if ($env{'form.'.$category} eq '-1' ) {
                     $instcode .= $codedefaults{$category};                      if ($noregexps) {
                           $instcode .= ' ';
                       } else {
                           $instcode .= $codedefaults{$category};
                       }
                 } else {                  } else {
                     $instcode .= $env{'form.'.$category};                      $instcode .= $env{'form.'.$category};
                 }                  }

Removed from v.1.13  
changed lines
  Added in v.1.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>