--- loncom/homework/grades.pm 2004/04/22 22:57:53 1.187
+++ loncom/homework/grades.pm 2004/11/17 20:32:44 1.228
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.187 2004/04/22 22:57:53 albertel Exp $
+# $Id: grades.pm,v 1.228 2004/11/17 20:32:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,16 +25,6 @@
#
# http://www.lon-capa.org/
#
-# 2/9,2/13 Guy Albertelli
-# 6/8 Gerd Kortemeyer
-# 7/26 H.K. Ng
-# 8/20 Gerd Kortemeyer
-# Year 2002
-# June-August H.K. Ng
-# Year 2003
-# February, March H.K. Ng
-# July, H. K. Ng
-#
package Apache::grades;
use strict;
@@ -101,25 +91,6 @@ sub get_symb_and_url {
return ($symb,$url);
}
-# --- Retrieve the fullname for a user. Return lastname, first middle ---
-# --- Generation is attached next to the lastname if it exists. ---
-sub get_fullname {
- my ($uname,$udom) = @_;
- my %name=&Apache::lonnet::get('environment', ['lastname','generation',
- 'firstname','middlename'],
- $udom,$uname);
- my $fullname;
- my ($tmp) = keys(%name);
- if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
- $fullname = &Apache::loncoursedata::ProcessFullName
- (@name{qw/lastname generation firstname middlename/});
- } else {
- &Apache::lonnet::logthis('grades.pm: no name data for '.$uname.
- '@'.$udom.':'.$tmp);
- }
- return $fullname;
-}
-
#--- Format fullname, username:domain if different for display
#--- Use anywhere where the student names are listed
sub nameUserString {
@@ -167,6 +138,20 @@ sub response_type {
return \@partlist,\%handgrade,\%responseType;
}
+sub get_display_part {
+ my ($partID,$url,$symb)=@_;
+ if (!defined($symb) || $symb eq '') {
+ $symb=$ENV{'form.symb'};
+ if ($symb eq '') { $symb=&Apache::lonnet::symbread($url) }
+ }
+ my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
+ if (defined($display) and $display ne '') {
+ $display.= " (id $partID)";
+ } else {
+ $display=$partID;
+ }
+ return $display;
+}
#--- Show resource title
#--- and parts and response type
sub showResourceInfo {
@@ -194,7 +179,8 @@ sub showResourceInfo {
}
$partsseen{$partID}=1;
}
- $result.='
Part '.$partID.' '.
+ my $display_part=&get_display_part($partID,$url);
+ $result.='
Part: '.$display_part.' '.
$resID.'
'.
'
Type: '.$responsetype.'
';
# '
Handgrade: '.$handgrade.'
';
@@ -349,27 +335,36 @@ sub getclasslist {
#
my %sections;
my %fullnames;
- foreach (keys(%$classlist)) {
- # the following undefs are for 'domain', and 'username' respectively.
- my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
- @{$classlist->{$_}};
+ foreach my $student (keys(%$classlist)) {
+ my $end =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_END()];
+ my $start =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_START()];
+ my $id =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_ID()];
+ my $section =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_SECTION()];
+ my $fullname =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_FULLNAME()];
+ my $status =
+ $classlist->{$student}->[&Apache::loncoursedata::CL_STATUS()];
# filter students according to status selected
if ($filterlist && $ENV{'form.Status'} ne 'Any') {
if ($ENV{'form.Status'} ne $status) {
- delete ($classlist->{$_});
+ delete ($classlist->{$student});
next;
}
}
- $section = ($section ne '' ? $section : 'no');
+ $section = ($section ne '' ? $section : 'none');
if (&canview($section)) {
if ($getsec eq 'all' || $getsec eq $section) {
$sections{$section}++;
- $fullnames{$_}=$fullname;
+ $fullnames{$student}=$fullname;
} else {
- delete($classlist->{$_});
+ delete($classlist->{$student});
}
} else {
- delete($classlist->{$_});
+ delete($classlist->{$student});
}
}
my %seen = ();
@@ -682,7 +677,9 @@ LISTJAVASCRIPT
'
'.&nameUserString('header').'
';
if ($ENV{'form.showgrading'} eq 'yes' && $submitonly ne 'all') {
foreach (sort(@$partlist)) {
- $gradeTable.='
Part '.(split(/_/))[0].' Status
';
+ my $display_part=&get_display_part((split(/_/))[0],$url,$symb);
+ $gradeTable.='
Part: '.
+ $display_part.' ( ID '.$respid.
' ) ';
if ($record{"resource.$partid.$respid.uploadedurl"}) {
- $lastsubonly.=' File uploaded by student Like all files provided by users, this file may contain virusses ';
+ &Apache::lonnet::allowuploaded('/adm/grades',
+ $record{"resource.$partid.$respid.uploadedurl"});
+ $lastsubonly.=' File uploaded by student Like all files provided by users, this file may contain virusses ';
}
$lastsubonly.='Submitted Answer: '.
&cleanRecord($subval,$responsetype,$symb,$partid,
@@ -2049,11 +2053,11 @@ sub saveHandGrade {
}
} elsif ($dropMenu eq 'reset status'
&& exists($record{'resource.'.$_.'.solved'})) { #don't bother if no old records -> no attempts
- $newrecord{'resource.'.$_.'.tries'} = 0;
- $newrecord{'resource.'.$_.'.solved'} = '';
- $newrecord{'resource.'.$_.'.award'} = '';
- $newrecord{'resource.'.$_.'.awarded'} = 0;
- $newrecord{'resource.'.$_.'.regrader'}="$ENV{'user.name'}:$ENV{'user.domain'}";
+ foreach my $key (keys (%record)) {
+ if ($key=~/^resource\.\Q$_\E\./) { $newrecord{$key} = ''; }
+ }
+ $newrecord{'resource.'.$_.'.regrader'}=
+ "$ENV{'user.name'}:$ENV{'user.domain'}";
} elsif ($dropMenu eq '') {
$pts = ($ENV{'form.GD_BOX'.$newflg.'_'.$_} ne '' ?
$ENV{'form.GD_BOX'.$newflg.'_'.$_} :
@@ -2297,7 +2301,7 @@ sub viewgrades {
my $sectionClass;
if ($ENV{'form.section'} eq 'all') {
$sectionClass='Class ';
- } elsif ($ENV{'form.section'} eq 'no') {
+ } elsif ($ENV{'form.section'} eq 'none') {
$sectionClass='Students in no Section ';
} else {
$sectionClass='Students in Section '.$ENV{'form.section'}.'';
@@ -2324,7 +2328,8 @@ sub viewgrades {
$ctsparts.'" value="'.$partid.'" />'."\n";
$result.=''."\n";
- $result.='
Part '.$partid.' Point:
';
+ my $display_part=&get_display_part($partid,$url,$symb);
+ $result.='
Part: '.$display_part.' Point:
';
$result.='
';
my $ctr = 0;
while ($ctr<=$weight{$partid}) { # display radio buttons in a nice table 10 across
@@ -2363,14 +2368,17 @@ sub viewgrades {
my $display=&Apache::lonnet::metadata($url,$part.'.display');
$display =~ s|^Number of Attempts|Tries |; # makes the column narrower
if (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
+ my ($partid) = &split_part_type($part);
+ my $display_part=&get_display_part($partid,$url,$symb);
if ($display =~ /^Partial Credit Factor/) {
- my ($partid) = &split_part_type($part);
- $result.='
Score Part '.$partid.' (weight = '.
- $weight{$partid}.')
';
@@ -2596,7 +2605,7 @@ sub editgrades {
if ($noupdate) {
# my $numcols=(scalar(@partid)*(scalar(@parts)-1)*2)+3;
my $numcols=scalar(@partid)*4+2;
- $result .= '
';
- my ($depth,$question) = (1,1);
+ my ($depth,$question,$prob) = (1,1,1);
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
while ($depth > 0) {
@@ -3119,7 +3126,7 @@ sub displayPage {
my $parts = $curRes->parts();
my $title = $curRes->compTitle();
my $symbx = $curRes->symb();
- $studentTable.='
'."\n".
''.
@@ -3190,9 +3196,12 @@ sub displayPage {
sub displaySubByDates {
my ($symb,$record,$parts,$responseType,$checkIcon,$uname,$udom) = @_;
+ my $isCODE=0;
+ if (exists($record->{'resource.CODE'})) { $isCODE=1; }
my $studentTable='
'.
'
'.
'
Date/Time
'.
+ ($isCODE?'
CODE
':'').
'
Submission
'.
'
Status
';
my ($version);
@@ -3205,17 +3214,22 @@ sub displaySubByDates {
for ($version=1;$version<=$$record{'version'};$version++) {
my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
$studentTable.='
'.$timestamp.'
';
+ if ($isCODE) {
+ $studentTable.='
'.$record->{$version.':resource.CODE'}.'
';
+ }
my @versionKeys = split(/\:/,$$record{$version.':keys'});
my @displaySub = ();
foreach my $partid (@{$parts}) {
my @matchKey = sort(grep /^resource\.\Q$partid\E\..*?\.submission$/,@versionKeys);
# next if ($$record{"$version:resource.$partid.solved"} eq '');
+ my $display_part=&get_display_part($partid,undef,$symb);
foreach my $matchKey (@matchKey) {
- if (exists $$record{$version.':'.$matchKey}) {
+ if (exists($$record{$version.':'.$matchKey}) &&
+ $$record{$version.':'.$matchKey} ne '') {
my ($responseId)=($matchKey=~ /^resource\.\Q$partid\E\.(.*?)\.submission$/);
- $displaySub[0].='Part '.$partid.' ';
+ $displaySub[0].='Part: '.$display_part.' ';
$displaySub[0].='(ID '.
- $responseId.') ';
+ $responseId.') ';
if ($$record{"$version:resource.$partid.tries"} eq '') {
$displaySub[0].='Trial not counted';
} else {
@@ -3233,14 +3247,14 @@ sub displaySubByDates {
}
}
if (exists $$record{"$version:resource.$partid.award"}) {
- $displaySub[1].='Part '.$partid.' '.
+ $displaySub[1].='Part: '.$display_part.' '.
lc($$record{"$version:resource.$partid.award"}).' '.
$mark{$$record{"$version:resource.$partid.solved"}}.
' ';
}
if (exists $$record{"$version:resource.$partid.regrader"}) {
$displaySub[2].=$$record{"$version:resource.$partid.regrader"}.
- ' ('.&mt('Part').': '.$partid.')';
+ ' ('.&mt('Part').': '.$display_part.')';
}
}
# needed because old essay regrader has not parts info
@@ -3295,7 +3309,7 @@ sub updateGradeByPage {
$iterator->next(); # skip the first BEGIN_MAP
my $curRes = $iterator->next(); # for "current resource"
- my ($depth,$question,$changeflag)= (1,1,0);
+ my ($depth,$question,$prob,$changeflag)= (1,1,1,0);
while ($depth > 0) {
if($curRes == $iterator->BEGIN_MAP) { $depth++; }
if($curRes == $iterator->END_MAP) { $depth--; }
@@ -3304,7 +3318,7 @@ sub updateGradeByPage {
my $parts = $curRes->parts();
my $title = $curRes->compTitle();
my $symbx = $curRes->symb();
- $studentTable.='