[LON-CAPA-cvs] cvs: loncom /imspackages imsprocessor.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 13 Jul 2005 19:56:39 -0000
raeburn Wed Jul 13 15:56:39 2005 EDT
Modified files:
/loncom/imspackages imsprocessor.pm
Log:
Now converts all WebCT CE functions, except sum(), to LON-CAPA equivalents.
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.23 loncom/imspackages/imsprocessor.pm:1.24
--- loncom/imspackages/imsprocessor.pm:1.23 Wed Jul 13 13:42:53 2005
+++ loncom/imspackages/imsprocessor.pm Wed Jul 13 15:56:37 2005
@@ -3251,16 +3251,34 @@
}
}
} elsif ($$settings{$id}{class} eq 'numerical') {
+ my %mathfns = (
+ 'abs' => 'abs',
+ 'acos' => 'acos',
+ 'asin' => 'asin',
+ 'atan' => 'atan',
+ 'ceil' => 'ceil',
+ 'cos' => 'cos',
+ 'exp' => 'exp',
+ 'fact' => 'factorial',
+ 'floor' => 'floor',
+ 'int' => 'int',
+ 'ln' => 'log',
+ 'log' => 'log',
+ 'max' => 'max',
+ 'min' => 'min',
+ 'round' => 'roundto',
+ 'sin' => 'sin',
+ 'sqrt' => 'sqrt',
+ 'tan' => 'tan',
+ );
+
my $scriptblock = qq|
<script type="loncapa/perl">
|;
foreach my $numid (@{$$settings{$id}{numids}}) {
my $formula = $$settings{$id}{$numid}{formula};
- $formula =~ s/ln/\&log/g;
- $formula =~ s/sqrt/\&sqrt/g;
- $formula =~ s/sin/\&sin/g;
- $formula =~ s/cos/\&cos/g;
- $formula =~ s/exp/\&exp/g;
+ 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.';