changeset 22:8c0783739337

Logs uploading. Questionnaire also.
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Thu, 24 Jan 2013 18:14:40 +0000
parents 650589cac373
children dae6d77657a0
files PresetAlertViewController.mm QuestionnaireViewController.h QuestionnaireViewController.mm QuestionnaireViewController.xib eventLogger.h eventLogger.mm grid.mm presetManager.h presetManager.mm testApp.h testApp.mm
diffstat 11 files changed, 300 insertions(+), 253 deletions(-) [+]
line wrap: on
line diff
--- a/PresetAlertViewController.mm	Fri Jan 18 15:48:33 2013 +0000
+++ b/PresetAlertViewController.mm	Thu Jan 24 18:14:40 2013 +0000
@@ -6,7 +6,6 @@
 //
 //
 #include "presetManager.h"
-
 #import "PresetAlertViewController.h"
 
 
@@ -29,7 +28,7 @@
 
 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
     
-    NSLog(@"Preset save ");
+    NSLog(@"Preset save %@", [[alertView textFieldAtIndex:0] text]);
     if(buttonIndex == 0){
         // cancel
         NSLog(@"preset save was cancelled");
--- a/QuestionnaireViewController.h	Fri Jan 18 15:48:33 2013 +0000
+++ b/QuestionnaireViewController.h	Thu Jan 24 18:14:40 2013 +0000
@@ -8,36 +8,33 @@
 
 #import <UIKit/UIKit.h>
 
+#import "Question.h"
+
 @interface QuestionnaireViewController : UIViewController
 <UIPickerViewDelegate, UIPickerViewDataSource>
 {
-    bool                agreeType;
+
     UIPickerView       *picker;
-    NSArray            *agreeAnswer;
-    NSArray            *interfaceAnswer;
+
     
 }
 @property (retain, nonatomic) IBOutlet UILabel *questionText;
 @property (retain, nonatomic) IBOutlet UILabel *titleText;
 @property (retain, nonatomic) IBOutlet UIButton *finishButton;
 @property (retain, nonatomic) IBOutlet UIButton *nextButton;
-@property (retain, nonatomic) IBOutlet UISegmentedControl *segControl;
+@property (retain, nonatomic) IBOutlet UIButton *previousButton;
 
-@property (nonatomic) bool agreeType;
 @property (strong, nonatomic) IBOutlet UIPickerView *picker;
-@property (strong, nonatomic) NSArray *agreeAnswer;
-@property (strong, nonatomic) NSArray *interfaceAnswer;
+
 
 //----------------------------------------------------------------
 -(IBAction)hide:(id)sender;
 -(IBAction)show:(id)sender;
 - (IBAction)nextQuestionPressed:(id)sender;
 - (IBAction)previousQuestionPressed:(id)sender;
-- (IBAction)answerSelected:(id)sender;
 //----------------------------------------------------------------
 - (void)setAppRef:(id)theOFApp;
 - (void)populateQuestionArray;
-- (void)populateAnswerArray;
 - (void)loadQuestion:(NSInteger)questionIndex;
 //----------------------------------------------------------------
 @end
--- a/QuestionnaireViewController.mm	Fri Jan 18 15:48:33 2013 +0000
+++ b/QuestionnaireViewController.mm	Thu Jan 24 18:14:40 2013 +0000
@@ -14,10 +14,8 @@
 #pragma mark QuestionnaireViewController
 
 @interface QuestionnaireViewController ()
-    // the "model" is an array of questions and a bunch of answers
+    // the "model" is an array of questions 
 @property (strong, nonatomic)       NSArray * questionArray;
-@property (strong, nonatomic)       NSArray * answerTypeArray;
-@property (strong, nonatomic)       NSMutableArray * answerArray;
 @property (nonatomic)               NSInteger currentQuestionIndex;
 @property (nonatomic, assign)       id theOFAppRef;
 
@@ -31,11 +29,9 @@
 @implementation QuestionnaireViewController
 
 @synthesize picker;
-@synthesize agreeAnswer;
-@synthesize agreeType;
-@synthesize answerTypeArray;
 @synthesize nextButton = _nextButton;
-@synthesize segControl = _segControl;
+@synthesize questionArray;
+
 
 //----------------------------------------------------------------
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
@@ -45,7 +41,6 @@
         // Custom initialization
         
         [self populateQuestionArray ];
-        [self populateAnswerArray];
         
     }
     return self;
@@ -60,18 +55,12 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view from its nib.
     self.currentQuestionIndex = 0;
-    // load question 1
     
-    self.agreeAnswer = [[NSArray alloc] initWithObjects:
-                        @"Strongly disagree", @"Disagree", @"Neither",
-                        @"Agree", @"Strongly agree", nil];
+    // load question 1    
+    [self loadQuestion:self.currentQuestionIndex];
     
-    self.interfaceAnswer = [[NSArray alloc] initWithObjects:
-                            @"Definitely Sliders", @"Maybe Sliders", @"Neither",
-                            @"Maybe Zoomer", @"Definitely Zoomer", nil];
-    agreeType = YES;
+    self.previousButton.hidden = YES; // dont bother
     
-    [self loadQuestion:self.currentQuestionIndex];
 }
 //----------------------------------------------------------------
 - (void)didReceiveMemoryWarning
