--- loncom/homework/grades.pm 2002/07/25 21:25:38 1.41 +++ loncom/homework/grades.pm 2002/07/26 20:28:42 1.42 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.41 2002/07/25 21:25:38 ng Exp $ +# $Id: grades.pm,v 1.42 2002/07/26 20:28:42 ng Exp $ # # Copyright Michigan State University Board of Trustees # @@ -321,55 +321,6 @@ sub getpartlist { return @parts; } -#FIXME need to look at the metadata spec on what type of data to accept and provide an -#interface based on that, also do that to above function. -sub setstudentgrade { - my ($url,$symb,$courseid,$student,@parts) = @_; - my $result =''; - my ($stuname,$domain) = split(/:/,$student); - my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname); - my %newrecord; - - foreach my $part (@parts) { - my ($temp,$part,$type)=split(/_/,$part); - my $oldscore=$record{"resource.$part.$type"}; - my $newscore=$ENV{"form.GRADE.$student.$part.$type"}; - if ($type eq 'solved') { - my $update=0; - if ($newscore eq 'nothing' ) { - if ($oldscore ne '') { - $update=1; - $newscore = ''; - } - } elsif ($oldscore !~ m/^$newscore/) { - $update=1; - $result.="Updating $stuname to $newscore
\n"; - if ($newscore eq 'correct') { $newscore = 'correct_by_override'; } - if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; } - if ($newscore eq 'excused') { $newscore = 'excused'; } - if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; } - } else { - #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore:
\n"; - } - if ($update) { $newrecord{"resource.$part.$type"}=$newscore; } - } else { - if ($oldscore ne $newscore) { - $newrecord{"resource.$part.$type"}=$newscore; - $result.="Updating $student"."'s status for $part.$type to $newscore
\n"; - } else { - #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore:
\n"; - } - } - } - if ( scalar(keys(%newrecord)) > 0 ) { - $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; -# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname); - - $result.="Stored away ".scalar(keys(%newrecord))." elements.
\n"; - } - return $result; -} - sub print_hash { my ($request, $hash) = @_; $request->print(''); @@ -1067,8 +1018,9 @@ sub verifyReceipt_form { return $result; } -sub viewgrades { - my ($request) = @_; +sub viewgrades_js { + my ($request) = shift; + $request->print(< function viewOneStudent(user) { @@ -1076,38 +1028,140 @@ sub viewgrades { document.onestudent.submit(); } - function writePoint(partid,weight,point) { + var radioButton = eval("document.classgrade.RADVAL_"+partid); + var textbox = eval("document.classgrade.TEXTVAL_"+partid); + if (point == "textval") { + var point = eval("document.classgrade.TEXTVAL_"+partid+".value"); + if (isNaN(point) || point < 0) { + alert("A number equal or greater than 0 is expected. Entered value = "+point); + var resetbox = false; + for (var i=0; i VIEWJAVASCRIPT +} + +sub viewgrades { + my ($request) = shift; + &viewgrades_js($request); my ($symb,$url) = ($ENV{'form.symb'},$ENV{'form.url'}); $request->print ('

Manual Grading

