[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Fri, 05 Sep 2003 18:11:26 -0000
bowersj2 Fri Sep 5 14:11:26 2003 EDT
Modified files:
/loncom/interface londocs.pm
Log:
I need this as a seperate function so I can call it programmatically
from the testing structure. (Need to add resources to a course so I can
test the printing routines.)
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.72 loncom/interface/londocs.pm:1.73
--- loncom/interface/londocs.pm:1.72 Tue Sep 2 11:49:42 2003
+++ loncom/interface/londocs.pm Fri Sep 5 14:11:26 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.72 2003/09/02 15:49:42 www Exp $
+# $Id: londocs.pm,v 1.73 2003/09/05 18:11:26 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -72,6 +72,29 @@
$map,1);
}
+# Imports the given (name, url) resources into the course
+# coursenum, coursedom, and folder must precede the list
+sub group_import {
+ my $coursenum = shift;
+ my $coursedom = shift;
+ my $folder = shift;
+ while (@_) {
+ my $name = shift;
+ my $url = shift;
+ if ($url) {
+ my $idx = $#Apache::lonratedt::resources + 1;
+ $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
+ my $ext = 'false';
+ if ($url=~/^http:\/\//) { $ext = 'true'; }
+ $url =~ s/:/\:/g;
+ $name =~ s/:/\:/g;
+ $Apache::lonratedt::resources[$idx] =
+ join ':', ($name, $url, $ext, 'normal', 'res');
+ }
+ }
+ &storemap($coursenum, $coursedom, $folder);
+}
+
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
if ($ENV{'form.foldername'}) {
@@ -158,26 +181,17 @@
}
# Group import/search
if ($ENV{'form.importdetail'}) {
- foreach (split(/\&/,$ENV{'form.importdetail'})) {
- if (defined($_)) {
- my ($name,$url)=split(/\=/,$_);
- $name=&Apache::lonnet::unescape($name);
- $url=&Apache::lonnet::unescape($url);
- if ($url) {
- my $idx=$#Apache::lonratedt::resources+1;
- $Apache::lonratedt::order
- [$#Apache::lonratedt::order+1]=$idx;
- my $ext='false';
- if ($url=~/^http\:\/\//) { $ext='true'; }
- $url=~s/\:/\:/g;
- $name=~s/\:/\:/g;
- $Apache::lonratedt::resources[$idx]=
- $name.':'.$url.':'.$ext.':normal:res';
- }
- }
- }
+ my @imports;
+ foreach (split(/\&/,$ENV{'form.importdetail'})) {
+ if (defined($_)) {
+ my ($name,$url)=split(/\=/,$_);
+ $name=&Apache::lonnet::unescape($name);
+ $url=&Apache::lonnet::unescape($url);
+ push @imports, $name, $url;
+ }
+ }
# Store the changed version
- &storemap($coursenum,$coursedom,$folder.'.sequence');
+ group_import($coursenum, $coursedom, $folder, @imports);
}
# Loading a complete map
if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {