--- loncom/interface/lonpickcode.pm 2006/03/15 22:11:04 1.9 +++ loncom/interface/lonpickcode.pm 2013/02/01 18:46:37 1.16 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a CODE from the list of possible CODEs # -# $Id: lonpickcode.pm,v 1.9 2006/03/15 22:11:04 albertel Exp $ +# $Id: lonpickcode.pm,v 1.16 2013/02/01 18:46:37 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,12 +69,14 @@ sub handler { if (!($env{'request.course.id'}) && (&Apache::lonnet::allowed('usc',$env{'request.course.id'}))) { $r->print(&Apache::loncommon::start_page(). - &mt('Access not allowed.'). + '<p class="LC_error">'.&mt('Access not allowed.').'</p>'. &Apache::loncommon::end_page()); return OK; } if ($env{'form.command'} eq 'codelist') { &code_list($r); + $r->print(&Apache::grades::show_grading_menu_form($env{'form.symb'}, + $env{'form.url'})); } elsif ($env{'form.command'} eq 'showcodes') { &show_codes($r); } else { @@ -85,27 +87,50 @@ sub handler { } sub code_list { - my ($r,$secondview)=@_; - if (!$secondview) { - $r->print(&Apache::loncommon::start_page("View CODEs")); - $r->print("<p>".&mt('Select a set of saved CODEs to view.')."</p>"); - } else { - $r->print("<p>".&mt('Select another set of saved CODEs to view.')."</p>"); - } - $r->print("<form method='POST' action='/adm/pickcode' name='pickcode'>"); + my ($r,$context)=@_; + # $context = 0 Print page header and enclosing table + # $context = 1 No page header, print enclosing table + # $context = 2 No page header, no enclosing table + my $table_head; + my $extra_css; + if (!$context) { + $r->print(&Apache::loncommon::start_page("View CODEs",undef, + {'no_nav_bar' => 1})); + $table_head = &mt('Select a set of saved CODEs to view.'); + } elsif ($context eq 1) { + $table_head = &mt('Select another set of saved CODEs to view.'); + } elsif ($context eq 2) { + $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(' + '.&Apache::loncommon::start_data_table($extra_css).' + '.&Apache::loncommon::start_data_table_header_row()); + $r->print('<th>'); + $r->print($table_head); + $r->print('</th>'); + $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('</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='symb' value='".$env{'form.symb'}."' />"); $r->print("<input type='hidden' name='url' value='".$env{'form.url'}."' />"); - $r->print("<input type='submit' name='submit' value='".&mt("View")."' />"); $r->print("</form>"); - $r->print(&Apache::grades::show_grading_menu_form($env{'form.symb'}, - $env{'form.url'})); + } sub show_codes { my ($r)=@_; - $r->print(&Apache::loncommon::start_page("View CODEs")); + $r->print(&Apache::loncommon::start_page("View CODEs",undef, + {'no_nav_bar' => 1})); my %codes=&Apache::grades::get_codes(); $r->print("<h2>".$env{'form.scantron_CODElist'}."</h2>"); $r->print('<pre>'); @@ -114,13 +139,18 @@ sub show_codes { } $r->print('</pre>'); &code_list($r,1); + $r->print(&Apache::grades::show_grading_menu_form($env{'form.symb'}, + $env{'form.url'})); } sub picking_a_code { my ($r)=@_; - $r->print(&Apache::loncommon::start_page("Selecting a CODE")); - $r->print(<<ENDSCRIPT); -<script> + my $title = 'Selecting a CODE'; + $r->print(&Apache::loncommon::start_page($title,undef, + {'no_nav_bar' => 1})); + $r->print('<h1>'.&mt($title).'</h1>'); + + $r->print(&Apache::lonhtmlcommon::scripttag(" function gochoose(newcode) { opener.document.$env{'form.form'}.scantron_CODE_selectedvalue.value=newcode; var slct=opener.document.$env{'form.form'}.scantron_CODE_resolution; @@ -130,18 +160,27 @@ function gochoose(newcode) { } self.close(); } -</script> -ENDSCRIPT +")); - - $r->print("<p>The CODE on the paper is <tt><b>".$env{'form.curCODE'}. - "</b></tt>. Please Select a new one.</p>\n".'<form>'); + $r->print( + '<p>' + .&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 %code_freq=&get_code_freq($r); my $num_matches=length($env{'form.curCODE'}); for (my $i=$num_matches;$i>=0;$i--) { - my $to_print="<p> CODEs with $i matches</p>"; - $to_print.='<table border="1"><tr><td></td><td>CODE</td><td>exams using this CODE</td>'; + my $to_print = + '<p>'.&mt('CODEs with [_1] matching letters:',$i)."</p>\n" + .&Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .'<th> </th>' + .'<th>'.&mt('CODE').'</th>' + .'<th>'.&mt('Bubblesheet Exams using this CODE').'</th>' + .&Apache::loncommon::end_data_table_header_row(); + my $print; foreach my $code (sort(keys(%codes))) { if (&Apache::grades::num_matches($env{'form.curCODE'},$code) != $i) { next; } @@ -153,15 +192,17 @@ ENDSCRIPT $count=scalar(@{$code_freq{$code}}); $list=' - '.join(', ',@{$code_freq{$code}}); } - $to_print.='<tr><td>'. - '<input type="button" value="'.&mt('Select'). - '" onClick="gochoose(\''.$code.'\')" /></td>'. - '<td><tt>'.$code.'</tt></td><td>'.$count. - $list.'</td></tr>'; - delete($codes{$code}); - } - $to_print.='</table>'; - if ($print) { $r->print($to_print); } + $to_print .= + &Apache::loncommon::start_data_table_row() + .'<td><input type="button" value="'.&mt('Select') + .'" onclick="gochoose(\''.$code.'\')" /></td>' + .'<td><tt>'.$code.'</tt></td>' + .'<td>'.$count.$list.'</td>' + .&Apache::loncommon::end_data_table_row(); + delete($codes{$code}); + } + $to_print .= &Apache::loncommon::end_data_table(); + if ($print) { $r->print($to_print); } } $r->print('</form>'); }