@@ -86,7 +75,7 @@
     [_titleText release];
     [_finishButton release];
     [_nextButton release];
-    [_segControl release];
+    [_previousButton release];
     [super dealloc];
 }
 //----------------------------------------------------------------
@@ -95,19 +84,25 @@
     [self setTitleText:nil];
     [self setFinishButton:nil];
     [self setNextButton:nil];
-    [self setSegControl:nil];
+    [self setPreviousButton:nil];
     [super viewDidUnload];
 }
 //----------------------------------------------------------------
-- (IBAction)answerWasSelected:(id)sender {
-    // look at property?
+-(IBAction)hide:(id)sender{
+    // called when finish button hit
+    // c++ call with NSArray argument??
+    // load answers into a c++ vector;
+    vector<int> answersArray;
+
+    Question *q;
     
-}
-
-//----------------------------------------------------------------
--(IBAction)hide:(id)sender{
-    // c++ call with NSArray argument??
-    ((testApp *)self.theOFAppRef)->questionnaireHidden(self.answerArray);
+    for(int i=0;i<[questionArray count];i++){
+        q = [questionArray objectAtIndex:i];
+        answersArray.push_back(q.answer);
+        
+    }
+    
+    ((testApp *)self.theOFAppRef)->questionnaireHidden(answersArray);
 	self.view.hidden = YES;
 }
 //----------------------------------------------------------------
@@ -139,28 +134,15 @@
         [self loadQuestion:self.currentQuestionIndex];
     }
 }
-//----------------------------------------------------------------
 
