--- loncom/imspackages/imsprocessor.pm 2005/05/03 18:38:37 1.20
+++ loncom/imspackages/imsprocessor.pm 2005/07/13 21:21:01 1.26
@@ -24,6 +24,7 @@
package Apache::imsprocessor;
use Apache::lonnet;
+use Apache::loncleanup;
use LWP::UserAgent;
use HTTP::Request::Common;
use LONCAPA::Configuration;
@@ -2094,7 +2095,7 @@ sub parse_webct4_questionDB {
$$settings{$id}{$numid}{toltype} = $attr->{type};
}
if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_unit") {
- my $unitid = $attr->{ident};
+ $unitid = $attr->{ident};
%{$$settings{$id}{$numid}{$unitid}} = ();
push(@{$$settings{$id}{$numid}{units}},$unitid);
$$settings{$id}{$numid}{$unitid}{value} = $attr->{value};
@@ -2864,7 +2865,7 @@ sub write_webct4_questions {
}
if ($$settings{$id}{texttype} eq 'text/html') {
$$settings{$id}{text} = &HTML::Entities::decode($$settings{$id}{text});
- $$settings{$id}{text} = &Apache::lonxml::htmlclean($$settings{$id}{text});
+ $$settings{$id}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{text});
$$settings{$id}{text} =~ s#(]+)(/?>)#$1../../resfiles/$2 />#gi;
$$settings{$id}{text} =~ s#<([bh])r>#<$1r />#g;
# $$settings{$id}{text} =~ s#
#
#g;
@@ -2892,8 +2893,10 @@ sub write_webct4_questions {
$resourcedata{$symb.'randomize'} = 'yes';
$resourcedata{$symb.'maxfoils'} = 10;
if ($context eq 'CSTR') {
- $output = qq|
+ unless ($$settings{$id}{class} eq 'numerical') {
+ $output = qq|
|;
+ }
}
$$total{prob} ++;
if (exists($$settings{$id}{uri})) {
@@ -2954,7 +2957,7 @@ sub write_webct4_questions {
}
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') {
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text});
- $$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::lonxml::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text});
+ $$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text});
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(]+)>#$1../../resfiles/$2 />#gi;
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#?p>##g;
@@ -3028,7 +3031,7 @@ sub write_webct4_questions {
$$settings{$id}{$grp}{$answer_id}{text} = &HTML::Entities::decode($$settings{$id}{$grp}{$answer_id}{text});
$test_for_html = &test_for_html($$settings{$id}{$grp}{$answer_id}{text});
- $$settings{$id}{$grp}{$answer_id}{text} = &Apache::lonxml::chtmlclean($$settings{$id}{$grp}{$answer_id}{text});
+ $$settings{$id}{$grp}{$answer_id}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$grp}{$answer_id}{text});
$$settings{$id}{$grp}{$answer_id}{text} =~ s#(
-
+
|;
}
} else {
@@ -3091,7 +3094,7 @@ sub write_webct4_questions {
for (my $k=0; $k<@{$$allchoices{$id}}; $k++) {
if ($$settings{$id}{$$allchoices{$id}[$k]}{texttype} eq 'text/html') {
$$settings{$id}{$$allchoices{$id}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$$allchoices{$id}[$k]}{text});
- $$settings{$id}{$$allchoices{$id}[$k]}{text} = &Apache::lonxml::htmlclean($$settings{$id}{$$allchoices{$id}[$k]}{text});
+ $$settings{$id}{$$allchoices{$id}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$$allchoices{$id}[$k]}{text});
$$settings{$id}{$$allchoices{$id}[$k]}{text} =~ s#(
|;
foreach my $numid (@{$$settings{$id}{numids}}) {
my $formula = $$settings{$id}{$numid}{formula};
+ my $pattern = join('|',(sort (keys (%mathfns))));
+ $formula =~ s/($pattern)/\&$mathfns{$1}/g;
foreach my $var (keys %{$$settings{$id}{$numid}{vars}}) {
my $decnum = $$settings{$id}{$numid}{vars}{$var}{dec};
my $increment = '0.';
@@ -3266,9 +3292,7 @@ sub write_webct4_questions {
}
$increment .= '1';
}
- $formula =~ s/{($var)}/\$$1/g;
- $formula =~ s/ln\(?([^\)])\)?/ &log($1) /g;
- $formula =~ s/sqrt/\&sqrt/g;
+ $formula =~ s/{($var)}/(\$$1)/g;
$scriptblock .= qq|
\$$var=&random($$settings{$id}{$numid}{vars}{$var}{min},$$settings{$id}{$numid}{vars}{$var}{max},$increment);
|;
@@ -3278,7 +3302,7 @@ sub write_webct4_questions {
|;
if ($context eq 'CSTR') {
- $output = $scriptblock.$output;
+ $output = "\n".$scriptblock.$output;
my $ansformat = '';
my $sigfig = '0,15';
if ($$settings{$id}{$numid}{format} eq 'sig') {
@@ -3299,7 +3323,7 @@ sub write_webct4_questions {
}
my $unitentry = '';
if ($unit ne '') {
- $unitentry = 'unit='.$unit;
+ $unitentry = 'unit="'.$unit.'"';
}
$output .= qq|