# Template for giving students a 2nd attempt with multiple choice, checkbox, and table questions; practice with h horizonal shift in sin and cos trig equations

Update: this has been fixed! Thank you.
Hi,

In this activity on slide 1, in the right hand column I currently have created 1 working question (question “1.” in the multiple choice buttons, labeled “gp1tab1” and “gp1tab2” in the tables). For each question, students should be able to submit an answer in the table titled gp#tab1 by pressing a button, then, their answers are copied to the table titled gp#tab2 and they are given feedback on the 2nd attempt. Their score on their 1st attempt is tracked in the note labeled “track” on the left column near the bottom and the score is calculated in the hidden graph labeled “sc” in the left column.

I copied the same code that worked for question 1 (in the components gp1tab1 and gp1tab2) to question 2 in the tables labeled “gp2tab1” and “gp2tab2”.

The component “gp2tab1” is working correctly because, when I go to the “preview” of the activity and click on the right side question “2.” in the multiple choice buttons and I press the “button” to submit the correct answer of h=1.5 or h=-4.5, the displayed score on the bottom left hand side of the slide in the “preview” of the activity says “1 out of 14 correct on the 1st attempt.”

However, the issue comes on the 2nd attempt for question 2 (in gp2tab2), where, after pressing the button, the student should see a “checkmark” in the component “gp2tab2” row 1 column 1 where the student writes the “h” value for a sin graph. Although this value is marked as correct in gp2tab1 row 1 column 1, the same code used in gp2tab2 row 1 column 1 is marking the correct answer as incorrect.

The particular variable at issue in gp2tab2 is:
`midlinehsin4=numericValue("\${orig.script.horizontalsinright1}")`

In the orig note component:
`horizontalsinright1="\${numericValue("\${horizontalcosright}-((0.25)(\${period}))")}"`

In the variable horizontalsinright1, I am taking the 1st horizontal shift to the right of the maximum y-value of a cos graph (called the variable `horizontalcosright`) and subtracting 1/4th of the `period` in order to get the 1st horizontal shift to the right of the midline y-value of a sin graph. I believe this is mathematically correct for a sin graph.

In the activity, the variable “`s`” denotes whether the graph should be treated as sin or cos. If `s=1`, the graph should be treated as sin. In table gp2tab2, under the “`checking1`” variable, I am giving the student 1 point in the “track” note, which tells them how many points they got correct on the 1st attempt if, when the graph is sin (meaning `s=1`), then they provide the correct horizontal shift for a sin graph.

The checking1 variable is this:

``````checking1=
when checkz1 1
when checkz2  1
when checkz3  1
when checkz4  1
when checkz5  1
when checkz6  1
when che2ckz1  1
when che2ckz2  1
when che2ckz3  1
when che2ckz4  1
when che2ckz5  1
when che2ckz6  1
when che3ckz1  1
when che3ckz2  1
when che3ckz3  1
when che3ckz4  1
when che3ckz5  1
when che3ckz6  1
when che4ckz1  1
when che4ckz2  1
when che4ckz3  1
when che4ckz4  1
when che4ckz5  1
when che4ckz6  1
otherwise 0
``````

In particular, under checking1, the variable that may be faulty is:

`che4ckz5=s=1 and (parseEquation(this.cellContent(1,1)).lhs="\${midlinevar}" and simpleFunction("\abs(\${parseEquation(this.cellContent(1,1)).lhs}-(\${parseEquation(this.cellContent(1,1)).rhs}))","\${midlinevar}").evaluateAt(midlinehsin4)<grace)`
`midlinevar="h"`

`grace=0.1`

`s=1`

(The above variable is meant to accept the answer “h=1.5” for a “sin” graph: meaning, for a sin graph, when the variable `s=1`, then the horizontal shift of the midline of the graph to the right of the y-axis (as denoted by “midlinehsin4”) is 1.5, as can be seen on the graph component “gp2pic” that appears when gp2tab2 is shown).

Also in the graph g2pic which appears for this question in the left hand column, the x-coordinate of that “point” (1.5, midline), as denoted by:

`number("a_4"): numericValue("\${ok1.script.horizontalsinright1}")`

is correctly labeled using the variable “`horizontalcosright`” in gp2tab1 which is the same as “`midlinehsin4`” in gp2tab2.

`che4ckz6=s=1 and (simpleFunction("\abs(\${parseEquation(this.cellContent(1,1)).lhs}-(\${parseEquation(this.cellContent(1,1)).rhs}))","\${midlinevar}").evaluateAt(midlinehsin4)<grace and parseEquation(this.cellContent(1,1)).rhs="\${midlinevar}")`

(The above variable is meant to accept the answer “1.5=h” for a “sin” graph)

Is there a reason that this above code for gp2tab2 is not working, even though it works for gp2tab1?

If you don’t get a response here it might be because your code is hard to read with the formatting as it is.

Can I suggest using the icons to edit your post so that code looks more like this (using backticks)
`grace = 0.1`

or using triple backticks if you have multiple lines of code

``````checking1 = when checkz1 1
when checkz2 1
otherwise 4
``````

Update: this has been fixed! Thank you so much.
That explains why I kept getting a yellow highlighter over some code- thanks.

I found the error: the issue was that the variable
`midlinehsin4=numericValue("\${orig.script.horizontalsinright1}")`

was copied from the “orig” note component using the above code.

However, that variable should have been copied from the “gp2tab1” component using the current code I edited:
`midlinehsin4=numericValue("\${gp1tab1.script.horizontalsinright1}")`

where it was already defined that `gp1tab1=gp2tab1`

Thanks so much!

1 Like