PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
Test Struct Reference

#include <Study.h>

Public Member Functions

 Test ()
 
bool Exists (const std::string &studyPath) const
 
std::vector< std::string > GetAvailableLanguages (const std::string &studyPath) const
 
const ParameterVariantGetVariant (const std::string &variantName) const
 

Public Attributes

std::string testName
 
std::string displayName
 
std::string testPath
 
bool included
 
std::map< std::string, ParameterVariantparameterVariants
 

Detailed Description

Definition at line 24 of file Study.h.

Constructor & Destructor Documentation

◆ Test()

Test::Test ( )
inline

Definition at line 31 of file Study.h.

31: included(true) {}
bool included
Definition Study.h:28

Member Function Documentation

◆ Exists()

bool Test::Exists ( const std::string &  studyPath) const

Definition at line 42 of file Study.cpp.

42 {
43 std::string fullPath = studyPath + "/tests/" + testPath;
44 struct stat info;
45 return (stat(fullPath.c_str(), &info) == 0 && (info.st_mode & S_IFDIR));
46}
std::string testPath
Definition Study.h:27

References testPath.

◆ GetAvailableLanguages()

std::vector< std::string > Test::GetAvailableLanguages ( const std::string &  studyPath) const

Definition at line 48 of file Study.cpp.

48 {
49 std::vector<std::string> languages;
50 std::string translationsDir = studyPath + "/tests/" + testPath + "/translations";
51
52 try {
53 if (!fs::exists(translationsDir) || !fs::is_directory(translationsDir)) {
54 return languages;
55 }
56
57 for (const auto& entry : fs::directory_iterator(translationsDir)) {
58 if (!entry.is_regular_file()) continue;
59
60 std::string filename = entry.path().filename().string();
61
62 // Look for pattern: testname.pbl-LANG.json
63 size_t dashPos = filename.rfind('-');
64 size_t jsonPos = filename.rfind(".json");
65
66 if (dashPos != std::string::npos && jsonPos != std::string::npos) {
67 std::string lang = filename.substr(dashPos + 1, jsonPos - dashPos - 1);
68 if (!lang.empty()) {
69 languages.push_back(lang);
70 }
71 }
72 }
73 } catch (const fs::filesystem_error&) {
74 // Directory doesn't exist or can't be read
75 }
76
77 return languages;
78}

References testPath.

Referenced by Chain::Validate().

◆ GetVariant()

const ParameterVariant * Test::GetVariant ( const std::string &  variantName) const

Definition at line 80 of file Study.cpp.

80 {
81 auto it = parameterVariants.find(variantName);
82 if (it != parameterVariants.end()) {
83 return &(it->second);
84 }
85 return nullptr;
86}
std::map< std::string, ParameterVariant > parameterVariants
Definition Study.h:29

References parameterVariants.

Referenced by Chain::Validate().

Member Data Documentation

◆ displayName

std::string Test::displayName

Definition at line 26 of file Study.h.

Referenced by ScaleManager::AddScaleToStudy(), and ScaleManager::CreateStudyFromScale().

◆ included

bool Test::included

◆ parameterVariants

std::map<std::string, ParameterVariant> Test::parameterVariants

Definition at line 29 of file Study.h.

Referenced by GetVariant().

◆ testName

std::string Test::testName

◆ testPath

std::string Test::testPath

The documentation for this struct was generated from the following files: