--- loncom/interface/portfolio.pm 2006/08/12 22:41:53 1.155
+++ loncom/interface/portfolio.pm 2006/08/24 18:28:43 1.162
@@ -1,7 +1,7 @@
# The LearningOnline Network
# portfolio browser
#
-# $Id: portfolio.pm,v 1.155 2006/08/12 22:41:53 banghart Exp $
+# $Id: portfolio.pm,v 1.162 2006/08/24 18:28:43 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -164,39 +164,41 @@ TABLE
}
sub display_directory_line {
- my ($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class,
+ my ($r,$select_mode, $filename, $mtime, $size, $css_class,
$line, $access_controls, $curr_access, $now, $version_flag,
$href_location, $url, $current_path, $access_admin_text, $versions)=@_;
- # my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
+
+ my $fullpath = &prepend_group($current_path.$filename);
$r->print('
');
$r->print($line); # contains first two cells of table
- $filename = $filename;
- $filename = &prepend_group($filename);
my $lock_info;
- if ($$version_flag{$filename}) { # versioned can't be versioned, so TRUE when root file
+ if ($version_flag) { # versioned can't be versioned, so TRUE when root file
$r->print(' ');
- $r->print(''.$$version_flag{$filename}.' ');
+ $r->print(''.$version_flag.' ');
} else { # this is a graded or handed back file
my ($user,$domain) = &get_name_dom();
my $permissions_hash = &Apache::lonnet::get_portfile_permissions($domain,$user);
- if (defined($filename) && defined($$permissions_hash{'/'.$filename})) {
- foreach my $array_item (@{$$permissions_hash{'/'.$filename}}) {
+ if (defined($$permissions_hash{$fullpath})) {
+ foreach my $array_item (@{$$permissions_hash{$fullpath}}) {
if (ref($array_item) eq 'ARRAY') {
- if ($$array_item[(@$array_item - 1)] eq 'handback') {
+ if ($$array_item[-1] eq 'handback') {
$lock_info = 'Handback';
- } elsif ($$array_item[(@$array_item - 1)] eq 'graded') {
+ } elsif ($$array_item[-1] eq 'graded') {
$lock_info = 'Graded';
}
}
}
}
- if ($lock_info) {
- my %anchor_fields = (
- 'lockinfo' => '/'.$filename
- );
- $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info);
- }
- $r->print(''.$lock_info.' ');
+ if ($lock_info) {
+ my %anchor_fields = ('lockinfo' => $fullpath);
+ if ($versions) { # hold the folder open
+ my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($fullpath);
+ $fname =~ s|^/||;
+ $anchor_fields{'showversions'} = $fname.'.'.$extension;
+ }
+ $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info);
+ }
+ $r->print(''.$lock_info.' ');
}
# $r->print(''.$$version_flag{$filename}.' ');
$r->print(' '.&make_anchor($href_location.$filename,undef,$filename).' ');
@@ -265,7 +267,6 @@ sub display_directory {
my $href_location="/uploaded/$udom/$uname/$port_path".$current_path;
my $href_edit_location="/editupload/$udom/$uname/$port_path".$current_path;
my @dir_lines;
- my @version_lines;
my %versioned;
foreach my $dir_line (sort
{
@@ -279,8 +280,9 @@ sub display_directory {
$filename =~ s/\s+$//;
my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
if ($version) {
- push(@version_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
- $versioned{$fname.'.'.$extension} .= $version.",";
+ my $fullpath = &prepend_group($current_path.$fname.'.'.$extension);
+ push(@{ $versioned{$fullpath} },
+ [$filename,$dom,$testdir,$size,$mtime,$obs,]);
} else {
push(@dir_lines, [$filename,$dom,$testdir,$size,$mtime,$obs]);
}
@@ -289,27 +291,33 @@ sub display_directory {
my ($filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename);
if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) {
- my %version_flag;
+ my $version_flag;
my $show_versions;
- if ($env{'form.showversions'} eq $filename) {
+ my $fullpath = &prepend_group($current_path.$filename);
+ if ($env{'form.showversions'} =~ /$filename/) {
$show_versions = 'true';
}
- if (exists($versioned{$filename})) {
+ if (exists($versioned{$fullpath})) {
my %anchor_fields = (
- 'selectfile' => $filename,
+ 'selectfile' => $fullpath,
'continue' => 'false',
'currentpath' => $current_path,
);
if ($show_versions) {
- $version_flag{$filename} = &make_anchor('portfolio',\%anchor_fields,
+ # Must preserve other possible showversion files
+ my $version_remainder = $env{'form.showversions'};
+ $version_remainder =~ s/$filename//g;
+ $anchor_fields{'showversions'} = $version_remainder;
+ $version_flag = &make_anchor('portfolio',\%anchor_fields,
' ');
} else {
- $anchor_fields{'showversions'} = $filename;
- $version_flag{$filename} = &make_anchor('portfolio',\%anchor_fields,
+ # allow multiple files to show versioned
+ $anchor_fields{'showversions'} = $env{'form.showversions'}.','.$filename;
+ $version_flag = &make_anchor('portfolio',\%anchor_fields,
' ');
}
} else {
- $version_flag{$filename} = ' ';
+ $version_flag = ' ';
}
if ($dirptr&$testdir) {
my $colspan='colspan="2"';
@@ -325,13 +333,11 @@ sub display_directory {
'fieldname' => $env{"form.fieldname"},
'continue' => $env{"form.continue"}
);
- $r->print(''.$version_flag{$filename}.' '.&make_anchor($url,\%anchor_fields,$filename.'/').' ');
+ $r->print(''.$version_flag.' '.&make_anchor($url,\%anchor_fields,$filename.'/').' ');
$r->print(' ');
} else {
my $css_class = 'LC_browser_file';
my $line;
- my $fullpath = $current_path.$filename;
- $fullpath = &prepend_group($fullpath);
if ($select_mode eq 'true') {
$line=' $current_path.$filename
+ 'lockinfo' => $fullpath
);
$line.=''.&make_anchor($url,\%anchor_fields,'Locked').' ';
$css_class= 'LC_browser_file_locked';
@@ -362,7 +368,7 @@ sub display_directory {
currentpath => $current_path
);
$line .= &make_anchor($url,\%anchor_fields,'Rename');
- $line .= ''.&make_anchor($href_edit_location.$filename.'.meta',undef,$cat);
+ $line .= ' '.&make_anchor($href_edit_location.$filename.'.meta',\%anchor_fields,$cat);
# ''.$cat.' ';
}
$line .= ' ';
@@ -401,19 +407,17 @@ sub display_directory {
$curr_access = join('+ ',@allaccesses);
}
}
- &display_directory_line($r,$select_mode,$fullpath, $filename, $mtime, $size, $css_class, $line,
- \%access_controls, $curr_access,$now, \%version_flag, $href_location,
+ &display_directory_line($r,$select_mode, $filename, $mtime, $size, $css_class, $line,
+ \%access_controls, $curr_access,$now, $version_flag, $href_location,
$url, $current_path, $access_admin_text);
if ($show_versions) {
- foreach my $dir_line (@version_lines) {
- my ($v_filename,$dom,$testdir,$size,$mtime,$obs) = @$dir_line;
- my ($v_fname,$version,$v_extension) = &Apache::grades::file_name_version_ext($v_filename);
+ foreach my $dir_line (@{ $versioned{$fullpath} }) {
+ my ($v_filename,$dom,$testdir,$size,$mtime,$obs) =
+ @$dir_line;
$line = ' ';
- if (($v_fname eq $fname)&&($v_extension eq $extension)) {
- &display_directory_line($r,$select_mode,$fullpath, $v_filename, $mtime, $size,
- $css_class, $line, \%access_controls, $curr_access, $now,
- \%version_flag, $href_location, $url, $current_path, $access_admin_text, 1);
- }
+ &display_directory_line($r,$select_mode, $v_filename, $mtime, $size,
+ $css_class, $line, \%access_controls, $curr_access, $now,
+ undef, $href_location, $url, $current_path, $access_admin_text, 1);
}
}
}
@@ -502,6 +506,7 @@ sub done {
$message='Done';
}
my %anchor_fields = (
+ 'showversions' => $env{'form.showversions'},
'currentpath' => $env{'form.currentpath'},
'fieldname' => $env{'form.fieldname'},
'mode' => $env{'form.mode'}
@@ -649,7 +654,7 @@ sub display_access {
$info .= &mt('The conditions can include affiliation with a particular course or group, or a user account in a specific domain.').' ';
$info .= &mt('Alternatively access can be granted to people with specific LON-CAPA usernames and domains.').'';
if ($group eq '') {
- $info .= (&mt("Direct others to the 'Display file listing' link (shown when there are viewable files) on your personal information page:http://$ENV{'SERVER_NAME'}/adm/$udom/$uname/aboutme "));
+ $info .= (&mt("A listing of files viewable without log-in is available at: http://$ENV{'SERVER_NAME'}/adm/$udom/$uname/aboutme/portfolio . For logged in users a 'Display file listing' link will also appear (when there are viewable files) on your personal information page:http://$ENV{'SERVER_NAME'}/adm/$udom/$uname/aboutme "));
}
if ($can_setacl) {
@@ -1609,35 +1614,35 @@ sub lock_info {
$file_name = &prepend_group($file_name);
if (defined($file_name) && defined($$current_permissions{$file_name})) {
foreach my $array_item (@{$$current_permissions{$file_name}}) {
- if (ref($array_item) eq 'ARRAY') {
- my $filetext;
- if (defined($group)) {
- $filetext = ''.$env{'form.lockinfo'}.
- ' (group: '.$group.')';
- } else {
- $filetext = ''.$file_name.' ';
- }
- if ($$array_item[(@$array_item - 1)] eq 'graded') {
- $r->print(&mt('[_1] was submitted in response to problem: ',
- $filetext).
- ''.&Apache::lonnet::gettitle($$array_item[0]).
- ' ');
- my %course_description = &Apache::lonnet::coursedescription($$array_item[1]);
- $r->print(&mt('In the course: [_1] ',
- $course_description{'description'}));
- } elsif ($$array_item[(@$array_item - 1)] eq 'handback') {
- $r->print(&mt('[_1] was handed back in response to problem: ',
- $filetext).
- ''.&Apache::lonnet::gettitle($$array_item[0]).
- ' ');
- my %course_description = &Apache::lonnet::coursedescription($$array_item[1]);
- $r->print(&mt('In the course: [_1] ',
- $course_description{'description'}));
-
- }
- # $r->print('the third is '.$$array_item[2].' ');
- # $r->print("item is $$array_item[0] and $$array_item[0]");
- }
+ next if (ref($array_item) ne 'ARRAY');
+
+ my $filetext;
+ if (defined($group)) {
+ $filetext = ''.$env{'form.lockinfo'}.
+ ' (group: '.$group.')';
+ } else {
+ $filetext = ''.$file_name.' ';
+ }
+
+ my $title =''.&Apache::lonnet::gettitle($$array_item[0]).
+ ' ';
+ if ($$array_item[-1] eq 'graded') {
+ $r->print(&mt('[_1] was submitted in response to problem: [_2]',
+ $filetext,$title));
+ } elsif ($$array_item[-1] eq 'handback') {
+ $r->print(&mt('[_1] was handed back in response to problem: [_2]',
+ $filetext,$title));
+ } else {
+ # submission style lock
+ $r->print(&mt('[_1] was submitted in response to problem: [_2]',
+ $filetext,$title));
+ }
+ my %course_description =
+ &Apache::lonnet::coursedescription($$array_item[1]);
+ if ( $course_description{'description'} ne '') {
+ $r->print(&mt('In the course: [_1] ',
+ $course_description{'description'}));
+ }
}
}
$r->print(&done('Back',$url));
@@ -1683,7 +1688,10 @@ sub createdir {
}
sub get_portfolio_root {
- my ($uname,$udom) = &get_name_dom();
+ my ($udom,$uname) = @_;
+ if (!(defined($udom)) || !(defined($uname))) {
+ ($uname,$udom) = &get_name_dom();
+ }
my $path;
if (defined($env{'form.group'})) {
$path = '/userfiles/groups/'.$env{'form.group'}.'/portfolio';