models

package
v0.0.0-...-d0785b3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CrowdSourcedUserSchema = `` /* 387-byte string literal not displayed */
View Source
var FeedbackQuestionnaireResponseSchema = `` /* 407-byte string literal not displayed */

StudySchema defines the SQL table schema for this model

View Source
var OrganizationSchema = `` /* 185-byte string literal not displayed */

OrganizationSchema defines the SQL table schema for this model

View Source
var ParticipantDataSchema = `` /* 448-byte string literal not displayed */

ParticipantDataSchema defines the SQL table schema for this model

View Source
var StudySchema = `` /* 559-byte string literal not displayed */

StudySchema defines the SQL table schema for this model

View Source
var StudyTaskSchema = `` /* 332-byte string literal not displayed */

StudyTaskSchema defines the SQL table schema for this model Composite primary key between studyId and taskOrder

View Source
var StudyUserSchema = `` /* 528-byte string literal not displayed */

StudyUserSchema defines the SQL table schema for this model

View Source
var TaskSchema = `` /* 444-byte string literal not displayed */

TaskSchema defines the SQL table schema for this model * NOTE: a task is defined as a thing within the study that the participant must do/see at a specific index * (can be psych task, info slide, questionnaire, etc)

View Source
var UserSchema = `` /* 547-byte string literal not displayed */

UserSchema defines the SQL table schema for this model

Functions

This section is empty.

Types

type Claims

type Claims struct {
	UserID string
	Email  string
	Role   string
	jwt.StandardClaims
}

Claims represents a model for JWT

type CrowdSourcedUser

type CrowdSourcedUser struct {
	ParticipantID  string    `json:"participantId"`
	StudyID        uint      `json:"studyId"`
	RegisterDate   time.Time `json:"registerDate"`
	CompletionCode string    `json:"completionCode"`
	Lang           string    `json:"lang"`
}

type DBStudy

type DBStudy struct {
	ID           uint               `json:"id"`
	OwnerId      uint               `json:"ownerId"`
	CreatedAt    time.Time          `json:"createdAt"`
	DeletedAt    sql.NullTime       `json:"deletedAt"`
	InternalName string             `json:"internalName"`
	ExternalName string             `json:"externalName"`
	Started      bool               `json:"started"`
	CanEdit      bool               `json:"canEdit"`
	ConsentId    uint               `json:"consentId"`
	Description  string             `json:"description"`
	Config       MapStringInterface `json:"config"`
}

DBStudy is the database representation of a study

type DBStudyTask

type DBStudyTask struct {
	StudyID   uint               `json:"studyId"`
	TaskID    uint               `json:"taskId"`
	TaskOrder int                `json:"taskOrder"`
	Config    MapStringInterface `json:"config"`
}

DBStudyTask is the database representation of a study task

type DBStudyUser

type DBStudyUser struct {
	UserID             uint               `json:"userId"`
	StudyID            uint               `json:"studyId"`
	CompletionCode     string             `json:"completionCode"`
	RegisterDate       time.Time          `json:"registerDate"`
	DueDate            sql.NullTime       `json:"dueDate"`
	CurrentTaskIndex   int                `json:"currentTaskIndex"`
	HasAcceptedConsent bool               `json:"hasAcceptedConsent"`
	Lang               string             `json:"lang"`
	Data               MapStringInterface `json:"data"`
}

DBStudyUser is the internal database representation of the study user

type DBUser

type DBUser struct {
	ID                     uint          `json:"id"`
	Name                   string        `json:"name"`
	OrganizationId         sql.NullInt32 `json:"organizationId"` // this can potentially be null in the db
	Email                  string        `json:"email"`
	Password               string        `json:"password"`
	Role                   string        `json:"role"`
	CreatedAt              time.Time     `json:"createdAt"`
	ChangePasswordRequired bool          `json:"changePasswordRequired"`
	Lang                   string        `json:"lang"`
}

internal DB representation of user

type FeedbackQuestionnaireResponse

type FeedbackQuestionnaireResponse struct {
	StudyId            uint      `json:"studyId"`
	UserID             string    `json:"userId"`
	IssuesEncountered  string    `json:"issuesEncountered"`
	AdditionalFeedback string    `json:"additionalFeedback"`
	SubmittedAt        time.Time `json:"submittedAt"`
	Browser            string    `json:"browser"`
	ParticipantType    string    `json:"participantType"`
}

FeedbackQuestionnaireResponse represents the feedback given by participants about the experiment

type HTTPStatus

