--- loncom/publisher/testbankimport.pm 2009/05/14 14:24:18 1.24 +++ loncom/publisher/testbankimport.pm 2011/01/31 17:49:13 1.29 @@ -1,5 +1,5 @@ # Handler for parsing text upload problem descriptions into .problems -# $Id: testbankimport.pm,v 1.24 2009/05/14 14:24:18 bisitz Exp $ +# $Id: testbankimport.pm,v 1.29 2011/01/31 17:49:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -88,6 +88,7 @@ function createWin() { newWindow.document.write("") newWindow.document.write("") newWindow.document.write("") + newWindow.document.write("") newWindow.document.write("$webpath") newWindow.document.write("") newWindow.document.write('$end_page') @@ -508,7 +509,7 @@ sub display_zero {
  • '.&mt('Review the identified questions, choose which to convert, and (optionally) override the default filename to be used for each problem file.').'
  • '.&mt('Complete the import of questions.').'
  • '. - &topic_bar(1,&mt('Optional: create a sub-directory in which the testbank questions will be saved')). + &Apache::lonhtmlcommon::topic_bar(1,&mt('Optional: create a sub-directory in which the testbank questions will be saved')). &mt('By default, LON-CAPA problems generated from the testbank file will be stored in the current directory.').' '.&mt('To store them in a new sub-directory:'). ' '. &page_footer($env{'form.newdir'},$uname,$fn,$page,$webpath).' @@ -533,7 +534,7 @@ sub display_one { $r->print('

    '.&mt('Identification of blocks of questions').'

    '."\n". ''."\n". &show_uploaded_data($textref,$header)."\n". - &topic_bar(2,$topics{2}).'

    '. + &Apache::lonhtmlcommon::topic_bar(2,$topics{2}).'

    '. &mt('A number in the specified format should appear at the start of each question.').'
    '. &mt('For multiple choice questions, the question number must begin the line that contains the question text; foils (starting (a), (i) etc.) should occur on subsequent lines.').'
    '."\n". &mt('Correct answers should be numbered in the same way as the questions and should appear after all the questions (including question text and possible foils for all questions).').'
    '."\n". @@ -556,7 +557,7 @@ sub display_one { 3. '. '

    '. - &topic_bar(3,$topics{3}).'

    '. + &Apache::lonhtmlcommon::topic_bar(3,$topics{3}).'

    '. &mt('For example, you would enter 6 if your testbank file contained the following sequence of questions:').'

    '. &mt('10 multiple choice questions').'
    '. &mt('5 essay questions').'
    '. @@ -608,7 +609,7 @@ sub display_two { &mt('You also indicated that the [quant,_1,question] can be divided into [quant,_2,block] of questions of a particular question type.',$qcount,$blocks).'

    '. &mt('Provide additional information below, about the types of questions you have uploaded, and, if applicable, the format of answers and "foils" for specific types of questions.').'

    '. &show_uploaded_data($textref,$header). - &topic_bar(4,$steptitle).'

    '. + &Apache::lonhtmlcommon::topic_bar(4,$steptitle).'

    '. &mt('For each of the [_1] question blocks, specify the question numbers of the first and last questions in the block (e.g., 1 and 10), and the question type of the questions in the block.',''.$blocks.'').' '. &mt('If required, provide additional information about foil formats and answer formats for the question types you select.').'

    '. &Apache::loncommon::start_data_table(). @@ -721,7 +722,7 @@ sub display_three { $r->print('

    '.&mt('Review and selection of problems to convert').'

    '."\n". ''."\n". &mt('Based on your previous responses your data have been split into a total of [quant,_1,question].',$numitems). - &topic_bar(5,&mt('Choose which problems to convert and names to use for individual problem files'))); + &Apache::lonhtmlcommon::topic_bar(5,&mt('Choose which problems to convert and names to use for individual problem files'))); if ($showheader) { $r->print($showheader.'
    '); } @@ -1032,7 +1033,7 @@ sub final_display { for (my $i=0; $i<$numitems; $i++) { $r->print(''."\n"); } - $r->print(&topic_bar(6,&mt('Result of conversion of testbank questions to LON-CAPA problems'))); + $r->print(&Apache::lonhtmlcommon::topic_bar(6,&mt('Result of conversion of testbank questions to LON-CAPA problems'))); my $destdir = $dirpath; if ($destdir ne '' && $subdir ne '') { $subdir .= '/'; @@ -1769,28 +1770,43 @@ sub build_image_url { } sub print_header { - my ($uname,$udom,$javascript,$loadentries,$title) = @_; + my ($uname,$udom,$javascript,$loadentries,$title,$current_page,$pagesref, + $namesref) = @_; + my $brcrum = [{'href' => &Apache::loncommon::authorspace(), + 'text' => 'Construction Space'}]; + if ($env{'form.phase'} eq 'three') { + if (ref($pagesref) eq 'ARRAY') { + for (my $i=0; $i<$current_page; $i++) { + my $goback = 1 + $i - $current_page; + if (ref($namesref) eq 'HASH') { + if ($namesref->{$pagesref->[$i]} ne '') { + if (ref($brcrum) eq 'ARRAY') { + my $text = $namesref->{$pagesref->[$i]}; + my $href; + if ($goback == -1) { + $href = 'javascript:backPage();'; + } else { + $href = 'javascript:history.go('.$goback.')'; + } + push(@{$brcrum}, {'href' => $href, + 'text' => $text}); + } + } + } + } + } + } my $output = &Apache::loncommon::start_page($title,$javascript, - {'add_entries' => $loadentries}); + {'bread_crumbs' => $brcrum, + 'add_entries' => $loadentries}); if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { - $output .= '

    ' + $output .= '

    ' .&mt('Co-Author [_1]',$uname.':'.$udom) .'

    '; } return $output; } -sub topic_bar { - my ($imgnum,$title) = @_; - my $output = ' -
    - '.&mt('Step [_1]',$imgnum).
-              '  '.$title.' -
    -'; - return $output; -} - # ---------------------------------------------------------------- Main Handler sub handler { my $r=shift; @@ -1836,11 +1852,17 @@ sub handler { my $webpath = '/priv/'.$uname.$pathname; my $urlpath = '/~'.$uname.$pathname; my $dirpath = '/home/'.$uname.'/public_html'.$pathname; - my ($res,$subdir,$badfile,$textref,$header,$css,$js,%loadentries); + my ($res,$subdir,$badfile,$textref,$header,$css,$js,%loadentries,@pages,%names); if ($env{'form.phase'} eq 'three') { $current_page = &display_control(); - my @pages = ('Welcome','Blocks','Format','Target','Confirmation'); + @pages = ('Welcome','Blocks','Format','Target','Confirmation'); + %names = ( + Welcome => 'Testbank Format', + Blocks => 'Classification', + Format => 'Selection', + Target => 'Result' + ); $page_name = $pages[$current_page]; if ($env{'form.timestamp'} eq '') { $env{'form.timestamp'} = time; @@ -1883,15 +1905,33 @@ sub handler { } } - $r->print(&print_header($uname,$udom,$javascript,\%loadentries,$title)); + $r->print(&print_header($uname,$udom,$javascript,\%loadentries,$title, + $current_page,\@pages,\%names)); - if ($env{'form.phase'} eq 'three') { - if ($env{'form.action'} eq 'upload_embedded') { - $r->print(&Apache::lonupload::phasethree($r,$fn,$uname,$udom,'testbank')); + if (($env{'form.phase'} eq 'four') || ($env{'form.phase'} eq 'three')) { + if ($env{'form.phase'} eq 'four') { + $r->print(&Apache::lonupload::phasefour($r,$fn,$uname,$udom,'testbank')); + my $current_page = 0; + my $js; + &jscript_zero($webpath,\$js); + $js = ''; + $r->print($js); + &display_zero($r,$uname,$fn,$current_page,$webpath); + } elsif ($env{'form.phase'} eq 'three') { + if ($env{'form.action'} eq 'upload_embedded') { + my ($result,$flag) = + &Apache::lonupload::phasethree($r,$fn,$uname,$udom,'testbank'); + $r->print($result); + if ($flag eq 'modify_orightml') { + undef($page_name); + $r->print(''. + &page_footer('',$uname,$fn).''); + } + } } if ($badfile) { &file_error($r,$uname,$fn,$current_page,$webpath,$res); - } else { + } 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'; &display_two ($r,$uname,$fn,$current_page,$textref,$header,$qcount) if $page_name eq 'Format';