diff TimedSessionController.mm @ 29:fabb3a5cdfc9

Timed session improvements. Desperate pathetic attempts to send a simple HTTP POST.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Fri, 22 Feb 2013 17:41:38 +0000
parents
children c0a6f7c66719
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TimedSessionController.mm	Fri Feb 22 17:41:38 2013 +0000
@@ -0,0 +1,101 @@
+//
+//  TimedSessionController.m
+//  sonicZoom
+//
+//  Created by Robert Tubb on 18/02/2013.
+//
+//
+#import "testApp.h"
+#import "TimedSessionController.h"
+@interface TimedSessionController()
+    // private stuff
+
+@end
+
+@implementation TimedSessionController
+
+    int orders[6][3] = {{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};
+    int theOrder;
+    int scount;
+
+    NSArray *alertMessages = [NSArray arrayWithObjects:
+                      @"Thanks, now try the sliders only",
+                      @"Thanks, now try the sliders and the Zoomer together",
+                      @"Thanks, now try the zoomer only",
+                      @"Thanks, now please take the questionnaire",nil];
+
+// nicer if it was initWithAppRef ?
+- (void)setAppRef:(id)theOFApp{
+    self.theOFAppRef = theOFApp;
+    theOrder = arc4random() % 6;
+    NSLog(@"the order: %d", theOrder);
+    
+    scount = 0;
+}
+-(void)startTimer{
+    // SHOW FIRST PROMPT
+    NSString *themessage;
+    themessage = [alertMessages objectAtIndex:orders[theOrder][0]];
+    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!"
+                                                     message:themessage
+                                                    delegate:self
+                                           cancelButtonTitle:@"Continue"
+                                           otherButtonTitles:nil];
+    alert.alertViewStyle = UIAlertViewStyleDefault;
+    [alert show];
+    [alert release];
+
+}
+-(void)resetTime:(int)newTime{
+    
+}
+
+// ALERT
+
+
+-(void)showNextPrompt{
+    NSString *themessage;
+    scount++;
+    if(scount < 3){
+        themessage = [alertMessages objectAtIndex:orders[theOrder][scount] ];
+    }else{
+        themessage = [alertMessages objectAtIndex:3 ];
+    }
+    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Thanks!"
+                                                     message:themessage
+                                                    delegate:self
+                                           cancelButtonTitle:@"Continue"
+                                           otherButtonTitles:nil];
+    alert.alertViewStyle = UIAlertViewStyleDefault;
+    [alert show];
+    [alert release];
+    
+}
+
+-(void)cancelTimers{
+    scount = 0;
+    if(self.theCurrentTimer){
+        [self.theCurrentTimer invalidate];
+        self.theCurrentTimer = nil;
+    }
+}
+- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
+    
+    NSLog(@"OK TO NEXT VIEW");
+    
+    if(scount < 3){
+        NSInteger next = orders[theOrder][scount];
+        ((testApp *)self.theOFAppRef)->interfaceSelected(next);
+        
+        self.theCurrentTimer = [NSTimer scheduledTimerWithTimeInterval:SECONDS_PER_INTERFACE target:self selector:@selector(showNextPrompt) userInfo:nil repeats:NO];
+        
+    }else{
+        ((testApp *)self.theOFAppRef)->showQuestionnaire();
+        scount = 0; // incase we try again
+        self.theCurrentTimer = nil;
+    }
+    
+}
+
+
+@end