[LON-CAPA-cvs] cvs: loncom /publisher testbankimport.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 22 Sep 2008 01:53:33 -0000
raeburn Sun Sep 21 21:53:33 2008 EDT
Modified files:
/loncom/publisher testbankimport.pm
Log:
- Provide information about file type of uploaded testbank file, if format was not identified as plain text, RTF or HTML.
- Prevent ISE by allowing &file_error() to retrieve arguments passed to it.
Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.16 loncom/publisher/testbankimport.pm:1.17
--- loncom/publisher/testbankimport.pm:1.16 Tue Jul 8 03:17:46 2008
+++ loncom/publisher/testbankimport.pm Sun Sep 21 21:53:33 2008
@@ -1,5 +1,5 @@
# Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.16 2008/07/08 07:17:46 raeburn Exp $
+# $Id: testbankimport.pm,v 1.17 2008/09/22 01:53:33 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1163,8 +1163,8 @@
my $nextval = &mt('Next Page');
my $prevclick = 'javascript:backPage();';
my $nextclick = 'javascript:nextPage();';
- my $go = '';
- if ($page == 0) {
+ my $go = '';
+ if (($page == 0) || ($state eq 'badfile')) {
$go = 'NextPage';
$prevval = &mt('Exit Now');
$prevclick = 'javascript:location.href='."'$webpath';";
@@ -1195,7 +1195,7 @@
<td>
<input type="button" name="backpage" value="'.$prevval.'" onclick="'.$prevclick.'" />
</td>';
- if ($page < 4) {
+ if (($page < 4) && ($state ne 'badfile')) {
$output .= '
<td> </td>
<td>
@@ -1599,8 +1599,14 @@
}
sub file_error {
- my ($r,$uname,$fn,$current_page);
- $r->print("No data here");
+ my ($r,$uname,$fn,$current_page,$webpath,$res) = @_;
+ $r->print('<p><form name="display" method="post" action="/adm/testbank">'.&mt('The file you uploaded does not appear to be in the correct format.').
+ '</p><p>'.&mt('Extraction of questions is only possible for the following file types:').
+ '<ul><li>'.&mt('plain text').'</li><li>RTF</li><li>HTML</li></ul>'.
+ &mt('The file type identified for the file you uploaded is [_1].','<b>'.$res.'</b>').'</p>');
+ $r->print(&page_footer($env{'form.newdir'},$uname,$fn,$current_page,$webpath,undef,'badfile').
+ '</form>');
+ return;
}
sub parse_datafile {
@@ -1875,7 +1881,7 @@
$r->print(&Apache::lonupload::phasethree($r,$fn,$uname,$udom,'testbank'));
}
if ($badfile) {
- &file_error($r,$uname,$fn,$current_page);
+ &file_error($r,$uname,$fn,$current_page,$webpath,$res);
} else {
&display_zero ($r,$uname,$fn,$current_page,$webpath) if $page_name eq 'Welcome';
&display_one ($r,$uname,$fn,$current_page,$textref,$header) if $page_name eq 'Blocks';