changeset 45:351b0c8b34ac

Fixed issue where error message was shown every time the user chose to move continue using the keyboard. Fixed issue where data wasn't saving to file after questionaire. Changed SubjectData output filename to "<Participant ID>_qu.dat" (previously was "subjects.dat". Would have been overwritten as wasn't dynamic.
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Sun, 09 Jun 2013 22:06:52 +0100
parents a80321f83468
children 5f9dde32392f
files Experiment.class Experiment.java ExperimentController.class ExperimentController.java SubjectResults.class SubjectResults.java
diffstat 6 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
Binary file Experiment.class has changed
--- a/Experiment.java	Fri Jun 07 18:28:39 2013 +0100
+++ b/Experiment.java	Sun Jun 09 22:06:52 2013 +0100
@@ -99,7 +99,8 @@
     public void setSubjectID(String id) { 
         subjectID = id; 
         results.setSubjectID(id); 
-        results.setOutputFile(id); 
+        results.setOutputFile(id);
+        results.setSubjectDataFile(id);
         getCurrentBlock().getMelodyResults().setSubjectID(id); 
 	System.out.println("Subject ID = " + subjectID);
     }
@@ -125,8 +126,6 @@
         PRACTICE_MIDIFILELIST_FILE = MIDI_DIRECTORY + "pfilelist.txt"; 
         INSTRUCTIONS_FILE = inf;
         RESULTS_DIRECTORY = rdr + File.separator;
-        SUBJECT_RESULTS_FILE = 
-            RESULTS_DIRECTORY + "subjects" + RESULTS_EXTENSION;
         
         if (fs == 0)
             fullScreen = false;
@@ -217,6 +216,9 @@
     /* Main method */
     public static void main(String[] args) {
 	
+        System.out.println("Working Directory = " +
+                           System.getProperty("user.dir"));
+        
 	if (args.length == 15) {
 
         // Parse Arguments 
Binary file ExperimentController.class has changed
--- a/ExperimentController.java	Fri Jun 07 18:28:39 2013 +0100
+++ b/ExperimentController.java	Sun Jun 09 22:06:52 2013 +0100
@@ -19,7 +19,7 @@
     SubjectResults results; 
 
     InstructionsPanel ip; 
-    StimulusPanel sp; 
+    StimulusPanel sp;
     SubjectDataPanel sdp; 
     InterBlockPanel ibp;
     
@@ -112,7 +112,7 @@
 //                 exp.runExperiment(); 
 //             else 
 //                 reportError("You have already played the melody.");
-        } else if (source == sp.getNextButton()) { 
+        } else if (source == sp.getNextButton()) {
             nextStimuli(block);
         } else { 
 	    if (exp.getDebug()) 
@@ -135,6 +135,8 @@
 
     
     public void keyPressed(KeyEvent e)  {
+        showDefaultMessagePrompt();
+        
         if (exp.getDebug())
 	    System.out.println("Key pressed: " + e.getKeyChar());
         long time = System.nanoTime();
@@ -203,7 +205,9 @@
             
         } else if (sp.unansweredQuestions())
             reportError("There are unanswered questions.");
+        
         else {
+            showDefaultMessagePrompt();
             // store results (and write to file)
             if (exp.getAskFamiliarity()) {
                 String answer1 = (String)(sp.getQ1Box().getSelectedItem());
Binary file SubjectResults.class has changed
--- a/SubjectResults.java	Fri Jun 07 18:28:39 2013 +0100
+++ b/SubjectResults.java	Sun Jun 09 22:06:52 2013 +0100
@@ -21,18 +21,21 @@
     /* accessors */ 
     public String getSubjectID() { return subjectID; }
     public void setSubjectID(String id) { subjectID = id; } 
-    public void setSubjectData (ArrayList sd) { subjectData = sd; } 
+    public void setSubjectData (ArrayList sd) { subjectData = sd; }
+    public void setSubjectDataFile(String id){
+        subjectDataFile = new File(exp.RESULTS_DIRECTORY + File.separator + id + "_q" + exp.RESULTS_EXTENSION);
+    }
     public void setOutputFile (String id) {
-	outputFile = new File(exp.RESULTS_DIRECTORY + id + 
+        outputFile = new File(exp.RESULTS_DIRECTORY + id + 
                               exp.RESULTS_EXTENSION); 
     }
 
     /* constructor */ 
     public SubjectResults(Experiment e) { 
         exp = e; 
-        subjectDataFile = new File(exp.SUBJECT_RESULTS_FILE); 
+        //subjectDataFile = new File(exp.SUBJECT_RESULTS_FILE);
         results = new ArrayList(); 
-        subjectData = new ArrayList(); 
+        subjectData = new ArrayList();
     }
 
     /* methods */ 
@@ -59,7 +62,8 @@
         try {
             writer = new FileWriter (subjectDataFile, true);
         } catch (IOException e) {
-            System.out.println("Could not write file: " + outputFile.getPath());
+            System.out.println("Could not write file: " + subjectDataFile.getPath());
+            e.printStackTrace();
             return;
         }