Check the state of a checkbox in a quiz

Hi everyone, I have checked the forums prior to posting and have not been able to find an answer for this one.


I currently have Lectora 11 and have setup a test at the end of the course. The client has requested that we provide feedback based on the number of correct answers. So basically, if we have a multiple correct answer question, if there are 3 correct answers, the user can only move forward if 3 answers have been selected. They will also see feedback that says you must select 3 correct answers to continue.


I created a variable to detect the correct number of choices selected. So when the user clicks on a checkbox, it adds 1 to the variable (great!). The problem is that when they uncheck the checkbox, it also adds one. I need it to subtract 1.


Since it is in a test, I have not been able to assign a variable to individual checkboxes. Does anyone have any ideas on how to accomplish what I need?


Basically I need to add 1 when the checkbox is selected and subtract 1 when the checkbox is unchecked.


Any help is greatly appreciated. I have been researching this issue for a couple of weeks now and have not found a suitable solution.


Thanks in advance for your help!

Discussion (4)

I can always count on you answering quickly. I was hoping that there was something I missed so I wouldn't have to create a crazy workaround especially since I have about 20 questions. I appreciate your help. I'll give it a try and see what happens. If by any chance I find an easier way, I will post it here. Hopefully it will help someone else. I may have to suggest a feature to Lectora where it checks for Checked/Unchecked instead of State Change for checkboxes. That would make our lives so much easier :D


Thanks again for your help!

You can do that fairly easily with a form radio button or check box but then you have to write other logic to check for correctness.

Instead of using a separate question to check for you can use a variable to store which checkboxes are checked. Still quite a bit of effort for each question.


1. Create a variable to save which checkboxes are checked, e.g. q1_checked


2. Add an action to each checkbox


For the first checkbox

On: Change / Select

Action: Modify variable

Target: q1_checked

Value: a

Type: Add

Condition: Only if q1_checked does not contain "a"

Else:

Action: Modify variable

Target: q1_checked

Value: a

Type: subtract


Add similar actions to each of your checkboxes only changing the value

b for the second checkbox, c for the third etc.


So in the beginning the first checkbox is unchecked and q1_checked does not contain "a". If it's checked "a" is added. If it's then unchecked again, q1_checked contains "a" so "a" is subtracted. If the the first checkbox is checked, q1_checked contains "a" if it's unchecked it does not contain "a".


3. Create another variable to calculate the number of checked checkboxes, e.g. q1_number


4. Create an action group


a. Reset variable

Action: Modify variable

Target: q1_number

Set equal to "0"


b. One action per checkbox, for the first

Action: Modify variable

Target: q1_number

Value: 1

Type: Add

Condition: Only if q1_checked contains "a"


Add similar actions for each checkbox only changing the value in the condition

contains "b" for the second

contains "c" for the third

etc.


5. Add a second action to each checkbox

On: Select / Change

Action: Run action group

Target: Above group


6. Add an action on page level to reset both variables

On: Show

Action: Modify variable

Target: q1_checked

Set as empty


On: Show

Action: Modify variable

Target: q1_number

Set equal to "0"


Tim

Ok, this is a bit tricky. Lectora does not have a real easy to do this. This is all I can think of.


It works if You are not using one of the standard Lectora Results pages where the questions and correct/incorrect answers are being shown.

  1. Code your question with A, B, C, D, ... as the answers in Lectora. Then hide these text boxes.
  2. Put the real answer choices in one text box and line the check boxes up with them.
  3. Create a group of actions like this:

    1. Set a counter variable (say _count) to 0.
    2. Follow that with an action that adds 1 to the counter if the Question variable contains A. (first check box)
    3. Another action of it contains a B.
    4. Repeat for each check box.
    5. Finally you have your correct count and now run actions depending on that count if needed.

  4. On each check box, add an action to Run Action Group and specify that action group.

Discussions have been disabled for this post