## WeBWorK Problems

### Evaluate Multiline, Full Solution

by Chris Pinto -
Number of replies: 6

I teach high school science, and use WebWork extensively for Chemistry and Physics problems. My students have found it to be a valuable resource, but I would like to take it one step further. Currently, only a final answer is evaluated, but students in high school need to develop a good procedure for approaching problems that I would like to setup WebWork to evaluate (i.e. Givens, Unknowns, Formula, Substitution, and a Solution).

For instance, take a typical problem I might ask:

How much current passes through a $R ohm resistor that has a$V V potential difference across it?

Typical WebWork solution:
DOCUMENT();...  $R = random(50,1000,10);$V= random(2,10,0.1);  $I= NumberWithUnits("$V/$R", "amp");...BEGIN_TEXTHow much current passes through a$R ohm resistor that has a $V V potential difference across it?END_TEXTANS($I->cmp() );ENDDOCUMENT();

On paper, I would have my students answer as follows:

R = 220 ohmV = 5 VI = ?I = V/RI = 5/220I = 0.023 A

I would like to setup a multi-line response where they can enter that online and have it evaluated by the system (I don't foresee an issue doing most of the programming myself, but I would appreciate any guidance in how to approach the problem). I had the following in mind:

1. All variables used in a response must be defined/declared before use (the givens/unknown) - to me, this is basically a list - type answer. I would like to make it more flexible over time, but initially, I know how many lines should be givens/unknowns, and can simply split on the line break (and somehow evaluate lines 1 to 3 as a list). I want them to use specific variables - e.g. I for current, not allow them to make up their own variables.
2. check the equation - I can use ImplicitEquation for this
3. check the substitution - I don't need units here (but would like to accept them), I don't want a mathematically equivalent answer to be valid (i.e. I want the actual substitution in the right order, not the final answer)
4. final answer - I can use the normal answer evaluator for this
If done as 4 separate inputs, I don't see the above as being too difficult to evaluate. I would, however, like to do it as one input (basically to make it more 'realistic' with less prompting).

Problems:

1. Parsing - I have seen some references to multiline problems on the forums where the parsing creates an array. I don't think I would have too much difficulty with this.
2. Passing to the correct evaluator - I think I would start with 4 inputs initially, and then try to move to one input. The issue I would have is that I want to allow a little flexibility in the number of lines. Which somewhat implies determining what type of response is on each line if everything is in one input. For example, to account for the following:
1. some students might miss a step - I would like to be able to identify which step is missed and not just mark the entire problem incorrect. e.g. the following should say something like 'variables V and R used without being defined' (like a programming language)

I = V/RI = 5/220I = 0.023 A

2. some students might do some steps in multiple lines (especially a formula/substitution step) - e.g. someone might write:

R = 220 ohmV = 5 VI = ?V = I*RI = V/RI = 5/220I = 0.023 A

OR

R = 220 ohmV = 5 VI = ?V = I*R5 = I*2205/220 = II = 0.023 A

3. The equation like structure is something I haven't used WebWork to grade previously (e.g. a normal answer would be 0.023A, not I = 0.023A) - but I don't expect this is that difficult to resolve.

I don't think it is an easy problem - or that it has an easy solution - but it is one I would like to work on over the next few months, and any advice on tackling it would be much appreciated.

### Re: Evaluate Multiline, Full Solution

by Alex Jordan -
I have some comments that might help.
• If the equations you are looking for are all like I=V/R, in that the left side will always consist of one variable, I would recommend looking at parserAssignment.pl rather than using an ImplicitEquation. ImplicitEquations require lots of care, especially (in my experience) if division is part of the equation.

• We have developed a macro file we call bizarroDivision.pl (with lots of help from David Cervone) which may help with your desire to have "I=5/220".

First, let's just talk about "5/220". With bizarroDivision, the student's answer for"5/220" would first be checked as a Math Object Formula. If it doesn't even match that, some kind of appropriate feedback can be sent to the student. If it does, the checker moves on.

At this point, the checker changes the meaning of whichever of the arithmetic symbols +, -, *, /, and ^ you would like it to change. It changes them in a way so that if you changed them all, you have a system where all the rules of arithmetic still hold. But these bizarro arithmetic symbols do different things than the usual symbols do. So the correct answer can be "5/220", but under bizarro division, that evaluates to a different decimal than 0.0227... In this way the checker detects if the form of the expression is the same as what the problem author used.

bizarroDivision.pl is attached. It's not perfect. One issue we have noticed has to do with test points. Domains of functions can be different under the two arithmetic systems, so attempts to control the test points for one system can sometimes cause trouble with the answer checking in the other system. To use bizarroArithmetic, read the commented documentation.

• To move on to "I=5/220" is possible, but complicated. It involves using parserAssignment.pl and sort of splicing it with bizarroArithmetic. You would break down the Formula object "I=5/220" into its left and right parts, and then customize a bizarroArithmetic checker on the right part after doing the usual check on the left part.

Units is a whole different issue though, and this approach and the current Units module are not well-suited to each other.

### Re: Evaluate Multiline, Full Solution

by Chris Pinto -
Firstly thank you for the quick and detailed response.
The equations do get a bit more complex than I = V / R.For instance:
• 1/f = 1 / do + 1 / di
• n1 sin(i) = n2 sin(R)

For these equations, I really am looking for two things:

1. they have the correct variables and
2. their equation equals the original equation(i.e.correct equation selected, and any rearrangement is mathematically correct)

bizzaroDivision.pl looks great - that was definitely a step I was unsure how to approach, and I think I can come up with something from your recommendations.

The final answer should always be a single variable assignment - so parserAssignment.pl will be perfect for that.

As a more complex example (i.e. a grade 10 question), I commonly ask:

An object is placed 15cm away from a concave mirror which has a focal length of 10cm.How far from the mirror does the image form?

Breaking down the answer I would want:

1. Givens / Unknowns(input field 1, for now) :

do = 15cm
f = 10cm
di = ?

I can create a list and use StringsInContext and parserAssignment.pl to define my three variables.

2. Formula (input field 2, for now):

1 / di = 1 / f - 1 / do

I would also want to accept

di = 1/ (1 / f - 1 / do)
or
1 / f = 1 / di + 1 / do

I don't think that bizzaroArithmetic would work for this (since the left side can change, and I am looking for mathematical equality not a specific response). implicitEquation might be my only other option here. The equations used are typically fairly easy - but division is common and the equations almost always have 3 or more variables.

3. Substitution (input field 3, for now):

1 / di = 1 / 10 - 1 / 15

I think for this I need to generate the answer in response to the student's answer (in the vein of a MultiPart question). Essentially, the answer here should be the formula from the last line of input field 3, with the numbers filled in for the known variables. Assuming the left side has the unknown, I can use bizzaroArithmetic to evaluate the right side.

4. Solve (input field 4, for now):

1 / di = 1 / 30

This could be many steps, or just one, or omitted - but I basically want to just verify that there are no math errors (so the statement on each line should be mathematically equal to the one in the substitution field).

5. Solution (input field 5, for now):

di = 30 cm

Final answer - I think parserAssignment together with numberWithUnits would work here.

It is always harder than expected to go from the basic ideas to a working product - but so far, I think this looks promising and doable (about on par with getting WebWork to balance a chemical equation). Once again, thanks for the comments.