Skip to content

Commit a4c4973

Browse files
committed
swap trials
1 parent 0b70805 commit a4c4973

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void OnGUI()
9898
GUILayout.Label("Cite UXF", EditorStyles.boldLabel);
9999

100100
if (GUILayout.Button("DOI Link"))
101-
Application.OpenURL("https://doi.org/10.1101/459339");
101+
Application.OpenURL("https://doi.org/10.3758/s13428-019-01242-0");
102102

103103
EditorGUILayout.Separator();
104104

Assets/UXF/Scripts/Tests/Editor/TestSessionBuilding.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,33 @@ public void ShuffleTrials()
102102
session.blocks = new List<Block>();
103103

104104
}
105+
106+
[Test]
107+
108+
public void SwapTrials()
109+
{
110+
Block block = session.CreateBlock(5);
111+
112+
for (int i = 0; i < block.trials.Count; i++)
113+
{
114+
block.trials[i].settings.SetValue("order", i);
115+
}
116+
117+
int[] expectedOrders = new int[] { 0, 3, 2, 1, 4 };
118+
119+
block.trials.Swap(1, 3);
120+
121+
for (int i = 0; i < block.trials.Count; i++)
122+
{
123+
var trial = block.trials[i];
124+
var expected = expectedOrders[i];
125+
Assert.AreEqual(trial.settings.GetInt("order"), expected);
126+
}
127+
128+
// reset blocks
129+
session.blocks = new List<Block>();
130+
131+
}
105132

106133
}
107134

Assets/UXF/Scripts/UI/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static void Shuffle<T>(this IList<T> list)
7070
/// <summary>
7171
/// Swaps the order of the elements at indeces `indexA` and `indexB` within `list`
7272
/// </summary>
73-
public static void Swap<T>(IList<T> list, int indexA, int indexB)
73+
public static void Swap<T>(this IList<T> list, int indexA, int indexB)
7474
{
7575
T tmp = list[indexA];
7676
list[indexA] = list[indexB];

0 commit comments

Comments
 (0)