studyengine

package
v0.0.0-...-45ce995 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STUDY_EVENT_TYPE_ENTER  = "ENTER"
	STUDY_EVENT_TYPE_SUBMIT = "SUBMIT"
	STUDY_EVENT_TYPE_TIMER  = "TIMER"
	STUDY_EVENT_TYPE_CUSTOM = "CUSTOM"
	STUDY_EVENT_TYPE_MERGE  = "MERGE"
	STUDY_EVENT_TYPE_LEAVE  = "LEAVE"
)

Variables

This section is empty.

Functions

func ExpressionEval

func ExpressionEval(expression studyTypes.Expression, evalCtx EvalContext) (val interface{}, err error)

func InitStudyEngine

func InitStudyEngine(dbService StudyDBService, externalServices []ExternalService)

Types

type ActionData

type ActionData struct {
	PState          studyTypes.Participant
	ReportsToCreate map[string]studyTypes.Report
}

func ActionEval

func ActionEval(action studyTypes.Expression, oldState ActionData, event StudyEvent) (newState ActionData, err error)

type EvalContext

type EvalContext struct {
	Event            StudyEvent
	ParticipantState studyTypes.Participant
}

EvalContext contains all the data that can be looked up by expressions

type ExternalEventPayload

type ExternalEventPayload struct {
	ParticipantState studyTypes.Participant    `json:"participantState"`
	EventType        string                    `json:"eventType"`
	StudyKey         string                    `json:"studyKey"`
	InstanceID       string                    `json:"instanceID"`
	Response         studyTypes.SurveyResponse `json:"surveyResponses"`
	EventKey         string                    `json:"eventKey"`
	Payload          map[string]interface{}    `json:"payload"`
}

type ExternalService

type ExternalService struct {
	Name            string           `yaml:"name"`
	URL             string           `yaml:"url"`
	APIKey          string           `yaml:"apiKey"`
	Timeout         int              `yaml:"timeout"`
	MutualTLSConfig *MutualTLSConfig `yaml:"mTLSConfig"`
}

type MutualTLSConfig

type MutualTLSConfig struct {
	CertFile string `yaml:"certFile"`
	KeyFile  string `yaml:"keyFile"`
	CAFile   string `yaml:"caFile"`
}

type StudyDBService

type StudyDBService interface {
	GetResponses(instanceID string, studyKey string, filter bson.M, sort bson.M, page int64, limit int64) (responses []studyTypes.SurveyResponse, paginationInfo *studyDB.PaginationInfos, err error)
	DeleteConfidentialResponses(instanceID string, studyKey string, participantID string, key string) (count int64, err error)
	SaveResearcherMessage(instanceID string, studyKey string, message studyTypes.StudyMessage) error
}

type StudyEngine

type StudyEngine struct {
	// contains filtered or unexported fields
}
var (
	CurrentStudyEngine *StudyEngine
)

type StudyEvent

type StudyEvent struct {
	InstanceID                            string
	StudyKey                              string
	Type                                  string                    // what kind of event (TIMER, SUBMISSION, ENTER etc.)
	Response                              studyTypes.SurveyResponse // if something is submitted during the event is added here
	Payload                               map[string]interface{}    // additional data
	EventKey                              string                    // key of the event	(for custom events)
	MergeWithParticipant                  studyTypes.Participant    // if need to merge with other participant state, is added here
	ParticipantIDForConfidentialResponses string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL