--- loncom/homework/structuretags.pm 2008/06/11 13:52:35 1.423
+++ loncom/homework/structuretags.pm 2009/05/15 14:48:35 1.445
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.423 2008/06/11 13:52:35 www Exp $
+# $Id: structuretags.pm,v 1.445 2009/05/15 14:48:35 bisitz 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;
@@ -188,7 +225,7 @@ sub page_start {
if ($bgcolor eq '' ) { $bgcolor = '#FFFFFF'; }
$body_args{'bgcolor'} = $bgcolor;
- $body_args{'no_title'} = 1;
+# $body_args{'no_title'} = 1;
$body_args{'force_register'} = 1;
$body_args{'add_entries'} = \%add_entries;
if ($env{'environment.remote'} eq 'off'
@@ -386,8 +423,8 @@ sub problem_web_to_edit_header {
&mt(' Show All Instances')
: &mt(' Show All Foils');
- my $show_all= '';
@@ -412,8 +449,9 @@ sub problem_web_to_edit_header {
$show_all
@@ -536,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;
@@ -572,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;
@@ -626,7 +677,7 @@ sub checkout_msg {
$lt{'warning'}
'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occured while running <while> on line').' '.$line.''); + &Apache::lonxml::error('
'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occurred while running <while> on line').' '.$line.''); } } elsif ($target eq "edit") { $result.= &Apache::edit::tag_end($target,$token,''); @@ -1529,6 +1601,20 @@ sub start_randomlist { my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval); $showarg--; if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; } + if (($target eq 'analyze') && ($env{'form.check_parts_withrandomlist'})) { + my @currlist; + my $part = $Apache::inputtags::part; + if ($part ne '') { + if (ref($Apache::lonhomework::analyze{'parts_withrandomlist'}) eq 'ARRAY') { + my @currlist = @{$Apache::lonhomework::analyze{'parts_withrandomlist'}}; + if (!(grep(/^\Q$part\E$/,@currlist))) { + push(@{$Apache::lonhomework::analyze{'parts_withrandomlist'}},$part); + } + } else { + push(@{$Apache::lonhomework::analyze{'parts_withrandomlist'}},$part); + } + } + } for(0 .. $show) { $bodytext .= "$randomlist[ $idx_arr[$_] ]"; } @@ -1835,7 +1921,8 @@ sub start_problemtype { $result .=&Apache::edit::checked_arg('When used as type(s):','for', [ ['exam','Exam/Quiz Problem'], ['survey','Survey'], - ['problem','Homework Problem'] ] + ['problem','Homework Problem'], + ['practice','Practice Problem'] ] ,$token); $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { @@ -1868,17 +1955,23 @@ sub end_startouttext { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result=''; my $text=''; - if ($target eq 'edit') { + my $areaid = 'homework_edit_'.$Apache::lonxml::curdepth; $text=&Apache::lonxml::get_all_text("endouttext",$parser,$style); - $result.=&Apache::edit::start_table($token)."
'. - ''.&mt('Edit').' - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.'). -&Apache::loncommon::help_open_topic('Caching').' |
' +# .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.') +# .&Apache::loncommon::help_open_topic('Caching') +# .'
'; + $result.=&Apache::lontemplate::start_functionslist() + .&Apache::lontemplate::item_functionslist( + ''.&mt('Edit').'') + .&Apache::lontemplate::end_functionslist(); + } return $result; } @@ -1952,5 +2052,17 @@ sub end_simpleeditbutton { return ''; } +sub practice_problem_header { + return '