--- loncom/homework/grades.pm 2008/04/21 16:30:47 1.518 +++ loncom/homework/grades.pm 2008/05/23 22:14:25 1.521 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.518 2008/04/21 16:30:47 raeburn Exp $ +# $Id: grades.pm,v 1.521 2008/05/23 22:14:25 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4908,7 +4908,7 @@ sub scantron_scantab { domainconfig user, lines are from this file. Otherwise, fall back to getting lines from the legacy file on the - local server: /home/httpd/lonTabs/scantronformat.tab + local server: /home/httpd/lonTabs/default_scantronformat.tab =cut @@ -4936,9 +4936,16 @@ sub get_scantronformat_file { } } if (!$gottab) { - my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); - @lines = <$fh>; - close($fh); + my @domains = &Apache::lonnet::current_machine_domains(); + if (grep(/^\Q$cdom\E$/,@domains)) { + my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); + @lines = <$fh>; + close($fh); + } else { + my $fh=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab'); + @lines = <$fh>; + close($fh); + } } return @lines; } @@ -7512,6 +7519,7 @@ SCANTRONFORM my @delayqueue; my %completedstudents; + my $lock=&Apache::lonnet::set_lock(&mt('Grading bubblesheet exam')); my $count=&get_todo_count($scanlines,$scan_data); my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Scantron Status', 'Scantron Progress',$count, @@ -7532,6 +7540,7 @@ SCANTRONFORM $r->print(""); &ssi_print_error($r); $r->print(&show_grading_menu_form($symb)); + &Apache::lonnet::remove_lock($lock); return ''; # Dunno why the other returns return '' rather than just returning. } @@ -7589,6 +7598,7 @@ SCANTRONFORM $r->print(""); &ssi_print_error($r); $r->print(&show_grading_menu_form($symb)); + &Apache::lonnet::remove_lock($lock); return ''; # Why return ''? Beats me. } @@ -7601,6 +7611,7 @@ SCANTRONFORM &Apache::lonnet::delenv('scantron\.'); } &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); + &Apache::lonnet::remove_lock($lock); # my $lasttime = &Time::HiRes::time()-$start; # $r->print("

took $lasttime

"); @@ -8215,7 +8226,7 @@ sub process_clicker { if (!$env{'form.upfiletype'}) { $env{'form.upfiletype'}='iclicker'; } my %checked; - foreach my $gradingmechanism ('attendance','personnel','specific') { + foreach my $gradingmechanism ('attendance','personnel','specific','given') { if ($env{'form.gradingmechanism'} eq $gradingmechanism) { $checked{$gradingmechanism}="checked='checked'"; } @@ -8226,6 +8237,8 @@ sub process_clicker { my $attendance=&mt("Award points just for participation"); my $personnel=&mt("Correctness determined from response by course personnel"); my $specific=&mt("Correctness determined from response with clicker ID(s)"); + my $given=&mt("Correctness determined from given list of answers").' '. + '('.&mt("Provide comma-separated list. Use '*' for any answer correct, '-' for skip").')'; my $pcorrect=&mt("Percentage points for correct solution"); my $pincorrect=&mt("Percentage points for incorrect solution"); my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype', @@ -8283,6 +8296,9 @@ function sanitycheck() {

+
+
    +

@@ -8309,6 +8325,16 @@ sub process_clicker_file { $result.=''.&mt('You need to specify a clicker ID for the correct answer').''; return $result.&show_grading_menu_form($symb); } + if (($env{'form.gradingmechanism'} eq 'given') && ($env{'form.givenanswer'}!~/\w/)) { + $result.=''.&mt('You need to specify the correct answer').''; + return $result.&show_grading_menu_form($symb); + } + if ($env{'form.gradingmechanism'} eq 'given') { + $env{'form.givenanswer'}=~s/^\s*//gs; + $env{'form.givenanswer'}=~s/\s*$//gs; + $env{'form.givenanswer'}=~s/[^a-zA-Z0-9\.\*\-]+/\,/g; + $env{'form.givenanswer'}=uc($env{'form.givenanswer'}); + } my %clicker_ids=&gather_clicker_ids(); my %correct_ids; if ($env{'form.gradingmechanism'} eq 'personnel') { @@ -8327,6 +8353,8 @@ sub process_clicker_file { } if ($env{'form.gradingmechanism'} eq 'attendance') { $result.=&mt('Score based on attendance only'); + } elsif ($env{'form.gradingmechanism'} eq 'given') { + $result.=&mt('Score based on [_1]',''.$env{'form.givenanswer'}.''); } else { my $number=0; $result.='

'.&mt('Correctness determined by the following IDs').''; @@ -8369,6 +8397,7 @@ sub process_clicker_file { + ENDHEADER @@ -8430,7 +8459,7 @@ ENDHEADER } $result.='


'. &mt('Found [_1] registered and [_2] unregistered clickers.',$student_count,$unknown_count); - if ($env{'form.gradingmechanism'} ne 'attendance') { + if (($env{'form.gradingmechanism'} ne 'attendance') && ($env{'form.gradingmechanism'} ne 'given')) { if ($correct_count==0) { $errormsg.="Found no correct answers answers for grading!"; } elsif ($correct_count>1) {