--- loncom/interface/portfolio.pm 2006/08/12 22:41:53 1.155 +++ loncom/interface/portfolio.pm 2006/08/14 21:25:42 1.156 @@ -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.156 2006/08/14 21:25:42 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -164,39 +164,36 @@ 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); + $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 +262,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 +275,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 +286,28 @@ 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; + my $fullpath = &prepend_group($current_path.$filename); if ($env{'form.showversions'} eq $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, + $version_flag = &make_anchor('portfolio',\%anchor_fields, ''.&mt('opened folder').''); } else { $anchor_fields{'showversions'} = $filename; - $version_flag{$filename} = &make_anchor('portfolio',\%anchor_fields, + $version_flag = &make_anchor('portfolio',\%anchor_fields, ''.&mt('closed folder').''); } } else { - $version_flag{$filename} = ' '; + $version_flag = ' '; } if ($dirptr&$testdir) { my $colspan='colspan="2"'; @@ -325,13 +323,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'; @@ -401,19 +397,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); } } } @@ -1609,35 +1603,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));