Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/trea #225

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions StroopTest/ClassDiagram1.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />
2 changes: 2 additions & 0 deletions StroopTest/ClassDiagram2.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />
7 changes: 7 additions & 0 deletions StroopTest/Controllers/ExpositionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows.Forms;
using TestPlatform.Views;
using TestPlatform.Views.ExperimentPages;
using TestPlatform.Views.SpacialRecognitionPages;
using Views.MatchingPages;

public class ExpositionController
Expand Down Expand Up @@ -143,6 +144,12 @@ public static void BeginMatchingTest(string programName, string participantName,
}
}

public static void BeginSpacialRecognitionTest(string programName, string participantName, char mark, Form form)
{
SendKeys.SendWait("i");
SpacialRecognitionExposition spacialRecognitionExposition = new SpacialRecognitionExposition(programName, participantName, mark);
}

public static PictureBox InitializeImageBox(double stimuliSize, Image image, bool expandImage, Form form)
{
PictureBox newPictureBox = new PictureBox();
Expand Down
107 changes: 79 additions & 28 deletions StroopTest/Controllers/StimulusPosition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,37 +188,70 @@ private Point generatePoint(int point)

}

public Point getPositon(Size stimulusSize)
public Point getPositon(Size stimulusSize, char direction = 'h')
{
this.stimulusSize = stimulusSize;
Console.WriteLine(pointCount);
Point position = new Point();
switch (PointsNumber)
if(direction == 'h')
{
case 1:
position = centerPosition(PointsNumber, pointCount);
break;
case 2:
position = twoPointsHorizontalPosition(pointCount);
break;
case 3:
position = threePointsPosition(pointCount);
break;
case 4:
position = fourPointsPosition(pointCount);
break;
case 5:
position = fivePointsPosition(pointCount);
break;
case 6:
position = sixPointsPosition(pointCount);
break;
case 7:
position = sevenPointsPosition(pointCount);
break;
case 8:
position = eightPointsPosition(pointCount);
break;
switch (PointsNumber)
{
case 1:
position = centerPosition(PointsNumber, pointCount);
break;
case 2:
position = twoPointsHorizontalPosition(pointCount);
break;
case 3:
position = threePointsPosition(pointCount);
break;
case 4:
position = fourPointsPosition(pointCount);
break;
case 5:
position = fivePointsPosition(pointCount);
break;
case 6:
position = sixPointsPosition(pointCount);
break;
case 7:
position = sevenPointsPosition(pointCount);
break;
case 8:
position = eightPointsPosition(pointCount);
break;
}
}
else
{
switch (PointsNumber)
{
case 1:
position = centerPosition(PointsNumber, pointCount);
break;
case 2:
position = twoPointsVerticalPosition(pointCount);
break;
case 3:
position = threePointsPosition(pointCount);
break;
case 4:
position = fourPointsPosition(pointCount);
break;
case 5:
position = fivePointsPosition(pointCount);
break;
case 6:
position = sixPointsPosition(pointCount);
break;
case 7:
position = sevenPointsPosition(pointCount);
break;
case 8:
position = eightPointsPosition(pointCount);
break;
}
}
pointCount++;
return position;
Expand All @@ -235,7 +268,6 @@ public Point centerPosition(int pointsNumber, int pointPosition)
if (pointPosition < pointsNumber)
{
/*middle center*/
float[] clientMiddle = { (clientSize.Width / 2), (clientSize.Height / 2) };
return generatePoint(D2); // D2
}
else
Expand All @@ -251,7 +283,6 @@ public Point centerPosition(int pointsNumber, int pointPosition)
/// </summary>
public Point twoPointsHorizontalPosition(int pointPosition)
{
float[] clientMiddle = { (clientSize.Width / 2), (clientSize.Height / 2) };
switch (pointPosition)
{
case 0: /*middle left */
Expand All @@ -263,6 +294,26 @@ public Point twoPointsHorizontalPosition(int pointPosition)
}
}



/// <summary>
/// Generate point in middle left or middle right of user screen
/// <param name="stimulusSize"> size of the stimulus that will be shown to user</param>
/// <param name="pointPosition">poistion of point that will be generated, must be 0 or 1</param>
/// </summary>
public Point twoPointsVerticalPosition(int pointPosition)
{
switch (pointPosition)
{
case 0: /*middle top */
return generatePoint(D1);
case 1: /*middle bottom */
return generatePoint(D3);
default:
throw new InvalidOperationException();
}
}

/// <summary>
/// Generate point in middle left, middle right or middle center of user screen
/// <param name="stimulusSize"> size of the stimulus that will be shown to user</param>
Expand Down
12 changes: 0 additions & 12 deletions StroopTest/Models/Experiment/ExperimentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ public DateTime ExpositionTime
}
}

