--- loncom/homework/grades.pm 2005/08/30 14:52:51 1.281
+++ loncom/homework/grades.pm 2006/02/13 22:11:51 1.312
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.281 2005/08/30 14:52:51 albertel Exp $
+# $Id: grades.pm,v 1.312 2006/02/13 22:11:51 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -334,7 +334,16 @@ COMMONJSFUNCTIONS
#--- section, ids and fullnames for each user.
sub getclasslist {
my ($getsec,$filterlist) = @_;
- $getsec = $getsec eq '' ? 'all' : $getsec;
+ my @getsec;
+ if (!ref($getsec)) {
+ if ($getsec ne '' && $getsec ne 'all') {
+ @getsec=($getsec);
+ }
+ } else {
+ @getsec=@{$getsec};
+ }
+ if (grep(/^all$/,@getsec)) { undef(@getsec); }
+
my $classlist=&Apache::loncoursedata::get_classlist();
# Bail out if we were unable to get the classlist
return if (! defined($classlist));
@@ -363,7 +372,7 @@ sub getclasslist {
}
$section = ($section ne '' ? $section : 'none');
if (&canview($section)) {
- if ($getsec eq 'all' || $getsec eq $section) {
+ if (!@getsec || grep(/^\Q$section\E$/,@getsec)) {
$sections{$section}++;
$fullnames{$student}=$fullname;
} else {
@@ -471,6 +480,10 @@ sub most_similar {
$uessay=~s/\W+/ /gs;
+# ignore empty submissions (occuring when only files are sent)
+
+ unless ($uessay=~/\w+/) { return ''; }
+
# these will be returned. Do not care if not at least 50 percent similar
my $limit=0.6;
my $sname='';
@@ -532,7 +545,13 @@ sub verifyreceipt {
if ($env{"course.$courseid.receiptalg"} eq 'receipt2') { $receiptparts=1; }
my $parts=['0'];
if ($receiptparts) { ($parts)=&response_type($url,$symb); }
- foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
+ foreach (sort
+ {
+ if (lc($$fullname{$a}) ne lc($$fullname{$b})) {
+ return (lc($$fullname{$a}) cmp lc($$fullname{$b}));
+ }
+ return $a cmp $b;
+ } (keys(%$fullname))) {
my ($uname,$udom)=split(/\:/);
foreach my $part (@$parts) {
if ($receipt eq &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb,$part)) {
@@ -685,12 +704,16 @@ LISTJAVASCRIPT
while ($loop < 2) {
$gradeTable.='
No. | Select | '.
''.&nameUserString('header').' Section/Group | ';
- if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ if ($env{'form.showgrading'} eq 'yes'
+ && $submitonly ne 'queued'
+ && $submitonly ne 'all') {
foreach (sort(@$partlist)) {
my $display_part=&get_display_part((split(/_/))[0],$url,$symb);
$gradeTable.=' Part: '.$display_part.
' Status | ';
}
+ } elsif ($submitonly eq 'queued') {
+ $gradeTable.=' '.&mt('Queue Status').' | ';
}
$loop++;
# $gradeTable.=' | ' if ($loop%2 ==1);
@@ -698,10 +721,29 @@ LISTJAVASCRIPT
$gradeTable.=''."\n";
my $ctr = 0;
- foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
+ foreach my $student (sort
+ {
+ if (lc($$fullname{$a}) ne lc($$fullname{$b})) {
+ return (lc($$fullname{$a}) cmp lc($$fullname{$b}));
+ }
+ return $a cmp $b;
+ }
+ (keys(%$fullname))) {
my ($uname,$udom) = split(/:/,$student);
+
my %status = ();
- if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+
+ if ($submitonly eq 'queued') {
+ my %queue_status =
+ &Apache::bridgetask::get_student_status($symb,$cdom,$cnum,
+ $udom,$uname);
+ next if (!defined($queue_status{'gradingqueue'}));
+ $status{'gradingqueue'} = $queue_status{'gradingqueue'};
+ }
+
+ if ($env{'form.showgrading'} eq 'yes'
+ && $submitonly ne 'queued'
+ && $submitonly ne 'all') {
(%status) =&student_gradeStatus($url,$symb,$udom,$uname,$partlist);
my $submitted = 0;
my $graded = 0;
@@ -752,10 +794,14 @@ LISTJAVASCRIPT
}
if ($ctr%2 ==1) {
$gradeTable.=' | | | ';
- if ($env{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
+ if ($env{'form.showgrading'} eq 'yes'
+ && $submitonly ne 'queued'
+ && $submitonly ne 'all') {
foreach (@$partlist) {
$gradeTable.=' | ';
}
+ } elsif ($submitonly eq 'queued') {
+ $gradeTable.=' | ';
}
$gradeTable.='';
}
@@ -772,6 +818,7 @@ LISTJAVASCRIPT
my $submissions='submissions';
if ($submitonly eq 'incorrect') { $submissions = 'incorrect submissions'; }
if ($submitonly eq 'graded' ) { $submissions = 'ungraded submissions'; }
+ if ($submitonly eq 'queued' ) { $submissions = 'queued submissions'; }
$gradeTable='
'.
'No '.$submissions.' found for this resource for any students. ('.$num_students.
' students checked for '.$submissions.')
';
@@ -1366,10 +1413,10 @@ sub gradeBox {
my $ctr = 0;
$result.=''."\n";
@@ -3134,8 +3339,13 @@ sub csvuploadmap {
unshift(@fields,['none','']);
$i=&Apache::loncommon::csv_samples_select_table($request,\@records,
\@fields);
- my %sone=&Apache::loncommon::record_sep($records[0]);
- $keyfields=join(',',sort(keys(%sone)));
+ foreach my $rec (@records) {
+ my %temp = &Apache::loncommon::record_sep($rec);
+ if (%temp) {
+ $keyfields=join(',',sort(keys(%temp)));
+ last;
+ }
+ }
}
}
&csvuploadmap_footer($request,$i,$keyfields);
@@ -3153,13 +3363,14 @@ sub csvuploadoptions {
\n");
+ $request->print('
+
'."\n");
$request->print(&show_grading_menu_form($symb,$url));
return '';
}
@@ -3277,9 +3489,19 @@ sub csvuploadassign {
if (! %grades) { push(@skipped,"$username:$domain no data to store"); }
$grades{"resource.regrader"}="$env{'user.name'}:$env{'user.domain'}";
# &Apache::lonnet::logthis(" storing ".(join('-',%grades)));
- &Apache::lonnet::cstore(\%grades,$symb,$env{'request.course.id'},
- $domain,$username);
- $request->print('.');
+ my $result=&Apache::lonnet::cstore(\%grades,$symb,
+ $env{'request.course.id'},
+ $domain,$username);
+ if ($result eq 'ok') {
+ $request->print('.');
+ } else {
+ $request->print("
+
+ Failed to store student $username\@$domain.
+ Message when trying to store was ($result)
+
+
" );
+ }
$request->rflush();
$countdone++;
}
@@ -3356,13 +3578,13 @@ LISTJAVASCRIPT
$result.=''."\n".
''."\n";
- $result.=' View Problems Text: no '."\n".
- ' yes '."
\n";
+ $result.=' View Problems Text: '."\n".
+ ''."
\n";
$result.=' Submission Details: '.
- ' none'."\n".
- ' by dates and submissions'."\n".
- ' all details'."\n";
+ ''."\n".
+ ''."\n".
+ ''."\n";
$result.=''."\n".
''."\n".
@@ -3386,12 +3608,18 @@ LISTJAVASCRIPT
my (undef,undef,$fullname) = &getclasslist($getsec,'1');
my $ptr = 1;
- foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
+ foreach my $student (sort
+ {
+ if (lc($$fullname{$a}) ne lc($$fullname{$b})) {
+ return (lc($$fullname{$a}) cmp lc($$fullname{$b}));
+ }
+ return $a cmp $b;
+ } (keys(%$fullname))) {
my ($uname,$udom) = split(/:/,$student);
$studentTable.=($ptr%2 == 1 ? '' : '');
$studentTable.=''.$ptr.' | ';
- $studentTable.=' '
- .&nameUserString(undef,$$fullname{$student},$uname,$udom)."\n";
+ $studentTable.=' | \n";
$studentTable.=($ptr%2 == 0 ? ' |
' : '');
$ptr++;
}
@@ -3463,7 +3691,11 @@ sub displayPage {
my $navmap = Apache::lonnavmaps::navmap->new();
my ($mapUrl, $id, $resUrl)=&Apache::lonnet::decode_symb($env{'form.page'});
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
-
+ if (!$map) {
+ $request->print('Unable to view requested sequence. ('.$resUrl.')');
+ $request->print(&show_grading_menu_form($symb,$url));
+ return;
+ }
my $iterator = $navmap->getIterator($map->map_start(),
$map->map_finish());
@@ -3669,7 +3901,12 @@ sub updateGradeByPage {
my $navmap = Apache::lonnavmaps::navmap->new();
my ($mapUrl, $id, $resUrl) = &Apache::lonnet::decode_symb( $env{'form.page'});
my $map = $navmap->getResourceByUrl($resUrl); # add to navmaps
-
+ if (!$map) {
+ $request->print('Unable to grade requested sequence. ('.$resUrl.')');
+ my ($symb,$url)=&get_symb_and_url($request);
+ $request->print(&show_grading_menu_form($symb,$url));
+ return;
+ }
my $iterator = $navmap->getIterator($map->map_start(),
$map->map_finish());
@@ -3874,11 +4111,11 @@ sub scantron_CODElist {
sub scantron_CODEunique {
my $result='
+ value="yes" checked="checked" /> Yes
+ value="no" /> No
';
return $result;
}
@@ -4009,7 +4246,7 @@ SCANTRONFORM
-
+
|
@@ -4315,7 +4552,7 @@ sub scantron_process_corrections {
}
}
if ($err) {
- $r->print("Unable to accept last correction, an error occurred :$errmsg:");
+ $r->print("Unable to accept last correction, an error occurred :$errmsg:");
} else {
&scantron_put_line($scanlines,$scan_data,$which,$line,$skip);
&scantron_putfile($scanlines,$scan_data);
@@ -4369,14 +4606,26 @@ sub check_for_error {
sub scantron_warning_screen {
my ($button_text)=@_;
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'});
+ my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
+ my $CODElist="a";
+ if ($scantron_config{'CODElocation'} &&
+ $scantron_config{'CODEstart'} &&
+ $scantron_config{'CODElength'}) {
+ $CODElist=$env{'form.scantron_CODElist'};
+ if ($CODElist eq '') { $CODElist='None'; }
+ $CODElist=
+ 'List of CODES to validate against: | '.
+ $CODElist.' |
';
+ }
return (<
Please double check the information
below before clicking on '$button_text'
-Sequence To be Graded: | $title |
+Sequence to be Graded: | $title |
Data File that will be used: | $env{'form.scantron_selectfile'} |
+$CODElist
@@ -5369,28 +5618,30 @@ GRADINGMENUJS
$result.='';
- $result.=''.
+ $result.=' |
|
'."\n";
+ ($saveSub eq 'all' ? 'selected="on"' : '').'>'.&mt('with any status').''."\n";
$result.=''.
- ' '.
- 'Current Resource: For all students in selected section or course |
'."\n";
+ 'Current Resource: For all students in selected section or course'."\n";
$result.=''.
- ' '.
- 'The complete set/page/sequence: For one student |
'."\n";
+ 'The complete set/page/sequence: For one student'."\n";
$result.=' '.
''.
@@ -5428,10 +5679,32 @@ GRADINGMENUJS
return $result;
}
+sub reset_perm {
+ undef(%perm);
+}
+
+sub init_perm {
+ &reset_perm();
+ foreach my $test_perm ('vgr','mgr','opa') {
+
+ my $scope = $env{'request.course.id'};
+ if (!($perm{$test_perm}=&Apache::lonnet::allowed($test_perm,$scope))) {
+
+ $scope .= '/'.$env{'request.course.sec'};
+ if ( $perm{$test_perm}=
+ &Apache::lonnet::allowed($test_perm,$scope)) {
+ $perm{$test_perm.'_section'}=$env{'request.course.sec'};
+ } else {
+ delete($perm{$test_perm});
+ }
+ }
+ }
+}
+
sub handler {
my $request=$_[0];
- undef(%perm);
+ &reset_perm();
if ($env{'browser.mathml'}) {
&Apache::loncommon::content_type($request,'text/xml');
} else {
@@ -5480,20 +5753,7 @@ sub handler {
}
}
} else {
- if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
- if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- $perm{'vgr_section'}=$env{'request.course.sec'};
- } else {
- delete($perm{'vgr'});
- }
- }
- if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) {
- if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- $perm{'mgr_section'}=$env{'request.course.sec'};
- } else {
- delete($perm{'mgr'});
- }
- }
+ &init_perm();
if ($command eq 'submission' && $perm{'vgr'}) {
($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {
|