--- loncom/homework/grades.pm 2003/04/30 20:16:02 1.88
+++ loncom/homework/grades.pm 2003/06/18 18:59:20 1.101
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.88 2003/04/30 20:16:02 www Exp $
+# $Id: grades.pm,v 1.101 2003/06/18 18:59:20 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -466,8 +466,13 @@ LISTJAVASCRIPT
'onClick="javascript:checkSelect(this.form.stuinfo);" '.
'value="'.$viewgrade.'" />'."\n";
if ($ctr == 0) {
- $gradeTable=' '.
- 'No submission found for this resource. ';
+ my $num_students=(scalar(keys(%$fullname)));
+ if ($num_students eq 0) {
+ $gradeTable=' There are no students currently enrolled. ';
+ } else {
+ $gradeTable=' '.
+ 'No submissions found for this resource for any students. ('.$num_students.' checked for submissions ';
+ }
} elsif ($ctr == 1) {
$gradeTable =~ s/type=checkbox/type=checkbox checked/;
}
@@ -1302,7 +1307,7 @@ KEYWORDS
my $lastone = pop @col_fullnames;
$msgfor .= ', '.(join ', ',@col_fullnames).' and '.$lastone.'.';
}
- $msgfor =~ s/\'/\\'/g; #\'
+ $msgfor =~ s/\'/\\'/g; #' stupid emacs
$result.='
'."\n".
' '.
@@ -1913,7 +1918,8 @@ sub viewgrades {
my (undef,undef,$fullname) = &getclasslist($ENV{'form.section'},'1');
my $ctr = 0;
foreach (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
- my ($uname,$udom) = split(/:/);
+ my $uname = $_;
+ $uname=~s/:/_/;
$result.=' '."\n";
$result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},
$_,$$fullname{$_},\@parts,\%weight);
@@ -1923,6 +1929,10 @@ sub viewgrades {
$result.=' '."\n";
$result.=' '."\n";
+ if (scalar(%$fullname) eq 0) {
+ my $colspan=3+scalar(@parts);
+ $result='There are no students in section "'.$ENV{'form.section'}.'" with enrollment status "'.$ENV{'form.status'}.'" to modify or grade. ';
+ }
$result.=&show_grading_menu_form($symb,$url);
return $result;
}
@@ -1931,6 +1941,7 @@ sub viewgrades {
sub viewstudentgrade {
my ($url,$symb,$courseid,$student,$fullname,$parts,$weight) = @_;
my ($uname,$udom) = split(/:/,$student);
+ $student=~s/:/_/;
my %record=&Apache::lonnet::restore($symb,$courseid,$udom,$uname);
my $result=''.
' '."\n";
+ 'GD_'.$student.'_'.$part.'_awarded_s" value="'.$pts.'" />'."\n";
$result.=' '."\n";
} elsif ($type eq 'solved') {
my ($status,$foo)=split(/_/,$score,2);
$status = 'nothing' if ($status eq '');
- $result.=' '."\n";
$result.=''."\n";
+ 'GD_'.$student.'_'.$part.'_solved" '.
+ 'onChange="javascript:changeOneScore(\''.$part.'\',\''.$student.'\')" >'."\n";
my $optsel = ' excused '."\n";
$optsel = ' excused '."\n"
if ($status eq 'excused');
@@ -1962,10 +1973,10 @@ sub viewstudentgrade {
$result.=" \n";
} else {
$result.=' '.
+ 'GD_'.$student.'_'.$part.'_'.$type.'_s" value="'.$score.'" />'.
"\n";
$result.=' '."\n";
}
}
@@ -1985,7 +1996,7 @@ sub editgrades {
$title.='Section: '.$ENV{'form.section'}.' '."\n";
my $result= ''."\n";
$result.= ''.
- 'Username Fullname '."\n";
+ 'Username Domain Fullname '."\n";
my %scoreptr = (
'correct' =>'correct_by_override',
@@ -2033,16 +2044,19 @@ sub editgrades {
$result .= ' ';
$result .= $header;
$result .= ' '."\n";
-
+ my $noupdate;
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 %newrecord;
my $updateflag = 0;
- my @userdom = grep /^$user:/,keys %$classlist;
- my (undef,$udom) = split(/:/,$userdom[0]);
- $result .= ''.$user.' '.
- $$fullname{$userdom[0]}.' ';
+ $line .= ''.$uname.' '.
+ $udom.' '.
+ $$fullname{$usercolon}.' ';
foreach (@partid) {
my $old_aw = $ENV{'form.GD_'.$user.'_'.$_.'_awarded_s'};
my $old_part_pcr = $old_aw/($weight{$_} ne '0' ? $weight{$_}:1);
@@ -2062,7 +2076,7 @@ sub editgrades {
}
$score = 'excused' if (($ENV{'form.GD_'.$user.'_'.$_.'_solved'} eq 'excused') &&
($score ne 'excused'));
- $result .= ''.$old_aw.' '.
+ $line .= ''.$old_aw.' '.
''.$awarded.
($score eq 'excused' ? $score : '').' ';
@@ -2085,17 +2099,23 @@ sub editgrades {
$newrecord{'resource.'.$part.'regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
$updateflag=1;
}
- $result .= ''.$old_aw.' '.
+ $line .= ''.$old_aw.' '.
''.$awarded.' ';
}
}
- $result .= ' '."\n";
+ $line.=''."\n";
if ($updateflag) {
$count++;
&Apache::lonnet::cstore(\%newrecord,$symb,$ENV{'request.course.id'},
- $udom,$user);
+ $udom,$uname);
+ $result.=$line;
+ } else {
+ $noupdate.=$line;
}
}
+ if ($noupdate) {
+ $result .= 'No Changes Occured For the Students Below '.$noupdate;
+ }
$result .= '
'."\n".
&show_grading_menu_form ($symb,$url);
my $msg = 'Number of records updated = '.$rec_update.
@@ -2375,7 +2395,7 @@ sub csvuploadassign {
}
$request->print('Assigning Grades ');
my $courseid=$ENV{'request.course.id'};
- my ($classlist) = &getclasslist('all','1');
+ my ($classlist) = &getclasslist('all',0);
my @skipped;
my $countdone=0;
foreach my $grade (@gradedata) {
@@ -2407,7 +2427,6 @@ sub csvuploadassign {
$request->print('Skipped Students ');
foreach my $student (@skipped) { $request->print(" $student"); }
}
- $request->print(&view_edit_entire_class_form($symb,$url));
$request->print(&show_grading_menu_form($symb,$url));
return '';
}
@@ -2578,15 +2597,14 @@ sub getSymbMap {
my $countProblems = 0;
$mapiterator->next(); # skip the first BEGIN_MAP
my $mapcurRes = $mapiterator->next(); # for "current resource"
- my $ctr=0;
- while ($mapdepth > 0 && $ctr < 100) {
+ while ($mapdepth > 0) {
if($mapcurRes == $mapiterator->BEGIN_MAP) { $mapdepth++; }
- if($mapcurRes == $mapiterator->END_MAP) { $mapdepth++; }
+ if($mapcurRes == $mapiterator->END_MAP) { $mapdepth--; }
if (ref($mapcurRes) && $mapcurRes->is_problem() && !$mapcurRes->randomout) {
$countProblems++;
}
- $ctr++;
+ $mapcurRes = $mapiterator->next();
}
if ($countProblems > 0) {
my $title = $curRes->compTitle();
@@ -2649,16 +2667,15 @@ sub displayPage {
' No '.
' '.($ENV{'form.vProb'} eq 'no' ? 'Title' : 'Problem View').'/Grade ';
- my ($depth,$ctr,$question) = (1,0,1);
+ my ($depth,$question) = (1,1);
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
- while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
+ while ($depth > 0) {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
- if($curRes == $iterator->END_MAP) { $depth++; }
+ if($curRes == $iterator->END_MAP) { $depth--; }
if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
my $parts = $curRes->parts();
- $parts = &temp_parts_fix($parts); # remove line when lonnavmap is fixed
my $title = $curRes->compTitle();
my $symbx = $curRes->symb();
$studentTable.=''.$question.
@@ -2738,9 +2755,10 @@ sub displayPage {
}
$curRes = $iterator->next();
- $ctr++;
}
+ $navmap->untieHashes();
+
$studentTable.=' '."\n".
' '.
@@ -2751,18 +2769,6 @@ sub displayPage {
return '';
}
-sub temp_parts_fix { #remove sub once lonnavmap is fixed
- my $parts = shift;
- my %seen = ();
- my @correctParts = ();
- foreach (@{$parts}) {
- next if ($seen{$_} > 0);
- $seen{$_}++;
- push @correctParts,$_;
- }
- return \@correctParts;
-}
-
sub updateGradeByPage {
my ($request) = shift;
@@ -2796,14 +2802,13 @@ sub updateGradeByPage {
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
- my ($depth,$ctr,$question,$changeflag)= (1,0,1,0);
- while ($depth > 0 && $ctr < 100) { # ctr, just in case it never gets out of loop
+ my ($depth,$question,$changeflag)= (1,1,0);
+ while ($depth > 0) {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
- if($curRes == $iterator->END_MAP) { $depth++; }
+ if($curRes == $iterator->END_MAP) { $depth--; }
if (ref($curRes) && $curRes->is_problem() && !$curRes->randomout) {
my $parts = $curRes->parts();
- $parts = &temp_parts_fix($parts); # remove line when lonnavmap is fixed
my $title = $curRes->compTitle();
my $symbx = $curRes->symb();
$studentTable.=''.$question.
@@ -2860,9 +2865,10 @@ sub updateGradeByPage {
}
$curRes = $iterator->next();
- $ctr++;
}
+ $navmap->untieHashes();
+
$studentTable.=' ';
$studentTable.=&show_grading_menu_form($ENV{'form.symb'},$ENV{'form.url'});
my $grademsg=($changeflag == 0 ? 'No score was changed or updated.' :
@@ -3419,15 +3425,14 @@ sub handler {
if ($tsymb) {
my ($map,$id,$url)=split(/\_\_\_/,$tsymb);
if (&Apache::lonnet::allowed('mgr',$tcrsid)) {
- $request->print(
- &Apache::lonnet::ssi('/res/'.$url,
- ('grade_username' => $tuname,
- 'grade_domain' => $tudom,
- 'grade_courseid' => $tcrsid,
- 'grade_symb' => $tsymb)));
+ $request->print(&Apache::lonnet::ssi_body('/res/'.$url,
+ ('grade_username' => $tuname,
+ 'grade_domain' => $tudom,
+ 'grade_courseid' => $tcrsid,
+ 'grade_symb' => $tsymb)));
} else {
$request->print('Not authorized: '.$token.' ');
- }
+ }
} else {
$request->print('Not a valid DocID: '.$token.' ');
}