type HTTPStatus struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

HTTPStatus represents the model for a HTTP response

type MapStringInterface

type MapStringInterface map[string]interface{}

we define this type in order to allow for flexible json in golang

func (*MapStringInterface) Scan

func (m *MapStringInterface) Scan(src interface{}) error

reads json columns from mysql and parses them into mapstringinterface The data stored in a JSON field is returned as a []uint8

func (MapStringInterface) Value

func (m MapStringInterface) Value() (driver.Value, error)

converts mapstringinterface data to json to insert into mysql

type Organization

type Organization struct {
	ID       uint   `json:"id"`
	Name     string `json:"name"`
	LogoPath string `json:"logoPath"`
}

type ParticipantData

type ParticipantData struct {
	UserID          string                  `json:"userId"`
	StudyID         uint                    `json:"studyId"`
	TaskOrder       int                     `json:"taskOrder"`
	ParticipantType string                  `json:"participantType"`
	SubmittedAt     time.Time               `json:"submittedAt"`
	Metadata        MapStringInterface      `json:"metadata"`
	Data            SliceMapStringInterface `json:"data"`
}

ParticipantData represents a model for storing all participant data including psych task responses and questionnaires. Will make manually defining structs for each task obsolete (aka all of the above structs)

type SliceMapStringInterface

type SliceMapStringInterface []map[string]interface{}

func (*SliceMapStringInterface) Scan

func (s *SliceMapStringInterface) Scan(src interface{}) error

reads json columns from mysql and parses them into mapstringinterface The data stored in a JSON field is returned as a []uint8

func (SliceMapStringInterface) Value

converts mapstringinterface data to json to insert into mysql

type Study

type Study struct {
	ID           uint               `json:"id"`
	Owner        User               `json:"owner"`
	CreatedAt    time.Time          `json:"createdAt"`
	DeletedAt    sql.NullTime       `json:"deletedAt"`
	InternalName string             `json:"internalName"`
	ExternalName string             `json:"externalName"`
	Started      bool               `json:"started"`
	CanEdit      bool               `json:"canEdit"`
	Consent      Task               `json:"consent"`
	Description  string             `json:"description"`
	Config       MapStringInterface `json:"config"`
	StudyTasks   []StudyTask        `json:"studyTasks"`
}

Study represents a model for a set of tasks

type StudyTask

type StudyTask struct {
	StudyID   uint               `json:"studyId"` // studyTasks are often embedded within studies, so we just store the ID to prevent an infinite loop
	Task      Task               `json:"task"`
	TaskOrder int                `json:"taskOrder"`
	Config    MapStringInterface `json:"config"`
}

StudyTask represents a many to many relationship between study and tasks

type StudyUser

type StudyUser struct {
	User               User               `json:"user"`
	Study              Study              `json:"study"`
	CompletionCode     string             `json:"completionCode"`
	RegisterDate       time.Time          `json:"registerDate"`
	DueDate            sql.NullTime       `json:"dueDate"`
	CurrentTaskIndex   int                `json:"currentTaskIndex"`
	HasAcceptedConsent bool               `json:"hasAcceptedConsent"`
	Lang               string             `json:"lang"`
	Data               MapStringInterface `json:"data"`
}

StudyUser represents a join table between studys and users keeping track of the progress for that user in each study that the user is part of

type StudyUserSummary

type StudyUserSummary struct {
	UserId  uint   `json:"userId"`
	Studies []uint `json:"studies"`
}

StudyUserSummary

type Task

type Task struct {
	ID           uint               `json:"id"`
	FromPlatform string             `json:"fromPlatform"`
	TaskType     string             `json:"taskType"`
	Name         string             `json:"name"`
	Description  string             `json:"description"`
	ExternalURL  string             `json:"externalURL"`
	Config       MapStringInterface `json:"config"` // will either store task metadata or questionnaire metadata
}

Task represents the most basic configuration for the tasks in sharplab

type User

type User struct {
	ID                     uint          `json:"id"`
	Name                   string        `json:"name"`
	Organization           *Organization `json:"organization"` // set to a pointer so that the returned json is null if pointer points to a nil value
	Email                  string        `json:"email"`
	Password               string        `json:"password"`
	Role                   string        `json:"role"`
	CreatedAt              time.Time     `json:"createdAt"`
	ChangePasswordRequired bool          `json:"changePasswordRequired"`
	Lang                   string        `json:"lang"`
}

User represents a model for a user

Jump to

Keyboard shortcuts

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