-// NAH
-- (IBAction)answerSelected:(id)sender {
-    // nice short lines of code.
-    
-    [self.answerArray replaceObjectAtIndex:self.currentQuestionIndex withObject:[NSNumber numberWithInteger:self.segControl.selectedSegmentIndex]];
-    
-    // chek wot we just rote
-    
-    NSLog(@"%@",[self.answerArray objectAtIndex:self.currentQuestionIndex]);
-    
-    
-}
 //----------------------------------------------------------------
 
 - (void)showThanks{
     // hide next question button
     self.nextButton.hidden = YES;
     // hide selector
-    self.segControl.hidden = YES;
-    
+    self.picker.hidden = YES;
+    self.previousButton.hidden = YES;
     
     self.titleText.text = @"Thank you!";
     
@@ -174,80 +156,43 @@
     qtitle = [@"Question " stringByAppendingFormat:@"%d / 16",questionIndex+1];
     self.titleText.text = qtitle;
     
-    self.questionText.text = [self.questionArray objectAtIndex:questionIndex];
+    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
     
-    // if question already answered show that
-    NSInteger answerInt = [[self.answerArray objectAtIndex:questionIndex] integerValue];
+    self.questionText.text = curQ.questionText;
     
-    // set different answer type
-    agreeType = [answerTypeArray objectAtIndex:questionIndex];
-    // then refresh picker view content
+    
+    // refresh picker view content
     [picker reloadComponent:0];
     
 
-    // DUZZNT WERK
-    if(answerInt==-1){
-        // select "neither" (2)
-        NSLog(@"No answer answerInt %d", answerInt);
-        [picker selectRow:2 inComponent:0 animated:YES];
-        
-    }else{
-        // select previous answer
-        NSLog(@"Prev answer answerInt %d", answerInt);
-        [picker selectRow:answerInt inComponent:0 animated:YES];
-    }
+    NSLog(@"Prev answer answerInt %d", curQ.answer);
+    [picker selectRow:curQ.answer inComponent:0 animated:YES];
+
 }
 //----------------------------------------------------------------
 - (void)populateQuestionArray{
-    self.questionArray = [[NSArray alloc] initWithObjects:
-                          @"I am familiar with music software and synthesisers.",
-                          @"The best way to get a feel for the possibilities of the synth was with:",
-                          @"Interesting sounds could be discovered more quickly as a result of using:",
-                          @"A sound could be fine tuned more easily using:",
-                          @"The correspondence between the sliders and the grid was understandable.",
-                          @"The interface that felt more familiar was:",
-                          @"Scrolling a greater distance the zoom grid seemed to correspond to larger  difference in the sound.",
-                          @"The ability to see other presets on the grid was useful.",
-                          @"The range of sounds was too limited to be able to judge the eventual usefulness of the interface.",
-                          @"The interface better for generating new ideas was",
-                          @"The interface better for live performance would be:",
-                          @"A specific type of sound could be found more quickly using:",
-                          @"I felt more in control when using:",
-                          @"The Zoomer was an improvement on just using a randomiser.",
-                          @"The combination of Zoomer and Sliders was more useful than either individually.",
-                          @"Overall, I preferred using:",
+
+    self.questionArray = [NSArray arrayWithObjects:
+                          [[Question alloc] initWithTextAndType:@"I am familiar with music software and sound synthesis.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"The best way to get a feel for the possibilities of the synth was with:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"Interesting sounds could be discovered more quickly as a result of using:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"A sound could be fine tuned more easily using:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"The correspondence between the sliders and the grid was understandable.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"The interface that felt more familiar was:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"Scrolling a greater distance the zoom grid seemed to correspond to larger  difference in the sound.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"The ability to see other presets on the grid was useful.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"The range of sounds was too limited to be able to judge the eventual usefulness of the interface.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"The interface better for generating new ideas was":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"The interface better for live performance would be:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"A specific type of sound could be found more quickly using:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"I felt more in control when using:":SLIDERS_ZOOMER],
+                          [[Question alloc] initWithTextAndType:@"The Zoomer was an improvement on just using a randomiser.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"The combination of Zoomer and Sliders was better than either individually.":AGREE_DISAGREE],
+                          [[Question alloc] initWithTextAndType:@"Overall, I preferred using:":SLIDERS_ZOOMER],
                           nil];
-    self.answerTypeArray = [[NSArray alloc] initWithObjects:
-                            YES,
-                            NO,
-                            NO,
-                            NO,
-                            YES,
-                            NO,
-                            YES,
-                            YES,
-                            YES,
-                            NO,
-                            NO,
-                            NO,
-                            NO,
-                            YES,
-                            YES,
-                            NO,
-                            nil]
+ 
 }
-//----------------------------------------------------------------
-- (void)populateAnswerArray{
-    int N = [self.questionArray count];
 
-    //[self.answerArray initWithCapacity:N]; // necessary?
-    self.answerArray = [[NSMutableArray alloc] initWithCapacity:N];
-    // set the number to what?
-    for(int i=0;i<N;i++){
-        [self.answerArray addObject:[NSNumber numberWithInt:-1]];
-    }
-    
-}
 //----------------------------------------------------------------
 #pragma mark -
 #pragma mark PickerView DataSource
@@ -257,44 +202,38 @@
 {
     return 1;
 }
+//----------------------------------------------------------------
 - (NSInteger)pickerView:(UIPickerView *)pickerView
 numberOfRowsInComponent:(NSInteger)component
 {
-    return [agreeAnswer count]; // always 5
+    return 6; // always 6 
 }
+//----------------------------------------------------------------
 - (NSString *)pickerView:(UIPickerView *)pickerView
              titleForRow:(NSInteger)row
             forComponent:(NSInteger)component
 {
-    if(agreeType){
-        return [agreeAnswer objectAtIndex:row];
-    }else{
-        return [interfaceAnswer objectAtIndex:row];
-    }
+    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
+
+    // get array of answers from Question class
+    NSArray * answers = [Question answersWithType:curQ.questionType];
+    return [answers objectAtIndex:row];
+
 }
-
+//----------------------------------------------------------------
 #pragma mark -
 #pragma mark PickerView Delegate
 -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
       inComponent:(NSInteger)component
 {
-    
+    Question *curQ = [questionArray objectAtIndex:self.currentQuestionIndex];
     // set question answerArray
-    [self.answerArray replaceObjectAtIndex:self.currentQuestionIndex withObject:[NSNumber numberWithInteger:row]];
+    curQ.answer = row;
     
     // chek wot we just rote
     
-    NSLog(@"%@",[self.answerArray objectAtIndex:self.currentQuestionIndex]);
-    /*
-     float rate = [[exchangeRates objectAtIndex:row] floatValue];
-     float dollars = [dollarText.text floatValue];
-     float result = dollars * rate;
-     
-     NSString *resultString = [[NSString alloc] initWithFormat:
-     @"%.2f USD = %.2f %@", dollars, result,
-     [countryNames objectAtIndex:row]];
-     resultLabel.text = resultString;
-     */
+    NSLog(@"Answer: %d",curQ.answer);
+
 }
 
 @end // end implementation
--- a/QuestionnaireViewController.xib	Fri Jan 18 15:48:33 2013 +0000
+++ b/QuestionnaireViewController.xib	Thu Jan 24 18:14:40 2013 +0000
@@ -40,7 +40,7 @@
 					<object class="IBUIButton" id="871929113">
 						<reference key="NSNextResponder" ref="766721923"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{517, 907}, {121, 44}}</string>
+						<string key="NSFrame">{{315, 645}, {121, 44}}</string>
 						<reference key="NSSuperview" ref="766721923"/>
 						<reference key="NSWindow"/>
 						<string key="NSReuseIdentifierKey">_NS:9</string>
@@ -75,10 +75,10 @@
 					<object class="IBUILabel" id="783180915">
 						<reference key="NSNextResponder" ref="766721923"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{118, 96}, {212, 53}}</string>
+						<string key="NSFrame">{{91, 51}, {212, 53}}</string>
 						<reference key="NSSuperview" ref="766721923"/>
 						<reference key="NSWindow"/>
-						<reference key="NSNextKeyView" ref="838658605"/>
+						<reference key="NSNextKeyView" ref="791686696"/>
 						<string key="NSReuseIdentifierKey">_NS:9</string>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
@@ -108,10 +108,10 @@
 					<object class="IBUILabel" id="838658605">
 						<reference key="NSNextResponder" ref="766721923"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{118, 178}, {533, 124}}</string>
+						<string key="NSFrame">{{91, 101}, {334, 125}}</string>
 						<reference key="NSSuperview" ref="766721923"/>
 						<reference key="NSWindow"/>
-						<reference key="NSNextKeyView"/>
+						<reference key="NSNextKeyView" ref="356964106"/>
 						<string key="NSReuseIdentifierKey">_NS:9</string>
 						<bool key="IBUIOpaque">NO</bool>
 						<bool key="IBUIClipsSubviews">YES</bool>
