Need specific help on a multiple-choice quiz

213 views
Skip to first unread message

chris.car...@gmail.com

unread,
May 31, 2014, 6:57:31 PM5/31/14
to mitappinv...@googlegroups.com
I am creating a multiple-choice quiz and I have followed this tutorial:(http://puravidaapps.com/quiz.php).
However there are a few things I need to change.

1. My first screen is a title screen and after pressing start, my buttons and labels appear with none of the questions and answers, just the default text. If I tap one of the buttons, then the questions and answers appear properly. How do I make sure this blank feature screen doesn't appear?

2. I am planning on implementing a lives counter (starting with 3, wrong answers -1 life, 0 means back to title screen). Every time I press any button, the next question appears which is what I want but I just want to -1 life whenever a wrong answer is pressed as well. How do I connect any wrong answers with this proposed counter?

I may need more help on some other things once I tackle this issues. 
 

 
Nutrission Impossible Screen 2 Blank Features.png
Nutrission Impossible Title Screen.jpg

SteveJG

unread,
May 31, 2014, 8:54:53 PM5/31/14
to
The answer depends.   Are these two separate screens?    Is ..Blank Screen1 and the second image the second screen?

If you do not want the Blank screen to appear, you might try:

1) you could, in screen1.initialize put code to  open Screen2.     Use the Control block  open another screen screenName  Screen2 .    Not sure how that would look but it should make the screen2 come up almost first.

2) you could use Scotts screen switching routine (search for the forum discussions on this, there are plenty recent conversations) to have the contents of the present screen1 become screen2.    However, be aware,
Screen1 always loads first.

3) you could temporarily make ALL the controls on Screen1    invisible.       set Label1.Visible to false etc.   for all the items; however, when you call the screen with the real question info, you have to return them to visible...that is Label1.Visible to true etc.   Put another button with an image to press to start on this form, with that button set to visible, and have it do what is done in #1 and call Screen2 and at the same time to set that splash button to invisible.

Lots of possibilities.

Regarding counter.... earlier, you were give some advice.  What did you try?

so, you will probably set the 'counting' .. accounting routine at the red asterisk.     Something like if  get youranswer = get correct answer then add one to the counter
                                                                                                                                                else   counter subtracts one.    Use the Math blocks

                                          youranswer = youranswer + 1       or youranswer = youranswer -1

Try some blocks.   You will need a global variable ... perhaps   global LivesCounter set initially to 0.  

Then you probably want to display this somewhere:   possibly label1.text = LivesCounter  ??




Best of luck.
Regards,
Steve

chris.car...@gmail.com

unread,
May 31, 2014, 10:50:34 PM5/31/14
to mitappinv...@googlegroups.com
For now, I'm just focusing on the screen issue. I tried adding a start button on screen 2 initialisation with everything else invisible. Once I press the start button I set everything else back to visible and the same issue keeps happening. I don't know what to do. Both of those image attachments are separate screens. The title screen is Screen1 and the screen with the 4 green buttons is Screen 2. Opening Screen2 on Screen1 initialisation doesn't work either.

phantomfoot

unread,
Jun 1, 2014, 2:17:14 AM6/1/14
to mitappinv...@googlegroups.com
When you press Start in Screen 1, presumably you then openAnotherScreen(Screen2)?

If so, then following Taifun's example, in Screen2.initialize you need to call the procedure 'nextQuestion', as this is where the labels and button texts get populated with the correct text.

SteveJG

unread,
Jun 1, 2014, 12:22:46 PM6/1/14
to mitappinv...@googlegroups.com
Steve's suggestion (the other Steve...Phantomfoot) might be your solution.    If that does not, read this article about changing screens ...   https://groups.google.com/forum/#!category-topic/mitappinventortest/CdHy4_2M8lw


SteveJG

unread,
Jun 1, 2014, 12:58:47 PM6/1/14
to mitappinv...@googlegroups.com
It is very difficult to get into someone else's code... this could be part of your current problem:


chris.car...@gmail.com

unread,
Jun 1, 2014, 1:13:15 PM6/1/14
to mitappinv...@googlegroups.com
I tried removing the text on each button to see if that would change anything but the same issue is still happening. My answers still don't appear. The question text does but not my answers.

Stephen Zipprich

unread,
Jun 1, 2014, 1:31:32 PM6/1/14
to mitappinv...@googlegroups.com
Can you post a picture of your blocks so we can see how you've setup your code?

SteveJG

unread,
Jun 1, 2014, 2:17:34 PM6/1/14
to
The problem may be what you name each button control Chris... look at your names, look at Taifun's names.    He is using the button name in the list, do you use your button NAMES the same way (the text the Control is called)?

chris.car...@gmail.com

