--- loncom/imspackages/imsimportdocs.pm 2004/03/02 15:45:06 1.1 +++ loncom/imspackages/imsimportdocs.pm 2004/08/05 23:21:49 1.7 @@ -1,10 +1,36 @@ +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# LON-CAPA is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LON-CAPA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LON-CAPA; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# /home/httpd/html/adm/gpl.txt +# +# http://www.lon-capa.org/ +# + package Apache::imsimportdocs; +use Apache::Constants qw(:common :http :methods); use Apache::lonnet; +use Apache::londocs; use Apache::loncommon; use Apache::lonlocal; use Apache::imsprocessor; use LONCAPA::Configuration; +use strict; sub jscript_one { my $javascript = shift; @@ -41,8 +67,8 @@ function setOptions(caller,itemnum) { 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[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) } else { if (caller == "users") { @@ -94,6 +120,16 @@ function nextPage(caller) { #; } +sub jscript_three { + my $javascript = shift; + $$javascript = qq| +function init(tf) { + setTimeout("self.close()",3000) + tf.submit(); +} + |; +} + sub handler { my $r = shift; my $javascript = ''; @@ -101,29 +137,10 @@ sub handler { $r->send_http_header; return OK if $r->header_only; - my @areas = ("doc","extlink","announce","staff","board","quiz","survey","pool","users"); + my @areas = (); my %cmsmap = (); - %{$cmsmap{bb5}} = ( - announce => 'resource/x-bb-announcement', - board => 'resource/x-bb-discussionboard', - doc => 'resource/x-bb-document', - extlink => 'resource/x-bb-externallink', - pool => 'assessment/x-bb-pool', - quiz => 'assessment/x-bb-quiz', - staff => 'resource/x-bb-staffinfo', - survey => 'assessment/x-bb-survey', - users => 'course/x-bb-user', - ); - - %{$cmsmap{angel}} = ( - board => 'BOARD', - extlink => 'LINK', - msg => 'MESSAGE', - quiz => 'QUIZ', - survey => 'FORM', - ); - - @{$cmsmap{angel}{doc}} = ('FILE','PAGE'); + my %areaname = (); + &Apache::imsprocessor::ims_config(\@areas,\%cmsmap,\%areaname); # get course data my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; @@ -153,6 +170,8 @@ sub handler { &jscript_one(\$javascript); } elsif ($ENV{'form.phase'} eq 'two') { &jscript_two(\$javascript); + } elsif ($ENV{'form.phase'} eq 'three') { + &jscript_three(\$javascript); } # print screen @@ -172,38 +191,17 @@ ENDHEAD if ($ENV{'form.phase'} eq 'one') { &display_one($r); } elsif ($ENV{'form.phase'} eq 'two') { - &display_two($r,$coursenum,\@areas,%cmsmap); + &display_two($r,$coursenum,\@areas,\%areaname,%cmsmap); } elsif ($ENV{'form.phase'} eq 'three') { - &display_three($r,$coursenum,$coursedom,$coursehome,\@areas,%cmsmap); + &display_three($r,$coursenum,$coursedom,$coursehome,$uname,$udom,\@areas,%cmsmap); } $r->print(""); + return OK; } -sub uploadzip { - my $tempdir = shift; - my $fname=$ENV{'form.uploadname.filename'}; -# Replace Windows backslashes by forward slashes - $fname=~s/\\/\//g; -# Get rid of everything but the actual filename - $fname=~s/^.*\/([^\/]+)$/$1/; -# Replace spaces by underscores - $fname=~s/\s+/\_/g; -# Replace all other weird characters by nothing - $fname=~s/[^\w\.\-]//g; -# See if there is anything left - unless ($fname) { return 'error: no uploaded file'; } - -# Save the file - chomp($ENV{'form.uploadname'}); - open(my $fh,'>'.$tempdir.'/'.$fname); - print $fh $ENV{'form.uploadname'}; - close($fh); - return $fname; -} sub display_one { - my $r = shift; - my $timestamp = time; + my ($r) = @_; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']); $r->print(<