@@ -125,7 +125,7 @@
 						</object>
 						<nil key="IBUIHighlightedColor"/>
 						<int key="IBUIBaselineAdjustment">0</int>
-						<int key="IBUINumberOfLines">3</int>
+						<int key="IBUINumberOfLines">4</int>
 						<object class="IBUIFontDescription" key="IBUIFontDescription">
 							<int key="type">1</int>
 							<double key="pointSize">18</double>
@@ -136,12 +136,12 @@
 							<int key="NSfFlags">16</int>
 						</object>
 						<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
-						<double key="preferredMaxLayoutWidth">533</double>
+						<double key="preferredMaxLayoutWidth">334</double>
 					</object>
 					<object class="IBUIButton" id="960474577">
 						<reference key="NSNextResponder" ref="766721923"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{517, 561}, {121, 44}}</string>
+						<string key="NSFrame">{{315, 490}, {121, 44}}</string>
 						<reference key="NSSuperview" ref="766721923"/>
 						<reference key="NSWindow"/>
 						<reference key="NSNextKeyView" ref="871929113"/>
@@ -164,13 +164,14 @@
 					<object class="IBUIButton" id="356964106">
 						<reference key="NSNextResponder" ref="766721923"/>
 						<int key="NSvFlags">292</int>
-						<string key="NSFrame">{{113, 561}, {157, 44}}</string>
+						<string key="NSFrame">{{97, 490}, {157, 44}}</string>
 						<reference key="NSSuperview" ref="766721923"/>
 						<reference key="NSWindow"/>
-						<reference key="NSNextKeyView" ref="791686696"/>
+						<reference key="NSNextKeyView" ref="960474577"/>
 						<string key="NSReuseIdentifierKey">_NS:9</string>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
+						<bool key="IBUIEnabled">NO</bool>
 						<int key="IBUIContentHorizontalAlignment">0</int>
 						<int key="IBUIContentVerticalAlignment">0</int>
 						<int key="IBUIButtonType">1</int>
@@ -187,10 +188,10 @@
 					<object class="IBUIPickerView" id="791686696">
 						<reference key="NSNextResponder" ref="766721923"/>
 						<int key="NSvFlags">290</int>
-						<string key="NSFrame">{{113, 301}, {250, 216}}</string>
+						<string key="NSFrame">{{91, 234}, {334, 216}}</string>
 						<reference key="NSSuperview" ref="766721923"/>
 						<reference key="NSWindow"/>
-						<reference key="NSNextKeyView" ref="960474577"/>
+						<reference key="NSNextKeyView" ref="838658605"/>
 						<string key="NSReuseIdentifierKey">_NS:9</string>
 						<string key="targetRuntimeIdentifier">IBIPadFramework</string>
 						<bool key="IBUIShowsSelectionIndicator">YES</bool>
@@ -277,6 +278,14 @@
 					<int key="connectionID">59</int>
 				</object>
 				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">previousButton</string>
+						<reference key="source" ref="841351856"/>
+						<reference key="destination" ref="356964106"/>
+					</object>
+					<int key="connectionID">60</int>
+				</object>
+				<object class="IBConnectionRecord">
 					<object class="IBCocoaTouchEventConnection" key="connection">
 						<string key="label">nextQuestionPressed:</string>
 						<reference key="source" ref="960474577"/>
@@ -345,10 +354,10 @@
 						<array class="NSMutableArray" key="children">
 							<reference ref="783180915"/>
 							<reference ref="838658605"/>
-							<reference ref="356964106"/>
+							<reference ref="791686696"/>
 							<reference ref="960474577"/>
 							<reference ref="871929113"/>
-							<reference ref="791686696"/>
+							<reference ref="356964106"/>
 						</array>
 						<reference key="parent" ref="0"/>
 					</object>
@@ -404,7 +413,7 @@
 			<nil key="activeLocalization"/>
 			<dictionary class="NSMutableDictionary" key="localizations"/>
 			<nil key="sourceID"/>
-			<int key="maxID">59</int>
+			<int key="maxID">60</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -412,17 +421,12 @@
 					<string key="className">QuestionnaireViewController</string>
 					<string key="superclassName">UIViewController</string>
 					<dictionary class="NSMutableDictionary" key="actions">
-						<string key="answerSelected:">id</string>
 						<string key="hide:">id</string>
 						<string key="nextQuestionPressed:">id</string>
 						<string key="previousQuestionPressed:">id</string>
 						<string key="show:">id</string>
 					</dictionary>
 					<dictionary class="NSMutableDictionary" key="actionInfosByName">
-						<object class="IBActionInfo" key="answerSelected:">
-							<string key="name">answerSelected:</string>
-							<string key="candidateClassName">id</string>
-						</object>
 						<object class="IBActionInfo" key="hide:">
 							<string key="name">hide:</string>
 							<string key="candidateClassName">id</string>
@@ -444,8 +448,8 @@
 						<string key="finishButton">UIButton</string>
 						<string key="nextButton">UIButton</string>
 						<string key="picker">UIPickerView</string>
+						<string key="previousButton">UIButton</string>
 						<string key="questionText">UILabel</string>
-						<string key="segControl">UISegmentedControl</string>
 						<string key="titleText">UILabel</string>
 					</dictionary>
 					<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