unread,
Jun 1, 2014, 2:48:31 PM6/1/14
to mitappinv...@googlegroups.com
Screen 2 initialise - listButtonComponents - buttons.jpg
Selected button procedure.jpg
When button click - buttons.jpg
NextQuestion code.jpg

Stephen Zipprich

unread,
Jun 1, 2014, 3:28:01 PM6/1/14
to mitappinv...@googlegroups.com
In your Screen1.Initialize block switch the order of the variable and procedure. Put the procedure after you specify your button list. Then come tell us what happens when you do that.

chris.car...@gmail.com

unread,
Jun 1, 2014, 4:44:26 PM6/1/14
to mitappinv...@googlegroups.com
I presume you mean Screen2.Initialise? Anyway, I swapped the arrangement of the variable and procedure and it worked, so thanks! Now onto my next issue.

I like the randomised arrangement of my answers but I don't understand how I could create a life counter and link it to my answers. If they are randomised, how can I link wrong answers to -1 life and correct answers to leave the number the same? Regardless of whether the answer is correct or not, I want the game to move onto the next question whenever an answer is picked. I looked at the counter example provided earlier but I can't understand where you could link it together with the answers.

Taifun

unread,
Jun 1, 2014, 5:02:40 PM6/1/14
to
I like the randomised arrangement of my answers but I don't understand how I could create a life counter and link it to my answers. 
in the example the given answers are compared with the correct answers in the "gameover" procedure. You have to change the logic and check, if the correct answer was given in the "selected" procedure
try something and if you get stuck, post a screenshot...
Taifun

chris.car...@gmail.com

