version 1.252, 2005/04/01 23:56:52
|
version 1.255, 2005/04/03 21:41:58
|
Line 2183 sub saveHandGrade {
|
Line 2183 sub saveHandGrade {
|
# ----------- Handles creating versions for portfolio files as answers |
# ----------- Handles creating versions for portfolio files as answers |
sub version_portfiles { |
sub version_portfiles { |
my ($record, $parts_graded, $courseid, $symb, $domain, $stuname) = @_; |
my ($record, $parts_graded, $courseid, $symb, $domain, $stuname) = @_; |
my $parts = join '|', @$parts_graded; |
my $parts = join('|', @$parts_graded); |
my $portfolio_root = &Apache::loncommon::propath($domain, |
my $portfolio_root = &Apache::loncommon::propath($domain, |
$stuname). |
$stuname). |
'/userfiles/portfolio'; |
'/userfiles/portfolio'; |
foreach my $key (keys %$record) { |
foreach my $key(keys %$record) { |
if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) { |
if ($key =~ /^resource\.($parts)\./ && $key =~ /\.portfiles$/) { |
my @portfiles = split /,/,$$record{$key}; |
my @portfiles = split(/,/,$$record{$key}); |
foreach my $file (@portfiles) { |
foreach my $file (@portfiles) { |
$file =~ /^(.*?)([^\/]*$)/; |
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*$)/); |
my $directory = $1; |
|
my $version = 0; |
my $version = 0; |
my $answer_file = $2; |
my @answer_file_parts = split(/\./, $answer_file); |
my @answer_file_parts = split /\./, $answer_file; |
|
my @dir_list = &Apache::lonnet::dirlist($directory,$domain,$stuname,$portfolio_root); |
my @dir_list = &Apache::lonnet::dirlist($directory,$domain,$stuname,$portfolio_root); |
my @file_names; |
my @file_names; |
my @file_name_parts; |
my @file_name_parts; |
foreach ( @dir_list) { |
foreach my $row (@dir_list) { |
@file_names = split /\&/,$_,2; |
@file_names = split(/\&/,$row,2); |
@file_name_parts = split /\./, $file_names[0]; |
@file_name_parts = split(/\./, $file_names[0]); |
# ($file_name_parts[scalar @file_name_parts] eq $answer_file_parts[scalar @answer_file_parts]) |
# ($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]) && |
if (($file_name_parts[0] eq $answer_file_parts[0]) && |
($file_name_parts[(scalar @file_name_parts)-1] eq $answer_file_parts[(scalar @answer_file_parts)-1])) { |
($file_name_parts[-1] eq $answer_file_parts[-1])) { |
# gets here if filename and extension match, regardless of version |
# gets here if filename and extension match, regardless of version |
if (scalar @file_name_parts == 3) { # a versioned file is found |
if (scalar @file_name_parts == 3) { # a versioned file is found |
# so save it for later |
# so save it for later |
Line 2212 sub version_portfiles {
|
Line 2210 sub version_portfiles {
|
} |
} |
} |
} |
} |
} |
$version += 1; |
$version++; |
&Apache::lonnet::logthis('answer file is '.$answer_file. |
&Apache::lonnet::logthis('answer file is '.$answer_file. |
' becomes '.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[(scalar @answer_file_parts)-1]); |
' becomes '.$answer_file_parts[0].'.'.$version.'.'.$answer_file_parts[-1]); |
&Apache::lonnet::logthis('from dir list is '.$file_names[0].' has '.@file_name_parts.' parts'); |
&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 key portfiles '.$key); |