STACK does syntax checking of the student answer and also checks that the answer is of the correct type. Is it also possible to have STACK test that the student's answer depends on all the variables it should depend on?

### Testing that student answer depends on given variables

Number of replies: 4### Re: Testing that student answer depends on given variables

It is possible to check this and give specific feedback as part of the PRT, but it is not possible to do this as validation. Possibly intersting idea. I will let Chris comment further.

### Re: Testing that student answer depends on given variables

Doing it as part of the potential response tree is of course quite adequate. However, how do I code the check. I know of the predicate function polynomialp(ans1,[p]) to check if the answer ans1 is a polynomial in the variable p, but I don't know how to check simply whether the variable p appears in the answer.

### Re: Testing that student answer depends on given variables

Is there a method that extracts the set of variables from an expression? I don't know. You need Chris. If I really had to work this out, I would look to see how he implemented the check for a constant of integration in that answer test.

### Re: Testing that student answer depends on given variables

Gustav, Good question.

The general principal is that validation should not depend (too much) no the actual answer, and should mostly be about syntax issues. That way validation doesn't vary (too much) from question to question. In my view, interface & "validity" should be a reasonably stable concept from the student's point of view.

There is a "same type" concept, which does of course depend on the actual answer, but this was mostly to ensure system stability. If the PRT expects an *equation* y=m*x+c and the student gives an *expression* e.g. m*x=c, then when the PRT take the right hand side, you get an error. Lots of assumptions about student's responses, and problems arrise from false assumptions, can be dealt with by having type at the validation level.

Ideally, we'd have a more subtle and sophisticated concept of type, e.g. %poly(Z; x), or %poly(Q; x,a), etc. This could then be used selectively to reject some things which can't possibly be correct. I think this might be difficult to author, and hard for students to understand.

To actually answer your question, have a look at Maxima's listofvars() function.

There are a couple of ways of using listofvars(ex). If you'd just like to know if a single variable appears in an expression use

member(p,listofvars(ans1));

To check if it depends on more than one variable in a single step, use sets. I'd do

AlgEquiv test on setify(listofvars(ans1)) with {x,a,b,c}.

for example, where the set {x,a,b,c} is the set of variables you want.

Chris