--- loncom/interface/groupsort.pm 2007/07/12 19:54:43 1.59 +++ loncom/interface/groupsort.pm 2009/03/13 15:39:43 1.65 @@ -2,7 +2,7 @@ # The LON-CAPA group sort handler # Allows for sorting prior to import into RAT. # -# $Id: groupsort.pm,v 1.59 2007/07/12 19:54:43 albertel Exp $ +# $Id: groupsort.pm,v 1.65 2009/03/13 15:39:43 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,7 +37,7 @@ use GDBM_File; use Apache::loncommon; use Apache::lonlocal; use Apache::lonnet; -use LONCAPA(); +use LONCAPA; my $iconpath; # variable to be accessible to multiple subroutines my %hash; # variable to tie to user specific database @@ -45,14 +45,15 @@ my %hash; # variable to tie to user spec sub update_actions_hash { my ($hash) = @_; + # be careful in here, there is also a global %hash my $acts=$env{'form.acts'}; my @Acts=split(/b/,$acts); my %ahash; my %achash; - my $ac=0; # some initial hashes for working with data + my $ac=0; foreach (@Acts) { - my ($state,$ref)=split(/a/); + my ($state,$ref)=split(/a/); $ahash{$ref}=$state; $achash{$ref}=$ac; $ac++; @@ -60,15 +61,16 @@ sub update_actions_hash { # sorting through the actions and changing the global database hash foreach my $key (sort {$achash{$a}<=>$achash{$b}} (keys %ahash)) { if ($ahash{$key} eq '1') { - $hash->{'store_'.$hash{'pre_'.$key.'_link'}}= + $hash->{'store_'.$hash->{'pre_'.$key.'_link'}}= $hash->{'pre_'.$key.'_title'}; - $hash->{'storectr_'.$hash{'pre_'.$key.'_link'}}= + $hash->{'storectr_'.$hash->{'pre_'.$key.'_link'}}= $hash->{'storectr'}+0; $hash->{'storectr'}++; } if ($ahash{$key} eq '0') { - if ($hash->{'store_'.$hash{'pre_'.$key.'_link'}}) { - delete($hash->{'store_'.$hash{'pre_'.$key.'_link'}}); + if ($hash->{'store_'.$hash->{'pre_'.$key.'_link'}}) { + delete($hash->{'store_'.$hash->{'pre_'.$key.'_link'}}); + delete($hash->{'storectr_'.$hash->{'pre_'.$key.'_link'}}); } } } @@ -204,9 +206,6 @@ sub handler { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['acts','mode','readfile','recover','bookmarks']); - # color scheme - my $fileclr = '#ffffe6'; - my $titleclr = '#ddffff'; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; @@ -227,9 +226,9 @@ function finish_import() { for (var num=0; num 'Continue Search', 'fi' => 'Finish Import', 're' => 'Recover Checked', + 'ip' => 'Import Checked', 'ca' => 'Cancel', 'co' => 'Change Order', 'ti' => 'Title', 'pa' => 'Path', 'in' => 'Include' ); - my $title = ($env{'form.recover'}) ? 'Recover Removed Resources' - : 'Sort Imported Resources'; + my $title = ''; + if ($env{'form.recover'}) { + $title = 'Recover Removed Resources'; + } else { + $title = 'Sort Imported Resources'; + } + if ($env{'form.bookmarks'}) { + $title = 'Import Resources from Bookmarks'; + } + $r->print(&Apache::loncommon::start_page($title, $js)); $r->print(<print(&Apache::loncommon::inhibit_menu_check('input')); # --- - - if ($env{'form.recover'}) { + + my $buttontext = $lt{'re'}; + if ($env{'form.bookmarks'}) { + $buttontext = $lt{'ip'} + } + if ($env{'form.recover'} || $env{'form.bookmarks'}) { $r->print(<  END @@ -351,7 +363,8 @@ END my $resurl = &Apache::loncommon::escape_single(&Apache::loncommon::lastresurl()); $r->print(<$lt{'fin'} +

$lt{'fin'}

+
    +
+
END } - $r->print("
"); - $r->print("\n"); - if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { - $r->print("\n"); - } else { - $r->print("\n"); - } - $r->print("\n"); - $r->print("\n"); + + # Only display header if content exists + if ($clen > 0) { + $r->print(&Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row()); + if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { + $r->print("\n"); + } else { + $r->print(''."\n"); + } + $r->print(''."\n"); + $r->print(""); + $r->print(&Apache::loncommon::end_data_table_header_row()."\n"); + } else { + $r->print('

'); + if ($env{'form.bookmarks'}) { + $r->print(&mt('There are no resources in your bookmarks to import.')); + } + $r->print('

'); + } } else { $r->print(&Apache::loncommon::start_page(undef,$js, {'only_body' => 1})); @@ -388,7 +414,8 @@ END $ctr++; my $iconname=&Apache::loncommon::icon($resource->{'url'}); if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { - $r->print(""); unless (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { - $r->print(""); } - $r->print("\n"); + $r->print("" + .&Apache::loncommon::end_data_table_row() + ."\n"); } } if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { - $r->print("
$lt{'in'}$lt{'co'}$lt{'ti'}$lt{'pa'}
$lt{'in'}'.$lt{'co'}.''.$lt{'ti'}.'$lt{'pa'}
"); + $r->print(&Apache::loncommon::start_data_table_row() + .""); if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { $r->print(&checkbox($ctr-1)); } else { @@ -400,19 +427,24 @@ END if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { $r->print("". + $r->print("". &select_box($clen,$ctr). ""); + $r->print(""); $r->print(""); - $r->print(""); - $r->print($resource->{'title'}.$resource->{'notes'}."\n"); - $r->print($resource->{'url'}."
"); + $r->print($resource->{'title'}.$resource->{'notes'}."\n"); + $r->print($resource->{'url'}."
"); + if ($clen > 0) { + $r->print(&Apache::loncommon::end_data_table()); + } + $r->print(''); } else { $r->print(< @@ -429,12 +461,12 @@ END # --------------------------------------- Hidden values (returns scalar string) sub hidden { my ($sel,$title,$filelink,$id) = @_; - my $string = ''; + my $string = ''; $filelink=~s|^/ext/|http://|; $string .= ''; - $string .= ''; + &escape($filelink).'" />'; + $string .= ''; return $string; } @@ -487,3 +519,30 @@ sub checkbox { 1; __END__ + +=pod + +=head1 NAME + +Apache::groupsort.pm + +=head1 SYNOPSIS + +Implements a second phase of importing +multiple resources into the RAT. Allows for +reordering the sequence of resources + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + + +=head1 NOTABLE SUBROUTINES + +=over + +=item + +=back + +=cut +