Coder Social home page Coder Social logo

gwquestionnaire's Introduction

GWQuestionnaire - easy questionnaires and surveys solution for iOS


alt tag

How to use it

Creating survey/questionnaire:

NSMutableArray *questions = [NSMutableArray array];

NSDictionary *a1 = [NSDictionary dictionaryWithObjectsAndKeys:@"YES",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a2 = [NSDictionary dictionaryWithObjectsAndKeys:@"NO",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a3 = [NSDictionary dictionaryWithObjectsAndKeys:@"A",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a4 = [NSDictionary dictionaryWithObjectsAndKeys:@"B",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a5 = [NSDictionary dictionaryWithObjectsAndKeys:@"C",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a6 = [NSDictionary dictionaryWithObjectsAndKeys:@"1",@"text",     
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a7 = [NSDictionary dictionaryWithObjectsAndKeys:@"2",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a8 = [NSDictionary dictionaryWithObjectsAndKeys:@"3",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];
NSDictionary *a9 = [NSDictionary dictionaryWithObjectsAndKeys:@"4",@"text",
                                                            [NSNumber numberWithBool:NO],@"marked", nil];


// single choice question
GWQuestionnaireItem *item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Single choice question ?"
                                                    answers:[NSArray arrayWithObjects:a1,a2, nil]
                                                       type:GWQuestionnaireSingleChoice];
[questions addObject:item];

// multiple choice question
item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Multiple choice question ?"
                                      answers:[NSArray arrayWithObjects:a3,a4,a5, nil]
                                         type:GWQuestionnaireMultipleChoice];
[questions addObject:item];

// "Rate" question
item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Rate it:"
                                      answers:[NSArray arrayWithObjects:a6,a7,a8,a9, nil]
                                         type:GWQuestionnaireRateQuestion];
[questions addObject:item];

// "open" question
item = [[GWQuestionnaireItem alloc] initWithQuestion:@"Type your answer:"
                                      answers:nil
                                         type:GWQuestionnaireOpenQuestion];
[questions addObject:item];

surveyController = [[GWQuestionnaire alloc] initWithItems:questions];
surveyController.view.frame = CGRectMake(0,20,self.view.frame.size.width,self.view.frame.size.height-20);
[self.view addSubview:surveyController.view];

Getting results from it:

// NSLog answers
for(GWQuestionnaireItem *item in surveyController.surveyItems)
{
    NSLog(@"-----------------");
    NSLog(@"%@",item.question);
    NSLog(@"-----------------");
    if(item.type == GWQuestionnaireOpenQuestion)
        NSLog(@"Answer: %@", item.userAnswer);
    else
        for(NSDictionary *dict in item.answers)
        {
            NSLog(@"%d - %@",[[dict objectForKey:@"marked"]boolValue], [dict objectForKey:@"text"]);
        }
}

gwquestionnaire's People

Contributors

wojczitsu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.