rt300@14: // rt300@14: // QuestionnaireViewController.m rt300@14: // oscSenderExample rt300@14: // rt300@14: // Created by Robert Tubb on 16/01/2013. rt300@14: // rt300@14: // rt300@14: rt300@14: #import "QuestionnaireViewController.h" rt300@14: rt300@14: @interface QuestionnaireViewController () rt300@14: // the "model" is an array of questions rt300@14: @property (strong, nonatomic) NSArray * questionArray; rt300@14: @property (strong, nonatomic) NSArray * answerArray; rt300@14: @property (nonatomic) NSInteger currentQuestionIndex; rt300@14: /* rt300@15: rt300@14: rt300@14: */ rt300@14: rt300@14: @end rt300@14: rt300@14: @implementation QuestionnaireViewController rt300@14: rt300@14: //---------------------------------------------------------------- rt300@14: - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil rt300@14: { rt300@14: self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; rt300@14: if (self) { rt300@14: // Custom initialization rt300@14: rt300@14: [self populateQuestionArray ]; rt300@14: rt300@14: rt300@14: } rt300@14: return self; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: - (void)viewDidLoad rt300@14: { rt300@14: [super viewDidLoad]; rt300@14: // Do any additional setup after loading the view from its nib. rt300@14: self.currentQuestionIndex = 0; rt300@14: // load question 1 rt300@14: [self loadQuestion:self.currentQuestionIndex]; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: - (void)didReceiveMemoryWarning rt300@14: { rt300@14: [super didReceiveMemoryWarning]; rt300@14: // Dispose of any resources that can be recreated. rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: - (void)dealloc { rt300@15: rt300@14: [_questionText release]; rt300@15: [_titleText release]; rt300@14: [super dealloc]; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: - (void)viewDidUnload { rt300@14: [self setAnswerPressed:nil]; rt300@14: [self setQuestionText:nil]; rt300@15: [self setTitleText:nil]; rt300@14: [super viewDidUnload]; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: - (IBAction)answerWasSelected:(id)sender { rt300@14: // look at property? rt300@14: rt300@14: } rt300@14: rt300@14: //---------------------------------------------------------------- rt300@14: -(IBAction)hide:(id)sender{ rt300@14: self.view.hidden = YES; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: -(IBAction)show:(id)sender{ rt300@14: self.view.hidden = NO; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: rt300@14: - (IBAction)nextQuestionPressed:(id)sender { rt300@14: // save answer ? no button did that hopefully rt300@15: rt300@14: // if last question show thanks rt300@14: // else go to next rt300@14: self.currentQuestionIndex++; rt300@15: if(self.currentQuestionIndex >= [self.questionArray count]){ rt300@15: [self showThanks]; rt300@15: }else{ rt300@15: [self loadQuestion:self.currentQuestionIndex]; rt300@15: rt300@15: } rt300@15: } rt300@15: rt300@15: - (IBAction)previousQuestionPressed:(id)sender { rt300@15: self.currentQuestionIndex--; rt300@15: if(self.currentQuestionIndex < 0){ rt300@15: // nothing rt300@15: self.currentQuestionIndex = 0; rt300@15: }else{ rt300@15: [self loadQuestion:self.currentQuestionIndex]; rt300@15: } rt300@15: } rt300@15: //---------------------------------------------------------------- rt300@15: rt300@15: - (void)showThanks{ rt300@15: // hide next question button rt300@15: // hide selector rt300@15: self.titleText.text = @"Thank you!"; rt300@15: rt300@15: self.questionText.text = @"Thanks for helping science help you. Visit the study website to keep abreast of exciting events."; rt300@15: } rt300@15: /* rt300@15: - (IBAction)previousQuestionPressed:(id)sender { rt300@15: self.currentQuestionIndex--; rt300@15: if(self.currentQuestionIndex > [self.questionArray count]){ rt300@15: [self showThanks]; rt300@15: } rt300@14: [self loadQuestion:self.currentQuestionIndex]; rt300@14: } rt300@15: */ rt300@14: //---------------------------------------------------------------- rt300@14: - (void)loadQuestion:(NSInteger)questionIndex { rt300@14: // populate text fields with question rt300@15: NSString *qtitle; rt300@15: qtitle = [@"Question " stringByAppendingFormat:@"%d",questionIndex+1]; rt300@15: self.titleText.text = qtitle; rt300@15: rt300@14: self.questionText.text = [self.questionArray objectAtIndex:questionIndex]; rt300@14: rt300@15: // if question already answered show that rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: - (void)populateQuestionArray{ rt300@15: self.questionArray = [[NSArray alloc] initWithObjects: rt300@15: @"I am familiar with music software and synthesisers.", rt300@15: @"The best way to get a feel for the possibilities of the synth was with:", rt300@15: @"Interesting sounds could be discovered more quickly as a result of using:", rt300@15: @"A sound could be fine tuned more easily using:", rt300@15: @"The correspondence between the sliders and the grid was understandable.", rt300@15: @"The interface that felt more familiar was:", rt300@15: @"Scrolling a greater distance the zoom grid seemed to correspond to larger difference in the sound.", rt300@15: @"The ability to see other presets on the grid was useful.", rt300@15: @"The range of sounds was too limited to be able to judge the eventual usefulness of the interface.", rt300@15: @"The interface better for generating new ideas was", rt300@15: @"The interface better for live performance would be:", rt300@15: @"A specific type of sound could be found more quickly using:", rt300@15: @"I felt more in control when using:", rt300@15: @"The Zoomer was an improvement on just using a randomiser.", rt300@15: @"The combination of Zoomer and Sliders was more useful than either individually.", rt300@15: @"Overall, I preferred using:", rt300@15: nil]; rt300@14: } rt300@14: //---------------------------------------------------------------- rt300@14: rt300@14: @end // end implementation