unread,
Jun 1, 2014, 8:13:44 PM6/1/14
to mitappinv...@googlegroups.com
I have re-added the gameover code (I removed it earlier because I wasn't sure if I needed it for my specific app, not a wise move, I know).

Anyway, I have tried changing it but I honestly have no idea how I would do this. I want a have a life counter set at 3 with a wrong answer taking 1 from the counter as well as moving onto the next question. (Lives left = 3, Lives left = 2 etc.) I also would like to have my lives label colour-coded to green for 3, amber for 2 and red for 1. When the counter value hits 0, then I want the gameover to occur. Sorry to repeat this again, I just want to be absolutely clear.
Game over code - Lives Left counter.jpg

Stephen Zipprich

unread,
Jun 1, 2014, 8:52:41 PM6/1/14
to mitappinv...@googlegroups.com
You need to check whether the user selected the correct answer. If they did not, you decrement a counter variable by one. You could have a procedure to check the number of the variable and change the label color as appropriate. Then once the counter reaches zero, you stop the quiz because they lost all their lives.

SteveJG

unread,
Jun 1, 2014, 9:53:26 PM6/1/14
to
Once again, to count:


  initialize counter = 3


 
 if  get youranswer = get correct answer then add one to the counter else   counter subtracts one.    Use the Math blocks

  If counter is 3 or greater then ... color block green 
else if counter is 2   the color block orange
else i f       if counter = 0 then go to the gameover procedure                             


or something like that.



chris.car...@gmail.com

unread,
Jun 1, 2014, 10:06:41 PM6/1/14
to mitappinv...@googlegroups.com
Ok, I have created the lives counter (I did make a working one on a previous version of this project) but the correct answer stuff is not registering. The counter seems to stay the same no matter what answer I select. I reckon I must be on the right track somewhat though. I'll attach images of my code.
Checklabel code.jpg
Latest gameover (3am).jpg

SteveJG

unread,
Jun 1, 2014, 10:52:31 PM6/1/14
to mitappinv...@googlegroups.com
This might help:

I do not see a place where after you get global lives, you actually set the global lives label or button or whatever to the globallives variable .. perhaps but that just before the call checklabel?l although your check label procedure should take care of that.

Good luck.






Stephen Zipprich

unread,
Jun 1, 2014, 11:17:38 PM6/1/14
to
I notice you're calling the nextQuestion procedure in your gameover procedure...is this on accident or by design?  Doesn't game over mean there isn't a next question to ask?

Earlier you gave us a screen shot of your nextQuestion procedure but it cut off the bottom portion.  Are you calling gameover in your IfElse block?  

Edit:

Also, you're doing the math on your lives counter in your gameover block but you want your user to lose lives as they answer wrong, is that correct?  I think you'll have to change up some other blocks if that's the case.  Right now the way you have it setup that's not how it's working as I see it.

chris.car...@gmail.com

unread,
Jun 1, 2014, 11:32:38 PM6/1/14
to mitappinv...@googlegroups.com
@SteveJG I changed the gameover block but it didn't work (if I did what you meant).

@Stephen Zipprich I did put the call nextQuestion procedure in there deliberately. Sorry about the screenshot, I didn't notice the cut-off at the bottom. I am calling gameover

Sorry if I'm making silly mistakes or anything like that. I'm new to programming. I really appreciate the help so far though. I haven;t got too much left to do, just fixing these issues and adding images.
Latest gameover (430am).jpg
NextQuestion code.jpg

Taifun

unread,
Jun 2, 2014, 10:25:51 AM6/2/14
to mitappinv...@googlegroups.com
meanwhile I added a description, how procedure "gameover" works here http://puravidaapps.com/quiz.php#gameover
This hopefully gives you a better understanding of the example...

Also I added some hints to your problem here http://puravidaapps.com/quiz.php#q
So what are the answers to the mentioned 4 questions?
Are you able to provide a screenshot of your solution now?

Taifun

chris.car...@gmail.com

unread,
Jun 2, 2014, 12:42:43 PM6/2/14
to mitappinv...@googlegroups.com
I have 50 questions in total for the record. I'll show you my code for the first 4 questions and their answers. I'll also show you my latest code.

I still don't fully understand what I need to change. Sorry, it's really hard for me.
First 4 questions.jpg
First 4 answers.jpg
Latest gameover code (530pm).jpg
selected procedure (530pm).jpg

Taifun

unread,
Jun 2, 2014, 12:53:15 PM6/2/14
to mitappinv...@googlegroups.com
you modified the "gameover" procedure, which is not what you want...
why: because in the gameover procedure you loop through all the answers in the end of the game, this is not what you want to do, 

the user answers a question and you have to check immediately, if the answer is correct or wrong, therefore (now read again my recommendation):

 In the example the given answers are compared with the correct answers in procedure "gameover" for each question. You have to change the logic and check, after an answer was given for a question, if the answer is correct. I recommend you check that in procedure "selected" and adjust that procedure accordingly. To find out what to change, you should have a good understanding, how the example is working currently. The following 4 questions should help you to find the solution:
1. How do you get the current question number in procedure "selected"?
2. How do you get the given answer of the current question in procedure "selected"?
3. How do you get the correct answer of the current question in procedure "selected"?
4. How can you compare, if the given answer of the current question is correct or wrong?
If the answer was wrong, decrement the lives counter. Then check, if the lives counter = 0. If yes: "Game Over", else continue with the next question.

so what are the answers to these 4 questions?

Taifun

chris.car...@gmail.com

unread,
Jun 2, 2014, 3:58:21 PM6/2/14
to mitappinv...@googlegroups.com
Ok, I have changed the gameover procedure slightly. I am trying to make it match the example but obviously the example is different to my specific project so I have tried adapting it to that. I have also tried adjusting the selected procedure but I am so confused as to what I need to do. I understand that the code won;t work with the red warning triangles but I don't know what to do. I am really sorry if I am going in circles or if this is a very obvious task. I'm a little stressed out and this is all new and overwhelming to me. I don't fully understand the example to be honest.
Latest gameover procedure (850pm).jpg
Latest nextQuestion procedure (850pm).jpg
Latest selected procedure (850pm).jpg

Taifun

unread,
Jun 2, 2014, 5:00:47 PM6/2/14
to mitappinv...@googlegroups.com
why do you change the "gameover" procedure, which does not make sense?
why don't you follow my suggestion???

SteveJG

unread,
Jun 2, 2014, 6:05:49 PM6/2/14
to mitappinv...@googlegroups.com
These might be the right answers.


1. How do you get the current question number in procedure "selected"?

from the list index ?

2. How do you get the given answer of the current question in procedure "selected"?

 the global index ?

3. How do you get the correct answer of the current question in procedure "selected"?

List index 1 is the correct answer

4. How can you compare, if the given answer of the current question is correct or wrong?
if the given answer does not have an index of 1  it is wrong.

if  global index  is not 1 then the answer is wrong.

If the answer was wrong, decrement the lives counter. Then check, if the lives counter = 0. If yes: "Game Over", else continue with the next question.


You might get the information by putting the comparison routine right after the  call selected  statement in EACH of the button.clicked event handlers.

This stuff is not easy Chris.  Try this... unless I am told I got the wrong answers of course.

-- Steve

Taifun

unread,
Jun 2, 2014, 7:14:01 PM6/2/14
to mitappinv...@googlegroups.com
you can find the correct answers now here http://puravidaapps.com/quiz.php#q including a screenshot of the solution
Taifun

SteveJG

unread,
Jun 2, 2014, 8:42:43 PM6/2/14
to mitappinv...@googlegroups.com
Thanks for the 'solution' Taifun.  Interesting app.  Many should appreciate this very interesting multiple choice question algorithm.

Regards,
Steve
Reply all
Reply to author
Forward
Message has been deleted
0 new messages