From 1902ad19090c4674439a26f8959cb1e35377f657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20K=C3=B6gel?= <koegel@vr.rwth-aachen.de> Date: Mon, 9 Oct 2023 15:42:26 +0200 Subject: [PATCH] revert dummy-data, instead recover IV's from previous participant. Also: never keep multiple records of one condition/participant combination --> Overwrite whether in debug mode or not. closes #97 --- .../Private/SFGameInstance.cpp | 22 ++++++++++++++----- .../Private/SFParticipant.cpp | 5 +---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp b/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp index 7c6467b..01b914f 100644 --- a/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp +++ b/Source/StudyFrameworkPlugin/Private/SFGameInstance.cpp @@ -151,15 +151,24 @@ void USFGameInstance::RestoreLastParticipantForDebugStart(USFCondition* InStartC const FString ParticipantID = USFParticipant::GetLastParticipantID(); Participant = NewObject<USFParticipant>(this, FName(TEXT("Participant_") + ParticipantID)); - StudySetup = USFParticipant::GetLastParticipantSetup(); + StartCondition = InStartCondition; Participant->Initialize(ParticipantSequenceNumber, ParticipantID); - Participant->LoadConditionsFromJson(); - Participant->SetIndependentVariablesFromStudySetup(StudySetup); - - InitFadeHandler(StudySetup->FadeConfig); + Participant->Conditions = Participant->GetLastParticipantsConditions(); + Participant->LoadLastParticipantsIndependentVariables(); - StartCondition = InStartCondition; + Participant->RecoverStudyResultsOfFinishedConditions(); + //also delete any data of the condition that is now restarted (StartCondition) + Participant->DeleteStoredDataForConditionFromLongTable(StartCondition); + for (USFDependentVariable* DV : StartCondition->DependentVariables) + { + if (USFMultipleTrialDependentVariable* MTDV = Cast<USFMultipleTrialDependentVariable>(DV)) + { + Participant->DeleteStoredTrialDataForCondition(StartCondition, MTDV); + } + } + + InitFadeHandler(StudySetup->FadeConfig); StartStudy(); //cannot directly fade in here, since Init might not be done, so we wait a second for safety @@ -208,6 +217,7 @@ void USFGameInstance::InitFadeHandler(FFadeConfig FadeConfig) } +// When starting on the setup map, i.e. not for debugging purposes void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup) { StudySetup = DuplicateObject(Setup, this); diff --git a/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp b/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp index 2b1de15..bc88b18 100644 --- a/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp +++ b/Source/StudyFrameworkPlugin/Private/SFParticipant.cpp @@ -600,10 +600,7 @@ void USFParticipant::SetIndependentVariablesFromStudySetup(ASFStudySetup* Setup) IndependentVariablesValues.Empty(); for (auto Var : Setup->IndependentVariables) { FString Value = ""; - if (USFGameInstance::Get()->IsInDebugMode()) { - Value = "DebugRun-NoData"; - } - else if (Var->bAskedAtBeginning) { + if (Var->bAskedAtBeginning) { switch (Var->ValueType) { case EValType::TEXT: -- GitLab