0 votes

Here is my program:
https://www.guidedtrack.com/programs/bxnyn3y/run

I want to ask a checkbox question and give feedback on which answers are correct or false. I've changed the question to a simple example. I want to ask my physics students questions and give explain to them later on why their chosen answers are correct or wrong.
This looks a bit convoluted, because I usually have very long question and feedback strings and don't want to copy paste them all over the code in case I change it later on.

Also, I want to use this program for different questions with different amounts of possible answers. That's why I have the *if: A2 line. This way, I can add more answers and still use the program even for questions with fewer answer options.

When I run the program, I get the feedback for the second answer option only if I also clicked the first one. If I only click the second one, I don't even get the "next question" button.

Why? Thank you in advance for the help! In addition: Sorry if I look like a complete coding fool to you, I'm not a programmer and very aware that there are probably much less convoluted ways of coding this.

These are my lines:

-- the question
>> Q = "What is 1+1"

-- possible answers
>> A1 = "2"
>> A2 = "42"
-- feedback for the chosen answers
>> R1 = "Yes"
>> R2 = "That's the answer to a different question."
>> answers_points = [1,-1]

*question: {Q}

*type: checkbox
{A1}
{A2}
*save: answerschosen

{Q}

*if: A1

*component
	*if: A1 in answerschosen
		*component 
			Your answer:
			*component
				{A1}
			*component
				{R1}
		>> points = points + answers_points[1]

*if: A2

*component
	*if: A2 in answerschosen
		*component 
			Your answer:
			*component
				{A2}
			*component
				{R2}
		>> points = points + answers_points[2]

*button: Next question

by (270 points)
edited by

1 Answer

0 votes

Hello! I'm not sure, but I think the reason you aren't getting to the feedback for A2 is to do with the way the *components are set out.

With the first component, I think GuidedTrack is being told to display a component anyway (regardless of which answer was chosen), then within that component, you've got the conditional statement (if: A1 in answerschosen) followed by the content you want displayed. If A1 wasn't chosen, though, then that statement won't apply, so I think the program gets stuck displaying an empty component - and I think that's why it doesn't progress to the next part of the code (so it doesn't display the feedback for A2).

I think it might help if you slightly change the ordering of the code, such that the "if" statements are before the component lines. I've put an example of how this could look here: https://www.guidedtrack.com/programs/15598/edit

Hope that helps! (By the way, I think it's absolutely awesome that you're creating interactive programs/quizzes for your physics students! Your students are lucky to have such a cool teacher.)

by (260 points)

Yes, that was it! Thank you so much for the swift response!

Awesome! Thank you - glad I could help! :)

Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users