# Help with CL code to respond to multiple answers

Hi , am doing a set of questions which self mark , give a correct or incorrect response to the student and then total up and provide a summary.

So far so good.

My code for a slid which has a single answer is:

Note code:(note1)
content: “{message} {feedback}”

message = “What is the 9th multiple of 15?”

feedback = when ans1.submitted and ans1.numericValue=135 “\n\n\n✅Good work ! !”
otherwise “”

Maths Answer Box code: - (ans1)
disableEvaluation: true

check1 = when this.numericValue=135 1 otherwise 0
correct: check1=1

However I am trying to do the same sort of thing for a slide that will have multiple answer , in this case list the factors of 49 in ascending order.

I am using a table instead for the student to input the answers and want the feedback to be based on ALL the answers being correct - however I can’t seem to get this to work. I am struggling with getting the feedback code in the note to work and also how to give check2(the variable that I use to total up the marks) a value of 1 when all items in the table are correct.

Here is my code:

What should the equivalent feedback code in order to work?

Here is my code for the table:
t=table2
cellContent(1,2): when t.cellNumericValue(1,1)=1 “ ” OTHERWISE “N”
cellContent(2,2): when t.cellNumericValue(2,1)=7 “ ” OTHERWISE “N”
cellContent(3,2): when t.cellNumericValue(3,1)=49 “ ” OTHERWISE “N”

isCorrect = t.cellNumericValue(1,1)=1 and t.cellNumericValue(2,1)=7 and t.cellNumericValue(3,1)=49
#check2 = isCorrect 1 otherwise 0
correct: isCorrect

Sorted it. Heres my code for the table:

t=table2
cellContent(1,2): when t.cellNumericValue(1,1)=1 “ ” OTHERWISE “N”
cellContent(2,2): when t.cellNumericValue(2,1)=7 “ ” OTHERWISE “N”
cellContent(3,2): when t.cellNumericValue(3,1)=49 “ ” OTHERWISE “N”

isCorrect = t.cellNumericValue(1,1)=1 and t.cellNumericValue(2,1)=7 and t.cellNumericValue(3,1)=49

correct: isCorrect

check2= when isCorrect 1 otherwise 0

and heres the Note feedback code:

content: “{message} {feedback}”

message = “List the factors of 49 in ascending order”

feedback = when table2.script.check2=1 “\n\n\n✅Good work ! !”
otherwise “”

This line of code can be deleted as it is the the same thing as isCorrect: `check2= when isCorrect 1 otherwise 0`

Then for the feedback variable, you can use this instead:

``````feedback = when table2.script.isCorrect “\n\n\n✅Good work ! !”
otherwise “”
``````

You could include a button press as well, if you’d like, otherwise the feedback will always be displayed.

1 Like

Just something for the future. Whenever you’re checking some kind of correctness multiple times, it can clean things up a little to make a variable for it. Makes debugging or changing values a little easier:

``````t=table2

c1= t.cellNumericValue(1,1)=1
c2= t.cellNumericValue(2,1)=7
c3= t.cellNumericValue(3,1)=49

cellContent(1,2): when c1 "✅" OTHERWISE “❌”
cellContent(2,2): when c2 "✅" OTHERWISE “❌”
cellContent(3,2): when c3 "✅" OTHERWISE “❌”

isCorrect = c1 and c2 and c3

correct: isCorrect
``````
2 Likes

Modular code best code.

1 Like

Hi,could you explain or give me some link to look at . Thanks

Not sure who you’re responding to. I think @SandiG was referring to my code. Also, you can share your own activity link and many times people are willing to edit a copy of your activity directly instead of needing to copy paste typed examples.

My example would just replace everything up to your correct sink from your original post. You can replace “check2=1” with “isCorrect” in your feedback code.

1 Like

Thanks. Heres the activity (hope I’ve shared it correctly)

I’m trying to get the first slide to act as a summary so the teacher can quickly see what topics are causing issues. Each topic has 2 queations so I’ve put 2 columns in which show this for the questions.

I would like there to be an N in the cells if no attempt has been made on that question. Is this possible?

I did consider giving subtotals for each topic but couldn’t get that to work.

Hi thanks.

I’m using check2 as a type of global variable that I can call on in a results page on slide 1.

To my knowledge, global variables aren’t a thing for CL. All variables are part of their individual components i.e. `component1.script.var1`.

I don’t think there’s a way to initialize every cell without specifying each in turn and I don’t know of a way to do loops with CL.

So my solution was to add another possible state for each cell

``````cellContent(1,3): when ans1.script.check1=1  "✅" when ans1.submitCount=0 "N" OTHERWISE "❌"
``````
1 Like

I think you want your first slide to function like an amped up version of slide 12 in this activity:

Note that it works pretty much like SandiG suggested - individual checks.

For checking whether students have made an attempt: for Q1, for example, you could see if the math input is blank AND if the submit count is 0. That won’t catch if they wrote something, erased it, and never hit submit, but it’ll catch every other case, I think.

1 Like

Thanks , I’ve used that and it works well. However on eof the slides has a table where the student has to list the factors of a number. I can get the summary table to show a tick or a cross depending onthe students answer but as there is not submit button I can’t get it to display an N if the student hasn’t attempted it. Is there someway of me checking on the slide whether the cell has not had any data entered and returning a value I can use inthe summary table?

This is the code I have on slide 2 which checks the table cells:

t=table2

c1= t.cellNumericValue(1,1)=1
c2= t.cellNumericValue(2,1)=5
c3= t.cellNumericValue(3,1)=25

cellContent(1,2): when c1 “ ” OTHERWISE “N”
cellContent(2,2): when c2 “ ” OTHERWISE “N”
cellContent(3,2): when c3 “ ” OTHERWISE “N”

check2 = when c1 and c2 and c3 1 otherwise 0

correct: check2=1

This is the code on the summary table whch works when I am using a maths answer box and submit button:

cellContent(1,3): when ans1.script.check1=1 “ ” when ans1.submitCount=0 “N” OTHERWISE “ cellContent(1,4): when table2.script.check2=1 “ ” when table2.submitCount=0 “N” OTHERWISE “ cellContent(2,3): when ans3.script.check3=1 “ ” when ans3.submitCount=0 “N” OTHERWISE “ cellContent(2,4): when ans4.script.check4=1 “ ” when ans4.submitCount=0 “N” OTHERWISE “ Maybe the best you can do for that is isBlank:

isBlank documentation

Something like this, perhaps?

``````cellContent(1,2): when not(isBlank(t.cellContent(1,1)) and not(c1) "Attempted"
``````

I think this is your best bet @tarnold. Though I think as written, that code would prevent students from entering anything? CL locks cells that have their content specified @Aethir, so wouldn’t that overwrite the student value when they enter it?

I would create a note component and put a checksum variable in there that displays a check when the whole table is correct to your specifications.

Here’s an example of what I mean from one of my activities earlier this week. Answers are specified in the table CL along with overall screen correctness, but answers are referenced and displayed by the notes with and .

1 Like

If you’re wanting “N/A” or something instead of a  before they attempt a question, I usually use this for a table:

``````cellContent(1,2): when isBlank(cellContent(1,1)) or cellHasFocus(1,1) "N/A"
when c1 "✅"
otherwise "❌"
``````
3 Likes