Discussion Forums  >  Uncategorized

Replies: 13    Views: 242

Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
08/16/11 02:00 PM (14 years ago)

Quiz reversal

Hi guys! Hope you are all well! Just wondering if you guys could help on a quiz modification. All I want to do is make the right answer the wrong answer if that makes sense. I want the points to be scored provided the user chooses on of the three wrong answers as opposed to the right answer? I have no real coding knowledge but would imagine this is a simple code adjustment? Thanks!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/16/11 11:37 PM (14 years ago)
SImple code adjustment - funny. What version, iOS / Android / v1.4, v1.5 You'de be amazed at how complicated the logic is on the quiz screens. I'm sure it's doable but the approach will depend on the version you're using. Have a look at the quiz .java file (android) or .m file (iOS), you'll see where the right/wrong happens.
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/17/11 12:45 AM (14 years ago)
Sorry I didn't mean to sound so overly confident! I'm just so used to how simple the BT interface is! Im working with iOS v1.5
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/17/11 12:55 AM (14 years ago)
No worries...just made me smile thats all. OK, so before we get too deep into this...lets get some foundation stuff down.. a) Open the BT_screen_quiz.m file in the BT_Screens folder in Xcode. b) Scroll down to line 934 and find the answerClick method. This method is long and ends on line 1083. Yup, 150 + lines of code run every single time an answer is tapped. c) Scroll down this method slowly a few times and try to get your head around how it's working. It looks daunting, it'll get easier after a few times through. Really, it does. You'll want to focus on around line 1000. This is where it checks to see if the answer was correct or not. It checks to see if the text on the button matches the text for the question. This is the logic you'll need to modify. Re-post when your totally lost ;-)
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/17/11 03:20 PM (14 years ago)
After spending a few times going over and over it, it is making a bit more sense but I still am not sure of exactly what needs modifying, from my very bare knowledge of the html and php bits I have done in the past, and i may be wrong, but is it to do with this: //correct or incorrect? if([tmpAnswer isEqualToString:selAnswer]){ My guess is that this is saying 'if the answer chosen is equal to the answer that was defined as correct when the question was written then it is correct and points will be added' Am i on the right path? If so I would imagine that I somehow need to modify it so that it is instead saying. 'if answer is equal to what was originally noted as an incorrect answer then apply the points' Hope this makes sense and that I am kind of getting it! Really appreciate the support!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/18/11 12:36 PM (14 years ago)
Exactly!!! The text on the button the user tapped is compared with the text you entered as the correct answer. Just like you described. So, you'll need to work out a way to compare the text on the other three buttons, or, another way to say it.. If the text DOES match, they must be wrong! I say this becuase you want to make the right answer actually wrong - I think. Too funny. if(![tmpAnswer isEqualToString:selAnswer]){ I added one character to this, the ! exclamation point. This means, 'if the answer does not match'
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/20/11 07:01 AM (14 years ago)
Fantastic :) its such a great feeling to at least be able to understand a little bit of what the code is doing :) That modification worked perfectly! And i never would have guessed it was by adding the exclamation point so thank you! Following that modification, I also found the code which depicts the color of the right and wrong answers which i have no adjusted. I would now like to make a change to the way the score multiplications work, I would like to remove any multiplications occurring, but keep the images coming after a certain stream of correct answers. From having a look I believe i need to work with this part of the code: //bonusImage for right in a row if(streak > 9){ pointsPerRight = (pointsPerRight * 10); tmpBonusImg = [UIImage imageNamed:@10X.png]; }else if (streak > 8){ pointsPerRight = (pointsPerRight * 9); tmpBonusImg = [UIImage imageNamed:@9X.png]; }else if (streak > 7){ pointsPerRight = (pointsPerRight * 8); tmpBonusImg = [UIImage imageNamed:@8X.png]; }else if (streak > 6){ pointsPerRight = (pointsPerRight * 7); tmpBonusImg = [UIImage imageNamed:@7X.png]; }else if (streak > 5){ pointsPerRight = (pointsPerRight * 6); tmpBonusImg = [UIImage imageNamed:@6X.png]; }else if (streak > 4){ pointsPerRight = (pointsPerRight * 5); tmpBonusImg = [UIImage imageNamed:@5X.png]; }else if (streak > 3){ pointsPerRight = (pointsPerRight * 4); tmpBonusImg = [UIImage imageNamed:@4X.png]; }else if (streak > 2){ pointsPerRight = (pointsPerRight * 3); tmpBonusImg = [UIImage imageNamed:@3X.png]; } My understanding is that the 'gold star' image is called up for every noted 'PointsPerRight' and the multiplacation image such as x10 is called up on top of the start from the code above? I would instead like to use an image which may say 'Keep going!' or something like that, therefore only ever calling up one image instead of a background and overlay, if my thoughts are right I can put something like: }else if (streak > 19){ pointsPerRight = (pointsPerRight * 20); tmpBonusImg = [UIImage imageNamed:@welldoneyouhavegot20rightsofar.png]; I hope this makes sense somehow! Thanks again!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/21/11 01:38 AM (14 years ago)
Makes perfect sense. All that code is doing is checking how many in-a-row were answered then changing the image accordingly. If you want to keep adding the score like it's doing now, just add the welldoneyouhavegot20rightsofar.png in all the places the multiplication image is showing. No need to change any code, just over-write the image names in the existing code block. You can remove the entire block if you don't want to give any 'bonus points' then just do a tmpBonusImg = [UIImage imageNamed:@welldoneyouhavegot20rightsofar.png]; at the end, after the code you removed.
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/21/11 02:45 AM (14 years ago)
Brilliant, so this piece of code I posted above is also the code that is multiplying the score as well as calling up the images?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/21/11 03:14 AM (14 years ago)
Exactly. In each little section...if(streak is greater than a number) the 'pointsPerRight' variables is multiplied by the number of answers in a row the user has accumulated. All this does is calculate the score. Then, directly under that, it sets the image for the number of answers in a row. When the user gets an answer wrong, the 'streak' variable is re-set to 1.
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/21/11 04:25 AM (14 years ago)
Brilliant that worked perfectly! Onto the next modifiction.... (By the way I do really appreciate your help I'm just getting really passionate about getting this finished and out there now, it's just I want to make changes rather then rushing and do very much appreciate your help. How can I customise display text, there are two bits in particular I would like to change: The first text is on the pop up display after the quiz has ended which shows the correct and incorrect answers as well as the try again buttons etc, I would like to instead only display the number of correct answers as well as the the text GAME OVER above in bold, therefore removing the elapsed time and incorrect answer count etc. I have tried to delete them from the code but this returned an error message and would not allow me to finisht he quiz in the simulator? I would also like to make the same modification to the scoreboard text, instead of the scoreboard displaying date, device and all of that, I would instead like for it to purely show the name, score and perhaps date, I have tried to look for this code but have had no luck! Thank you so much for the help!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/22/11 01:27 AM (14 years ago)
a) Quiz Results: As you figured out, this is a simple 'string' of data put together with carriage returns and other simple formatting that is displayed in a simple alert pop-up. You can change the text itself by mofifing the tmpResults variable you see on line 504. This won't change the way it looks, only they what it reads. Changing the layout of this would require some changes. The message itself is passed to a method called 'showAlert' The showAlert message is setup in the Act_ActivityBase.java file. Sidenote / Programming 101: Because the Screen_QuizMultipleChoice.java file is a 'child class' and based on the Act_ActivityBase.java file (see extends Act_ActivityBase on line 29 of the quiz screen code) all of the methods in the Act_ActivityBase.java class are available to the quiz class. This is why we can call 'showAlert' from the quiz class. So, you to change how this works, you'll need to create another showAlert method with a different layout. You could call it 'showMyScore' or something. Just copy the entire showAlert method in the Act_ActivtyBase.java class and paste it in the quiz class, then re-name it 'showMyScore' Then, when the quiz ends, trigger the showMyScore method instead of the showAlert method like it's doing now on line 508. This would do the same thing until you customized it. Customizing how an alert looks does take some skill but you may be able to figure it out. See this to get started making your own alert. http://www.tutorialforandroid.com/2009/01/displaying-alertdialog-in-android.html b) Scoreboard: This is probably beyond your skill level? The scoreboard layout and text comes from our backend and isnt' something you can control. Changing this would require you to 'send' the results to your own backend then output them in a newer format. It's not possible to walk you through this...complex stuff ;-)
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/22/11 08:16 AM (14 years ago)
Haha ok well I will accept defeat on those issues for the time being! I have a friend who is a developer and should be able to help I hope! My FINAL change I would like to make is i'm trying desperately to find a way to call up the high scores page on my own page as opposed to just at the end of the quiz? My app basically consists of four seperate 'topic' quiz games, and I have created a list menu on the home screen which features, 'How to Play', 'High Scores' and 'About Us', what I am hopefully aiming to do is to have this link go to a grid menu page of which each box will take you to the high scores of that topic. (Again I hope that makes sense!) I can see from the code that this page is getting called up after the quiz but I cannot seem to find a way to call it up elsewhere, and also I cant find the way in which to define which high score code is which for example it is calling 'highscore' as opposed to 'maths quiz highscore' Really hope this is doable as it is the remaining key feature to my app! Thanks again, this will be the last time I hassle regarding this topic! haha
 
Tango
Lost but trying
Profile
Posts: 25
Reg: Aug 03, 2011
Peterborough
250
like
08/22/11 09:42 AM (14 years ago)
Ooo and one last thing..... how can i modify the quiz so that the first incorrect answer ends the quiz? thanks!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.