'.&mt('Or [_1]continue[_2] the testbank import without these files','','').'
';
+ }
+ }
+ }
+ if (($mode ne 'imsimport') && ($mode ne 'testbank')) {
+ $result .= ' '.
+ &mt('View file').'';
+ }
+ } else {
+ $result .= &mt('Failed to copy: [_1].',$!);
+ }
+ if ($mode ne 'imsimport' && $mode ne 'testbank') {
+ $result .= ' '.
+ &mt('Back to Directory').' ';
}
- return $returnflag;
+ return ($result,$returnflag);
+}
+
+sub phasethree {
+ my ($r,$fn,$uname,$udom,$mode) = @_;
+ my $result;
+ my $dir_root = '/home/'.$uname.'/public_html';
+ my $url_root = '/priv/'.$uname;
+ my $base = &File::Basename::basename($fn);
+ my $path = &File::Basename::dirname($fn);
+ $result = &Apache::loncommon::upload_embedded($mode,$path,$uname,$udom,
+ $dir_root,$url_root);
+ if ($mode ne 'imsimport' && $mode ne 'testbank') {
+ $result = ' '.
+ &mt('View main file').''.
+ ' '.
+ &mt('Back to Directory').' ';
+ }
+ return $result;
}
# ---------------------------------------------------------------- Main Handler
@@ -250,69 +296,49 @@ sub handler {
#
# phase two: re-attach user
#
- if ($ENV{'form.uploaduname'}) {
- $ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'.
- $ENV{'form.filename'};
+ if ($env{'form.uploaduname'}) {
+ $env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
+ $env{'form.filename'};
}
- unless ($ENV{'form.phase'} eq 'two') {
+ unless ($env{'form.phase'} eq 'two') {
$javascript = qq|
function verifyForm() {
- var mode = document.forms[0].filetype.options[document.forms[0].filetype.selectedIndex].value
+ var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value
if (mode == "testbank") {
- document.forms[0].action = "/adm/testbank";
+ document.fileupload.action = "/adm/testbank";
}
if (mode == "imsimport") {
- document.forms[0].action = "/adm/imsimport";
+ document.fileupload.action = "/adm/imsimport";
}
if (mode == "standard") {
- document.forms[0].action = "/adm/upload";
+ document.fileupload.action = "/adm/upload";
}
- document.forms[0].submit();
+ document.fileupload.submit();
}
-
-function testbankWin() {
- newWindow = window.open("","testbankinfo","HEIGHT=400,WIDTH=750,scrollbars=yes")
- newWindow.document.open()
- newWindow.document.write("'Importing a Testbank file into LON-CAPA\\n")
- newWindow.document.write("\\n")
- newWindow.document.write("\\n")
- newWindow.document.write("
\\n")
- newWindow.document.write("
\\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("
The questions and answers you upload must be in plain text format. Any header lines should occur before the text containing the questions and answers.
")
- newWindow.document.write("
All questions must occur before any of the answers. Each question should be numbered sequentially using a number followed immediately by a space, a period, or enclosed in parentheses, i.e., 1 , 1., (1), 1), or (1 .
")
- newWindow.document.write("
One or more correct answers should be provided for all questions (although blank answers may be provided for essay questions). Answers should be numbered sequentially, using the same scheme as used for the questions, and must occur after all the questions.")
- newWindow.document.write("
Multiple choice and multiple answer correct questions should consist of (i) the question number followed by (ii) a question stem beginning on the same line and (iii) two or more foils, with each foil beginning on a new line and prefixed by a unique letter, or Roman numeral, listed in alphabetic or numeric order, beginning at a (alphabetic) or i (Roman numeral), followed by a period, or enclosed in parentheses, i.e., a., (a), i., or (i) .
")
- newWindow.document.write("
If fill-in-the-blank or multiple answer questions have more than one correct answer, each answer should appear in a comma-, tab-, space-, or new line-delimited list.
")
- newWindow.document.write("
\\n")
- newWindow.document.write("
")
- newWindow.document.close()
- newWindow.focus()
-}
-|;
+ |;
}
($uname,$udom)=
- &Apache::loncacc::constructaccess($ENV{'form.filename'},
+ &Apache::loncacc::constructaccess($env{'form.filename'},
$r->dir_config('lonDefDomain'));
+
unless (($uname) && ($udom)) {
$r->log_reason($uname.' at '.$udom.
- ' trying to publish file '.$ENV{'form.filename'}.
+ ' trying to publish file '.$env{'form.filename'}.
' - not authorized',
$r->filename);
return HTTP_NOT_ACCEPTABLE;
}
my $fn;
- if ($ENV{'form.filename'}) {
- $fn=$ENV{'form.filename'};
+ if ($env{'form.filename'}) {
+ $fn=$env{'form.filename'};
$fn=~s/^http\:\/\/[^\/]+\///;
$fn=~s/^\///;
- $fn=~s/(\~|priv\/)(\w+)//;
+ $fn=~s{(~|priv/)($LONCAPA::username_re)}{};
$fn=~s/\/+/\//g;
} else {
- $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}.
+ $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
' unspecified filename for upload', $r->filename);
return HTTP_NOT_FOUND;
}
@@ -323,22 +349,28 @@ function testbankWin() {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- $r->print("LON-CAPA Construction Space\n");
+ $javascript = "\n";
- $r->print(&Apache::loncommon::bodytag('Upload file to Construction Space'));
+ $r->print(&Apache::loncommon::start_page('Upload file to Construction Space',
+ $javascript));
- if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
- $r->print('
'.&mt('Co-Author').': '.$uname.
- &mt(' at ').$udom.'
');
+ if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
+ $r->print('
'.&mt('Co-Author').': '.$uname.
+ &mt(' at ').$udom.'