Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 22    Views: 92

Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
07/12/12 05:08 PM (13 years ago)

Where are the questions for a quiz located in Xcode?

Hey all, I'm trying to find where the questions for my quiz are located in Xcode. I'm going to attempt to write code under each question to give each question different point values for different answers. Any help with that would be appreciated too. I'm not sure if that's even possible but that's where I'm headed right now. Thanks! Best, Matt
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
07/12/12 05:19 PM (13 years ago)
They pull from the JSON data from your config file. That is why it can be changed dynamically. If you look at the config file you will see all of your ? & A's
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/12/12 05:23 PM (13 years ago)
Ah, great! Thank you. I just found them. Where would I change the values of each answer? For example, I want each answer to garner a point value, one gets 4 points, another gets 3, another gets 2, and the last gets 1.
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
07/12/12 05:55 PM (13 years ago)
They are set up to all have the same value (That is pulled from JSON Data too) Changing this looks like ti would be different in iOS and Android. It may be easier in Android looking at how the questions are numbered in the code and you could insert an if / then, but the actual code is not something I know how to do off the top of my head.
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/12/12 06:58 PM (13 years ago)
Haven't looked at the Android quiz, but for iOS (assuming you're using all text questions and not image questions) put the designated point value in one of the image fields. For my example below I'm using the image small device url field. You'll want to define a variable to hold the data. In the BT_screenQuiz.h, add: int *customPoints; @property (nonatomic) int customPoints; Then in BT_screenQuiz.m, add: @synthesize customPoints; Then find this section: //properties for this question NSString *tmpQuestionText = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"questionText":@""]; NSString *tmpImageName = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageNameSmallDevice":@""]; NSString *tmpImageURL = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageURLSmallDevice":@""]; Change it to: //properties for this question NSString *tmpQuestionText = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"questionText":@""]; customPoints = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageURLSmallDevice":@""]; You've now captured the custom point value. Find this section: //determine how many points we earned for this answer int pointsPerRight = quizPointsPerAnswer; and change to: //determine how many points we earned for this answer int pointsPerRight = customPoints; You may want to comment out the bonuses. That should work. Haven't tested it, but I did something similar in an app.
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
07/12/12 07:07 PM (13 years ago)
Just following
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
07/12/12 10:25 PM (13 years ago)
There is a podcast on quizzes as idevdepot.com. I think you will find what you need.
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 12:50 PM (13 years ago)
Thanks Blue! I'm going to try this right now. I'll let you know how it goes. Best, Matt
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 01:38 PM (13 years ago)
I tried it and I ended up getting a lot of errors. I tried to re-download the app from Buzztouch to start over and when I opened it in Xcode the same errors were there. How can I re-download the app without the errors to give it another try?
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/13/12 01:56 PM (13 years ago)
Well... you should not get the same errors from a fresh download. Nothing would be changed in the file you just downloaded. Can you post the errors? That would help me diagnose.
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 02:02 PM (13 years ago)
Ok, well I just re-made the app because I haven't done that much to it yet. I want to work out the logistics before I start adding the main details. I'll try again and post the errors. Thanks for the help! Best, Matt
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 02:57 PM (13 years ago)
Ok, I got past the first two steps without any errors, but I got a few on the third instruction in "//properties for this question. The first one is on the line of code in inserted: Semantic Issue: Incompatible pointer types assigning to 'int *' from 'NSString *' The rest of them have errors having to do with use of undeclared identifier 'tmpimageName' and 'tmpImageURL' in various lines below the code I inserted. Thanks! Best, Matt
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/13/12 03:29 PM (13 years ago)
Okay. The tmpImageName and tmpImageURL must be used elsewhere in the code. Either find those instances and comment them out, or reinsert the deleted lines: NSString *tmpImageName = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageNameSmallDevice":@""]; NSString *tmpImageURL = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageURLSmallDevice":@""]; For the Incompatible Pointer Typy, try this: Instead of adding this: customPoints = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageURLSmallDevice":@""]; Add this: NSString *tmpCustomPoints = [BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"imageURLSmallDevice":@""]; customPoints = [tmpCustomPoints intValue];
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 04:17 PM (13 years ago)
Ok, I tried to comment out other instances but that wasn't working. I reinserted the lines I deleted and the errors went away. I then added the additional lines and all of the errors cleared except one. The last one says: Semantic Issue: incompatiable integer to pointer conversion assigning to 'int *' from 'int' Thanks! Best, Matt
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 04:22 PM (13 years ago)
The error is on this line: customPoints = [tmpCustomPoints intValue];
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/13/12 04:31 PM (13 years ago)
Okay, try changing to this: @property (nonatomic, assign) int customPoints;
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 04:47 PM (13 years ago)
Ah, it worked! Now the real question: How do I assign certain answers different point values? The layout for the quiz is each question will have the same four responses with each response having values 1-4. Then based of how many points you have at the end of the quiz you'll get a different rewards screen. Thank you! Best, Matt
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/13/12 05:13 PM (13 years ago)
Okay. Well, this is a first step. This will let you assign a different point value based on the question. We'll have to figure out a routine to determine which answer is selected and how many points that is worth. I'll give it some thought.
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 06:26 PM (13 years ago)
Great! That sounds good. I'll tinker with it a bit and see what happens. Thanks again. Best, Matt
 
MGoBlue
Apple Fan
Profile
Posts: 980
Reg: Jun 07, 2011
Gold River, CA
10,600
like
07/13/12 06:41 PM (13 years ago)
Probably the easiest way is a multiplier or divider. So if the top answer is 40 the second is 20, third is 10 and fourth is 5. Simple math and an if then statement could work.
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 06:45 PM (13 years ago)
Ok. What file would I enter the code into? Best, Matt
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/13/12 06:45 PM (13 years ago)
*Double post
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/14/12 07:05 PM (13 years ago)
So I've been tinkering with the code and I haven't had much luck. I have been learning a lot though with this being my first app and relatively first time dealing with code in an app. I think I might be able to figure out the scoring but I'm having trouble setting each response as a right answer so each response can garner some sort of point value. Any tips? Thanks! Best, Matt
 

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.