version 1.379, 2007/06/05 22:37:56
|
version 1.394, 2007/09/10 16:25:38
|
Line 47 BEGIN {
|
Line 47 BEGIN {
|
|
|
sub start_web { |
sub start_web { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style); |
if ($target ne 'edit' && $target ne 'modified') { |
if ($target eq 'web' || $target eq 'webgrade') { |
my $bodytext=&Apache::lonxml::get_all_text("/web",$parser,$style); |
return $bodytext; |
if ($target eq 'web' || $target eq 'webgrade') { |
|
return $bodytext; |
|
} |
|
} elsif ($target eq "edit" ) { |
|
my $bodytext = |
|
&Apache::lonxml::get_all_text_unbalanced("/web",$parser); |
|
my $result = &Apache::edit::tag_start($target,$token); |
|
$result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1); |
|
return $result; |
|
} elsif ( $target eq "modified" ) { |
|
return $token->[4].&Apache::edit::modifiedfield("/web",$parser); |
} |
} |
return ''; |
return ''; |
} |
} |
Line 61 sub end_web {
|
Line 71 sub end_web {
|
sub start_tex { |
sub start_tex { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result=''; |
my $result=''; |
my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style); |
if ($target ne 'edit' && $target ne 'modified') { |
if ($target eq 'tex') { |
my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style); |
return $bodytext.' '; |
if ($target eq 'tex') { |
|
return $bodytext.' '; |
|
} |
|
} elsif ($target eq "edit" ) { |
|
my $bodytext = |
|
&Apache::lonxml::get_all_text_unbalanced("/tex",$parser); |
|
my $result = &Apache::edit::tag_start($target,$token); |
|
$result .= &Apache::edit::editfield($token->[1],$bodytext,'',80,1); |
|
return $result; |
|
} elsif ( $target eq "modified" ) { |
|
return $token->[4].&Apache::edit::modifiedfield("/tex",$parser); |
} |
} |
return $result;; |
return $result;; |
} |
} |
Line 105 function setSubmittedPart (part) {
|
Line 125 function setSubmittedPart (part) {
|
|
|
$extra_head .= &Apache::londefdef::generate_css_links(); |
$extra_head .= &Apache::londefdef::generate_css_links(); |
|
|
if ($target eq 'edit') { |
if ($env{'request.state'} eq 'construct') { |
$extra_head.=&Apache::edit::js_change_detection(). |
$extra_head.=&Apache::edit::js_change_detection(). |
"<script type=\"text/javascript\">\n". |
"<script type=\"text/javascript\">\n". |
"if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". |
"if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". |
Line 137 function setSubmittedPart (part) {
|
Line 157 function setSubmittedPart (part) {
|
$body_args{'no_title'} = 1; |
$body_args{'no_title'} = 1; |
$body_args{'force_register'} = 1; |
$body_args{'force_register'} = 1; |
$body_args{'add_entries'} = \%add_entries; |
$body_args{'add_entries'} = \%add_entries; |
|
if ($env{'environment.remote'} eq 'off' |
|
&& $env{'request.state'} eq 'construct') { |
|
$body_args{'only_body'} = 1; |
|
} |
} |
} |
$body_args{'no_auto_mt_title'} = 1; |
$body_args{'no_auto_mt_title'} = 1; |
my $page_start = &Apache::loncommon::start_page($name,$extra_head, |
my $page_start = &Apache::loncommon::start_page($name,$extra_head, |
Line 182 function setSubmittedPart (part) {
|
Line 206 function setSubmittedPart (part) {
|
#use Time::HiRes(); |
#use Time::HiRes(); |
sub get_resource_name { |
sub get_resource_name { |
my ($parstack,$safeeval)=@_; |
my ($parstack,$safeeval)=@_; |
|
my $name; |
if (defined($Apache::lonhomework::name)) { |
if (defined($Apache::lonhomework::name)) { |
return $Apache::lonhomework::name; |
$name = $Apache::lonhomework::name; |
} |
} else { |
my ($symb)=&Apache::lonnet::whichuser(); |
my ($symb)=&Apache::lonnet::whichuser(); |
my $name=&Apache::lonnet::gettitle($symb); |
$name=&Apache::lonnet::gettitle($symb); |
if ($name eq '') { |
if ($name eq '') { |
$name=&Apache::lonnet::EXT('resource.title'); |
$name=&Apache::lonnet::EXT('resource.title'); |
if ($name eq 'con_lost') { $name = ''; } |
if ($name eq 'con_lost') { $name = ''; } |
} |
} |
if ($name!~/\S+/) { |
if ($name!~/\S+/) { |
$name=$env{'request.uri'}; |
$name=$env{'request.uri'}; |
$name=~s-.*/([^/]+)$-$1-; |
$name=~s-.*/([^/]+)$-$1-; |
|
} |
|
# The name has had html tags escaped: |
|
|
|
$name=~s/</</gs; |
|
$name=~s/>/>/gs; |
|
|
|
$Apache::lonhomework::name=$name; |
} |
} |
$Apache::lonhomework::name=$name; |
|
return $name; |
return $name; |
} |
} |
|
|
Line 289 sub problem_web_to_edit_header {
|
Line 320 sub problem_web_to_edit_header {
|
<input type="text" name="rndseed" size="10" value="'. |
<input type="text" name="rndseed" size="10" value="'. |
$rndseed.'" |
$rndseed.'" |
onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr> |
onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr> |
<label><input type="checkbox" name="showallfoils" '; |
<span class="LC_nobreak"><label><input type="checkbox" name="showallfoils" '; |
my $show_all_foils_text = |
my $show_all_foils_text = |
($Apache::lonhomework::parsing_a_task) ? |
($Apache::lonhomework::parsing_a_task) ? |
&mt(' Show All Instances') |
&mt(' Show All Instances') |
: &mt(' Show All Foils'); |
: &mt(' Show All Foils'); |
|
|
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; } |
if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; } |
$result.= ' />'.$show_all_foils_text.'</label>'. |
$result.= ' />'.$show_all_foils_text.'</label></span>'. |
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). |
&Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). |
'<hr />'; |
'<hr />'; |
|
$result.=&mt('Apply style file: ').' |
|
<input type="text" name="style_file" value="'.&HTML::Entities::encode($env{'construct.style'},'"<>&').'" /> |
|
<a href="javascript:openbrowser(\'lonhomework\',\'style_file\',\'sty\')">'.&mt('Select').'</a> |
|
<input type="submit" name="clear_style_file" value="'.&mt('Clear').'" /> |
|
<br />'; |
|
|
if (!$Apache::lonhomework::parsing_a_task) { |
if (!$Apache::lonhomework::parsing_a_task) { |
$result.=" |
$result.=" |
<nobr> |
<nobr> |
Line 432 sub finalize_storage {
|
Line 469 sub finalize_storage {
|
} |
} |
return $result; |
return $result; |
} |
} |
use Data::Dumper; |
|
|
|
# -------------------------------------------------------------store_aggregates |
# -------------------------------------------------------------store_aggregates |
# Sends hash of values to be incremented in nohist_resourcetracker.db |
# Sends hash of values to be incremented in nohist_resourcetracker.db |
Line 612 sub start_problem {
|
Line 648 sub start_problem {
|
} |
} |
|
|
if ($target ne 'analyze') { |
if ($target ne 'analyze') { |
if ($env{'request.state'} eq 'construct') { &set_problem_state('0'); } |
|
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type'); |
$Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type'); |
if (($env{'request.state'} eq 'construct') && |
if (($env{'request.state'} eq 'construct') && |
defined($env{'form.problemtype'})) { |
defined($env{'form.problemtype'})) { |
Line 633 sub start_problem {
|
Line 668 sub start_problem {
|
$Apache::lonhomework::default_type = $Apache::lonhomework::type; |
$Apache::lonhomework::default_type = $Apache::lonhomework::type; |
|
|
&initialize_storage(); |
&initialize_storage(); |
|
if ($target ne 'analyze' |
|
&& $env{'request.state'} eq 'construct') { |
|
&set_problem_state('0'); |
|
} |
|
|
if ($target eq 'web') { |
if ($target eq 'web') { |
&Apache::lonxml::debug(" grading history "); |
&Apache::lonxml::debug(" grading history "); |
&Apache::lonhomework::showhash(%Apache::lonhomework::history); |
&Apache::lonhomework::showhash(%Apache::lonhomework::history); |
Line 725 sub start_problem {
|
Line 765 sub start_problem {
|
$msg.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
$msg.='<h1>'.&mt('Not open to be viewed').'</h1>'; |
} |
} |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') { |
$msg.='The problem '.$accessmsg; |
$msg.=&mt('The problem ').$accessmsg; |
} elsif ($status eq 'UNCHECKEDOUT') { |
} elsif ($status eq 'UNCHECKEDOUT') { |
$msg.=&checkout_msg(); |
$msg.=&checkout_msg(); |
} elsif ($status eq 'NOT_YET_VIEWED') { |
} elsif ($status eq 'NOT_YET_VIEWED') { |
Line 880 sub end_problem {
|
Line 920 sub end_problem {
|
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
} |
} |
} else { |
} else { |
$frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\'; |
$frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\'.$startminipage; |
} |
} |
} else { |
} else { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
$frontmatter .= $begin_doc.$toc_line; |
$frontmatter .= $begin_doc.$toc_line; |
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';} |
} else { |
} else { |
$frontmatter .= '\vskip 1mm \\\\\\\\'; |
$frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage; |
} |
} |
} |
} |
$result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/; |
$result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/; |
Line 937 sub end_problem {
|
Line 977 sub end_problem {
|
if (not $env{'request.symb'} =~ m/\.page_/) { |
if (not $env{'request.symb'} =~ m/\.page_/) { |
$result .= $endminipage.'\end{document} '; |
$result .= $endminipage.'\end{document} '; |
} else { |
} else { |
$result .= ''; |
$result .= $endminipage; |
} |
} |
} |
} |
} |
} |
Line 1055 sub start_block {
|
Line 1095 sub start_block {
|
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || |
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') { |
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') { |
my $code = $token->[2]->{'condition'}; |
my $code = $token->[2]->{'condition'}; |
if (defined($code)) { |
if (defined($code) && $code ne '') { |
if (!$Apache::lonxml::default_homework_loaded) { |
if (!$Apache::lonxml::default_homework_loaded) { |
&Apache::lonxml::default_homework_load($safeeval); |
&Apache::lonxml::default_homework_load($safeeval); |
} |
} |
Line 1100 sub start_languageblock {
|
Line 1140 sub start_languageblock {
|
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') { |
$target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') { |
my $include = $token->[2]->{'include'}; |
my $include = $token->[2]->{'include'}; |
my $exclude = $token->[2]->{'exclude'}; |
my $exclude = $token->[2]->{'exclude'}; |
my %languages=&Apache::loncommon::display_languages(); |
my $preferred_language=(&Apache::loncommon::preferred_languages)[0]; |
|
# This should not even happen, since we should at least have the server language |
|
unless ($preferred_language) { $preferred_language='en'; } |
|
# If the languageblock has no arguments, show the contents |
$result='1'; |
$result='1'; |
|
# Do we have an include argument? |
if ($include) { |
if ($include) { |
|
# If include is specified, by default, don't render the block |
$result=''; |
$result=''; |
foreach (split(/\,/,$include)) { |
foreach my $included_language (split(/\,/,$include)) { |
if ($languages{$_}) { $result='1'; } |
# ... but if my preferred language is included, render it |
|
if ($included_language eq $preferred_language) { $result='1'; } |
} |
} |
} |
} |
|
# Do we have an exclude argument? |
if ($exclude) { |
if ($exclude) { |
foreach (split(/\,/,$exclude)) { |
$result='1'; |
if ($languages{$_}) { $result='0'; } |
foreach my $excluded_language (split(/\,/,$exclude)) { |
|
if ($excluded_language eq $preferred_language) { $result='0'; } |
} |
} |
} |
} |
if ( ! $result ) { |
if ( ! $result ) { |
Line 1225 sub end_while {
|
Line 1273 sub end_while {
|
$return = 0; $error=1; next; |
$return = 0; $error=1; next; |
} |
} |
$result.=&Apache::scripttag::xmlparse($bodytext); |
$result.=&Apache::scripttag::xmlparse($bodytext); |
|
if ($target eq 'grade' || $target eq 'answer' || |
|
$target eq 'analyze') { |
|
# grade/answer/analyze should produce no output but if we |
|
# are redirecting, the redirecter should know what to do |
|
# with the output |
|
if (!$Apache::lonxml::redirection) { undef($result); } |
|
} |
$return = &Apache::run::run($code,$safeeval); |
$return = &Apache::run::run($code,$safeeval); |
} |
} |
if ($error) { |
if ($error) { |
Line 1342 sub start_part {
|
Line 1397 sub start_part {
|
# duedates. |
# duedates. |
} |
} |
my $result=''; |
my $result=''; |
my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); |
my $id= &Apache::lonxml::get_id($parstack,$safeeval); |
if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; } |
|
$Apache::inputtags::part=$id; |
$Apache::inputtags::part=$id; |
push(@Apache::inputtags::partlist,$id); |
push(@Apache::inputtags::partlist,$id); |
@Apache::inputtags::response=(); |
@Apache::inputtags::response=(); |
Line 1396 sub start_part {
|
Line 1450 sub start_part {
|
if ($target eq 'tex') { |
if ($target eq 'tex') { |
if (not $env{'form.problem_split'}=~/yes/) { |
if (not $env{'form.problem_split'}=~/yes/) { |
if ($$tagstack[-2] eq 'td') { |
if ($$tagstack[-2] eq 'td') { |
$result.='\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent'; |
$result.='\noindent \begin{minipage}{\textwidth}\noindent'; |
} else { |
} else { |
$result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent'; |
$result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent'; |
} |
} |