From a0ee168bf29c43f0644eceac1ebc2ab6d8ec4872 Mon Sep 17 00:00:00 2001 From: John Gamboa Date: Sun, 1 Jul 2018 04:42:31 +0200 Subject: [PATCH 1/2] Implements (very uncleanly) Backward Digit Span task Changes to be committed: new file: modules/core_wm_modules/backward_digit_span.xml new file: src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java modified: src/main/java/jms/cogtasks/executables/WordDigitSpan.java new file: src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html --- .../core_wm_modules/backward_digit_span.xml | 288 ++++++++++++++++++ .../executables/BackwardDigitSpan.java | 64 ++++ .../cogtasks/executables/WordDigitSpan.java | 30 +- .../BackwardDigitSpanInstructions.html | 34 +++ 4 files changed, 401 insertions(+), 15 deletions(-) create mode 100755 modules/core_wm_modules/backward_digit_span.xml create mode 100644 src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java create mode 100644 src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html diff --git a/modules/core_wm_modules/backward_digit_span.xml b/modules/core_wm_modules/backward_digit_span.xml new file mode 100755 index 0000000..b63ed72 --- /dev/null +++ b/modules/core_wm_modules/backward_digit_span.xml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BackwardDigitSpanInstructions.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + endOfModule.htm + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java b/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java new file mode 100644 index 0000000..da8e451 --- /dev/null +++ b/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java @@ -0,0 +1,64 @@ +package jms.cogtasks.executables; + +import ch.tatool.core.data.*; +import ch.tatool.core.display.swing.status.StatusPanel; +import ch.tatool.core.display.swing.status.StatusRegionUtil; +import ch.tatool.data.Trial; +import ch.tatool.exec.ExecutionOutcome; + +public class BackwardDigitSpan extends WordDigitSpan{ + public void processProperties() { + int stimulus_num = numbers[numbers.length - (respCounter+1)]; + correctResponseDigits = Integer.valueOf(stimulus_num); + Question.getResponseProperty().setValue(this, givenResponseDigits); + Question.setQuestionAnswer(this, String.valueOf(stimulus_num), correctResponseDigits); + + + Boolean success = correctResponseDigits == givenResponseDigits; + loadProperty.setValue(this, numbers.length); + + Points.setZeroOneMinMaxPoints(this); + Points.setZeroOnePoints(this, success); + Result.getResultProperty().setValue(this, success); + + if (respCounter < (numbers.length - 1)) { + Misc.getOutcomeProperty().setValue(this, ExecutionOutcome.SUSPENDED); + } else { + Misc.getOutcomeProperty().setValue(this, ExecutionOutcome.FINISHED); + } + + trialNoProperty.setValue(this, trialCounter + 1); + + // change feedback status panel + changeStatusPanelOutcome(success); + + // set duration time property + long duration = 0; + if (endTime > 0) { + duration = endTime - startTime; + } + long ms = (long) duration / 1000000; + Timing.getDurationTimeProperty().setValue(this, ms); + + if (getExecutionContext() != null) { + Misc.getOutcomeProperty().setValue(getExecutionContext(), ExecutionOutcome.FINISHED); + } + + // create new trial and store all executable properties in the trial + Trial currentTrial = getExecutionContext().getExecutionData().addTrial(); + currentTrial.setParentId(getId()); + DataUtils.storeProperties(currentTrial, this); + } + + public void changeStatusPanelOutcome(Boolean value) { + StatusPanel panelFeedback = StatusRegionUtil.getStatusPanel(StatusPanel.STATUS_PANEL_OUTCOME); + if (panelFeedback != null) { + if (value == null) { + panelFeedback.reset(); + } else { + panelFeedback.setProperty(StatusPanel.PROPERTY_VALUE, value); + } + } + } + +} diff --git a/src/main/java/jms/cogtasks/executables/WordDigitSpan.java b/src/main/java/jms/cogtasks/executables/WordDigitSpan.java index dde8c4e..972e833 100644 --- a/src/main/java/jms/cogtasks/executables/WordDigitSpan.java +++ b/src/main/java/jms/cogtasks/executables/WordDigitSpan.java @@ -60,7 +60,7 @@ public class WordDigitSpan extends BlockingAWTExecutable implements private RegionsContainer regionsContainer; String current_user; - private int StimuliType = 0; //set this using the XML, 1 for digits, 2 for words.// + public int StimuliType = 0; //set this using the XML, 1 for digits, 2 for words.// final Font treb = new Font("Trebuchet MS", 1, 26); final Color fontColor = new Color(0,51,102); @@ -73,8 +73,8 @@ public enum Phase { private Phase currentPhase; //properties of interest// - private IntegerProperty loadProperty = new IntegerProperty("load"); - private IntegerProperty trialNoProperty = new IntegerProperty("trialNo"); + public IntegerProperty loadProperty = new IntegerProperty("load"); + public IntegerProperty trialNoProperty = new IntegerProperty("trialNo"); //panels// private CenteredTextPanel displayPanel; @@ -88,8 +88,8 @@ public enum Phase { private static int interResponseDuration = 1000; //blank screen between recalls// //stimuli// - private int[] numbers; //if digit span// - private String[] words; //if word span// + public int[] numbers; //if digit span// + public String[] words; //if word span// private ArrayList wordBank = new ArrayList(); //method will fill this arraylist with words from an external file// private String WordBankFileName = ""; private Random rand; @@ -110,13 +110,13 @@ public enum Phase { //should the list length be ordered presentation or randomised private int randomisedTrials = 0; //default is 0 which is for in sequence, set to 1 in the XML for randomised order. - private int trialCounter = 0; + public int trialCounter = 0; private int memCounter; //counts memoranda presented per trial// - private int respCounter; //counts responses given// - private int correctResponseDigits; //if digit span// - private String correctResponseWord; //if word span// - private int givenResponseDigits; //if digit span// - private String givenResponseWord; //if word span// + public int respCounter; //counts responses given// + public int correctResponseDigits; //if digit span// + public String correctResponseWord; //if word span// + public int givenResponseDigits; //if digit span// + public String givenResponseWord; //if word span// /* * need an indicator as to whether this executable is being used to run a simple span task @@ -125,8 +125,8 @@ public enum Phase { private int ComplexSpan = 0; //"0" by default, this will be the code for simple span, "1" if complex.// - private long startTime; - private long endTime; + public long startTime; + public long endTime; /* * constructor @@ -359,7 +359,7 @@ public void run() { } - private void processProperties() { + public void processProperties() { switch (StimuliType) { case 1: int stimulus_num = numbers[respCounter]; @@ -435,7 +435,7 @@ private void processProperties() { * Tatool should take care of feedback if I have set the variables and asked for a * feedback status panel....look into this. */ - private void changeStatusPanelOutcome(Boolean value) { + public void changeStatusPanelOutcome(Boolean value) { StatusPanel panelFeedback = StatusRegionUtil.getStatusPanel(StatusPanel.STATUS_PANEL_OUTCOME); if (panelFeedback != null) { if (value == null) { diff --git a/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html b/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html new file mode 100644 index 0000000..01dc00e --- /dev/null +++ b/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html @@ -0,0 +1,34 @@ + + + + + + +
+
Backward Digit Span
+ +
+

Instructions

+

Presentation Phase

+
+ This is the backward digit span task, a task that involves the presentation of a series of numbers (between 1-99) that you + must remember. A trial will consist of between 2 and 7 numbers for you to remember. They will be shown one at a time in the center of the screen. +
+
+ +
+

Recall Phase

+
+ After all the numbers in a given trial have been presented to you it is your turn: type in the numbers you remember seeing backwards. It is important to remember to type them backwards, that is, if you saw 21 33 54, then you should type 54 33 21. The program will ask for one number at a time (the message "Number 1: " etc) and you must type it in and press enter to submit it. +
+
+ +
+
+
+ Press the right arrow key on your + keyboard to start the task. +
+
+ + From 59a716b865c37771442877229ffc02164db85bdf Mon Sep 17 00:00:00 2001 From: John Gamboa Date: Mon, 2 Jul 2018 11:10:20 +0200 Subject: [PATCH 2/2] Cleans a little the code for the BackwardDigitSpan --- ...an.xml => default_backward_digit_span.xml} | 0 .../executables/BackwardDigitSpan.java | 12 --------- .../cogtasks/executables/WordDigitSpan.java | 26 +++++++++---------- .../BackwardDigitSpanInstructions.html | 5 +++- 4 files changed, 17 insertions(+), 26 deletions(-) rename modules/core_wm_modules/{backward_digit_span.xml => default_backward_digit_span.xml} (100%) diff --git a/modules/core_wm_modules/backward_digit_span.xml b/modules/core_wm_modules/default_backward_digit_span.xml similarity index 100% rename from modules/core_wm_modules/backward_digit_span.xml rename to modules/core_wm_modules/default_backward_digit_span.xml diff --git a/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java b/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java index da8e451..756216c 100644 --- a/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java +++ b/src/main/java/jms/cogtasks/executables/BackwardDigitSpan.java @@ -49,16 +49,4 @@ public void processProperties() { currentTrial.setParentId(getId()); DataUtils.storeProperties(currentTrial, this); } - - public void changeStatusPanelOutcome(Boolean value) { - StatusPanel panelFeedback = StatusRegionUtil.getStatusPanel(StatusPanel.STATUS_PANEL_OUTCOME); - if (panelFeedback != null) { - if (value == null) { - panelFeedback.reset(); - } else { - panelFeedback.setProperty(StatusPanel.PROPERTY_VALUE, value); - } - } - } - } diff --git a/src/main/java/jms/cogtasks/executables/WordDigitSpan.java b/src/main/java/jms/cogtasks/executables/WordDigitSpan.java index 972e833..8c4cb1e 100644 --- a/src/main/java/jms/cogtasks/executables/WordDigitSpan.java +++ b/src/main/java/jms/cogtasks/executables/WordDigitSpan.java @@ -60,7 +60,7 @@ public class WordDigitSpan extends BlockingAWTExecutable implements private RegionsContainer regionsContainer; String current_user; - public int StimuliType = 0; //set this using the XML, 1 for digits, 2 for words.// + protected int StimuliType = 0; //set this using the XML, 1 for digits, 2 for words.// final Font treb = new Font("Trebuchet MS", 1, 26); final Color fontColor = new Color(0,51,102); @@ -73,8 +73,8 @@ public enum Phase { private Phase currentPhase; //properties of interest// - public IntegerProperty loadProperty = new IntegerProperty("load"); - public IntegerProperty trialNoProperty = new IntegerProperty("trialNo"); + protected IntegerProperty loadProperty = new IntegerProperty("load"); + protected IntegerProperty trialNoProperty = new IntegerProperty("trialNo"); //panels// private CenteredTextPanel displayPanel; @@ -88,8 +88,8 @@ public enum Phase { private static int interResponseDuration = 1000; //blank screen between recalls// //stimuli// - public int[] numbers; //if digit span// - public String[] words; //if word span// + protected int[] numbers; //if digit span// + protected String[] words; //if word span// private ArrayList wordBank = new ArrayList(); //method will fill this arraylist with words from an external file// private String WordBankFileName = ""; private Random rand; @@ -110,13 +110,13 @@ public enum Phase { //should the list length be ordered presentation or randomised private int randomisedTrials = 0; //default is 0 which is for in sequence, set to 1 in the XML for randomised order. - public int trialCounter = 0; + protected int trialCounter = 0; private int memCounter; //counts memoranda presented per trial// - public int respCounter; //counts responses given// - public int correctResponseDigits; //if digit span// - public String correctResponseWord; //if word span// - public int givenResponseDigits; //if digit span// - public String givenResponseWord; //if word span// + protected int respCounter; //counts responses given// + protected int correctResponseDigits; //if digit span// + protected String correctResponseWord; //if word span// + protected int givenResponseDigits; //if digit span// + protected String givenResponseWord; //if word span// /* * need an indicator as to whether this executable is being used to run a simple span task @@ -125,8 +125,8 @@ public enum Phase { private int ComplexSpan = 0; //"0" by default, this will be the code for simple span, "1" if complex.// - public long startTime; - public long endTime; + protected long startTime; + protected long endTime; /* * constructor diff --git a/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html b/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html index 01dc00e..fcdac0f 100644 --- a/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html +++ b/src/main/resources/jms/cogtasks/instructions/BackwardDigitSpan/BackwardDigitSpanInstructions.html @@ -19,7 +19,10 @@

Presentation Phase


Recall Phase


- After all the numbers in a given trial have been presented to you it is your turn: type in the numbers you remember seeing backwards. It is important to remember to type them backwards, that is, if you saw 21 33 54, then you should type 54 33 21. The program will ask for one number at a time (the message "Number 1: " etc) and you must type it in and press enter to submit it. + After all the numbers in a given trial have been presented to you it is your turn: type in the numbers you + remember seeing backwards. It is important to remember to type them backwards, + that is, if you saw 21 33 54, then you should type first 54, then 33, and then 21. The program will ask for + one number at a time (the message "Number 1: " etc) and you must type it in and press enter to submit it.