[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface groupsort.pm
raeburn
raeburn at source.lon-capa.org
Wed May 2 15:10:13 EDT 2012
raeburn Wed May 2 19:10:13 2012 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface groupsort.pm
Log:
- For 2.11 reverse changes in 1.67.
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.68 loncom/interface/groupsort.pm:1.68.6.1
--- loncom/interface/groupsort.pm:1.68 Mon Jul 4 09:24:58 2011
+++ loncom/interface/groupsort.pm Wed May 2 19:10:13 2012
@@ -2,7 +2,7 @@
# The LON-CAPA group sort handler
# Allows for sorting prior to import into RAT.
#
-# $Id: groupsort.pm,v 1.68 2011/07/04 09:24:58 foxr Exp $
+# $Id: groupsort.pm,v 1.68.6.1 2012/05/02 19:10:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -181,13 +181,31 @@
}
}
+# --------------------------------------------------------- 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']);
+ ['acts','mode','readfile','recover','bookmarks']);
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
@@ -197,7 +215,7 @@
my $finishimport='';
my $begincondition='';
my $endcondition='';
- if (($env{'form.readfile'})) {
+ if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
$begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';
$endcondition='}';
}
@@ -281,6 +299,8 @@
if ($env{'form.readfile'}) {
&readfromfile($r,\@resources);
+ } elsif ($env{'form.bookmarks'}) {
+ &readfrombookmarks($r,\@resources);
} else {
&readfromdb($r,\@resources);
}
@@ -293,7 +313,10 @@
} else {
$title = 'Sort Imported Resources';
}
- if (($clen > 1) || ($env{'form.readfile'})) {
+ if ($env{'form.bookmarks'}) {
+ $title = 'Import Resources from Bookmarks';
+ }
+ if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
my %lt=&Apache::lonlocal::texthash(
'fin'=> 'Finalize order of resources',
'ci' => 'Continue Import',
@@ -319,6 +342,7 @@
<input type="hidden" name="newval" value="" />
<input type="hidden" name="mode" value="$env{'form.mode'}" />
<input type="hidden" name="readfile" value="$env{'form.readfile'}" />
+<input type="hidden" name="bookmarks" value="$env{'form.bookmarks'}" />
<input type="hidden" name="recover" value="$env{'form.recover'}" />
END
@@ -326,7 +350,10 @@
# ---
my $buttontext = $lt{'re'};
- if ($env{'form.recover'}) {
+ if ($env{'form.bookmarks'}) {
+ $buttontext = $lt{'ip'}
+ }
+ if ($env{'form.recover'} || $env{'form.bookmarks'}) {
$r->print(<<END);
<input type="button" name="alter" value="$buttontext"
onClick="finish_import()" />
@@ -370,6 +397,9 @@
} else {
$errtxt = 'There are no resources to import.';
}
+ if ($env{'form.bookmarks'}) {
+ $errtxt = 'There are no resources in your bookmarks to import.';
+ }
$r->print('<p class="LC_info">'.&mt($errtxt).'</p>');
}
} else {
@@ -390,10 +420,10 @@
foreach my $resource (@resources) {
$ctr++;
my $iconname=&Apache::loncommon::icon($resource->{'url'});
- if (($clen > 1) || ($env{'form.readfile'})) {
+ if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
$r->print(&Apache::loncommon::start_data_table_row()
."<td>");
- if (($env{'form.readfile'})) {
+ if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
$r->print(&checkbox($ctr-1));
} else {
$r->print(&movers($clen,$ctr));
@@ -401,9 +431,9 @@
}
$r->print(&hidden($ctr-1,$resource->{'title'},$resource->{'url'},
$resource->{'id'}));
- if (($clen > 1) || ($env{'form.readfile'})) {
+ if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
$r->print("</td>");
- unless (($env{'form.readfile'})) {
+ unless (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
$r->print("<td>".
&select_box($clen,$ctr).
"</td>");
@@ -417,7 +447,7 @@
."\n");
}
}
- if (($clen > 1) || ($env{'form.readfile'})) {
+ if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
if ($clen > 0) {
$r->print(&Apache::loncommon::end_data_table());
}
More information about the LON-CAPA-cvs
mailing list