--- loncom/homework/structuretags.pm 2008/01/28 21:42:28 1.417 +++ loncom/homework/structuretags.pm 2009/03/27 01:07:10 1.441 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.417 2008/01/28 21:42:28 www Exp $ +# $Id: structuretags.pm,v 1.441 2009/03/27 01:07:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,6 +27,29 @@ # ### +=pod + +=head1 NAME + +Apache::structuretags + +=head1 SYNOPSIS + + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + + +=head1 NOTABLE SUBROUTINES + +=over + +=item + +=back + +=cut + package Apache::structuretags; @@ -36,6 +59,7 @@ use Apache::File(); use Apache::lonmenu; use Apache::lonlocal; use Apache::lonxml; +use Apache::londefdef; use Apache::lonenc(); use Time::HiRes qw( gettimeofday tv_interval ); use lib '/home/httpd/lib/perl/'; @@ -74,7 +98,14 @@ sub start_tex { if ($target ne 'edit' && $target ne 'modified') { my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser,$style); if ($target eq 'tex') { - return $bodytext.' '; + + # If inside a table, occurrences of \\ must be removed; + # else the table blows up. + + if (&Apache::londefdef::is_inside_of($tagstack, "table")) { + $bodytext =~ s/\\\\//g; + } + return $bodytext.'{}'; } } elsif ($target eq "edit" ) { my $bodytext = @@ -148,6 +179,12 @@ sub page_start { $extra_head .= &homework_js(); + if ($env{'environment.wysiwygeditor'} eq 'on') { + $extra_head .= &Apache::lonhtmlcommon::dragmath_js("FCKEditMathPopup"); + } else { + $extra_head .= &Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); + } + my %body_args; if (defined($found{'html'})) { $body_args{'skip_phases'}{'head'}=1; @@ -312,24 +349,28 @@ sub remember_problem_state { '; } -sub problem_edit_header { - return ''. - &Apache::structuretags::remember_problem_state().' -
-
-'.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').' -
+sub problem_edit_buttons { + return '
- + ' onclick="javscript:setmode(this.form,'."'discard'".')" />
-
+
'; +} + +sub problem_edit_header { + return ''. + &Apache::structuretags::remember_problem_state().' +
+
+'.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').' +
'. +&problem_edit_buttons().'
'.&Apache::lonxml::message_location().'
@@ -340,17 +381,8 @@ sub problem_edit_header { sub problem_edit_footer { return '
'. @@ -391,8 +423,8 @@ sub problem_web_to_edit_header { &mt(' Show All Instances') : &mt(' Show All Foils'); - my $show_all= ''; @@ -417,8 +449,9 @@ sub problem_web_to_edit_header { $show_all @@ -451,7 +484,6 @@ $show_all $show_all "; } - $result.=' '.&mt('Apply style file: ').' @@ -459,6 +491,9 @@ $show_all '.&mt('Select').' +
'. + &Apache::lonxml::renderingoptions().' +
@@ -477,8 +512,8 @@ $show_all $result .= ''. &mt('[_1] for [_2] versions.', ' - ' + ,''). &Apache::loncommon::help_open_topic("Analyze_Problem",'',undef,undef,300). ''; @@ -539,12 +574,19 @@ sub initialize_storage { if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); } } -# -------------------------------------------------------------finalize_storage -# Stores away the result has to a student's environment -# checks form.grade_ for specific values, other wises stores -# to the running users environment -# Will increment totals for attempts, students, and corrects -# if running user has student role. +=pod + +=item finalize_storage() + + Stores away the result has to a student's environment + checks form.grade_ for specific values, other wises stores + to the running users environment + Will increment totals for attempts, students, and corrects + if running user has student role. + +=cut + + sub finalize_storage { my ($given_symb) = @_; my $result; @@ -575,10 +617,16 @@ sub finalize_storage { return $result; } -# -------------------------------------------------------------store_aggregates -# Sends hash of values to be incremented in nohist_resourcetracker.db -# for the course. Increments total number of attempts, unique students -# and corrects for each part for an instance of a problem, as appropriate. +=pod + +item store_aggregates() + + Sends hash of values to be incremented in nohist_resourcetracker.db + for the course. Increments total number of attempts, unique students + and corrects for each part for an instance of a problem, as appropriate. + +=cut + sub store_aggregates { my ($symb,$courseid) = @_; my %aggregate; @@ -645,26 +693,27 @@ sub firstaccess_msg { my $foldertitle=&Apache::lonnet::gettitle($map); &Apache::lonxml::debug("map is $map title is $foldertitle"); - $result .= (<The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle". -ENDCHECKOUT + $result .= "

".&mt('The resources in "[_1]" are open for a limited time.' + .' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' + ,$foldertitle,$time)."

"; } elsif ($interval[1] eq 'course') { my $course = $env{'course.'.$env{'request.course.id'}.'.description'}; - $result .= (<The resources in "$course" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources in "$course". -ENDCHECKOUT + $result .= "

".&mt('The resources in "[_1]" are open for a limited time.' + .' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' + ,$course,$time)."

"; } else { my $title=&Apache::lonnet::gettitle($symb); - $result .= (<This resource "$title" is open for a limited time. Once you click the 'Show Resource' button below you have $time to complete this resource "$title". -ENDCHECKOUT - + $result .= "

".&mt('This resource "[_1]" is open for a limited time.' + .' Once you click the "Show Resource" button below you have [_2] to complete this resource "[_1]".' + ,$title,$time)."

"; } my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); + my $buttontext = &mt('Show Resource'); + my $timertext = &mt('Start Timer?'); $result .= (< - + ENDCHECKOUT return $result; @@ -855,16 +904,15 @@ sub start_problem { } if ($env{'request.role.adv'}) { $form_tag_start.= - '