Creating a Quiz App

How can we get all of the incorrect answer buttons to go to another question rather than back to allowing user to just guess again? Trying to find the most efficient way.

https://studio.code.org/projects/applab/JviW5pAKxfmWjahfNDPEd63gisDBg792psQBWV-BecI

Howdy @jcostanza,

Well for starters this is very disorganized we should remove all the win screens since they all serve the same purpose, the second nitpick is the naming scheme you came up with for the buttons which took more effort to learn how the program works rather than taking time to give them appropriate names

So what do we do first?

Were going to remove all the correct screens from this project except the “YouAreCorrect” tag on it, this will make your life way less stressful instead of keeping track of all the win screens

What happens to the screens that were previously used?

Were going to convert all those screen to the “YouAreCorrect” id that way we won’t get all the warning messages that would come from set screen along with getting rid of all the buttons involved with those win screens

Now for a proper solution

We’ll use use a variable to keep track of the last current question answered and move it to the next screen regardless of weather you got it wrong or right
Here’s my Link: https://studio.code.org/projects/applab/Fbp2bB034bfo8apoR1K2h3ZOjOWkZ8kuPS67JMnNBeA/view to get your program working as intended though you’ll probably need to include the rest

Hope this helps!

Thanks! I agree. This was the work of one of my students. I stress the importance of descriptive element ids but sometimes they don’t get it until they start trying to code!

Can you send me a screenshot of how you would create and code the variables for this to work properly? Do we need more than just a variable to bring the user to the next question? Thanks for any help you can offer.

Oh, sorry about that the link i shared earlier apparently didn’t link the proper project, but i should also show a basic demo of how it works, you’ll need to include this for both screens though this is quite small I’d recommend using a tiny function I’ll probably just be showing the button code with it though since that basically only pertains to your main problem

var currentQuestion = 1; // screen starts at 1
onEvent("Next1", "click", nextQuestion);
onEvent("button5", "click", nextQuestion)
// this supplies the current question and + 1 it
function nextQuestion() {
// also yes ++ is legal before a variable and can save you a line
// basically like currentQuestion += 1;
setScreen("screen" + ++currentQuestion);
}

I’ve updated my link too so it should hopefully show my project now if you do want a working one to compare against, best of luck!