WeBWorK Problems

Scientific Notation context issue

Scientific Notation context issue

by Carl Yao -
Number of replies: 4
Hi:

I love contextScientificNotation.pl, but it forces students to use 'x' instead of '*' to represent the multiplication symbol. How can I redefine it?

Thanks!

Carl Yao
In reply to Carl Yao

Re: Scientific Notation context issue

by Ryan Maccombs -
so what I would do (and there is probably a much better way) is download a copy of the file contextScientificNotation.pl

https://github.com/openwebwork/pg/blob/master/macros/contextScientificNotation.pl

and put it in your macros file in "File Manager"

then edit around line 143

$context->operators->add(
'x' => {precedence => 3, associativity => 'left', type => 'bin',
string => 'x', TeX => '\times ', perl => '*',
class => 'ScientificNotation::BOP::x'},

'*' => {precedence => 3, associativity => 'left', type => 'bin',
string => '*', TeX => '\times ', perl => '*',
class => 'ScientificNotation::BOP::x'},

'^' => {precedence => 7, associativity => 'right', type => 'bin',
string => '^', perl => '**',
class => 'ScientificNotation::BOP::power'},

'**'=> {precedence => 7, associativity => 'right', type => 'bin',
string => '^', perl => '**',
class => 'ScientificNotation::BOP::power'}
);

and see if that works

In reply to Carl Yao

Re: Scientific Notation context issue

by Davide Cervone -
While Ryan's solution would work, it would also mean that your problems would only work with your modified version of contextScientificNotation.pl, and so would be less portable.

An alternative would be to do:

loadMacros("contextScientificNotation.pl");

Context("ScientificNotation");
Context()->operators->add("*" => Context()->operators->get("x"));
which will add the definition of * to be the same as that of x.