[LON-CAPA-cvs] cvs: loncom /interface portfolio.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 14 Aug 2006 21:25:42 -0000
This is a MIME encoded message
--albertel1155590742
Content-Type: text/plain
albertel Mon Aug 14 17:25:42 2006 EDT
Modified files:
/loncom/interface portfolio.pm
Log:
- version lock info failed to work in anything but top directory
- simplified some of the version data passing
- simplified the lock display
- some style improvbements
--albertel1155590742
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060814172542.txt"
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.155 loncom/interface/portfolio.pm:1.156
--- loncom/interface/portfolio.pm:1.155 Sat Aug 12 18:41:53 2006
+++ loncom/interface/portfolio.pm Mon Aug 14 17:25:42 2006
@@ -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 @@
}
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('<tr class="'.$css_class.'">');
$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('<td><img alt="" src="'.&Apache::loncommon::icon($filename).'" /></td>');
- $r->print('<td>'.$$version_flag{$filename}.'</td>');
+ $r->print('<td>'.$version_flag.'</td>');
} 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('<td colspan="2">'.$lock_info.'</td>');
+ if ($lock_info) {
+ my %anchor_fields = ('lockinfo' => $fullpath);
+ $lock_info = &make_anchor(undef,\%anchor_fields,$lock_info);
+ }
+ $r->print('<td colspan="2">'.$lock_info.'</td>');
}
# $r->print('<td>'.$$version_flag{$filename}.'</td><td>');
$r->print('<td>'.&make_anchor($href_location.$filename,undef,$filename).'</td>');
@@ -265,7 +262,6 @@
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 @@
$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 @@
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,
'<img class="LC_icon" alt="'.&mt('opened folder').'" src="'.$iconpath.'folder_pointer_opened.gif" />');
} else {
$anchor_fields{'showversions'} = $filename;
- $version_flag{$filename} = &make_anchor('portfolio',\%anchor_fields,
+ $version_flag = &make_anchor('portfolio',\%anchor_fields,
'<img class="LC_icon" alt="'.&mt('closed folder').'" src="'.$iconpath.'folder_pointer_closed.gif" />');
}
} else {
- $version_flag{$filename} = ' ';
+ $version_flag = ' ';
}
if ($dirptr&$testdir) {
my $colspan='colspan="2"';
@@ -325,13 +323,11 @@
'fieldname' => $env{"form.fieldname"},
'continue' => $env{"form.continue"}
);
- $r->print('<td>'.$version_flag{$filename}.'</td><td>'.&make_anchor($url,\%anchor_fields,$filename.'/').'</td>');
+ $r->print('<td>'.$version_flag.'</td><td>'.&make_anchor($url,\%anchor_fields,$filename.'/').'</td>');
$r->print('</tr>');
} else {
my $css_class = 'LC_browser_file';
my $line;
- my $fullpath = $current_path.$filename;
- $fullpath = &prepend_group($fullpath);
if ($select_mode eq 'true') {
$line='<td><input type="checkbox" name="checkfile" value="'.$filename.'"';
if ($$checked_files{$filename} eq 'selected') {
@@ -341,7 +337,7 @@
} else {
if (exists $locked_files{$fullpath}) {
my %anchor_fields = (
- 'lockinfo' => $current_path.$filename
+ 'lockinfo' => $fullpath
);
$line.='<td colspan="2">'.&make_anchor($url,\%anchor_fields,'Locked').'</td>';
$css_class= 'LC_browser_file_locked';
@@ -401,19 +397,17 @@
$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 = '<td colspan="2"> </td>';
- 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 @@
$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 = '<strong>'.$env{'form.lockinfo'}.
- '</strong> (group: '.$group.')';
- } else {
- $filetext = '<strong>'.$file_name.'</strong>';
- }
- if ($$array_item[(@$array_item - 1)] eq 'graded') {
- $r->print(&mt('[_1] was submitted in response to problem: ',
- $filetext).
- '<strong>'.&Apache::lonnet::gettitle($$array_item[0]).
- '</strong><br />');
- my %course_description = &Apache::lonnet::coursedescription($$array_item[1]);
- $r->print(&mt('In the course: <strong>[_1]</strong><br />',
- $course_description{'description'}));
- } elsif ($$array_item[(@$array_item - 1)] eq 'handback') {
- $r->print(&mt('[_1] was handed back in response to problem: ',
- $filetext).
- '<strong>'.&Apache::lonnet::gettitle($$array_item[0]).
- '</strong><br />');
- my %course_description = &Apache::lonnet::coursedescription($$array_item[1]);
- $r->print(&mt('In the course: <strong>[_1]</strong><br />',
- $course_description{'description'}));
-
- }
- # $r->print('the third is '.$$array_item[2].'<br>');
- # $r->print("item is $$array_item[0]<br> and $$array_item[0]");
- }
+ next if (ref($array_item) ne 'ARRAY');
+
+ my $filetext;
+ if (defined($group)) {
+ $filetext = '<strong>'.$env{'form.lockinfo'}.
+ '</strong> (group: '.$group.')';
+ } else {
+ $filetext = '<strong>'.$file_name.'</strong>';
+ }
+
+ my $title ='<strong>'.&Apache::lonnet::gettitle($$array_item[0]).
+ '</strong><br />';
+ 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: <strong>[_1]</strong><br />',
+ $course_description{'description'}));
+ }
}
}
$r->print(&done('Back',$url));
--albertel1155590742--