--- loncom/interface/groupsort.pm 2007/11/02 21:08:45 1.61
+++ loncom/interface/groupsort.pm 2011/07/04 09:24:58 1.68
@@ -2,7 +2,7 @@
# The LON-CAPA group sort handler
# Allows for sorting prior to import into RAT.
#
-# $Id: groupsort.pm,v 1.61 2007/11/02 21:08:45 albertel Exp $
+# $Id: groupsort.pm,v 1.68 2011/07/04 09:24:58 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -86,8 +86,8 @@ sub update_actions_hash {
sub readfromdb {
my ($r,$resources)=@_;
- my $diropendb =
- "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db";
+ my $diropendb = LONCAPA::tempdir() .
+ "$env{'user.domain'}_$env{'user.name'}_sel_res.db";
# ----------------------------- diropendb is now the filename of the db to open
if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
@@ -181,34 +181,13 @@ sub readfromfile {
}
}
-# --------------------------------------------------------- Read from bookmarks
-
-sub readfrombookmarks {
- my ($r,$resources)=@_;
- my %bookmarks=&Apache::lonnet::dump('bookmarks');
-# the bookmark "hash" is just one entry
-# it's a javascript program code with arguments like ('title','url');
- my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g);
- for (my $index=0;$index<($#bookmarks+1)/2;$index++) {
- if ($bookmarks[$index*2+1]) {
- my $url = $bookmarks[$index*2+1];
- my $name = $bookmarks[$index*2];
- $name =~ s/^LON\-CAPA\s+//;
-
- push(@{$resources},{'url' => $url, 'title' => $name});
- }
- }
-}
# ---------------------------------------------------------------- Main Handler
sub handler {
my $r = shift;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['acts','mode','readfile','recover','bookmarks']);
- # color scheme
- my $fileclr = '#ffffe6';
- my $titleclr = '#ddffff';
+ ['acts','mode','readfile','recover']);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -218,7 +197,7 @@ sub handler {
my $finishimport='';
my $begincondition='';
my $endcondition='';
- if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
+ if (($env{'form.readfile'})) {
$begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';
$endcondition='}';
}
@@ -302,30 +281,35 @@ END
if ($env{'form.readfile'}) {
&readfromfile($r,\@resources);
- } elsif ($env{'form.bookmarks'}) {
- &readfrombookmarks($r,\@resources);
} else {
&readfromdb($r,\@resources);
}
my $ctr = 0;
my $clen = scalar(@resources);
- if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
+ my $title = '';
+ if ($env{'form.recover'}) {
+ $title = 'Recover Removed Resources';
+ } else {
+ $title = 'Sort Imported Resources';
+ }
+ if (($clen > 1) || ($env{'form.readfile'})) {
my %lt=&Apache::lonlocal::texthash(
'fin'=> 'Finalize order of resources',
'ci' => 'Continue Import',
'cs' => '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';
+
$r->print(&Apache::loncommon::start_page($title, $js));
+ $r->print('
'.&mt($title).'
');
$r->print(<
-
END
$r->print(&Apache::loncommon::inhibit_menu_check('input'));
# ---
-
+
+ my $buttontext = $lt{'re'};
if ($env{'form.recover'}) {
$r->print(<
END
@@ -353,7 +337,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("
$lt{'in'}
\n");
- } else {
- $r->print("
$lt{'co'}
\n");
- }
- $r->print("
$lt{'ti'}
\n");
- $r->print("
$lt{'pa'}
\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'})) {
+ $r->print("
$lt{'in'}
\n");
+ } else {
+ $r->print('
'.$lt{'co'}.'
'."\n");
+ }
+ $r->print('
'.$lt{'ti'}.'
'."\n");
+ $r->print("
$lt{'pa'}
");
+ $r->print(&Apache::loncommon::end_data_table_header_row()."\n");
+ } else {
+ my $errtxt = '';
+ if ($env{'form.recover'}) {
+ $errtxt = 'There are no resources to recover.';
+ } else {
+ $errtxt = 'There are no resources to import.';
+ }
+ $r->print('
");
+ if (($clen > 1) || ($env{'form.readfile'})) {
+ if ($clen > 0) {
+ $r->print(&Apache::loncommon::end_data_table());
+ }
+ $r->print('');
} else {
$r->print(<
@@ -489,3 +496,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
+