version 1.250, 2005/03/03 05:57:26
|
version 1.253, 2005/04/02 02:22:10
|
Line 2113 sub saveHandGrade {
|
Line 2113 sub saveHandGrade {
|
$ENV{'request.course.id'}); |
$ENV{'request.course.id'}); |
if (!&canmodify($usec)) { return('not_allowed'); } |
if (!&canmodify($usec)) { return('not_allowed'); } |
my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname); |
my %record = &Apache::lonnet::restore($symb,$ENV{'request.course.id'},$domain,$stuname); |
|
my @parts_graded; |
my %newrecord = (); |
my %newrecord = (); |
my ($pts,$wgt) = ('',''); |
my ($pts,$wgt) = ('',''); |
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) { |
foreach (split(/:/,$ENV{'form.partlist'.$newflg})) { |
Line 2147 sub saveHandGrade {
|
Line 2148 sub saveHandGrade {
|
if ($partial eq $record{'resource.'.$_.'.awarded'}) { |
if ($partial eq $record{'resource.'.$_.'.awarded'}) { |
#do not update score for part if not changed. |
#do not update score for part if not changed. |
next; |
next; |
|
} else { |
|
push @parts_graded, $_; |
} |
} |
if ($record{'resource.'.$_.'.awarded'} ne $partial) { |
if ($record{'resource.'.$_.'.awarded'} ne $partial) { |
$newrecord{'resource.'.$_.'.awarded'} = $partial; |
$newrecord{'resource.'.$_.'.awarded'} = $partial; |
Line 2170 sub saveHandGrade {
|
Line 2173 sub saveHandGrade {
|
} |
} |
} |
} |
if (scalar(keys(%newrecord)) > 0) { |
if (scalar(keys(%newrecord)) > 0) { |
|
&version_portfiles(\%record, \@parts_graded, $ENV{'request.course.id'}, $symb, $domain, $stuname); |
&Apache::lonnet::cstore(\%newrecord,$symb, |
&Apache::lonnet::cstore(\%newrecord,$symb, |
$ENV{'request.course.id'},$domain,$stuname); |
$ENV{'request.course.id'},$domain,$stuname); |
} |
} |
return '',$pts,$wgt; |
return '',$pts,$wgt; |
} |
} |
|
|
|
# ----------- Handles creating versions for portfolio files as answers |
|
sub version_portfiles { |
|
my ($record, $parts_graded, $courseid, $symb, $domain, $stuname) = @_; |
|
my $parts = join '|', @$parts_graded; |
|
my $portfolio_root = &Apache::loncommon::propath($domain, |
|
$stuname). |
|
'/userfiles/portfolio'; |
|
foreach my $key (keys %$record) { |
|
if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) { |
|
my @portfiles = split /,/,$$record{$key}; |
|
foreach my $file (@portfiles) { |
|
$file =~ /^(.*?)([^\/]*$)/; |
|
my $directory = $1; |
|
my $version = 0; |
|
my $answer_file = $2; |
|
my @answer_file_parts = split /\./, $answer_file; |
|
my @dir_list = &Apache::lonnet::dirlist($directory,$domain,$stuname,$portfolio_root); |
|
my @file_names; |
|
my @file_name_parts; |
|
foreach my $row (@dir_list) { |
|
@file_names = split (/\&/,$row,2); |
|
@file_name_parts = split (/\./, $file_names[0]); |
|
# ($file_name_parts[scalar @file_name_parts] eq $answer_file_parts[scalar @answer_file_parts]) |
|
if (($file_name_parts[0] eq $answer_file_parts[0]) && |
|
($file_name_parts[-1] eq $answer_file_parts[-1])) { |
|
# gets here if filename and extension match, regardless of version |
|
if (scalar @file_name_parts == 3) { # a versioned file is found |
|
# so save it for later |
|
if ($file_name_parts[1] > $version) {$version = $file_name_parts[1]}; |
|
} |
|
} |
|
} |
|
$version += 1; |
|
&Apache::lonnet::logthis('answer file is '.$answer_file. |
|
' becomes '.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[(scalar @answer_file_parts)-1]); |
|
&Apache::lonnet::logthis('from dir list is '.$file_names[0].' has '.@file_name_parts.' parts'); |
|
} |
|
&Apache::lonnet::logthis('found key portfiles '.$key); |
|
&Apache::lonnet::logthis('found value portfiles '.$$record{$key}); |
|
} |
|
} |
|
|
|
|
|
} |
|
|
#-------------------------------------------------------------------------------------- |
#-------------------------------------------------------------------------------------- |
# |
# |
#-------------------------- Next few routines handles grading by section or whole class |
#-------------------------- Next few routines handles grading by section or whole class |