# Two CL questions from a newbie!

First question - I tried to make an ordered list screen and used some code for checking that I found. My issue is that I’m not sure how to make the items to be ordered show up randomly. Whenever I preview the screen, the list is already in the correct order. What am I missing?

Second question - I want to give feedback (right/wrong) for a factored expression. Is there a way to account for the order of the factors or do I have to put in all possible options?

1. The three dots menu at the upper right has checkboxes for using your order as the answer key and randomizing.

2. A combination of simpleFunction().evaluateAt() and countNumberUsage is the most stable way to check. If you’re using latex matching, you’d need to give all possible options.

Thank you!!! I’m feeling a bit dumb about that first one Here’s an example:

Looking for an answer `(2x-3)(x+2)(x-1)`

``````input=inputName.latex
f=simpleFunction(input)
eval=f.evaluateAt(-2)=0 and f.evaluateAt(1)=0 and f.evaluateAt(1.5)=0
counts=countNumberUsage(input,2)=2 and countNumberUsage(input,3)=1
and countNumberUsage(input,1)=1
check= eval and counts
correct: check
``````

`eval` checks that student input evaluates to what’s expected for a variety of values. I just chose the roots because it was easiest to calculate, but you could use any values.

`counts` checks the occurrence of each number expected in the answer. Ignore negatives when using `countNumberUsage`. Evaluating should cover any ambiguity.

Note `eval` and `counts` could be combined into the variable check. I just have them for explanation purposes.

Thank you! I want to show a “You got it!” or “Oops. Try again!” message. This is the CL I used on a different screen, but it doesn’t seem to work with this one. (My input is called exp9)

content:
when exp9.submitted and exp9.script.correct “You got it!”
when exp9.submitted “Oops Try again!”
otherwise “”

Can you provide the code for the `correct` variable that you are using for that input? That might be what’s causing the issue.

The reason @cwinske is asking is that you can’t access the correct sink (i.e. `correct:`), but you could access a correct variable (i.e. `correct=`). This is the reason in my sample code I use a variable `check` so it’s not confused with the sink. If you used my code, change `correct` to `check` in your `content` code and it should work.

`.script` is used to access variables in other components, otherwise (if you’re able to) you use a source like `.pressCount` or `.latex`

I am super grateful for your help but I’m still not making it work.

The question is asking students to factor and the answer should be (2x+3)(2x-3)(x+2), but allow them to be in any order.

Here is the code I have in my math input box:

input=exp9.latex

f=simpleFunction(input)
eval=f.evaluateAt(-1.5)=0 and f.evaluateAt(1.5)=0 and f.evaluateAt(-2)=0
counts=countNumberUsage(input,1.5)=2 and countNumberUsage(input,2)=1
check= eval and counts

correct: check

And here is the code I have in a note:

content:
when exp9.submitted and exp9.script.check “\nYou got it!”
when exp9.submitted “\Oops! Try again. You can always ask for help!”
otherwise " "

The problem looks like it’s in the `counts` variable. Try this instead:

``````counts=countNumberUsage(input,3)=2 and countNumberUsage(input,2)=3
``````

countNumberUsage will count all the numbers that are typed in the math input by students. Since the student will never type 1.5 for the correct answer, the correct answer will never be marked as intended.

1 Like

Thank you!!! I was not familiar with the countNumberUsage, now I am! 1 Like