Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6814959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:45:01+00:00 2026-05-26T20:45:01+00:00

I am writing a small app, like an English multiple choices question test .

  • 0

I am writing a small app, like an English multiple choices question test . I have a lot of questions, each question has few options, there is only one correct answer.

User choose an option to be an answer, then press next to display another question.
I can do until knowing whether the user select wrong or right answer already. But finish the question. I don’t know, how to calculate how many right or wrong answers. Because the user can go back to change the answer selection. Here is the code, Please help me to modify to the right code.

-(IBAction) checkButtonPressed:(UIButton *) sender{
    for(int i=0;i<[self.arrayButtons count];i++){
        [[self.arrayButtons objectAtIndex:i] setImage:[UIImage imageNamed:@"chkUnChecked.png"] forState:UIControlStateNormal];
    }
    NSLog(@"sender tag: %d", sender.tag);
    [sender setImage:[UIImage imageNamed:@"chkChecked.png"] forState:UIControlStateNormal];
    TrainEnglishAppDelegate *delegate = (TrainEnglishAppDelegate*)[UIApplication sharedApplication].delegate; 
    NSDictionary *item = [delegate.fullQuestion objectAtIndex:z];
    NSString *correctAnswer = [item objectForKey:@"correct"];
    NSArray *answers = [item objectForKey:@"answers"];
    NSString *answer = [answers objectAtIndex:sender.tag];

    if ([answer isEqualToString:correctAnswer]) {
        ++numberCorrect; 
        NSLog(@"did correct");
    } else
    {
        if (numberCorrect > 0) {
            --numberCorrect;
        } else
        {
            ++numberWrong;
        }
        NSLog(@"did wrong");
    }
}

PS: if the user cannot go back to fix their selection, it is much easier. But the requirement say so. I am not sure now. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:45:02+00:00Added an answer on May 26, 2026 at 8:45 pm

    I’ve done something similar (though more complex), and I’ve found that the only reasonable way to do it is to keep a “scorecard” with all of the answers and not generate a “score” until the end, at which time I scan back through the “scorecard” and add things up. Trying to keep a “running score”, while possible, just isn’t a robust way to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a small Sinatra-based app and would like each view to be
I have a small C# console app I am writing. I would like the
I am writing a small app which I need to test with utf-8 characters
I'm writing a small app in python which lets users answer math questions. The
I'm writing a small app that needs to have a super easy install process.
I'm writing a small app (learning Python and PyQt) that has an About box.
I'm writing a small app for my friend's business, and thought I'd take the
I am writing a small app to teach myself ASP.NET MVC, and one of
I'm writing a small app to do a little processing on some cells in
I am writing a small app to automatically connect my PC to the internet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.