public string HeaderOutputFileText
{
get
{
return headerOutputFileText;
}

set
{
headerOutputFileText = value;
}
}

public void writeLineOutput(int currentExposition, Program currentProgram)
{
Expand Down
34 changes: 28 additions & 6 deletions StroopTest/Models/General/FileManipulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TestPlatform.Models.Tests.SpacialRecognition;

namespace TestPlatform.Models
{
Expand All @@ -22,7 +23,7 @@ public sealed class FileManipulation
private static FileManipulation instance;

private static string PROGRAM_EXTENSION = ".prg";
private static string _instructionsFilePath = "editableInstructions.txt";
private static string _instructionsFilePath = "/editableInstructions.txt";

private static FormMain _globalFormMain;
private static string _defaultPath; // path of execution program
Expand All @@ -32,11 +33,14 @@ public sealed class FileManipulation
private static string _reactionTestFilesPath = "/ReactionTestFiles/";
private static string _experimentTestFilesPath = "/ExperimentTestFiles/";
private static string _matchingTestFilesPath = "/MatchingTestFiles/";
private static string _spacialRecoginitionTestFilesPath = "/SpacialRecognitionTestFiles/";
private static string _stroopTestFilesBackupPath = "/StroopTestFiles/";
private static string _reactionTestFilesBackupPath = "/ReactionTestFiles/";
public static string _spacialRecognitionTestFilesBackupPath = "/SpacialRecognitionTestFiles/";

public static string _experimentTestFilesBackupPath = "/ExperimentTestFiles/";
public static string _matchingTestFilesBackupPath = "/MatchingTestFiles/";
public static string _spacialRecoginitionFilesBackup = "/SpacialRecognitionTestFiles/";
public static string _listFilesBackup = "/Lst/";
public static string _participantDataPath = "/ParticipantData/";
public static string _listFolderName = "/Lst/";
Expand Down Expand Up @@ -65,6 +69,7 @@ private FileManipulation(FormMain globalFormMain) {
CreateSubFolders(_stroopTestFilesPath);
CreateSubFolders(_experimentTestFilesPath);
CreateSubFolders(_matchingTestFilesPath);
CreateSubFolders(_spacialRecoginitionTestFilesPath);

CreateFolder(_listFolderName);
CreateFolder(_participantDataPath);
Expand Down Expand Up @@ -94,6 +99,7 @@ private FileManipulation(string path)
CreateSubFolders(_stroopTestFilesPath);
CreateSubFolders(_experimentTestFilesPath);
CreateSubFolders(_matchingTestFilesPath);
CreateSubFolders(_spacialRecoginitionTestFilesPath);

/* creating Lists folder*/

Expand Down Expand Up @@ -150,6 +156,7 @@ public static void CreateExportationFolders(string fileName)
CreateFolder(directory + "/ExportingFiles/" + "ExperimentProgram");
CreateFolder(directory + "/ExportingFiles/" + "Lists");
CreateFolder(directory + "/ExportingFiles/" + "MatchingProgram");
CreateFolder(directory + "/ExportingFiles/" + "SpacialRecognitionProgram");
}

public static void CreateFolder(string path)
Expand Down Expand Up @@ -338,7 +345,9 @@ private void CreateBackupFolders()
_reactionTestFilesBackupPath = _defaultPath + _backupFolderName + ReactionTestFilesBackupPath;
_experimentTestFilesBackupPath = _defaultPath + _backupFolderName + _experimentTestFilesBackupPath;
_matchingTestFilesBackupPath = _defaultPath + _backupFolderName + _matchingTestFilesBackupPath;
_spacialRecognitionTestFilesBackupPath = _defaultPath + _backupFolderName + _spacialRecognitionTestFilesBackupPath;
_listFilesBackup = _defaultPath + _backupFolderName + _listFilesBackup;
_spacialRecoginitionFilesBackup = _defaultPath + _backupFolderName + _spacialRecoginitionFilesBackup;

if (!Directory.Exists(_experimentTestFilesBackupPath))
Directory.CreateDirectory(_experimentTestFilesBackupPath);
Expand All @@ -348,8 +357,12 @@ private void CreateBackupFolders()
Directory.CreateDirectory(ReactionTestFilesBackupPath);
if (!Directory.Exists(_matchingTestFilesBackupPath))
Directory.CreateDirectory(_matchingTestFilesBackupPath);
if (!Directory.Exists(_spacialRecognitionTestFilesBackupPath))
Directory.CreateDirectory(_spacialRecognitionTestFilesBackupPath);
if (!Directory.Exists(_listFilesBackup))
Directory.CreateDirectory(_listFilesBackup);
if (!Directory.Exists(_spacialRecoginitionFilesBackup))
Directory.CreateDirectory(_spacialRecoginitionFilesBackup);
}

/// <summary>
Expand Down Expand Up @@ -392,11 +405,17 @@ public static void ExtractImportFile(string fileName)
/// </summary>
private void InitializeDefaultPrograms()
{
StroopProgram programDefault = new StroopProgram();
programDefault.writeDefaultProgramFile(_stroopTestFilesPath + _programFolderName);
StroopProgram defaultStroop = new StroopProgram();
defaultStroop.writeDefaultProgramFile(_stroopTestFilesPath + _programFolderName);

ReactionProgram defaultProgram = new ReactionProgram();
defaultProgram.writeDefaultProgramFile();
ReactionProgram defaultReaction = new ReactionProgram();
defaultReaction.writeDefaultProgramFile();

SpacialRecognitionProgram defaultSR = new SpacialRecognitionProgram();
defaultSR.writeDefaultProgramFile(_spacialRecoginitionTestFilesPath + _programFolderName);

MatchingProgram defaultMatching = new MatchingProgram();
defaultMatching.writeDefaultProgramFile(_matchingTestFilesPath + _programFolderName);

StrList.writeDefaultWordsList(_listFolderName);
StrList.writeDefaultColorsList(_listFolderName);
Expand Down Expand Up @@ -442,9 +461,10 @@ private void CreateMainFolderAndPaths(string path)
_reactionTestFilesPath = _testFilesPath + _reactionTestFilesPath;
_experimentTestFilesPath = _testFilesPath + _experimentTestFilesPath;
_matchingTestFilesPath = _testFilesPath + _matchingTestFilesPath;
_spacialRecoginitionTestFilesPath = _testFilesPath + _spacialRecoginitionTestFilesPath;
_importPath = _testFilesPath + _importPath;
_participantDataPath = _testFilesPath + _participantDataPath;
_instructionsFilePath = _instructionsFilePath + _defaultPath;
_instructionsFilePath = _defaultPath + _instructionsFilePath;

if (!Directory.Exists(_testFilesPath))
{
Expand All @@ -462,7 +482,9 @@ private void CreateMainFolderAndPaths(string path)
public static string ExperimentTestFilesPath { get => _experimentTestFilesPath;}
public static string ProgramExtension { get => PROGRAM_EXTENSION; }
public static string MatchingTestFilesPath { get => _matchingTestFilesPath; }
public static string SpacialRecognitionTestFilesPath { get => _spacialRecoginitionTestFilesPath; }
public static string StroopTestFilesBackupPath { get => _stroopTestFilesBackupPath; }
public static string ReactionTestFilesBackupPath { get => _reactionTestFilesBackupPath; }
public static string SpacialReconitionTestFilesBackupPath { get => _spacialRecognitionTestFilesBackupPath; }
}
}
24 changes: 24 additions & 0 deletions StroopTest/Models/Tests/Matching/MatchingProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,30 @@ public void configureReadProgram(string filepath)
}
}


// writes default file
public void writeDefaultProgramFile(string filepath) // escreve
{
string[] defaultInstructionText = { LocRM.GetString("defaultMatchingInstruction1", currentCulture),
LocRM.GetString("defaultMatchingInstruction2", currentCulture)};
this.ProgramName = LocRM.GetString("default", currentCulture);
try
{
TextWriter tw = new StreamWriter(filepath + ProgramName + ".prg");
tw.WriteLine(LocRM.GetString("defaultMatchingProgram", currentCulture));
for (int i = 0; i < defaultInstructionText.Length; i++)
{
tw.WriteLine(defaultInstructionText[i]);
}
tw.Close();
}
catch (Exception e)
{
Console.WriteLine("The file could not be written:");
Console.WriteLine(e.Message);
}
}

public bool saveProgramFile(string instructionBoxText)
{
StreamWriter writer = new StreamWriter(GetProgramsPath() + ProgramName + ".prg");
Expand Down
Loading