--- loncom/publisher/testbankimport.pm 2005/11/08 17:58:35 1.7 +++ loncom/publisher/testbankimport.pm 2008/04/17 15:58:45 1.13 @@ -1,5 +1,5 @@ # Handler for parsing text upload problem descriptions into .problems -# $Id: testbankimport.pm,v 1.7 2005/11/08 17:58:35 albertel Exp $ +# $Id: testbankimport.pm,v 1.13 2008/04/17 15:58:45 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use HTML::Entities(); use Apache::lonlocal; use Apache::lonupload; use File::Basename(); +use LONCAPA(); # ---------------------------------------------------------------- Display Control sub display_control { @@ -347,6 +348,20 @@ sub jscript_three { if (exists($env{'form.go'}) ) { $source = $env{'form.go'}; } + + my %body_layout = ('rightmargin' => "0", + 'leftmargin' => "0", + 'marginwidth' => "0", + 'topmargin' => "0", + 'marginheight' => "0"); + + my $start_page = + &Apache::loncommon::start_page('Create Testbank directory',undef, + {'only_body' => 1, + 'add_entries' => \%body_layout, + 'js_ready' => 1,}); + my $end_page = + &Apache::loncommon::end_page({'js_ready' => 1,}); $$jsref = <<"END_OF_ONE"; function verify() { if ((document.forms.dataForm.newdir.value == '') || (!document.forms.dataForm.newdir.value)) { @@ -371,22 +386,22 @@ function createWin() { document.dataForm.newdir.value = ""; newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes") newWindow.document.open() - newWindow.document.write("Create Testbank directory\\n") - newWindow.document.write("\\n") + newWindow.document.write('$start_page') newWindow.document.write("[Author Header]\\n") newWindow.document.write("\\n") newWindow.document.write("\\n") newWindow.document.write("\\n") newWindow.document.write("\\n") newWindow.document.write("\\n") - newWindow.document.write("
  

Location: $fullpath

New Directory

  
\\n") - newWindow.document.write("Enter the name of the new directory where you will store the converted testbank questions

") + newWindow.document.write("Enter the name of the new directory where you will save the converted testbank questions

") newWindow.document.write("") newWindow.document.write("") newWindow.document.write("") newWindow.document.write("$fullpath") newWindow.document.write("") newWindow.document.write("
") + newWindow.document.write("") + newWindow.document.write('$end_page') newWindow.document.close() newWindow.focus() } @@ -455,7 +470,7 @@ Five steps are involved in the import pr $r->print(qq|
  • Provide information about the question format - i.e., question numbering style, and the number of blocks of questions of each question type.
  • Provide information about the questions in each block, including question type, start and end question numbers for each block, and foil labelling style and answer format where required.
  • -
  • Create a new directory where you will store the converted testbank questions.
  • +
  • Create a new directory where you will save the converted testbank questions.
  • Complete the import of questions to the selected pool.
  • @@ -1015,7 +1030,7 @@ END_OF_ONE    - Create a directory to store your testbank questions. + Create a directory to save your testbank questions. @@ -1025,7 +1040,7 @@ END_OF_ONE   -Please choose a destination LON-CAPA directory in which to store your uploaded questions.   +Please choose a destination LON-CAPA directory in which to save your uploaded questions.   @@ -1340,8 +1355,6 @@ END_OF_BLOCK - - END_OF_FAIL return; } @@ -1653,7 +1666,9 @@ sub create_ess { + $answertxt + |; } elsif ($qtype eq "TF") { @@ -1699,7 +1714,6 @@ sub handler { my $javascript = ''; my $page_name = ''; my $current_page = ''; - my $loadentries = ''; my $qcount = ''; # # phase two: re-attach user @@ -1725,7 +1739,7 @@ sub handler { $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'}. @@ -1741,7 +1755,6 @@ sub handler { my $dirpath = '/home/'.$uname.'/public_html'; my @text = (); - my $loadentries = ''; if ($env{'form.phase'} eq 'three') { if (-e "$dirpath$fn") { open(TESTBANK,"<$dirpath$fn"); @@ -1756,31 +1769,35 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + my %loadentries; if ($env{'form.phase'} eq 'three') { $current_page = &display_control(); my @PAGES = ('Welcome','Blocks','Format','Target','Confirmation'); $page_name = $PAGES[$current_page]; if ($page_name eq 'Blocks') { - $loadentries = 'onLoad= "setElements()"'; + $loadentries{'onload'} = "setElements()"; &jscript_one(\$javascript); } elsif ($page_name eq 'Format') { $qcount = question_count($env{'form.qnumformat'},\@text); &jscript_two(\$javascript,$qcount); } elsif ($page_name eq 'Target') { if ($env{'form.go'} eq "PreviousPage") { - $loadentries = 'onLoad = "setElements()"'; + $loadentries{'onload'} = "setElements()"; } &jscript_three($fullpath,\$javascript); } elsif ($page_name eq 'Confirmation') { &jscript_four(\$javascript,$fullpath); } - } + } + + $javascript = "\n"; + + $r->print(&Apache::loncommon::start_page('Upload testbank questions to Construction Space', + $javascript, + {'add_entries' => \%loadentries})); - $r->print("LON-CAPA Construction Space\n"); - - $r->print(&Apache::loncommon::bodytag('Upload testbank questions to Construction Space',undef,$loadentries)); - if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { $r->print('

    '.&mt('Co-Author').': '.$uname. &mt(' at ').$udom.'

    '); @@ -1805,7 +1822,7 @@ sub handler { } else { &Apache::lonupload::phaseone($r,$fn,$uname,$udom,'testbank'); } - $r->print(''); + $r->print(&Apache::loncommon::end_page()); return OK; } 1;