'); - my $result='
KeyValue
'; - $result.=''."\n"; - my ($partlist,$handgrade) = &response_type($ENV{'form.url'}); - my %weight = (); - for (sort keys(%$handgrade)) { - my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_}); - my ($partid,$respid) = split (/_/); - my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb); - $weight{$partid} = $wgt eq '' ? '1' : $wgt; - $result.=''. - ''. - ''."\n"; - } - $request->print($result.'
Resource: '.$ENV{'form.url'}. - '
Part id: '.$partid.'Type: '.$responsetype.'Handgrade: '.$handgrade.'
'."\n"); + my $result='Resource: '.$ENV{'form.url'}.''."\n"; #view individual student submission form - called using Javascript viewOneStudent - $result = '
'."\n". + $result.= ''."\n". ''."\n". ''."\n". ''."\n". @@ -1120,26 +1174,50 @@ VIEWJAVASCRIPT ''."\n". ''."\n". ''."\n"; - $result.='To assign the same score for all the students use the radio buttons or box below. '. - 'To assign individual score fill in the score for each student in the table below.
'; + + $result.='To assign the same score for all the students use the radio buttons or '. + 'text box below. To assign scores individually fill in the score boxes for '. + 'each student in the table below. A score that has already '. + 'been graded does not get changed using the radio buttons or text box. '. + 'If needed, it has to be changed individually.'; + + my ($partlist,$handgrade) = &response_type($ENV{'form.url'}); + my %weight = (); + my $ctsparts = 0; $result.=''; - for (sort keys (%weight)) { + for (sort keys(%$handgrade)) { + my ($responsetype,$handgrade)=split(/:/,$$handgrade{$_}); + my ($partid,$respid) = split (/_/); + my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb); + $weight{$partid} = $wgt eq '' ? '1' : $wgt; + + $result.=''."\n"; + $result.='
Part ID: '.$partid.'   '; + $result.=''; my $ctr = 0; - $result.=''."\n"; + $result.= ''."\n"; + $ctsparts++; } - $result.='
Part '.$_.''; - $result.=''; # display radio buttons in a nice table 10 across - while ($ctr<=$weight{$_}) { - $result.= '\n"; $result.=(($ctr+1)%10 == 0 ? '' : ''); $ctr++; } $result.='
'.$ctr."
'; + $result.= '
or /'. + $weight{$partid}.' (problem weight)
'; + $result.='
'; + $result.='    '; + $result.= ''."\n"; - $result.= ''."\n". - '
'."\n". + $result.= '
'."\n". ''. ''."\n"; #get list of parts for this problem @@ -1151,10 +1229,11 @@ VIEWJAVASCRIPT if ($display =~ /^Partial Credit Factor/) { $_ = $display; my ($partid) = /.*?(\d+).*/; - $result.=''."\n"; + $result.=''."\n"; next; } - $display =~ s/Problem Status/Grade Status/; + $display =~ s/Problem Status/Grade Status
/; $result.=''."\n"; } $result.=''; @@ -1187,20 +1266,24 @@ sub viewstudentgrade { my $score=$record{"resource.$part.$type"}; next if $type eq 'tries'; if ($type eq 'awarded') { - my $pts = $score*$$weight{$part}; - $result.=''."\n"; -# $result.=''."\n"; -# } elsif ($type eq 'tries') { -# $result.=''."\n"; + my $pts = $score eq '' ? '' : $score*$$weight{$part}; + $result.=''."\n"; + $result.=''."\n"; } elsif ($type eq 'solved') { my ($status,$foo)=split(/_/,$score,2); - $result.="\n"; } @@ -1233,6 +1316,57 @@ sub editgrades { return $result; } + +#FIXME need to look at the metadata spec on what type of data to accept and provide an +#interface based on that, also do that to above function. +sub setstudentgrade { + my ($url,$symb,$courseid,$student,@parts) = @_; + my $result =''; + my ($stuname,$domain) = split(/:/,$student); + my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname); + my %newrecord; + + foreach my $part (@parts) { + my ($temp,$part,$type)=split(/_/,$part); + my $oldscore=$record{"resource.$part.$type"}; + my $newscore=$ENV{"form.GRADE.$student.$part.$type"}; + if ($type eq 'solved') { + my $update=0; + if ($newscore eq 'nothing' ) { + if ($oldscore ne '') { + $update=1; + $newscore = ''; + } + } elsif ($oldscore !~ m/^$newscore/) { + $update=1; + $result.="Updating $stuname to $newscore
\n"; + if ($newscore eq 'correct') { $newscore = 'correct_by_override'; } + if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; } + if ($newscore eq 'excused') { $newscore = 'excused'; } + if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; } + } else { + #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore:
\n"; + } + if ($update) { $newrecord{"resource.$part.$type"}=$newscore; } + } else { + if ($oldscore ne $newscore) { + $newrecord{"resource.$part.$type"}=$newscore; + $result.="Updating $student"."'s status for $part.$type to $newscore
\n"; + } else { + #$result.="$stuname:$part:$type:unchanged $oldscore to $newscore:
\n"; + } + } + } + if ( scalar(keys(%newrecord)) > 0 ) { + $newrecord{'resource.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}"; +# &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname); + + $result.="Stored away ".scalar(keys(%newrecord))." elements.
\n"; + } + return $result; +} + + sub sub_page_js { my $request = shift; $request->print(<
UsernameFullnameDomainScore Part '.$partid.'
(weight = '.$weight{$partid}.')
Score Part '.$partid.'
(weight = '. + $weight{$partid}.')
'.$display.'
'.$score.' '."\n"; + $result.='