rt300@29
|
1 //
|
rt300@29
|
2 // TimedSessionController.m
|
rt300@29
|
3 // sonicZoom
|
rt300@29
|
4 //
|
rt300@29
|
5 // Created by Robert Tubb on 18/02/2013.
|
rt300@29
|
6 //
|
rt300@29
|
7 //
|
rt300@29
|
8 #import "testApp.h"
|
rt300@29
|
9 #import "TimedSessionController.h"
|
rt300@29
|
10 @interface TimedSessionController()
|
rt300@29
|
11 // private stuff
|
rt300@29
|
12
|
rt300@29
|
13 @end
|
rt300@29
|
14
|
rt300@29
|
15 @implementation TimedSessionController
|
rt300@29
|
16
|
rt300@29
|
17 int orders[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};
|
rt300@29
|
18 int theOrder;
|
rt300@29
|
19 int scount;
|
rt300@29
|
20
|
rt300@29
|
21 NSArray *alertMessages = [NSArray arrayWithObjects:
|
rt300@29
|
22 @"Thanks, now try the sliders only",
|
rt300@29
|
23 @"Thanks, now try the sliders and the Zoomer together",
|
rt300@29
|
24 @"Thanks, now try the zoomer only",
|
rt300@29
|
25 @"Thanks, now please take the questionnaire",nil];
|
rt300@29
|
26
|
rt300@29
|
27 // nicer if it was initWithAppRef ?
|
rt300@29
|
28 - (void)setAppRef:(id)theOFApp{
|
rt300@29
|
29 self.theOFAppRef = theOFApp;
|
rt300@29
|
30 theOrder = arc4random() % 6;
|
rt300@29
|
31 NSLog(@"the order: %d", theOrder);
|
rt300@29
|
32
|
rt300@29
|
33 scount = 0;
|
rt300@29
|
34 }
|
rt300@29
|
35 -(void)startTimer{
|
rt300@29
|
36 // SHOW FIRST PROMPT
|
rt300@29
|
37 NSString *themessage;
|
rt300@29
|
38 themessage = [alertMessages objectAtIndex:orders[theOrder][0]];
|
rt300@29
|
39 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!"
|
rt300@29
|
40 message:themessage
|
rt300@29
|
41 delegate:self
|
rt300@29
|
42 cancelButtonTitle:@"Continue"
|
rt300@29
|
43 otherButtonTitles:nil];
|
rt300@29
|
44 alert.alertViewStyle = UIAlertViewStyleDefault;
|
rt300@29
|
45 [alert show];
|
rt300@29
|
46 [alert release];
|
rt300@29
|
47
|
rt300@29
|
48 }
|
rt300@29
|
49 -(void)resetTime:(int)newTime{
|
rt300@29
|
50
|
rt300@29
|
51 }
|
rt300@29
|
52
|
rt300@29
|
53 // ALERT
|
rt300@29
|
54
|
rt300@29
|
55
|
rt300@29
|
56 -(void)showNextPrompt{
|
rt300@29
|
57 NSString *themessage;
|
rt300@29
|
58 scount++;
|
rt300@29
|
59 if(scount < 3){
|
rt300@29
|
60 themessage = [alertMessages objectAtIndex:orders[theOrder][scount] ];
|
rt300@29
|
61 }else{
|
rt300@29
|
62 themessage = [alertMessages objectAtIndex:3 ];
|
rt300@29
|
63 }
|
rt300@29
|
64 UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!"
|
rt300@29
|
65 message:themessage
|
rt300@29
|
66 delegate:self
|
rt300@29
|
67 cancelButtonTitle:@"Continue"
|
rt300@29
|
68 otherButtonTitles:nil];
|
rt300@29
|
69 alert.alertViewStyle = UIAlertViewStyleDefault;
|
rt300@29
|
70 [alert show];
|
rt300@29
|
71 [alert release];
|
rt300@29
|
72
|
rt300@29
|
73 }
|
rt300@29
|
74
|
rt300@29
|
75 -(void)cancelTimers{
|
rt300@29
|
76 scount = 0;
|
rt300@29
|
77 if(self.theCurrentTimer){
|
rt300@29
|
78 [self.theCurrentTimer invalidate];
|
rt300@29
|
79 self.theCurrentTimer = nil;
|
rt300@29
|
80 }
|
rt300@29
|
81 }
|
rt300@29
|
82 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
|
rt300@29
|
83
|
rt300@29
|
84 NSLog(@"OK TO NEXT VIEW");
|
rt300@29
|
85
|
rt300@29
|
86 if(scount < 3){
|
rt300@29
|
87 NSInteger next = orders[theOrder][scount];
|
rt300@29
|
88 ((testApp *)self.theOFAppRef)->interfaceSelected(next);
|
rt300@29
|
89
|
rt300@29
|
90 self.theCurrentTimer = [NSTimer scheduledTimerWithTimeInterval:SECONDS_PER_INTERFACE target:self selector:@selector(showNextPrompt) userInfo:nil repeats:NO];
|
rt300@29
|
91
|
rt300@29
|
92 }else{
|
rt300@29
|
93 ((testApp *)self.theOFAppRef)->showQuestionnaire();
|
rt300@29
|
94 scount = 0; // incase we try again
|
rt300@29
|
95 self.theCurrentTimer = nil;
|
rt300@29
|
96 }
|
rt300@29
|
97
|
rt300@29
|
98 }
|
rt300@29
|
99
|
rt300@29
|
100
|
rt300@29
|
101 @end
|