--- loncom/interface/lonpickcode.pm 2007/10/12 20:08:38 1.13 +++ loncom/interface/lonpickcode.pm 2019/01/31 16:08:06 1.17 @@ -1,7 +1,7 @@ # The LearningOnline Network # Pick a CODE from the list of possible CODEs # -# $Id: lonpickcode.pm,v 1.13 2007/10/12 20:08:38 banghart Exp $ +# $Id: lonpickcode.pm,v 1.17 2019/01/31 16:08:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -39,7 +39,7 @@ sub get_code_freq { my ($r)=@_; my %codes; my %scantron_config= - &Apache::grades::get_scantron_config($env{'form.scantron_format'}); + &Apache::lonnet::get_scantron_config($env{'form.scantron_format'}); $r->rflush(); my ($scanlines,$scan_data)=&Apache::grades::scantron_getfile(); for (my $i=0;$i<=$scanlines->{'count'};$i++) { @@ -69,7 +69,7 @@ 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.'). + '

'.&mt('Access not allowed.').'

'. &Apache::loncommon::end_page()); return OK; } @@ -92,37 +92,37 @@ sub code_list { # $context = 1 No page header, print enclosing table # $context = 2 No page header, no enclosing table my $table_head; - my $enc_table_start; - my $enc_table_close; - + 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.').""); + $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.').""); - $enc_table_start = '
'; - $enc_table_close = '
'; + $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.').""); + $table_head = &mt('Select a set of saved CODEs to view.'); + $extra_css = 'LC_scantron_action'; } - $r->print("
"); - $r->print($enc_table_start); - $r->print(''); - $r->print(''); - $r->print(''); + $r->print(''); + $r->print(' + '.&Apache::loncommon::end_data_table_row().' + '.&Apache::loncommon::end_data_table()); $r->print(""); $r->print(""); $r->print(""); - $r->print(''); - $r->print('
'); + $r->print(""); + $r->print(' + '.&Apache::loncommon::start_data_table($extra_css).' + '.&Apache::loncommon::start_data_table_header_row()); + $r->print(''); $r->print($table_head); - $r->print('
'); + $r->print(''); + $r->print(' + '.&Apache::loncommon::end_data_table_header_row().' + '.&Apache::loncommon::start_data_table_row()); + $r->print(''); + $r->print(" "); $r->print(&Apache::grades::scantron_CODElist()); - $r->print('
'); - $r->print(""); - $r->print('
'); - $r->print($enc_table_close); # conditional $r->print("
"); } @@ -145,10 +145,12 @@ sub show_codes { sub picking_a_code { 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})); - $r->print(< + $r->print('

'.&mt($title).'

'); + + $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; @@ -158,18 +160,27 @@ function gochoose(newcode) { } self.close(); } - -ENDSCRIPT +")); - - $r->print("

The CODE on the paper is ".$env{'form.curCODE'}. - ". Please Select a new one.

\n".'
'); + $r->print( + '

' + .&mt('The CODE on the paper is [_1]. Please select a new one.', + ''.$env{'form.curCODE'}.'') + ."

\n".'' + ); 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="

".&mt("CODEs with [_1] matching letters",$i)."

"; - $to_print.=''; + my $to_print = + '

'.&mt('CODEs with [_1] matching letters:',$i)."

\n" + .&Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .'' + .'' + .'' + .&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; } @@ -181,15 +192,17 @@ ENDSCRIPT $count=scalar(@{$code_freq{$code}}); $list=' - '.join(', ',@{$code_freq{$code}}); } - $to_print.=''. - ''; - delete($codes{$code}); - } - $to_print.='
CODEexams using this CODE '.&mt('CODE').''.&mt('Bubblesheet Exams using this CODE').'
'. - ''.$code.''.$count. - $list.'
'; - if ($print) { $r->print($to_print); } + $to_print .= + &Apache::loncommon::start_data_table_row() + .'' + .''.$code.'' + .''.$count.$list.'' + .&Apache::loncommon::end_data_table_row(); + delete($codes{$code}); + } + $to_print .= &Apache::loncommon::end_data_table(); + if ($print) { $r->print($to_print); } } $r->print('
'); }