version 1.37, 2012/12/16 20:06:44
|
version 1.46, 2023/07/23 01:09:04
|
Line 89 function createWin() {
|
Line 89 function createWin() {
|
newWindow.document.write("<input type='hidden' name='callingmode' value='testbank' />") |
newWindow.document.write("<input type='hidden' name='callingmode' value='testbank' />") |
newWindow.document.write("<input type='hidden' name='inhibitmenu' value='yes' />") |
newWindow.document.write("<input type='hidden' name='inhibitmenu' value='yes' />") |
newWindow.document.write("$webpath<input type='text' name='newfilename' value='' />") |
newWindow.document.write("$webpath<input type='text' name='newfilename' value='' />") |
newWindow.document.write("<input type='button' value='$lt{'go'}' onClick='document.fileaction.submit();' /></form>") |
newWindow.document.write("<input type='button' value='$lt{'go'}' onclick='document.fileaction.submit();' /></form>") |
newWindow.document.write('$end_page') |
newWindow.document.write('$end_page') |
newWindow.document.close() |
newWindow.document.close() |
newWindow.focus() |
newWindow.focus() |
Line 289 function colSet(caller) {
|
Line 289 function colSet(caller) {
|
else { |
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")) { |
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[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[1] = new Option("a ","lcspace",false,false) |
poolForm.elements[caller*5+4].options[2] = new Option("A.","ucperiod",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)","lcparen",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)","ucparen",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)","lconeparen",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)","uconeparen",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.)","lcdotparen",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.)","ucdotparen",false,false) |
poolForm.elements[caller*5+4].options[8] = new Option("A)","uconeparen",false,false) |
poolForm.elements[caller*5+4].options[9] = new Option("(i)","romparen",false,false) |
poolForm.elements[caller*5+4].options[9] = new Option("a.)","lcdotparen",false,false) |
poolForm.elements[caller*5+4].options[10] = new Option("i)","romoneparen",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.)","romdotparen",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.","romperiod",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 |
poolForm.elements[caller*5+4].selectedIndex = 0 |
} |
} |
else { |
else { |
Line 444 function verify() {
|
Line 446 function verify() {
|
if ($numitems > 0) { |
if ($numitems > 0) { |
my $maxnum = $numitems - 1; |
my $maxnum = $numitems - 1; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
fnmb => 'File names must be unique', |
fnmb => 'Filenames must be unique', |
isum => 'is used more than once', |
isum => 'is used more than once', |
); |
); |
$$jsref .= qq| |
$$jsref .= qq| |
Line 487 sub display_zero {
|
Line 489 sub display_zero {
|
my ($r,$fn,$page,$webpath) = @_; |
my ($r,$fn,$page,$webpath) = @_; |
my $go_default = 'NextPage'; |
my $go_default = 'NextPage'; |
if ($fn eq '') { |
if ($fn eq '') { |
$r->print('<b>'.&mt('Incomplete file upload').'</b> '.&mt('Return to the [_1]construction space menu[_2] to upload a file','<a href="'.$webpath.'">','</a>')); |
$r->print('<b>'.&mt('Incomplete file upload').'</b> '.&mt('Return to the [_1]Authoring Space menu[_2] to upload a file','<a href="'.$webpath.'">','</a>')); |
} |
} |
$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.','<b>','</b>').'<br />'. |
$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.','<b>','</b>').'<br />'. |
&mt('The following question types can be converted:').' |
&mt('The following question types can be converted:').' |
Line 510 sub display_zero {
|
Line 512 sub display_zero {
|
</ol><form name="info" method="post" action="/adm/testbank">'. |
</ol><form name="info" method="post" action="/adm/testbank">'. |
&Apache::lonhtmlcommon::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:'). |
&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:'). |
' <input type="button" name="createdir" value="'.&mt('Create sub-directory').'" onClick="javascript:createWin()" />'. |
' <input type="button" name="createdir" value="'.&mt('Create sub-directory').'" onclick="javascript:createWin()" />'. |
&page_footer($env{'form.newdir'},$fn,$page,$webpath).' |
&page_footer($env{'form.newdir'},$fn,$page,$webpath).' |
</form>'); |
</form>'); |
} |
} |
Line 577 sub display_two {
|
Line 579 sub display_two {
|
my $blocks = $env{'form.blocks'}; |
my $blocks = $env{'form.blocks'}; |
my $qnumformat = $env{'form.qnumformat'}; |
my $qnumformat = $env{'form.qnumformat'}; |
my @types = ("MC","MA","TF","Ess","FIB","Ord"); |
my @types = ("MC","MA","TF","Ess","FIB","Ord"); |
my %typenames = ( |
my %typenames = &Apache::lonlocal::texthash( |
MC => "Multiple Choice", |
MC => "Multiple Choice", |
TF => "True/False", |
TF => "True/False", |
MA => "Multiple Answer", |
MA => "Multiple Answer", |
Line 627 sub display_two {
|
Line 629 sub display_two {
|
'<td valign="top"> <input type="text" name="start_'.$i.'" value="'.$bl1st.'" size="5" /> </td>'."\n". |
'<td valign="top"> <input type="text" name="start_'.$i.'" value="'.$bl1st.'" size="5" /> </td>'."\n". |
'<td valign="top"> <input type="text" name="end_'.$i.'" value="'.$bl1end.'" size="5" /> </td>'."\n". |
'<td valign="top"> <input type="text" name="end_'.$i.'" value="'.$bl1end.'" size="5" /> </td>'."\n". |
'<td valign="top"> |
'<td valign="top"> |
<select name="qtype_'.$i.'" onChange="colSet('.$i.')"> |
<select name="qtype_'.$i.'" onchange="colSet('.$i.')"> |
<option value="-1" selected="selected">'.&mt('Select').'</option>'."\n"); |
<option value="-1" selected="selected">'.&mt('Select').'</option>'."\n"); |
foreach my $qtype (@types) { |
foreach my $qtype (@types) { |
$r->print('<option value="'.$qtype.'">'.$typenames{$qtype}.'</option>'."\n"); |
$r->print('<option value="'.$qtype.'">'.$typenames{$qtype}.'</option>'."\n"); |
Line 681 sub display_three {
|
Line 683 sub display_three {
|
my %lt = &Apache::lonlocal::texthash ( |
my %lt = &Apache::lonlocal::texthash ( |
crt => 'Create?', |
crt => 'Create?', |
typ => 'Type', |
typ => 'Type', |
fnam => 'File Name', |
fnam => 'Filename', |
ques => 'Question', |
ques => 'Question', |
answ => 'Answer', |
answ => 'Answer', |
chka => 'check all', |
chka => 'check all', |
Line 774 sub display_three {
|
Line 776 sub display_three {
|
'<td valign="top">'.$showqn.'<br /><br />'."\n"); |
'<td valign="top">'.$showqn.'<br /><br />'."\n"); |
} else { |
} else { |
my $foiltag = ''; |
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].'.'; |
$foiltag = $alphabet->[$k-1].'.'; |
} elsif ($foilformats[$i] eq "lcparen") { |
} elsif ($foilformats[$i] eq "lcparen") { |
$foiltag = '('.$alphabet->[$k-1].')'; |
$foiltag = '('.$alphabet->[$k-1].')'; |
Line 924 sub final_display {
|
Line 931 sub final_display {
|
$items->[$k] =~ tr/A-Z/a-z/; |
$items->[$k] =~ tr/A-Z/a-z/; |
$items->[$k] =~ s/<\/?[^>]+>//g; |
$items->[$k] =~ s/<\/?[^>]+>//g; |
$items->[$k] =~ s/\W//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++) { |
for (my $j=0; $j<@{$alphabet}; $j++) { |
if ($alphabet->[$j] eq $items->[$k]) { |
if ($alphabet->[$j] eq $items->[$k]) { |
push @{$answers{$qnum}}, $j; |
push @{$answers{$qnum}}, $j; |
Line 957 sub final_display {
|
Line 964 sub final_display {
|
} else { |
} else { |
$correct =~s/\W//g; |
$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)) { |
if (($qtype[$i] eq "Ord") && (@tied > 0)) { |
my @ties; |
my @ties; |
foreach my $tie (@tied) { |
foreach my $tie (@tied) { |
Line 1275 sub file_split {
|
Line 1282 sub file_split {
|
if (${$numsref}[$i] > 0) { |
if (${$numsref}[$i] > 0) { |
if ((${$qtyperef}[$i] eq "MC") || (${$qtyperef}[$i] eq "MA") || (${$qtyperef}[$i] eq "Ord")) { |
if ((${$qtyperef}[$i] eq "MC") || (${$qtyperef}[$i] eq "MA") || (${$qtyperef}[$i] eq "Ord")) { |
my $splitstr = ''; |
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]\.'; |
$splitstr = '[a-z]\.'; |
} elsif (${$foilsref}[$i] eq "lcparen") { |
} elsif (${$foilsref}[$i] eq "lcparen") { |
$splitstr = '\([a-z]\)'; |
$splitstr = '\([a-z]\)'; |
Line 1497 sub create_mcq {
|
Line 1508 sub create_mcq {
|
if (-e $destdir.$libfile) { |
if (-e $destdir.$libfile) { |
$result = 'exists'; |
$result = 'exists'; |
} else { |
} else { |
if (open(PROB,">$destdir$libfile")) { |
if (open(PROB,">",$destdir.$libfile)) { |
print PROB $output; |
print PROB $output; |
close(PROB); |
close(PROB); |
$result = 'ok'; |
$result = 'ok'; |
Line 1575 sub create_ess {
|
Line 1586 sub create_ess {
|
if (-e $destdir.$libfile) { |
if (-e $destdir.$libfile) { |
$result = 'exists'; |
$result = 'exists'; |
} else { |
} else { |
if (open(PROB,">$destdir$libfile")) { |
if (open(PROB,">",$destdir.$libfile)) { |
print PROB $output; |
print PROB $output; |
close(PROB); |
close(PROB); |
$result = 'ok'; |
$result = 'ok'; |
Line 1606 sub file_error {
|
Line 1617 sub file_error {
|
my ($r,$fn,$current_page,$webpath,$res) = @_; |
my ($r,$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.'). |
$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:'). |
'</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>'. |
'<ul>'. |
|
'<li>'.&mt('plain text').'</li>'. |
|
'<li>'.&mt('RTF').'</li>'. |
|
'<li>'.&mt('HTML').'</li></ul>'. |
&mt('The file type identified for the file you uploaded is [_1].','<b>'.$res.'</b>').'</p>'); |
&mt('The file type identified for the file you uploaded is [_1].','<b>'.$res.'</b>').'</p>'); |
$r->print(&page_footer($env{'form.newdir'},$fn,$current_page,$webpath,undef,'badfile'). |
$r->print(&page_footer($env{'form.newdir'},$fn,$current_page,$webpath,undef,'badfile'). |
'</form>'); |
'</form>'); |
Line 1622 sub parse_datafile {
|
Line 1636 sub parse_datafile {
|
$res = $mm->checktype_filename($dirpath.$filename); |
$res = $mm->checktype_filename($dirpath.$filename); |
if ($env{'form.phase'} eq 'three') { |
if ($env{'form.phase'} eq 'three') { |
if ($res eq 'text/plain') { |
if ($res eq 'text/plain') { |
open(TESTBANK,"<$dirpath$filename"); |
open(TESTBANK,"<",$dirpath.$filename); |
@{$text} = <TESTBANK>; |
@{$text} = <TESTBANK>; |
close(TESTBANK); |
close(TESTBANK); |
} elsif ($res eq 'application/rtf') { |
} elsif ($res eq 'application/rtf') { |
Line 1773 sub build_image_url {
|
Line 1787 sub build_image_url {
|
} |
} |
|
|
sub print_header { |
sub print_header { |
my ($uname,$udom,$javascript,$loadentries,$title,$current_page,$pagesref, |
my ($uname,$udom,$javascript,$loadentries,$title,$crumbtext,$crumbhref, |
$namesref) = @_; |
$crsauthor,$current_page,$pagesref,$namesref) = @_; |
my $brcrum = [{'href' => &Apache::loncommon::authorspace("/priv/$udom/$uname/"), |
my $brcrum = [{'href' => $crumbhref), |
'text' => 'Construction Space'}]; |
'text' => $crumbtext}]; |
if ($env{'form.phase'} eq 'three') { |
if ($env{'form.phase'} eq 'three') { |
if (ref($pagesref) eq 'ARRAY') { |
if (ref($pagesref) eq 'ARRAY') { |
for (my $i=0; $i<$current_page; $i++) { |
for (my $i=0; $i<$current_page; $i++) { |
Line 1802 sub print_header {
|
Line 1816 sub print_header {
|
my $output = &Apache::loncommon::start_page($title,$javascript, |
my $output = &Apache::loncommon::start_page($title,$javascript, |
{'bread_crumbs' => $brcrum, |
{'bread_crumbs' => $brcrum, |
'add_entries' => $loadentries}); |
'add_entries' => $loadentries}); |
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
unless ($crsauthor) { |
$output .= '<p class="LC_info">' |
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
.&mt('Co-Author [_1]',$uname.':'.$udom) |
$output .= '<p class="LC_info">' |
.'</p>'; |
.&mt('Co-Author [_1]',$uname.':'.$udom) |
|
.'</p>'; |
|
} |
} |
} |
return $output; |
return $output; |
} |
} |
Line 1838 sub handler {
|
Line 1854 sub handler {
|
my $page_name = ''; |
my $page_name = ''; |
my $current_page = ''; |
my $current_page = ''; |
my $qcount = ''; |
my $qcount = ''; |
my $title = 'Upload testbank questions to Construction Space'; |
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 |
# ----------------------------------------------------------- Start page output |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
Line 1851 sub handler {
|
Line 1879 sub handler {
|
if ($env{'form.phase'} eq 'three') { |
if ($env{'form.phase'} eq 'three') { |
$current_page = &display_control(); |
$current_page = &display_control(); |
@pages = ('Welcome','Blocks','Format','Target','Confirmation'); |
@pages = ('Welcome','Blocks','Format','Target','Confirmation'); |
%names = ( |
%names = &Apache::lonlocal::texthash( |
Welcome => 'Testbank Format', |
Welcome => 'Testbank Format', |
Blocks => 'Classification', |
Blocks => 'Classification', |
Format => 'Selection', |
Format => 'Selection', |
Line 1900 sub handler {
|
Line 1928 sub handler {
|
} |
} |
|
|
$r->print(&print_header($uname,$udom,$javascript,\%loadentries,$title, |
$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') || ($env{'form.phase'} eq 'three')) { |
if ($env{'form.phase'} eq 'four') { |
if ($env{'form.phase'} eq 'four') { |
Line 1947 sub handler {
|
Line 1976 sub handler {
|
&page_footer('',$fn).'</form>'); |
&page_footer('',$fn).'</form>'); |
} |
} |
} else { |
} else { |
&Apache::lonupload::phaseone($r,$fn,'testbank'); |
&Apache::lonupload::phaseone($r,$fn,'testbank',$uname,$udom); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |