--- loncom/publisher/testbankimport.pm 2012/10/29 17:38:55 1.35 +++ loncom/publisher/testbankimport.pm 2014/02/11 19:11:18 1.44 @@ -1,5 +1,5 @@ # Handler for parsing text upload problem descriptions into .problems -# $Id: testbankimport.pm,v 1.35 2012/10/29 17:38:55 raeburn Exp $ +# $Id: testbankimport.pm,v 1.44 2014/02/11 19:11:18 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -89,7 +89,7 @@ function createWin() { newWindow.document.write("") newWindow.document.write("") newWindow.document.write("$webpath") - newWindow.document.write("") + newWindow.document.write("") newWindow.document.write('$end_page') newWindow.document.close() newWindow.focus() @@ -289,18 +289,20 @@ function colSet(caller) { else { if ((poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "MC") || (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "MA") || (poolForm.elements[caller*5+3].options[poolForm.elements[caller*5+3].selectedIndex].value == "Ord")) { poolForm.elements[caller*5+4].options[0] = new Option("Select","-1",true,true) - poolForm.elements[caller*5+4].options[1] = new Option("a.","lcperiod",false,false) - poolForm.elements[caller*5+4].options[2] = new Option("A.","ucperiod",false,false) - poolForm.elements[caller*5+4].options[3] = new Option("(a)","lcparen",false,false) - poolForm.elements[caller*5+4].options[4] = new Option("(A)","ucparen",false,false) - poolForm.elements[caller*5+4].options[5] = new Option("a)","lconeparen",false,false) - poolForm.elements[caller*5+4].options[6] = new Option("A)","uconeparen",false,false) - poolForm.elements[caller*5+4].options[7] = new Option("a.)","lcdotparen",false,false) - poolForm.elements[caller*5+4].options[8] = new Option("A.)","ucdotparen",false,false) - poolForm.elements[caller*5+4].options[9] = new Option("(i)","romparen",false,false) - poolForm.elements[caller*5+4].options[10] = new Option("i)","romoneparen",false,false) - poolForm.elements[caller*5+4].options[11] = new Option("i.)","romdotparen",false,false) - poolForm.elements[caller*5+4].options[12] = new Option("i.","romperiod",false,false) + poolForm.elements[caller*5+4].options[1] = new Option("a ","lcspace",false,false) + poolForm.elements[caller*5+4].options[2] = new Option("A ","ucspace",false,false) + poolForm.elements[caller*5+4].options[3] = new Option("a.","lcperiod",false,false) + poolForm.elements[caller*5+4].options[4] = new Option("A.","ucperiod",false,false) + poolForm.elements[caller*5+4].options[5] = new Option("(a)","lcparen",false,false) + poolForm.elements[caller*5+4].options[6] = new Option("(A)","ucparen",false,false) + poolForm.elements[caller*5+4].options[7] = new Option("a)","lconeparen",false,false) + poolForm.elements[caller*5+4].options[8] = new Option("A)","uconeparen",false,false) + poolForm.elements[caller*5+4].options[9] = new Option("a.)","lcdotparen",false,false) + poolForm.elements[caller*5+4].options[10] = new Option("A.)","ucdotparen",false,false) + poolForm.elements[caller*5+4].options[11] = new Option("(i)","romparen",false,false) + poolForm.elements[caller*5+4].options[12] = new Option("i)","romoneparen",false,false) + poolForm.elements[caller*5+4].options[13] = new Option("i.)","romdotparen",false,false) + poolForm.elements[caller*5+4].options[14] = new Option("i.","romperiod",false,false) poolForm.elements[caller*5+4].selectedIndex = 0 } else { @@ -444,7 +446,7 @@ function verify() { if ($numitems > 0) { my $maxnum = $numitems - 1; my %lt = &Apache::lonlocal::texthash( - fnmb => 'File names must be unique', + fnmb => 'Filenames must be unique', isum => 'is used more than once', ); $$jsref .= qq| @@ -487,9 +489,9 @@ sub display_zero { my ($r,$fn,$page,$webpath) = @_; my $go_default = 'NextPage'; if ($fn eq '') { - $r->print(''.&mt('Incomplete file upload').' '.&mt('Return to the [_1]construction space menu[_2] to upload a file','','')); + $r->print(''.&mt('Incomplete file upload').' '.&mt('Return to the [_1]Authoring Space menu[_2] to upload a file','','')); } - $r->print(&mt('The Testbank Upload utility can be used by LON-CAPA authors to generate LON-CAPA problem files from a testbank file of questions/answers.').'
'. + $r->print(&mt('The [_1]Testbank Upload[_2] utility can be used by LON-CAPA authors to generate LON-CAPA problem files from a testbank file of questions/answers.','','').'
'. &mt('The following question types can be converted:').' '. &page_footer($env{'form.newdir'},$fn,$page).' @@ -681,7 +683,7 @@ sub display_three { my %lt = &Apache::lonlocal::texthash ( crt => 'Create?', typ => 'Type', - fnam => 'File Name', + fnam => 'Filename', ques => 'Question', answ => 'Answer', chka => 'check all', @@ -774,7 +776,12 @@ sub display_three { ''.$showqn.'

'."\n"); } else { my $foiltag = ''; - if ($foilformats[$i] eq "lcperiod") { + if ($foilformats[$i] eq "lcspace") { + $foiltag = $alphabet->[$k-1].' '; + } elsif ($foilformats[$i] eq "ucspace") { + $foiltag = $alphabet->[$k-1].' '; + $foiltag =~ tr/a-z/A-Z/; + } elsif ($foilformats[$i] eq "lcperiod") { $foiltag = $alphabet->[$k-1].'.'; } elsif ($foilformats[$i] eq "lcparen") { $foiltag = '('.$alphabet->[$k-1].')'; @@ -924,7 +931,7 @@ sub final_display { $items->[$k] =~ tr/A-Z/a-z/; $items->[$k] =~ s/<\/?[^>]+>//g; $items->[$k] =~ s/\W//g; - if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "lconeparen" || $foilformats[$i] eq "lcdotparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod" || $foilformats[$i] eq "uconeparen" || $foilformats[$i] eq "ucdotparen") { + if ($foilformats[$i] eq "lcspace" || $foilformats[$i] eq "ucspace" || $foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "lconeparen" || $foilformats[$i] eq "lcdotparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod" || $foilformats[$i] eq "uconeparen" || $foilformats[$i] eq "ucdotparen") { for (my $j=0; $j<@{$alphabet}; $j++) { if ($alphabet->[$j] eq $items->[$k]) { push @{$answers{$qnum}}, $j; @@ -957,7 +964,7 @@ sub final_display { } else { $correct =~s/\W//g; } - if ($foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") { + if ($foilformats[$i] eq "lcspace" || $foilformats[$i] eq "ucspace" || $foilformats[$i] eq "lcperiod" || $foilformats[$i] eq "lcparen" || $foilformats[$i] eq "ucparen" || $foilformats[$i] eq "ucperiod") { if (($qtype[$i] eq "Ord") && (@tied > 0)) { my @ties; foreach my $tie (@tied) { @@ -1275,7 +1282,11 @@ sub file_split { if (${$numsref}[$i] > 0) { if ((${$qtyperef}[$i] eq "MC") || (${$qtyperef}[$i] eq "MA") || (${$qtyperef}[$i] eq "Ord")) { my $splitstr = ''; - if (${$foilsref}[$i] eq "lcperiod") { + if (${$foilsref}[$i] eq "lcspace") { + $splitstr = '[a-z]\s'; + } elsif (${$foilsref}[$i] eq "ucspace") { + $splitstr = '[A-Z]\s'; + } elsif (${$foilsref}[$i] eq "lcperiod") { $splitstr = '[a-z]\.'; } elsif (${$foilsref}[$i] eq "lcparen") { $splitstr = '\([a-z]\)'; @@ -1578,6 +1589,7 @@ sub create_ess { if (open(PROB,">$destdir$libfile")) { print PROB $output; close(PROB); + $result = 'ok'; } else { $result = 'failed'; } @@ -1605,7 +1617,10 @@ sub file_error { my ($r,$fn,$current_page,$webpath,$res) = @_; $r->print('

'.&mt('The file you uploaded does not appear to be in the correct format.'). '

'.&mt('Extraction of questions is only possible for the following file types:'). - '

'. + ''. &mt('The file type identified for the file you uploaded is [_1].',''.$res.'').'

'); $r->print(&page_footer($env{'form.newdir'},$fn,$current_page,$webpath,undef,'badfile'). ''); @@ -1775,7 +1790,7 @@ sub print_header { my ($uname,$udom,$javascript,$loadentries,$title,$current_page,$pagesref, $namesref) = @_; my $brcrum = [{'href' => &Apache::loncommon::authorspace("/priv/$udom/$uname/"), - 'text' => 'Construction Space'}]; + 'text' => 'Authoring Space'}]; if ($env{'form.phase'} eq 'three') { if (ref($pagesref) eq 'ARRAY') { for (my $i=0; $i<$current_page; $i++) { @@ -1837,7 +1852,7 @@ sub handler { my $page_name = ''; my $current_page = ''; my $qcount = ''; - my $title = 'Upload testbank questions to Construction Space'; + my $title = 'Upload testbank questions to Authoring Space'; # ----------------------------------------------------------- Start page output &Apache::loncommon::content_type($r,'text/html'); @@ -1850,7 +1865,7 @@ sub handler { if ($env{'form.phase'} eq 'three') { $current_page = &display_control(); @pages = ('Welcome','Blocks','Format','Target','Confirmation'); - %names = ( + %names = &Apache::lonlocal::texthash( Welcome => 'Testbank Format', Blocks => 'Classification', Format => 'Selection', @@ -1946,7 +1961,7 @@ sub handler { &page_footer('',$fn).''); } } else { - &Apache::lonupload::phaseone($r,$fn,'testbank'); + &Apache::lonupload::phaseone($r,$fn,'testbank',$uname,$udom); } $r->print(&Apache::loncommon::end_page()); return OK;