Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 83

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

Quiz plugin: How to have each response garner some sort of point value?

Hey everyone, I'm trying to have each response garner a point value. I've been messing around with the following code with no luck. //tmp array of answers..3 are incorrect, 1 is correct NSMutableArray *tmpAnswers = [[NSMutableArray alloc] init]; [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"incorrectText1":@""]]; [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"incorrectText2":@""]]; [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"incorrectText3":@""]]; [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"correctAnswerText":@""]]; I attempted to changing "incorrectText1' to "correctAnswerText" but when I ran the app the questions disappeared. Any idea on how to do this? Thanks! Best, Matt
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
07/15/12 01:01 PM (13 years ago)
Its do-able, but it would require quite a bit of code modification. I think you would have to remove the part of the code that compares the selected answer to the "correctAnswerText", and then add a block of code that builds a cast statement about the position of the selected answer and assigns different points. (also, you'd probably need to disable the answer order randomization) This would be more like a survey and less like a quiz, correct?
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/15/12 01:11 PM (13 years ago)
Exactly. It's more of a survey. Based on the amount of points you have you'll see a different rewards screen that will explain the results. I'll mess around with it for a little bit, but I'm limited due to experience with code, especially Objective-C. What's the variable BT uses for the position of the answers? Is it 'answerButton1', 'answerButton2', ect? Thanks for the help! Best, Matt
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/15/12 01:13 PM (13 years ago)
I'm glad you recommended a case statement. I was thinking the same thing. Gives me some more confidence in myself. Ha..
 
Rem
Aspiring developer
Profile
Posts: 23
Reg: Jul 08, 2012
Inland Empire
2,580
like
07/15/12 01:47 PM (13 years ago)
Well, here's what I put. I'm getting a few errors and I'm not sure what to put as the expression in the switch statement. See the '???'. Also, with the help of MGoBlue I inserted a custom points feature. switch (???) { case [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"incorrectText1":@""]]: customPoints = (customPoints + 1); break; case [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"incorrectText2":@""]]: customPoints = (customPoints + 2); break; case [tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"incorrectText3":@""]]: customPoints = (customPoints + 3); break; default[tmpAnswers addObject:[BT_strings getJsonPropertyValue:tmpQuestion.jsonVars:@"correctAnswerText":@""]]: customPoints = (customPoints + 4); break;
 

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.