--- loncom/publisher/testbankimport.pm 2013/10/10 00:46:50 1.43 +++ loncom/publisher/testbankimport.pm 2023/07/23 01:09:04 1.46 @@ -1,5 +1,5 @@ # Handler for parsing text upload problem descriptions into .problems -# $Id: testbankimport.pm,v 1.43 2013/10/10 00:46:50 raeburn Exp $ +# $Id: testbankimport.pm,v 1.46 2023/07/23 01:09:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -579,7 +579,7 @@ sub display_two { my $blocks = $env{'form.blocks'}; my $qnumformat = $env{'form.qnumformat'}; my @types = ("MC","MA","TF","Ess","FIB","Ord"); - my %typenames = ( + my %typenames = &Apache::lonlocal::texthash( MC => "Multiple Choice", TF => "True/False", MA => "Multiple Answer", @@ -1508,7 +1508,7 @@ sub create_mcq { if (-e $destdir.$libfile) { $result = 'exists'; } else { - if (open(PROB,">$destdir$libfile")) { + if (open(PROB,">",$destdir.$libfile)) { print PROB $output; close(PROB); $result = 'ok'; @@ -1586,7 +1586,7 @@ sub create_ess { if (-e $destdir.$libfile) { $result = 'exists'; } else { - if (open(PROB,">$destdir$libfile")) { + if (open(PROB,">",$destdir.$libfile)) { print PROB $output; close(PROB); $result = 'ok'; @@ -1617,7 +1617,10 @@ sub file_error { my ($r,$fn,$current_page,$webpath,$res) = @_; $r->print('
'); @@ -1633,7 +1636,7 @@ sub parse_datafile { $res = $mm->checktype_filename($dirpath.$filename); if ($env{'form.phase'} eq 'three') { if ($res eq 'text/plain') { - open(TESTBANK,"<$dirpath$filename"); + open(TESTBANK,"<",$dirpath.$filename); @{$text} =' - .&mt('Co-Author [_1]',$uname.':'.$udom) - .'
'; + unless ($crsauthor) { + if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { + $output .= '' + .&mt('Co-Author [_1]',$uname.':'.$udom) + .'
'; + } } return $output; } @@ -1849,7 +1854,19 @@ sub handler { my $page_name = ''; my $current_page = ''; my $qcount = ''; + my $crsauthor; my $title = 'Upload testbank questions to Authoring Space'; + my $crumbtext = 'Authoring Space'; + my $crumbhref = &Apache::loncommon::authorspace($fn); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($crumbhref eq "/priv/$cdom/$cnum/") { + $title = 'Upload testbank questions to Course Authoring Space'; + $crumbtext = 'Course Authoring Space'; + $crsauthor = 1; + } + } # ----------------------------------------------------------- Start page output &Apache::loncommon::content_type($r,'text/html'); @@ -1862,7 +1879,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', @@ -1911,7 +1928,8 @@ sub handler { } $r->print(&print_header($uname,$udom,$javascript,\%loadentries,$title, - $current_page,\@pages,\%names)); + $crumbtext,$crumbhref,$crsauthor,$current_page, + \@pages,\%names)); if (($env{'form.phase'} eq 'four') || ($env{'form.phase'} eq 'three')) { if ($env{'form.phase'} eq 'four') {