--- loncom/imspackages/imsimportdocs.pm 2006/03/23 23:12:21 1.15
+++ loncom/imspackages/imsimportdocs.pm 2014/12/11 00:35:53 1.34
@@ -1,3 +1,7 @@
+# The LearningOnline Network with CAPA
+#
+# $Id: imsimportdocs.pm,v 1.34 2014/12/11 00:35:53 raeburn Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -29,58 +33,48 @@ use Apache::londocs;
use Apache::loncommon;
use Apache::lonlocal;
use Apache::imsprocessor;
-use LONCAPA::Configuration;
+use LONCAPA::map();
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
use strict;
sub jscript_one {
- my $javascript = shift;
- $$javascript = qq#
-function verify() {
- if ((document.forms.pickcms.uploadname.value == '') || (!document.forms.pickcms.uploadname.value)) {
- alert("You must provide the name of the IMS package to be imported")
- return false
- }
- if (document.forms.pickcms.source.selectedIndex == 0) {
- alert("You must choose the Course Management System from which the IMS package was exported");
- return false
- }
- return true
-}
-
-function nextPage() {
- if (verify()) {
- document.forms.pickcms.submit()
- }
-}
-#;
-
-}
-
-sub jscript_two {
- my $javascript = shift;
- $$javascript = qq#
+ my %lt = &Apache::lonlocal::texthash(
+ se => 'Select',
+ to => 'Import topics only',
+ tp => 'Import topics + posts (with author)',
+ tn => 'Import topics + posts (no author)',
+ es => 'Enroll students only',
+ ea => 'Enroll all users',
+ nr => 'Not required',
+ id => 'You must select one of the additional options when importing Discussion Boards.',
+ ie => 'You must select one of the additional options when importing Enrollment.',
+ ct => 'You must check at least one Content Type.',
+ );
+ return <<"ENDJS";
function setOptions(caller,itemnum) {
var opForm = document.forms.pickoptions
var menu = 1 + itemnum*2
opForm.elements[menu].length = 0
if (opForm.elements[itemnum*2].checked == true) {
if (caller == "board") {
- opForm.elements[menu].options[0] = new Option("Select","-1",true,true)
- opForm.elements[menu].options[1] = new Option("Import topics only","topics",true,true)
- opForm.elements[menu].options[2] = new Option("Import topics + posts (with author)","allpost",true,true)
- opForm.elements[menu].options[3] = new Option("Import topics + posts (no author)","allanon",true,true)
+ opForm.elements[menu].options[0] = new Option("$lt{'se'}","-1",true,true)
+ opForm.elements[menu].options[1] = new Option("$lt{'to'}","topics",true,true)
+ opForm.elements[menu].options[2] = new Option("$lt{'tp'}","allpost",true,true)
+ opForm.elements[menu].options[3] = new Option("$lt{'tn'}","allanon",true,true)
}
else {
if (caller == "users") {
opForm.elements[menu].length = 0
- opForm.elements[menu].options[0] = new Option("Select","-1",true,true)
- opForm.elements[menu].options[1] = new Option("Enroll students only","students",true,true)
- opForm.elements[menu].options[2] = new Option("Enroll all users","all",true,true)
+ opForm.elements[menu].options[0] = new Option("$lt{'se'}","-1",true,true)
+ opForm.elements[menu].options[1] = new Option("$lt{'es'}","students",true,true)
+ opForm.elements[menu].options[2] = new Option("$lt{'ea'}","all",true,true)
}
}
}
else {
- opForm.elements[menu].options[0] = new Option("Not required","0",true,true)
+ opForm.elements[menu].options[0] = new Option("$lt{'nr'}","0",true,true)
}
opForm.elements[menu].selectedIndex = 0
}
@@ -93,20 +87,20 @@ function verify(caller) {
totcheck ++
if (opForm.elements[2*i].name == "board") {
if (opForm.elements[2*i+1].selectedIndex == 0) {
- alert("You must select one of the additional options when importing Discussion Boards ")
+ alert("$lt{'id'}")
return false
}
}
if (opForm.elements[2*i].name == "users") {
if (opForm.elements[2*i+1].selectedIndex == 0) {
- alert("You must select one of the additional options when importing Enrollment")
+ alert("$lt{'ie'}")
return false
}
}
}
}
if (totcheck == 0) {
- alert("You must check the Checkbox for at least one Content Type");
+ alert("$lt{'ct'}");
return false
}
return true
@@ -117,22 +111,23 @@ function nextPage(caller) {
document.forms.pickoptions.submit()
}
}
-#;
+
+ENDJS
+
}
-sub jscript_three {
- my $javascript = shift;
- $$javascript = qq|
+sub jscript_two {
+ return <<"ENDJS";
function init(tf) {
setTimeout("self.close()",3000)
tf.submit();
}
- |;
+
+ENDJS
}
sub handler {
my $r = shift;
- my $javascript = '';
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
@@ -150,151 +145,54 @@ sub handler {
my $uname=$env{'user.name'};
my $udom=$env{'user.domain'};
- my $plainname=&Apache::lonnet::escape(
+ my $plainname=&escape(
&Apache::loncommon::plainname($uname,$udom));
# does this user have privileges to post, etc?
my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
unless ($allowed) {
$r->print(&Apache::loncommon::start_page('Import IMS package',undef,
- {'only_body' => 1,}));
- $r->print('
'.&mt('Modification of Course Contents Disallowed').'
'.&mt('Your current role does not grant you the right to modify course content in this course.').
- &Apache::loncommon::end_page());
+ {'only_body' => 1,}));
+ $r->print(
+ '
'
+ .&mt('Modification of Course Contents Disallowed')
+ .'
'
+ .&mt('Your current role does not grant you the right to modify course content in this course.')
+ .'
- Choose display options for listing of contents of top level of package.
-
-
-
-
-
-
-
-
-
-
-
Display listing of contents in a new folder, with folder name:
-
-
-
Append listing of contents of top level of package to contents list for the current folder.
-
-
-
-
-
-
-
-
-
-
Once you have checked the checkboxes for all areas you wish to import from the IMS package, selected options (if available), and selected a display option for the package contents you should click the 'Complete Import' button.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ENDDOCUMENT
+ } else { # Unknown cms format
+ $r->print(
+ ''
+ .&mt('Unsupported IMS format: [_1]',$cms)
+ .' '
+ );
+ # return();
+ }
+ }
+
+
+ # Start output: Step 1 and step 2
+
+ $r->print(
+ '');
+}
-sub display_three {
+sub display_two {
my ($r,$crs,$cdom,$uname,$udom,$areas,%cmsmap) = @_;
my $folder = $env{'form.folder'};
my $cms = $env{'form.source'};
@@ -545,7 +440,7 @@ sub display_three {
foreach my $area (@{$areas}) {
if (defined($env{"form.$area"}) && ($env{'form.'.$area} ne '')) {
- if ($cms eq 'angel' && $area eq 'doc') {
+ if ($cms eq 'angel5' && $area eq 'doc') {
foreach (@{$cmsmap{$cms}{$area}}) {
$importareas{$_} = 1;
}
@@ -562,16 +457,16 @@ sub display_three {
my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'prepare',\%includedres,\%includeditems);
if ($manifest_result eq 'ok') {
- foreach my $res (sort keys %resources) {
+ foreach my $res (sort(keys(%resources))) {
if ($importareas{$resources{$res}{type}}) {
$includedres{$res} = 1;
}
}
- foreach my $itm (sort keys %items) {
+ foreach my $itm (sort(keys(%items))) {
&Apache::imsprocessor::get_imports(\%includeditems,\%items,\%resources,\%importareas,$itm);
}
}
- foreach my $itm (sort keys %includeditems) {
+ foreach my $itm (sort(keys(%includeditems))) {
&Apache::imsprocessor::get_parents(\%includeditems,\%items,$itm);
}
@@ -609,7 +504,7 @@ sub display_three {
&Apache::imsprocessor::process_resinfo($cms,'DOCS',$tempdir,$destdir,\%items,\%resources,\@targets,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs,\@pages,\@sequences);
- my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$destdir,$timenow,\%importareas);
+ my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,\%resources,$tempdir,\@targets,\%urls,$crs,$cdom,$destdir,$timenow,\%importareas);
&Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems);
@@ -631,71 +526,54 @@ sub display_three {
my @imports = ();
if ($toplevel eq 'oldfolder') {
for (my $i=0; $i<@topurls; $i++) {
- my $url = &Apache::lonnet::unescape($topurls[$i]);
- my $name = &Apache::lonnet::unescape($topnames[$i]);
- push @imports, $name, $url;
+ my $url = &unescape($topurls[$i]);
+ my $name = &unescape($topnames[$i]);
+ push(@imports, [$name, $url]);
}
} elsif ($toplevel eq 'newfolder') {
- my $url = &Apache::lonnet::unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");
- my $name = &Apache::lonnet::unescape("$env{'form.foldername'}");
- push @imports, $name, $url;
+ my $url = &unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");
+ my $name = &unescape("$env{'form.foldername'}");
+ push(@imports, [$name, $url]);
}
my $errtext='';
my $fatal=0;
($errtext,$fatal)= &Apache::londocs::mapread($crs,$cdom,$folder.'.sequence');
- if ($#Apache::lonratedt::order<1) {
- $Apache::lonratedt::order[0]=1;
- $Apache::lonratedt::resources[1]='';
+ if ($#LONCAPA::map::order<1) {
+ $LONCAPA::map::order[0]=1;
+ $LONCAPA::map::resources[1]='';
}
my ($errtext,$fatal)=&Apache::londocs::group_import($crs,$cdom,$folder,'sequence','imsimport',@imports);
if ($fatal) {
- print STDERR "Fatal error during group_import\n";
+ &Apache::lonnet::logthis("Fatal error during group_import.");
}
}
if ($tempdir =~ m/^\/home\/httpd\/perl\/tmp\/$crs\/\d{10}/) {
system("rm -r -f $tempdir");
}
- $r->print(<
-