Skip to content

Commit ad0f446

Browse files
committed
fix #78 and new tests
1 parent 49ddc95 commit ad0f446

File tree

7 files changed

+52
-10
lines changed

7 files changed

+52
-10
lines changed

Assets/UXF/Examples/1a_SpaceShuttle/SpaceShuttleExample.unity

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,12 @@ PrefabInstance:
777777
- target: {fileID: 114916036141644208, guid: 0a3b6392f04558844bd340e68ced1ff9,
778778
type: 3}
779779
propertyPath: storeSessionSettings
780-
value: 0
780+
value: 1
781781
objectReference: {fileID: 0}
782782
- target: {fileID: 114916036141644208, guid: 0a3b6392f04558844bd340e68ced1ff9,
783783
type: 3}
784784
propertyPath: storeParticipantDetails
785-
value: 0
785+
value: 1
786786
objectReference: {fileID: 0}
787787
- target: {fileID: 203569540471596912, guid: 0a3b6392f04558844bd340e68ced1ff9,
788788
type: 3}
@@ -997,7 +997,7 @@ PrefabInstance:
997997
- target: {fileID: 653059108743847710, guid: 0a3b6392f04558844bd340e68ced1ff9,
998998
type: 3}
999999
propertyPath: participantDataPoints.Array.data[0].displayName
1000-
value: Age
1000+
value: 34354635463546345
10011001
objectReference: {fileID: 0}
10021002
- target: {fileID: 653059108743847710, guid: 0a3b6392f04558844bd340e68ced1ff9,
10031003
type: 3}
@@ -1054,11 +1054,6 @@ PrefabInstance:
10541054
propertyPath: ppidMode
10551055
value: 0
10561056
objectReference: {fileID: 0}
1057-
- target: {fileID: 653059108743847710, guid: 0a3b6392f04558844bd340e68ced1ff9,
1058-
type: 3}
1059-
propertyPath: termsAndConditions
1060-
value: Please tick if you understand the instructions.<color=red>*</color>
1061-
objectReference: {fileID: 0}
10621057
- target: {fileID: 653059108743847710, guid: 0a3b6392f04558844bd340e68ced1ff9,
10631058
type: 3}
10641059
propertyPath: participantDataPoints.Array.data[2].displayName
@@ -1099,6 +1094,11 @@ PrefabInstance:
10991094
propertyPath: startupMode
11001095
value: 0
11011096
objectReference: {fileID: 0}
1097+
- target: {fileID: 653059108743847710, guid: 0a3b6392f04558844bd340e68ced1ff9,
1098+
type: 3}
1099+
propertyPath: termsAndConditions
1100+
value: Please tick if you understand the instructions.<color=red>*</color>
1101+
objectReference: {fileID: 0}
11021102
- target: {fileID: 759169902625461607, guid: 0a3b6392f04558844bd340e68ced1ff9,
11031103
type: 3}
11041104
propertyPath: m_AnchorMin.y
@@ -2690,6 +2690,12 @@ PrefabInstance:
26902690
propertyPath: m_SizeDelta.x
26912691
value: 0
26922692
objectReference: {fileID: 0}
2693+
- target: {fileID: 5489284586117691312, guid: 0a3b6392f04558844bd340e68ced1ff9,
2694+
type: 3}
2695+
propertyPath: m_Text
2696+
value: Please tick if you understand the instructions and agree for your data
2697+
to be collected and used for research purposes.<color=red>*</color>
2698+
objectReference: {fileID: 0}
26932699
- target: {fileID: 5540555593714305841, guid: 0a3b6392f04558844bd340e68ced1ff9,
26942700
type: 3}
26952701
propertyPath: m_AnchorMin.y

Assets/UXF/Scripts/Etc/Trial.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ private void SetReferences(Block trialBlock)
7878
/// </summary>
7979
public void Begin()
8080
{
81+
if (!session.hasInitialised)
82+
{
83+
throw new InvalidOperationException("Cannot begin trial, session is is not ready! Session has not been started yet with session.Begin() (or via the UI), or session has already ended.");
84+
}
8185
if (session.InTrial) session.CurrentTrial.End();
8286

8387
session.currentTrialNum = number;

Assets/UXF/Scripts/Session.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public class Session : MonoBehaviour, ISettingsContainer, IDataAssociatable
224224
/// <summary>
225225
/// Stores combined list of headers for the behavioural output.
226226
/// </summary>
227-
public List<string> Headers { get { return baseHeaders.Concat(settingsToLog).Concat(customHeaders).ToList(); } }
227+
public List<string> Headers { get { return baseHeaders.Concat(settingsToLog).Concat(customHeaders).Distinct().ToList(); } }
228228

229229
/// <summary>
230230
/// Dictionary of objects for datapoints collected via the UI, or otherwise.

Assets/UXF/Tests/Editor/TestSessionBehaviour.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ public void TestCurrentEndTrialOnBeginNext()
101101
GameObject.DestroyImmediate(session.gameObject);
102102
}
103103

104+
105+
[Test]
106+
public void DuplicateHeaders()
107+
{
108+
(Session session, FileSaver fileSaver) = CreateSession("duplicateheaders");
109+
110+
session.settingsToLog.Add("hello");
111+
session.settingsToLog.Add("hello");
112+
session.customHeaders.Add("hello");
113+
session.customHeaders.Add("hello");
114+
115+
session.FirstTrial.Begin();
116+
session.FirstTrial.End();
117+
118+
session.End();
119+
}
120+
104121
Tuple<Session, FileSaver> CreateSession(string ppidExtra)
105122
{
106123
GameObject gameObject = new GameObject();

Assets/UXF/Tests/Editor/TestSessionBuilding.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public void FirstLast()
167167
session.blocks = new List<Block>();
168168
}
169169

170+
171+
170172
}
171173

172174
}

Assets/UXF/Tests/Editor/TestTrials.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ public void RunTrialsAdHocResultsAddEarlyExit()
9797
Finish(); // check we dont throw an error
9898
}
9999

100+
[Test]
101+
public void BeginTrialBeforeBeginSession()
102+
{
103+
gameObject = new GameObject();
104+
session = gameObject.AddComponent<Session>();
105+
106+
// generate trials
107+
session.CreateBlock(1);
108+
109+
Assert.Throws<InvalidOperationException>(() => session.FirstTrial.Begin());
110+
}
111+
112+
100113
[Test]
101114
public void WriteCommas()
102115
{

Assets/UXF/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.1
1+
2.2.2

0 commit comments

Comments
 (0)