--- loncom/publisher/lonupload.pm 2003/11/08 11:13:50 1.24 +++ loncom/publisher/lonupload.pm 2005/04/07 06:56:27 1.29 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Handler to upload files into construction space # -# $Id: lonupload.pm,v 1.24 2003/11/08 11:13:50 albertel Exp $ +# $Id: lonupload.pm,v 1.29 2005/04/07 06:56:27 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::Log(); use Apache::lonnet; use HTML::Entities(); use Apache::lonlocal; +use Apache::lonnet; my $DEBUG=0; @@ -62,30 +63,36 @@ sub Debug { sub upfile_store { my $r=shift; - my $fname=$ENV{'form.upfile.filename'}; + my $fname=$env{'form.upfile.filename'}; $fname=~s/\W//g; - chomp($ENV{'form.upfile'}); + chomp($env{'form.upfile'}); - my $datatoken=$ENV{'user.name'}.'_'.$ENV{'user.domain'}. + my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}. '_upload_'.$fname.'_'.time.'_'.$$; { my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons'). '/tmp/'.$datatoken.'.tmp'); - print $fh $ENV{'form.upfile'}; + print $fh $env{'form.upfile'}; } return $datatoken; } sub phaseone { - my ($r,$fn,$uname,$udom)=@_; - $ENV{'form.upfile.filename'}=~s/\\/\//g; - $ENV{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/; - if ($ENV{'form.upfile.filename'}) { + my ($r,$fn,$uname,$udom,$mode)=@_; + my $action = '/adm/upload'; + if ($mode eq 'testbank') { + $action = '/adm/testbank'; + } elsif ($mode eq 'imsimport') { + $action = '/adm/imsimport'; + } + $env{'form.upfile.filename'}=~s/\\/\//g; + $env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/; + if ($env{'form.upfile.filename'}) { $fn=~s/\/[^\/]+$//; $fn=~s/([^\/])$/$1\//; - $fn.=$ENV{'form.upfile.filename'}; + $fn.=$env{'form.upfile.filename'}; $fn=~s/^\///; $fn=~s/(\/)+/\//g; @@ -94,16 +101,31 @@ sub phaseone { &Debug($r, "Filename for upload: $fn"); if (($fn) && ($fn!~/\/$/)) { - $r->print('
'); + "/priv/$uname/". + '\\n") + newWindow.document.write(" | Importing Testbank questions into LON-CAPA") + newWindow.document.write("Four requirements must be met to ensure that you will succeed in building LON-CAPA problem files using your plain text file containing testbank questions.") + newWindow.document.write("
|