@@ -461,14 +465,14 @@
 							<string key="name">picker</string>
 							<string key="candidateClassName">UIPickerView</string>
 						</object>
+						<object class="IBToOneOutletInfo" key="previousButton">
+							<string key="name">previousButton</string>
+							<string key="candidateClassName">UIButton</string>
+						</object>
 						<object class="IBToOneOutletInfo" key="questionText">
 							<string key="name">questionText</string>
 							<string key="candidateClassName">UILabel</string>
 						</object>
-						<object class="IBToOneOutletInfo" key="segControl">
-							<string key="name">segControl</string>
-							<string key="candidateClassName">UISegmentedControl</string>
-						</object>
 						<object class="IBToOneOutletInfo" key="titleText">
 							<string key="name">titleText</string>
 							<string key="candidateClassName">UILabel</string>
--- a/eventLogger.h	Fri Jan 18 15:48:33 2013 +0000
+++ b/eventLogger.h	Thu Jan 24 18:14:40 2013 +0000
@@ -12,6 +12,7 @@
 #define __oscSenderExample__eventLogger__
 
 #define EVENT_LOG_FILENAME "log.json"
+#define SERVER_URL "http://127.0.0.1:8080/testservice/"
 
 #include "ofMain.h"
 #include "ofxiPhone.h"
@@ -20,6 +21,7 @@
 #include <sys/time.h>
 #include <iostream>
 #include <string>
+#include <cstring>
 #include <map>
 #include "2dvector.h"
 #include "json.h"
@@ -28,11 +30,14 @@
 
 
 // can add but don't change ordering - this will invalidate logs
