version 1.17, 2008/09/22 01:53:33
|
version 1.21, 2009/04/04 21:45:57
|
Line 85 function createWin() {
|
Line 85 function createWin() {
|
newWindow.document.write("<h3>$lt{'loca'}: <tt>$webpath</tt></h3><h3>$lt{'newd'}</h3>\\n") |
newWindow.document.write("<h3>$lt{'loca'}: <tt>$webpath</tt></h3><h3>$lt{'newd'}</h3>\\n") |
newWindow.document.write("<form name='fileaction' action='/adm/cfile' method='post'>\\n") |
newWindow.document.write("<form name='fileaction' action='/adm/cfile' method='post'>\\n") |
newWindow.document.write("$lt{'ente'}.<br /><br />") |
newWindow.document.write("$lt{'ente'}.<br /><br />") |
newWindow.document.write("<input type='hidden' name='filename' value='$webpath'>") |
newWindow.document.write("<input type='hidden' name='filename' value='$webpath' />") |
newWindow.document.write("<input type='hidden' name='action' value='newdir'>") |
newWindow.document.write("<input type='hidden' name='action' value='newdir'>") |
newWindow.document.write("<input type='hidden' name='callingmode' value='testbank'>") |
newWindow.document.write("<input type='hidden' name='callingmode' value='testbank' />") |
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() |
Line 510 sub display_zero {
|
Line 510 sub display_zero {
|
</ol><form name="info" method="post" action="/adm/testbank">'. |
</ol><form name="info" method="post" action="/adm/testbank">'. |
&topic_bar(1,&mt('Optional: create a sub-directory in which the testbank questions will be saved')). |
&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'},$uname,$fn,$page,$webpath).' |
&page_footer($env{'form.newdir'},$uname,$fn,$page,$webpath).' |
</form>'); |
</form>'); |
} |
} |
Line 625 sub display_two {
|
Line 625 sub display_two {
|
$r->print(&Apache::loncommon::start_data_table_row(). |
$r->print(&Apache::loncommon::start_data_table_row(). |
'<td valign="top"> '.$iter.' </td>'."\n". |
'<td valign="top"> '.$iter.' </td>'."\n". |
'<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>'.&mt('Select').'</option>'."\n"); |
<option value= "-1" selected>'.&mt('Select').'</option>'."\n"); |
Line 1187 sub page_footer {
|
Line 1187 sub page_footer {
|
<input type="hidden" name="filename" value="'.$fn.'" /> |
<input type="hidden" name="filename" value="'.$fn.'" /> |
<input type="hidden" name="page" value="'.$page.'" /> |
<input type="hidden" name="page" value="'.$page.'" /> |
<input type="hidden" name="phase" value="three" /> |
<input type="hidden" name="phase" value="three" /> |
<input type="hidden" name="go" value="'.$go.'" />'; |
<input type="hidden" name="go" value="'.$go.'" /> |
|
<input type="hidden" name="timestamp" value="'.$env{'form.timestamp'}.'" />'; |
if ($page ne '') { |
if ($page ne '') { |
$output .= ' |
$output .= ' |
<table border="0"> |
<table border="0"> |
Line 1199 sub page_footer {
|
Line 1200 sub page_footer {
|
$output .= ' |
$output .= ' |
<td> </td> |
<td> </td> |
<td> |
<td> |
<input type="button" name="nextpage" value="'.$nextval.'" onclick="'.$nextclick.'"> |
<input type="button" name="nextpage" value="'.$nextval.'" onclick="'.$nextclick.'" /> |
</td>'; |
</td>'; |
} |
} |
$output .= ' </tr> |
$output .= ' </tr> |
Line 1327 sub create_mcq {
|
Line 1328 sub create_mcq {
|
my $qstn = ${$qstnref}[0]; |
my $qstn = ${$qstnref}[0]; |
my $numfoils = scalar(@{$qstnref}) - 1; |
my $numfoils = scalar(@{$qstnref}) - 1; |
my $datestamp = localtime; |
my $datestamp = localtime; |
my $timestamp = time; |
|
my $numansrs = scalar(@{$answerref}); |
my $numansrs = scalar(@{$answerref}); |
my $output = '<problem> |
my $output = '<problem> |
<startouttext />'; |
<startouttext />'; |
Line 1610 sub file_error {
|
Line 1610 sub file_error {
|
} |
} |
|
|
sub parse_datafile { |
sub parse_datafile { |
my ($r,$uname,$filename,$pathname,$dirpath,$urlpath,$page_name,$subdir) = @_; |
my ($r,$uname,$filename,$pathname,$dirpath,$urlpath,$page_name,$subdir,$timestamp) = @_; |
my ($badfile,$res,%allfiles,%codebase); |
my ($badfile,$res,%allfiles,%codebase); |
my $mm = new File::MMagic; |
my $mm = new File::MMagic; |
my ($text,$header,$css,$js); |
my ($text,$header,$css,$js); |
Line 1623 sub parse_datafile {
|
Line 1623 sub parse_datafile {
|
close(TESTBANK); |
close(TESTBANK); |
} elsif ($res eq 'application/rtf') { |
} elsif ($res eq 'application/rtf') { |
my $html = ''; |
my $html = ''; |
# my $image_uri = '..'.$pathname; |
my $image_uri = $timestamp; |
my $image_uri = $pathname; |
|
if ($page_name eq 'Target') { |
if ($page_name eq 'Target') { |
$image_uri = $urlpath; |
$image_uri = $urlpath.'/'.$timestamp; |
} |
} |
$image_uri =~ s/\/$//; |
|
my $image_dir; |
my $image_dir; |
if ($page_name eq 'Blocks') { |
if ($page_name eq 'Blocks') { |
$image_dir = $dirpath; |
$image_dir = $dirpath; |
$image_dir =~ s/\/$//; |
$image_dir =~ s/\/$//; |
|
$image_dir .= '/'.$timestamp; |
|
if (!-e $image_dir) { |
|
mkdir($image_dir,0755); |
|
} |
} else { |
} else { |
$image_dir = $r->dir_config('lonDaemons').'/tmp/'. |
$image_dir = $r->dir_config('lonDaemons').'/tmp/'. |
$env{'user.name'}.'_'.$env{'user.domain'}. |
$env{'user.name'}.'_'.$env{'user.domain'}. |
Line 1651 sub parse_datafile {
|
Line 1653 sub parse_datafile {
|
$parser->parse(); |
$parser->parse(); |
utf8::decode($html); |
utf8::decode($html); |
($text,$header,$css,$js) = |
($text,$header,$css,$js) = |
&parse_htmlcontent($res,$subdir,$html); |
&parse_htmlcontent($res,$subdir,$html,undef,$page_name); |
} elsif ($res eq 'text/html') { |
} elsif ($res eq 'text/html') { |
($text,$header,$css,$js) = |
($text,$header,$css,$js) = |
&parse_htmlcontent($res,$subdir,undef,$dirpath.$filename); |
&parse_htmlcontent($res,$subdir,undef,$dirpath.$filename,$page_name); |
} else { |
} else { |
$badfile = 1; |
$badfile = 1; |
} |
} |
Line 1664 sub parse_datafile {
|
Line 1666 sub parse_datafile {
|
} |
} |
|
|
sub parse_htmlcontent { |
sub parse_htmlcontent { |
my ($res,$subdir,$html,$fullpath) = @_; |
my ($res,$subdir,$html,$fullpath,$page_name) = @_; |
my ($p,$fh); |
my ($p,$fh); |
if ($res eq 'application/rtf') { |
if ($res eq 'application/rtf') { |
$p = HTML::TokeParser->new( \$html ); |
$p = HTML::TokeParser->new( \$html ); |
Line 1702 sub parse_htmlcontent {
|
Line 1704 sub parse_htmlcontent {
|
my $contents = $token->[4]; |
my $contents = $token->[4]; |
if ($subdir ne '') { |
if ($subdir ne '') { |
if (($token->[1] eq 'img') && ($token->[2]->{'src'} ne '')) { |
if (($token->[1] eq 'img') && ($token->[2]->{'src'} ne '')) { |
$contents =~ s/(src=\s*["']?)/$1..\//i; |
if (($res eq 'text/html') || |
|
($res eq 'application/rtf') && ($page_name ne 'Target')) { |
|
$contents =~ s/(src=\s*["']?)/$1..\//i; |
|
} |
} |
} |
} |
} |
if (($line eq '') && ($current_tag eq 'font')) { |
if (($line eq '') && ($current_tag eq 'font')) { |
Line 1768 sub print_header {
|
Line 1773 sub print_header {
|
my $output = &Apache::loncommon::start_page($title,$javascript, |
my $output = &Apache::loncommon::start_page($title,$javascript, |
{'add_entries' => $loadentries}); |
{'add_entries' => $loadentries}); |
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
$output .= '<h3><span class="LC_error">'.&mt('Co-Author').': '.$uname. |
$output .= '<p class="LC_warning">' |
&mt(' at ').$udom.'</span></h3>'; |
.&mt('Co-Author [_1]:[_2]',$uname,$udom) |
|
.'</p>'; |
} |
} |
return $output; |
return $output; |
} |
} |
Line 1812 sub handler {
|
Line 1818 sub handler {
|
my ($fn,$filename); |
my ($fn,$filename); |
if ($env{'form.filename'}) { |
if ($env{'form.filename'}) { |
$fn=$env{'form.filename'}; |
$fn=$env{'form.filename'}; |
$fn=~s/^http\:\/\/[^\/]+\///; |
$fn=~s/^https?\:\/\/[^\/]+\///; |
$fn=~s/^\///; |
$fn=~s/^\///; |
$fn=~s{(~|priv/)($LONCAPA::username_re)}{}; |
$fn=~s{(~|priv/)($LONCAPA::username_re)}{}; |
$fn=~s/\/+/\//g; |
$fn=~s/\/+/\//g; |
Line 1836 sub handler {
|
Line 1842 sub handler {
|
$current_page = &display_control(); |
$current_page = &display_control(); |
my @pages = ('Welcome','Blocks','Format','Target','Confirmation'); |
my @pages = ('Welcome','Blocks','Format','Target','Confirmation'); |
$page_name = $pages[$current_page]; |
$page_name = $pages[$current_page]; |
|
if ($env{'form.timestamp'} eq '') { |
|
$env{'form.timestamp'} = time; |
|
} |
if ($env{'form.newdir'} ne '') { |
if ($env{'form.newdir'} ne '') { |
if ($env{'form.newdir'} =~ /^\Q$dirpath\E(.+)$/) { |
if ($env{'form.newdir'} =~ /^\Q$dirpath\E(.+)$/) { |
$subdir = $1; |
$subdir = $1; |
Line 1843 sub handler {
|
Line 1852 sub handler {
|
} |
} |
($res,$badfile,$textref,$header,$css,$js) = |
($res,$badfile,$textref,$header,$css,$js) = |
&parse_datafile($r,$uname,$filename,$pathname,$dirpath,$urlpath, |
&parse_datafile($r,$uname,$filename,$pathname,$dirpath,$urlpath, |
$page_name,$subdir); |
$page_name,$subdir,$env{'form.timestamp'}); |
if ($page_name eq 'Welcome') { |
if ($page_name eq 'Welcome') { |
&jscript_zero($webpath,\$javascript); |
&jscript_zero($webpath,\$javascript); |
} elsif ($page_name eq 'Blocks') { |
} elsif ($page_name eq 'Blocks') { |