--- loncom/homework/grades.pm 2005/08/12 21:33:41 1.278
+++ loncom/homework/grades.pm 2005/10/01 03:27:44 1.291
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.278 2005/08/12 21:33:41 albertel Exp $
+# $Id: grades.pm,v 1.291 2005/10/01 03:27:44 albertel 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='';
@@ -1366,10 +1379,10 @@ sub gradeBox {
my $ctr = 0;
$result.='
'."\n"; # display radio buttons in a nice table 10 across
while ($ctr<=$wgt) {
- $result.= ' '.$ctr." \n";
+ ($score eq $ctr ? 'checked':'').' /> '.$ctr."\n";
$result.=(($ctr+1)%10 == 0 ? ' ' : '');
$ctr++;
}
@@ -2328,7 +2341,7 @@ sub version_portfiles {
} else {
my $copy_result = &Apache::lonnet::finishuserfileupload($stuname,$domain,'copy',
'/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
- push(@v_portfiles, $answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
+ push(@v_portfiles, $directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]);
&Apache::lonnet::mark_as_readonly($domain,$stuname,
['/portfolio'.$directory.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]],
[$symb,$env{'request.course.id'},'graded']);
@@ -2390,6 +2403,7 @@ sub viewgrades_js {
}
for (i=0;i';
my $ctr = 0;
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
- $result.= ' '.$ctr." \n";
+ ','.$ctr.')" />'.$ctr."\n";
$result.=(($ctr+1)%10 == 0 ? ' ' : '');
$ctr++;
}
@@ -2656,7 +2673,6 @@ sub viewgrades {
sub viewstudentgrade {
my ($url,$symb,$courseid,$student,$fullname,$parts,$weight,$ctr,$last_resets) = @_;
my ($uname,$udom) = split(/:/,$student);
- $student=~s/:/_/;
my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
my %aggregates = ();
my $result=' '.
@@ -2665,6 +2681,7 @@ sub viewstudentgrade {
''.$fullname.' '.
'('.$uname.($env{'user.domain'} eq $udom ? '' : ':'.$udom).') '."\n";
+ $student=~s/:/_/; # colon doen't work in javascript for names
foreach my $apart (@$parts) {
my ($part,$type) = &split_part_type($apart);
my $score=$record{"resource.$part.$type"};
@@ -2786,12 +2803,10 @@ sub editgrades {
for ($i=0; $i<$env{'form.total'}; $i++) {
my $line;
my $user = $env{'form.ctr'.$i};
- my $usercolon = $user;
- $usercolon =~s/_/:/;
- my ($uname,$udom)=split(/_/,$user);
+ my ($uname,$udom)=split(/:/,$user);
my %newrecord;
my $updateflag = 0;
- $line .= ''.&nameUserString(undef,$$fullname{$usercolon},$uname,$udom).' ';
+ $line .= ''.&nameUserString(undef,$$fullname{$user},$uname,$udom).' ';
my $usec=$classlist->{"$uname:$udom"}[5];
if (!&canmodify($usec)) {
my $numcols=scalar(@partid)*4+2;
@@ -2800,6 +2815,7 @@ sub editgrades {
}
my %aggregate = ();
my $aggregateflag = 0;
+ $user=~s/:/_/; # colon doen't work in javascript for names
foreach (@partid) {
my $old_aw = $env{'form.GD_'.$user.'_'.$_.'_awarded_s'};
my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
@@ -3062,10 +3078,7 @@ sub csvuploadmap_footer {
ENDPICK
}
-sub upcsvScores_form {
- my ($request) = shift;
- my ($symb,$url)=&get_symb_and_url($request);
- if (!$symb) {return '';}
+sub checkforfile_js {
my $result =<
function checkUpload(formname) {
@@ -3077,6 +3090,14 @@ sub upcsvScores_form {
}
CSVFORMJS
+ return $result;
+}
+
+sub upcsvScores_form {
+ my ($request) = shift;
+ my ($symb,$url)=&get_symb_and_url($request);
+ if (!$symb) {return '';}
+ my $result=&checkforfile_js();
$env{'form.probTitle'} = &Apache::lonnet::gettitle($symb);
my ($table) = &showResourceInfo($url,$env{'form.probTitle'});
$result.=$table;
@@ -3096,7 +3117,7 @@ CSVFORMJS
$upfile_select
- $ignore
+ $ignore
ENDUPFORM
$result.='
'."\n";
@@ -3154,7 +3175,6 @@ sub csvuploadoptions {
\n");
+ $request->print('
+ '."\n");
$request->print(&show_grading_menu_form($symb,$url));
return '';
}
@@ -3357,13 +3378,13 @@ LISTJAVASCRIPT
$result.=' '."\n".
' '."\n";
- $result.=' View Problems Text: no '."\n".
- ' yes '." \n";
+ $result.=' View Problems Text: no '."\n".
+ ' yes '." \n";
$result.=' Submission Details: '.
- ' none'."\n".
- ' by dates and submissions'."\n".
- ' all details'."\n";
+ ' none '."\n".
+ ' by dates and submissions '."\n".
+ ' all details '."\n";
$result.=' '."\n".
' '."\n".
@@ -3391,8 +3412,8 @@ LISTJAVASCRIPT
my ($uname,$udom) = split(/:/,$student);
$studentTable.=($ptr%2 == 1 ? '' : '');
$studentTable.=''.$ptr.' ';
- $studentTable.=' '
- .&nameUserString(undef,$$fullname{$student},$uname,$udom)."\n";
+ $studentTable.=' '
+ .&nameUserString(undef,$$fullname{$student},$uname,$udom)." \n";
$studentTable.=($ptr%2 == 0 ? ' ' : '');
$ptr++;
}
@@ -3464,7 +3485,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());
@@ -3670,7 +3695,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());
@@ -4316,7 +4346,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);
@@ -4370,14 +4400,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
@@ -4869,9 +4911,16 @@ sub scantron_get_closely_matching_CODEs
}
sub get_codes {
- my $old_name=$env{'form.scantron_CODElist'};
- my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
+ my ($old_name, $cdom, $cnum) = @_;
+ if (!$old_name) {
+ $old_name=$env{'form.scantron_CODElist'};
+ }
+ if (!$cdom) {
+ $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
+ }
+ if (!$cnum) {
+ $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
+ }
my %result=&Apache::lonnet::get('CODEs',[$old_name,"type\0$old_name"],
$cdom,$cnum);
my %allcodes;
@@ -5363,10 +5412,10 @@ GRADINGMENUJS
$result.='';
- $result.=''.
+ $result.=' '.
' '.''.&mt('Current Resource').': '.&mt('For one or more students').
- ' '.
+ ' '.
'with submissions '.
'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.=' '.
' '.
@@ -5412,6 +5461,9 @@ GRADINGMENUJS
$result.=''.
' access times. '."\n";
+ $result.=''.
+ ' saved CODEs. '."\n";
$result.=''."\n".
''."\n".
@@ -5419,10 +5471,32 @@ GRADINGMENUJS
return $result;
}
+sub reset_perm {
+ undef(%perm);
+}
+
+sub init_perm {
+ &reset_perm();
+ 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'});
+ }
+ }
+}
+
sub handler {
my $request=$_[0];
- undef(%perm);
+ &reset_perm();
if ($env{'browser.mathml'}) {
&Apache::loncommon::content_type($request,'text/xml');
} else {
@@ -5471,20 +5545,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'}) {