+#define PROGRAM_VERSION 1.0
 enum leventType {SAVE_PRESET,
     SAVE_DESET,
     SCROLL,
+    ZOOM,
     SCROLL_STOPPED,
-    ZOOM,
+    ZOOM_STOPPED,
+    SNAPPED_TO_PRESET,
     CHANGE_SLIDER,
     SWAP_VIEW,
     SET_MIN_ZOOM,
@@ -109,7 +114,7 @@
 class EventLogger{
 public:
     bool loggingEnabled;
-    bool internetConnectionOK;
+    bool serverConnectionOK;
     unsigned int deviceID; // unique get something from hardware??
     unsigned int totalInteractionTime, sessionTime, sessionStartTime;
     string userName; // not unique
@@ -119,7 +124,7 @@
     void exitAndSave();
     void setUsername(const char *u);
     void logEvent(const leventType& evtType,const TwoVector& centre = TwoVector(), const double& scale = 1.0, const int& sliderID = -1, const double& sliderVal = 0.0);
-
+    void questionnaireAnswersObtained(vector<int> answers);
     
 private:
     // what we need...
@@ -136,17 +141,21 @@
     unsigned int nextUploadQty;
 
     
+    ofxiPhoneDeviceType iOSdeviceType;
     
     bool testConnection();
-    
+    vector<int> questionnaireAnswers;
+    bool questionnaireCompleted;
+    bool questionnaireUploaded;
 
-    void sendHttp();
     void checkLogFile();
-    bool attemptUpload();
+    bool uploadEventLog();
     void firstEverAppOpen();
     void readJsonToLog(const string &jsonFile);
-    
+    bool uploadQuestionnaire();
+    bool sendToServer(string functionName, Json::Value jsonData);
     Json::Value logsToJson();
+    Json::Value questionnaireToJson();
     void printAll(){
         cout << "ALL LOGGED EVENTS!: \n";
         vector<lEvent>::iterator evIter;
--- a/eventLogger.mm	Fri Jan 18 15:48:33 2013 +0000
+++ b/eventLogger.mm	Thu Jan 24 18:14:40 2013 +0000
@@ -19,7 +19,14 @@
 
     
     loggingEnabled = true;
-    internetConnectionOK = false;
+    serverConnectionOK = false;
+    questionnaireCompleted = false;
+    questionnaireUploaded = false;
+    
+    
+    ofxiPhoneDeviceType iOSdeviceType = ofxiPhoneGetDeviceType();
+    cout << "Device: " << iOSdeviceType << '\n';
+    
     nextUploadQty = 5000; // amount of data uploaded is always more than 5000 events
 }
 //---------------------------------------------------------------------------
@@ -33,26 +40,82 @@
 
 }
 //---------------------------------------------------------------------------
-bool EventLogger::testConnection(){
-    string url = "http://127.0.0.1:8080/testservice/testConnection?testtext={%22test%22=%22sometext%22}";
-    bool success = false;
+void EventLogger::questionnaireAnswersObtained(vector<int> answers){
+    
+    questionnaireCompleted = true;
+    questionnaireAnswers = answers;
+    
+    uploadQuestionnaire();
+    
+}
+//---------------------------------------------------------------------------
+bool EventLogger::uploadQuestionnaire(){
+    // show indicator
+    cout << "^^^^^^^^ UPLOADING QUESTIONNAIRE ^^^^^^^^ \n";
+    
+    questionnaireUploaded = sendToServer("questionnaire", questionnaireToJson());
+    return questionnaireUploaded;
+}
+//---------------------------------------------------------------------------
+bool EventLogger::sendToServer(string functionName, Json::Value jsonData){
+    bool sent;
+    string request;
+
+    if(functionName == "testConnection"){
+         request = "http://127.0.0.1:8080/testservice/testConnection?jsontext=";
+    }else if(functionName == "questionnaire"){
+         request = "http://127.0.0.1:8080/testservice/questionnaire?jsontext=";
+    }else if(functionName == "eventlog"){
+         request = "http://127.0.0.1:8080/testservice/eventlog?jsontext=";
+    }
+    Json::FastWriter writer;
+    string jsontext = writer.write( jsonData );
+    
+    if (!jsontext.empty() && jsontext[jsontext.length()-1] == '\n') {
+        jsontext.erase(jsontext.length()-1);
+    }
+
+    request.append(jsontext);
+
     ofURLFileLoader fileLoader;
     ofHttpResponse resp;
-    resp = fileLoader.get(url);
-    
+    resp = fileLoader.get(request);
+
     cout << "HTTP STATUS  " << resp.status << "\n";
     cout << "HTTP ERROR  " << resp.error << "\n";
-    cout << "HTTP DATA  " << resp.data << "\n";
+    cout << "HTTP DATA  " << resp.data << "\n"; // ofBuffer
     
-    if (resp.status == 0){
-        success = true;
-        internetConnectionOK = true;
+    stringstream response;
+    response << resp.data;
+    
+    if (resp.status == 200){
+        if(response.str() == "OK"){
+            
+            sent = true;
+        }else{
+            // not ok
+            // problem serverside
+            sent = false;
+        }
     }else{
-        success = false;
-        internetConnectionOK = false;
+        
+        sent = false;
         // SHOW AN ALERT TO USER?
     }
-    return success;
+    return sent;
+}
+//---------------------------------------------------------------------------
+bool EventLogger::testConnection(){
+    Json::Value root;
+    root["test"] = "test";
+    
+    
+    serverConnectionOK = sendToServer("testConnection", root);
+    if (serverConnectionOK){
+        cout << "^^^^^^^^ server connection OK ^^^^^^^^ \n";
+    }else{
+         cout << "server connection ERROR \n";
+    }
 }
 //---------------------------------------------------------------------------
 void EventLogger::readJsonToLog(const string &jsonFile){
@@ -88,7 +151,7 @@
     if ( !parsingSuccessful )
     {
         // report to the user the failure and their locations in the document.
-        std::cout  << "Failed to parse preset JSON\n"
+        std::cout  << "Failed to parse event log JSON: \n"
         << reader.getFormattedErrorMessages();
         return;
     }
@@ -97,6 +160,22 @@
     userName = root["userName"].asString();
     deviceID = root["deviceID"].asLargestInt();
     totalInteractionTime = root["totalInteractionTime"].asLargestInt();
+    questionnaireCompleted = root["questionnaireCompleted"].asBool();
+    questionnaireUploaded = root["questionnaireUploaded"].asBool();
+    
+    
+    if(questionnaireCompleted && !questionnaireUploaded){
+        // then read it in and upload it
+        Json::Value JArray = root["questionnaireAnswers"];
+        if(JArray.size() < 2){
+            cout << "Error - status of questionnaire is wierd\n";
+        }
+        for ( unsigned int i = 0; i < JArray.size(); i++ )
+        {
+            questionnaireAnswers.push_back(JArray[1].asInt());
+        }
+        uploadQuestionnaire();
+    }
     
     // check for unuploaded evts
     const Json::Value jlogs = root["events"];
@@ -104,21 +183,17 @@
     for ( int index = 0; index < jlogs.size(); ++index ) theEvents.push_back(lEvent(jlogs[index]));
     if(theEvents.size() > nextUploadQty){
         //try to upload
-        attemptUpload();
+        uploadEventLog();
     }
     // TODO if the total interaction time is greater than a certain amount && no questions answered - questionnaire time!
     cout << "Total interaction time: " << totalInteractionTime << '\n';
     
-    if(totalInteractionTime > 0){
-        // testApp.showQuestionnaire();
+    if(totalInteractionTime > 123){
+        //testApp->showQuestionnaire();
         
     }
-    // is there logged stuff that hasn't been uploaded yet?
-    
-    // don't actually need to load old ones unless uploading? or saving...
-    //while(eventLogFile >> nextLine){
-    
-    //}
+    // is there logged stuff that hasn't been uploaded yet? - handled automatically
+
 
     
 }
@@ -126,33 +201,12 @@
 
 //---------------------------------------------------------------------------
 
-bool EventLogger::attemptUpload(){
+bool EventLogger::uploadEventLog(){
+    // show indicator
+    cout << "^^^^^^^^  UPLOADING: " << theEvents.size() << " EVENTS ^^^^^^^^ .\n";
     
-    // do simple check of internet connection ?
-    // if not connected return
-    if(!internetConnectionOK){
-        return false;
-    }
-    // show indicator
-    cout << "UPLOADING: " << theEvents.size() << " logs.\n";
-    
-    // if numlogs > 500000 show alert...?
-    
-    string url = "http://127.0.0.1:8080/testservice/eventlog?jsontext=";
-    url.append(logsToJson().toStyledString());
-    
-    
-    ofURLFileLoader fileLoader;
-    ofHttpResponse resp;
-    resp = fileLoader.get(url); // Does this sit and wait and arse up interaction?
-    
-    cout << "HTTP STATUS  " << resp.status << "\n";
-    cout << "HTTP ERROR  " << resp.error << "\n";
-    cout << "HTTP DATA  " << resp.data << "\n";
-    
-    bool uploaded = false;
-    if (resp.status == 0) uploaded = true; // should do a check on server, and report in data ?
-    if(!uploaded){
+    bool logUploaded = sendToServer("eventlog", logsToJson());
+    if(!logUploaded){
         // try later
         nextUploadQty += 5000;
     }else{
@@ -160,10 +214,9 @@
         // if success - clear memory
         theEvents.clear();
     }
-    return uploaded;
+    return logUploaded;
     
 }
-
 //----------------------------------------------------------------------------
 //void EventLogger::deleteLogFile(){
 
@@ -172,6 +225,8 @@
 void EventLogger::firstEverAppOpen(){
     deviceID = ofGetSystemTimeMicros();
     totalInteractionTime = 0;
+    questionnaireCompleted = false;
+    questionnaireUploaded = false;
     
     [usernameAlertViewController showUserNamePrompt];
     // then we get userName via setUsername, called from button delegate
@@ -212,6 +267,11 @@
             break;
         case SCROLL_STOPPED:
             theEvents.push_back(lEvent(evtType,centre.x,centre.y));
+            cout << "SCROLL STOPPED EVENT\n";
+            break;
+        case SNAPPED_TO_PRESET:
+            theEvents.push_back(lEvent(evtType,centre.x,centre.y,sliderID));
+            cout << "SCROLL STOPPED EVENT\n";
             break;
         case ZOOM:
             theEvents.push_back(lEvent(evtType,scale));
@@ -225,7 +285,7 @@
     }
     if(theEvents.size() > nextUploadQty){
         //try to upload
-        attemptUpload();
+        uploadEventLog();
     }
     //sessionTime = (ofGetSystemTime() - sessionStartTime);
     
@@ -233,20 +293,6 @@
 }
 
 //---------------------------------------------------------------------------
-void EventLogger::sendHttp(){
-    
-    string url = "http://www.rootnot.co.uk/cgi-bin/zoomlogs.cgi";
-    ofURLFileLoader fileLoader;
-    ofHttpResponse resp;
-    resp = fileLoader.get(url);
-    cout << "HTTP STATUS  " << resp.status << "\n";
-    cout << "HTTP ERROR  " << resp.error << "\n";
-    cout << "HTTP DATA  " << resp.data << "\n";
-}
-
-
-
-//---------------------------------------------------------------------------
 
 void EventLogger::exitAndSave(){
     totalInteractionTime = totalInteractionTime + (ofGetSystemTime() - sessionStartTime);
@@ -255,7 +301,7 @@
 
     Json::Value jlogs = logsToJson();
     // try to upload
-    bool uploaded = attemptUpload();
+    uploadEventLog();
     
     // write to file
     
@@ -271,9 +317,16 @@
 
     vector<lEvent>::iterator eventIter;
     
+    root["programVersion"] = PROGRAM_VERSION;
     root["userName"] = userName;
     root["deviceID"] = deviceID;
+    root["iOSdeviceType"] = iOSdeviceType;
     root["totalInteractionTime"] = totalInteractionTime;
+    root["questionnaireCompleted"] = questionnaireCompleted;
+    root["questionnaireUploaded"] = questionnaireUploaded;
+    if(questionnaireCompleted && !questionnaireUploaded){
+        root["qAnswers"] = questionnaireToJson();
+    }
     
     int i = 0;
     for(eventIter = theEvents.begin(); eventIter < theEvents.end(); eventIter++){
@@ -283,6 +336,31 @@
     
     return root;
 }
+
 //---------------------------------------------------------------------------
+
+Json::Value EventLogger::questionnaireToJson(){
+    // put all answers into Json formatted string
+    Json::Value root;
+    
+    vector<int>::iterator aIter;
+
+    Json::Value questionnaire;
+    
+    int i = 0;
+    for(aIter = questionnaireAnswers.begin(); aIter < questionnaireAnswers.end(); aIter++){
+        questionnaire[i] = (*aIter);
+        i++;
+    }
+
+    root["qAnswers"] = questionnaire;
+    root["userName"] = userName;
+    root["deviceID"] = deviceID;
+    root["iOSdeviceType"] = iOSdeviceType;
+    root["programVersion"] = PROGRAM_VERSION;
+    
+    return root;
+}
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
--- a/grid.mm	Fri Jan 18 15:48:33 2013 +0000
+++ b/grid.mm	Thu Jan 24 18:14:40 2013 +0000
@@ -497,7 +497,8 @@
             }
         }
         snapCentre = closestPreset->coordinates;
-        
+        eventLogger.logEvent(SNAPPED_TO_PRESET, getCoord(),closestPreset->creationTime );
+        cout << "SNAPPED CHECK\n";
     }else{
         snapped = false;
         closestPreset = NULL;
--- a/presetManager.h	Fri Jan 18 15:48:33 2013 +0000
+++ b/presetManager.h	Thu Jan 24 18:14:40 2013 +0000
@@ -99,6 +99,8 @@
 public:
     int nextID;
     int timesOpened;
+    bool presetAlertShowing;
+    
     // names values
     // check if already there
     // find and return all(?) presets within a certain coordinate range
--- a/presetManager.mm	Fri Jan 18 15:48:33 2013 +0000
+++ b/presetManager.mm	Thu Jan 24 18:14:40 2013 +0000
@@ -92,6 +92,10 @@
     nextID = 0;
    
     string ts = ofGetTimestampString();
+    
+    presetAlertShowing = false;
+
+    
     cout << "ofGetTimestampString: " << ts << '\n';
 }
 //---------------------------------------------------------------------------
@@ -122,7 +126,7 @@
     string line;
     if(!theFile){
         cout<<"can't find preset file \n";
-        
+        return;
     }else{
         
         while(theFile){
@@ -140,7 +144,7 @@
     if ( !parsingSuccessful )
     {
         // report to the user the failure and their locations in the document.
-        std::cout  << "Failed to parse preset JSON\n"
+        std::cout  << "Failed to parse preset JSON: \n"
         << reader.getFormattedErrorMessages();
         return;
     }
@@ -163,13 +167,18 @@
     }
 }
 void PresetManager::showNameDialog(){
-    [presetAlertViewController showPresetNamePrompt];
+    if(!presetAlertShowing){ // this is to stop wierd infinite loop in ios5 (simulator)
+        presetAlertShowing = true;
+        [presetAlertViewController showPresetNamePrompt];
+        
+    }
+    
 }
 //---------------------------------------------------------------------------
 // when save button pressed
 int PresetManager::addPreset(const string name){
 
-    
+    presetAlertShowing = false;
     // check for same name
     vector<Preset *>::iterator iter;
     for(iter = thePresets.begin(); iter < thePresets.end(); iter++){
--- a/testApp.h	Fri Jan 18 15:48:33 2013 +0000
+++ b/testApp.h	Thu Jan 24 18:14:40 2013 +0000
@@ -87,20 +87,21 @@
     void sendOSCParams();
     
     void showQuestionnaire();
-    void questionnaireHidden(NSArray * answers);
+    void questionnaireHidden(vector<int> answers);
     
     // stardard GUI - knbs and sliders - hides zoomer
     bool standardGUIShowing;
     void standardGUIEvent(ofxUIEventArgs &e);
     void setupStandardGui();
     ofxUICanvas *standardGUI;
+    void sliderMoved(int which, float value);
+    void setAllGUISliders(vector<int> vals);
     
     // zoom gui - the swap view button and save preset button
     void zoomGUIEvent(ofxUIEventArgs &e);
     void setupZoomGui();
     
-    void sliderMoved(int which, float value);
-    void setAllGUISliders(vector<int> vals);
+
     void sendParametersToPD();
     void sendOscShape(int ctrlin);
     void sendFiltShape(int ctrlin);
@@ -119,3 +120,7 @@
     
 };
 
+// should be off split into
+// GUI controller
+// parameter converter
+// 
\ No newline at end of file
--- a/testApp.mm	Fri Jan 18 15:48:33 2013 +0000
+++ b/testApp.mm	Thu Jan 24 18:14:40 2013 +0000
@@ -43,9 +43,6 @@
     freqIndexes.push_back(7);
     freqIndexes.push_back(8);
     
-    ofxiPhoneDeviceType device = ofxiPhoneGetDeviceType();
-    cout << "Device: " << device << '\n';
-    
     
     ofxiPhoneSetOrientation( OFXIPHONE_ORIENTATION_PORTRAIT ); // do this before setting up all the other objects
     
@@ -162,6 +159,8 @@
 void testApp::showQuestionnaire(){
     // stop updating / drawing
 
+    // if(eventLogger.questionnaireCompleted) return;
+    
     paused = true;
     
     questionnaireViewController	= [[QuestionnaireViewController alloc] initWithNibName:@"QuestionnaireViewController" bundle:nil];
@@ -177,9 +176,9 @@
 
 }
 //--------------------------------------------------------------
-void testApp::questionnaireHidden(NSArray * answers){
+void testApp::questionnaireHidden(vector<int> answers){
     // send answers to server as json
-    
+    eventLogger.questionnaireAnswersObtained(answers);
     
     // set "we've done questionnaire" to true in event logger
     paused = false;
@@ -346,19 +345,24 @@
     if (numActiveTouches == 0){ // no touches, use momentum
         // TODO set velocity to 0 when hits walls
 
-        if(moveVel.norm() > 0.3 && !theGridView.snapped){
-            theGridView.move(moveVel);
-            moveVel = moveVel*slowFactor;
-         
+        if(moveVel.norm() > 0.3){
+            if(theGridView.snapped){
+                // stop it, send snap event
+                moveVel.setCoord(0.0,0.0);
+            }else{
+                theGridView.move(moveVel);
+                moveVel = moveVel*slowFactor;
+            }
          // and get new parameter values
             setAllGUISliders(theGridView.getParams());
             sendParametersToPD();
-        }else if(moveVel.norm() > 0.01 || theGridView.snapped){
+        }else if(moveVel.norm() > 0.01){ // and less than 0.3
             // stop it
             moveVel.setCoord(0.0,0.0);
             setAllGUISliders(theGridView.getParams());
             sendParametersToPD();
             eventLogger.logEvent(SCROLL_STOPPED, theGridView.getCoord() );
+            
         }else{
             // stopped - do nothing
         }