Skip to content

Commit 9287e88

Browse files
Merge pull request #191 from lab-neuro-comp/Create_Participant
Create participant
2 parents 5f5bc9c + 345df43 commit 9287e88

32 files changed

+3701
-1185
lines changed

StroopTest/Models/Experiment/ExperimentTest.cs

+5-49
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,16 @@
22
using System.Collections.Generic;
33
using System.Globalization;
44
using System.Resources;
5+
using TestPlatform.Models.Tests;
56

67
namespace TestPlatform.Models
78
{
89
/*
910
* Class that represents results found while executing a test program (ExperimentProgram) and stores data from a partincipant test
1011
*
1112
*/
12-
class ExperimentTest
13+
class ExperimentTest : Test
1314
{
14-
// properties used to localize strings during runtime
15-
private ResourceManager LocRM = new ResourceManager("TestPlatform.Resources.Localizations.LocalizedResources", typeof(FormMain).Assembly);
16-
private CultureInfo currentCulture = CultureInfo.CurrentUICulture;
17-
private static String headerOutputFileText;
18-
private DateTime initialDate = DateTime.Now; // test execution date
19-
private String participantName; // tested person name
20-
private Char mark; // char mark made into neurospectrum program
2115
private ExperimentProgram programInUse = new ExperimentProgram();
2216
private List<string> output = new List<string>();
2317
private DateTime expositionTime;
@@ -27,46 +21,6 @@ public ExperimentTest()
2721
headerOutputFileText = LocRM.GetString("experimentHeader", currentCulture);
2822
}
2923

30-
31-
public DateTime InitialDate
32-
{
33-
get
34-
{
35-
return initialDate;
36-
}
37-
38-
set
39-
{
40-
initialDate = value;
41-
}
42-
}
43-
44-
public string ParticipantName
45-
{
46-
get
47-
{
48-
return participantName;
49-
}
50-
51-
set
52-
{
53-
participantName = value;
54-
}
55-
}
56-
57-
public char Mark
58-
{
59-
get
60-
{
61-
return mark;
62-
}
63-
64-
set
65-
{
66-
mark = value;
67-
}
68-
}
69-
7024
internal ExperimentProgram ProgramInUse
7125
{
7226
get
@@ -138,7 +92,9 @@ public void writeLineOutput(int currentExposition, Program currentProgram)
13892
{
13993
programType = "MatchingTest";
14094
}
141-
var text = programInUse.Name + "\t" + currentProgram.ProgramName + "\t" + programType + "\t" + participantName + "\t" + initialDate.Day + "/" +
95+
string[] currentParticipant = participant();
96+
var text = programInUse.Name + "\t" + currentProgram.ProgramName + "\t" + programType + "\t" + currentParticipant[0] + "\t" +
97+
currentParticipant[1] + "\t" + initialDate.Day + "/" +
14298
initialDate.Month + "/" + initialDate.Year + "\t" + initialDate.Hour + ":" + initialDate.Minute +
14399
":" + initialDate.Second + ":" + initialDate.Millisecond.ToString() + "\t" + ExpositionTime.Hour + ":" + ExpositionTime.Minute +
144100
":" + ExpositionTime.Second + ":" + ExpositionTime.Millisecond.ToString() + "\t" + currentExposition;

StroopTest/Models/General/Global.cs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ static class Global
1313
public static string reactionTestFilesPath = "/ReactionTestFiles/";
1414
public static string experimentTestFilesPath = "/ExperimentTestFiles/";
1515
public static string matchingTestFilesPath = "/MatchingTestFiles/";
16+
public static string partcipantDataPath = "/ParticipantData/";
1617

1718
public static string stroopTestFilesBackupPath = "/StroopTestFiles/";
1819
public static string reactionTestFilesBackupPath = "/ReactionTestFiles/";
+273
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using TestPlatform.Views;
7+
8+
namespace TestPlatform.Models.General
9+
{
10+
class Participant
11+
{
12+
private int registrationID;
13+
private string name;
14+
15+
/// <summary> 1 female 2 male </summary>
16+
private int sex;
17+
/// <summary> City or state of residence </summary>
18+
private string livingLocation;
19+
20+
/// <summary>
21+
/// 1. Elementary school
22+
/// 2. High school
23+
/// 3.Incomplete higher education
24+
/// 4. Complete higher education
25+
/// 5. Post graduate
26+
/// </summary>
27+
private int degreeOfSchooling;
28+
29+
private int age;
30+
private DateTime birthDate;
31+
private DateTime lastPeriodDate;
32+
33+
/// <summary> 0 do not apply 1 Usage of continuos contraception and 3 menopause </summary>
34+
private int reasonForNotMenstruating;
35+
36+
private bool wearGlasses;
37+
38+
private bool usesMedication;
39+
40+
private bool goodLastNightOfSleep;
41+
42+
/// <summary> True if participant consumed alcohol in past 24 hours </summary>
43+
private bool consumedAlcohol;
44+
45+
/// <summary> True if participant used any relaxant in past 24 hours </summary>
46+
private bool usedRelaxant;
47+
48+
/// <summary> True if participant consumed any illicit drugs in past 24 hours </summary>
49+
private bool consumedDrugs;
50+
51+
/// <summary> True if participant consumed coffe, soda, chocolate or any energizer drink in the last 2 hours prior to test </summary>
52+
private bool consumedEnergizers;
53+
54+
private string glassesEspecification;
55+
private string medicationEspecification;
56+
private string relaxantEspecification;
57+
private string sleepEspecification;
58+
private string alcoholEspecification;
59+
private string drugsEspecification;
60+
private string energizersEspecification;
61+
62+
/// <summary> Any complementar comment goes here </summary>
63+
private List<string> observations = new List<string>();
64+
65+
public Participant(string fileName)
66+
{
67+
readParticipantFile(fileName);
68+
}
69+
70+
public Participant(string name, int registrationID, int sex, string livingLocation, int degreeOfSchooling, int age,
71+
DateTime birthDate, DateTime lastPeriodDate, int reasonForNotMenstruating,
72+
bool wearGlass, bool usesMedication, bool consumedEnergizers, bool consumedDrugs,
73+
bool usedRelaxant, bool consumedAlcohol, bool goodLastNightOfSleep, string glassesEspecification,
74+
string medicationEspecification, string relaxantEspecification, string sleepEspecification,
75+
string alcoholEspecification, string drugsEspecification, string energizersEspecification, List<string> observations)
76+
{
77+
this.name = name;
78+
this.registrationID = registrationID;
79+
this.sex = sex;
80+
this.livingLocation = livingLocation;
81+
this.DegreeOfSchooling = degreeOfSchooling;
82+
this.age = age;
83+
this.birthDate = birthDate;
84+
this.lastPeriodDate = lastPeriodDate;
85+
this.reasonForNotMenstruating = reasonForNotMenstruating;
86+
this.wearGlasses = wearGlass;
87+
this.usesMedication = usesMedication;
88+
this.consumedAlcohol = consumedAlcohol;
89+
this.consumedDrugs = consumedDrugs;
90+
this.consumedEnergizers = consumedEnergizers;
91+
this.goodLastNightOfSleep = goodLastNightOfSleep;
92+
this.usedRelaxant = usedRelaxant;
93+
this.glassesEspecification = glassesEspecification;
94+
this.medicationEspecification = medicationEspecification;
95+
this.relaxantEspecification = relaxantEspecification;
96+
this.sleepEspecification = sleepEspecification;
97+
this.alcoholEspecification = alcoholEspecification;
98+
this.drugsEspecification = drugsEspecification;
99+
this.energizersEspecification = energizersEspecification;
100+
this.observations = observations;
101+
}
102+
103+
104+
105+
106+
private string Data()
107+
{
108+
string participantData = this.registrationID + " " +
109+
this.name + " " +
110+
this.age + " " +
111+
this.sex + " " +
112+
this.livingLocation + " " +
113+
this.DegreeOfSchooling + " " +
114+
this.birthDate.Date.ToShortDateString() + " " +
115+
this.lastPeriodDate.Date.ToShortDateString() + " " +
116+
this.reasonForNotMenstruating + " " +
117+
this.wearGlasses + " " +
118+
this.usesMedication + " " +
119+
this.goodLastNightOfSleep + " " +
120+
this.consumedAlcohol + " " +
121+
this.usedRelaxant + " " +
122+
this.consumedDrugs + " " +
123+
this.consumedEnergizers + "\n" +
124+
this.glassesEspecification + "\n" +
125+
this.medicationEspecification + "\n" +
126+
this.relaxantEspecification + "\n" +
127+
this.sleepEspecification + "\n" +
128+
this.alcoholEspecification + "\n" +
129+
this.drugsEspecification + "\n" +
130+
this.energizersEspecification + "\n";
131+
132+
return participantData;
133+
}
134+
135+
public string getParticipantPath()
136+
{
137+
return Global.testFilesPath + Global.partcipantDataPath + registrationID + "-" + name + ".data";
138+
}
139+
140+
public string getParticipantPath(string filename)
141+
{
142+
return Global.testFilesPath + Global.partcipantDataPath + filename + ".data";
143+
}
144+
145+
public bool saveParticipantFile()
146+
{
147+
StreamWriter writer = new StreamWriter(getParticipantPath());
148+
writer.Write(Data());
149+
if (observations != null)
150+
{
151+
for (int i = 0; i < observations.Count; i++)
152+
{
153+
writer.WriteLine(observations[i]);
154+
}
155+
}
156+
writer.Close();
157+
return true;
158+
}
159+
160+
161+
private void readParticipantFile(string fileName)
162+
{
163+
if(File.Exists(getParticipantPath(fileName)))
164+
{
165+
StreamReader tr;
166+
string line;
167+
string[] linesInstruction;
168+
List<string> config = new List<string>();
169+
170+
tr = new StreamReader(getParticipantPath(fileName), Encoding.Default, true);
171+
line = tr.ReadLine();
172+
line = Program.encodeLatinText(line);
173+
config = line.Split().ToList();
174+
175+
this.registrationID = int.Parse(config[0]);
176+
this.name = config[1];
177+
this.age = int.Parse(config[2]);
178+
this.sex = int.Parse(config[3]);
179+
this.livingLocation = config[4];
180+
this.DegreeOfSchooling = int.Parse(config[5]);
181+
this.birthDate = DateTime.Parse(config[6]);
182+
this.lastPeriodDate = DateTime.Parse(config[7]);
183+
this.reasonForNotMenstruating = int.Parse(config[8]);
184+
this.wearGlasses = bool.Parse(config[9]);
185+
this.usesMedication = bool.Parse(config[10]);
186+
this.goodLastNightOfSleep = bool.Parse(config[11]);
187+
this.consumedAlcohol = bool.Parse(config[12]);
188+
this.usedRelaxant = bool.Parse(config[13]);
189+
this.consumedDrugs = bool.Parse(config[14]);
190+
this.consumedEnergizers = bool.Parse(config[15]);
191+
192+
this.glassesEspecification = Program.encodeLatinText(tr.ReadLine());
193+
this.medicationEspecification = Program.encodeLatinText(tr.ReadLine());
194+
this.relaxantEspecification = Program.encodeLatinText(tr.ReadLine());
195+
this.sleepEspecification = Program.encodeLatinText(tr.ReadLine());
196+
this.alcoholEspecification = Program.encodeLatinText(tr.ReadLine());
197+
this.drugsEspecification = Program.encodeLatinText(tr.ReadLine());
198+
this.energizersEspecification = Program.encodeLatinText(tr.ReadLine());
199+
tr.Close();
200+
linesInstruction = File.ReadAllLines(getParticipantPath(fileName));
201+
if (linesInstruction.Length > 8) // read instructions if any
202+
{
203+
for (int i = 8; i < linesInstruction.Length; i++)
204+
{
205+
this.observations.Add(linesInstruction[i]);
206+
}
207+
}
208+
else
209+
{
210+
this.observations = null;
211+
}
212+
}
213+
else
214+
{
215+
throw new FileNotFoundException();
216+
}
217+
}
218+
219+
220+
221+
/// <summary>
222+
/// getters and setters below
223+
/// </summary>
224+
225+
public int DegreeOfSchooling { get => degreeOfSchooling; set => degreeOfSchooling = value; }
226+
227+
public int Age { get => age; set => age = value; }
228+
229+
public DateTime BirthDate { get => birthDate; set => birthDate = value; }
230+
231+
public DateTime LastPeriodDate { get => lastPeriodDate; set => lastPeriodDate = value; }
232+
233+
public int ReasonForNotMenstruating { get => reasonForNotMenstruating; set => reasonForNotMenstruating = value; }
234+
235+
public bool WearGlasses { get => wearGlasses; set => wearGlasses = value; }
236+
237+
public bool UsesMedication { get => usesMedication; set => usesMedication = value; }
238+
239+
public bool GoodLastNightOfSleep { get => goodLastNightOfSleep; set => goodLastNightOfSleep = value; }
240+
241+
public bool ConsumedAlcohol { get => consumedAlcohol; set => consumedAlcohol = value; }
242+
243+
public bool UsedRelaxant { get => usedRelaxant; set => usedRelaxant = value; }
244+
245+
public bool ConsumedDrugs { get => consumedDrugs; set => consumedDrugs = value; }
246+
247+
public bool ConsumedEnergizers { get => consumedEnergizers; set => consumedEnergizers = value; }
248+
249+
public string GlassesEspecification { get => glassesEspecification; set => glassesEspecification = value; }
250+
251+
public string MedicationEspecification { get => medicationEspecification; set => medicationEspecification = value; }
252+
253+
public string RelaxantEspecification { get => relaxantEspecification; set => relaxantEspecification = value; }
254+
255+
public string SleepEspecification { get => sleepEspecification; set => sleepEspecification = value; }
256+
257+
public string AlcoholEspecification { get => alcoholEspecification; set => alcoholEspecification = value; }
258+
259+
public string DrugsEspecification { get => drugsEspecification; set => drugsEspecification = value; }
260+
261+
public string EnergizersEspecification { get => energizersEspecification; set => energizersEspecification = value; }
262+
263+
public List<string> Observations { get => observations; set => observations = value; }
264+
265+
public string LivingLocation { get => livingLocation; set => livingLocation = value; }
266+
267+
public int Sex { get => sex; set => sex = value; }
268+
269+
public string Name { get => name; set => name = value; }
270+
271+
public int RegistrationID { get => registrationID; set => registrationID = value; }
272+
}
273+
}

0 commit comments

Comments
 (0)