Diff for /loncom/interface/lonpickcode.pm between versions 1.13 and 1.16

version 1.13, 2007/10/12 20:08:38 version 1.16, 2013/02/01 18:46:37
Line 69  sub handler { Line 69  sub handler {
     if  (!($env{'request.course.id'}) &&       if  (!($env{'request.course.id'}) && 
  (&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {   (&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) {
  $r->print(&Apache::loncommon::start_page().   $r->print(&Apache::loncommon::start_page().
   &mt('Access not allowed.').    '<p class="LC_error">'.&mt('Access not allowed.').'</p>'.
   &Apache::loncommon::end_page());    &Apache::loncommon::end_page());
         return OK;          return OK;
     }      }
Line 92  sub code_list { Line 92  sub code_list {
     # $context = 1 No page header, print enclosing table      # $context = 1 No page header, print enclosing table
     # $context = 2 No page header, no enclosing table      # $context = 2 No page header, no enclosing table
     my $table_head;      my $table_head;
     my $enc_table_start;      my $extra_css;
     my $enc_table_close;  
       
     if (!$context) {      if (!$context) {
  $r->print(&Apache::loncommon::start_page("View CODEs",undef,   $r->print(&Apache::loncommon::start_page("View CODEs",undef,
  {'no_nav_bar' => 1}));   {'no_nav_bar' => 1}));
  $table_head = ('<b>'.&mt('Select a set of saved CODEs to view.')."</b>");   $table_head = &mt('Select a set of saved CODEs to view.');
     } elsif ($context eq 1) {      } elsif ($context eq 1) {
  $table_head = ('<b>'.&mt('Select another set of saved CODEs to view.')."</b>");   $table_head = &mt('Select another set of saved CODEs to view.');
  $enc_table_start = '<table width="100%"><tr><td bgcolor="#777777">';  
  $enc_table_close = '</tr></td></table>';  
     } elsif ($context eq 2) {      } elsif ($context eq 2) {
         $table_head = ('<b>'.&mt('Select a set of saved CODEs to view.')."</b>");          $table_head = &mt('Select a set of saved CODEs to view.');
    $extra_css = 'LC_scantron_action';
     }      }
     $r->print("<form method='POST' action='/adm/pickcode' name='pickcode'>");      $r->print("<form method='post' action='/adm/pickcode' name='pickcode'>");
     $r->print($enc_table_start);      $r->print('
     $r->print('<table width="100%">');       '.&Apache::loncommon::start_data_table($extra_css).'
     $r->print('<tr><td bgcolor="#e6ffff">');         '.&Apache::loncommon::start_data_table_header_row());
       $r->print('<th>');
     $r->print($table_head);      $r->print($table_head);
     $r->print('</td></tr>');      $r->print('</th>');
     $r->print('<tr><td bgcolor="#ffffe6">');      $r->print('
          '.&Apache::loncommon::end_data_table_header_row().'
          '.&Apache::loncommon::start_data_table_row());
       $r->print('<td>');
       $r->print("<input type='submit' name='submit' value='".&mt("View:")."' /> ");
     $r->print(&Apache::grades::scantron_CODElist());      $r->print(&Apache::grades::scantron_CODElist());
     $r->print('</td></tr>');      $r->print('</td>');
       $r->print('
          '.&Apache::loncommon::end_data_table_row().'
          '.&Apache::loncommon::end_data_table());
     $r->print("<input type='hidden' name='command' value='showcodes' />");      $r->print("<input type='hidden' name='command' value='showcodes' />");
     $r->print("<input type='hidden' name='symb' value='".$env{'form.symb'}."' />");      $r->print("<input type='hidden' name='symb' value='".$env{'form.symb'}."' />");
     $r->print("<input type='hidden' name='url' value='".$env{'form.url'}."' />");      $r->print("<input type='hidden' name='url' value='".$env{'form.url'}."' />");
     $r->print('<tr><td bgcolor="#ffffe6">');  
     $r->print("<input type='submit' name='submit' value='".&mt("View")."' />");  
     $r->print('</td></tr>');  
     $r->print('</table>');  
     $r->print($enc_table_close); # conditional  
     $r->print("</form>");      $r->print("</form>");
           
 }  }
Line 145  sub show_codes { Line 145  sub show_codes {
   
 sub picking_a_code {  sub picking_a_code {
     my ($r)=@_;      my ($r)=@_;
     $r->print(&Apache::loncommon::start_page("Selecting a CODE",undef,      my $title = 'Selecting a CODE';
       $r->print(&Apache::loncommon::start_page($title,undef,
      {'no_nav_bar' => 1}));       {'no_nav_bar' => 1}));
     $r->print(<<ENDSCRIPT);      $r->print('<h1>'.&mt($title).'</h1>');
 <script>  
       $r->print(&Apache::lonhtmlcommon::scripttag("
 function gochoose(newcode) {  function gochoose(newcode) {
     opener.document.$env{'form.form'}.scantron_CODE_selectedvalue.value=newcode;      opener.document.$env{'form.form'}.scantron_CODE_selectedvalue.value=newcode;
     var slct=opener.document.$env{'form.form'}.scantron_CODE_resolution;      var slct=opener.document.$env{'form.form'}.scantron_CODE_resolution;
Line 158  function gochoose(newcode) { Line 160  function gochoose(newcode) {
     }      }
     self.close();      self.close();
 }  }
 </script>  "));
 ENDSCRIPT  
   
       $r->print(
     $r->print("<p>The CODE on the paper is <tt><b>".$env{'form.curCODE'}.          '<p>'
       "</b></tt>. Please Select a new one.</p>\n".'<form>');         .&mt('The CODE on the paper is [_1]. Please select a new one.',
                   '<tt><b>'.$env{'form.curCODE'}.'</b></tt>')
          ."</p>\n".'<form action="">'
       );
     my %codes=&Apache::grades::get_codes();      my %codes=&Apache::grades::get_codes();
     my %code_freq=&get_code_freq($r);      my %code_freq=&get_code_freq($r);
     my $num_matches=length($env{'form.curCODE'});      my $num_matches=length($env{'form.curCODE'});
     for (my $i=$num_matches;$i>=0;$i--) {      for (my $i=$num_matches;$i>=0;$i--) {
  my $to_print="<p>".&mt("CODEs with [_1] matching letters",$i)."</p>";   my $to_print =
  $to_print.='<table border="1"><tr><td></td><td>CODE</td><td>exams using this CODE</td>';              '<p>'.&mt('CODEs with [_1] matching letters:',$i)."</p>\n"
              .&Apache::loncommon::start_data_table()
              .&Apache::loncommon::start_data_table_header_row()
              .'<th>&nbsp;</th>'
              .'<th>'.&mt('CODE').'</th>'
              .'<th>'.&mt('Bubblesheet Exams using this CODE').'</th>'
              .&Apache::loncommon::end_data_table_header_row();
   
  my $print;   my $print;
  foreach my $code (sort(keys(%codes))) {   foreach my $code (sort(keys(%codes))) {
     if (&Apache::grades::num_matches($env{'form.curCODE'},$code) != $i) { next; }      if (&Apache::grades::num_matches($env{'form.curCODE'},$code) != $i) { next; }
Line 181  ENDSCRIPT Line 192  ENDSCRIPT
  $count=scalar(@{$code_freq{$code}});   $count=scalar(@{$code_freq{$code}});
  $list=' - '.join(', ',@{$code_freq{$code}});   $list=' - '.join(', ',@{$code_freq{$code}});
     }      }
     $to_print.='<tr><td>'.          $to_print .=
       '<input type="button" value="'.&mt('Select').              &Apache::loncommon::start_data_table_row()
       '" onClick="gochoose(\''.$code.'\')" /></td>'.             .'<td><input type="button" value="'.&mt('Select')
       '<td><tt>'.$code.'</tt></td><td>'.$count.             .'" onclick="gochoose(\''.$code.'\')" /></td>'
       $list.'</td></tr>';             .'<td><tt>'.$code.'</tt></td>'
     delete($codes{$code});             .'<td>'.$count.$list.'</td>'
  }             .&Apache::loncommon::end_data_table_row();
  $to_print.='</table>';              delete($codes{$code});
  if ($print) { $r->print($to_print); }          }
           $to_print .= &Apache::loncommon::end_data_table();
           if ($print) { $r->print($to_print); }
     }      }
     $r->print('</form>');      $r->print('</form>');
 }   } 

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


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