Documentation
¶
Index ¶
- Constants
- func CalculateDuration(input time.Time) (year, month, day, hour, min, sec int)
- func CheckConfiguration()
- func CheckProjectParticipantStatusForParticipant(participantID, projectID int64) (string, error)
- func CreateBlock(input *Block) error
- func CreateBlockFormQuestion(input *BlockFormQuestion) error
- func CreateBlockFormQuestionOption(input *BlockFormQuestionOption) error
- func CreateBlockFormSubmission(input *BlockFormSubmission) error
- func CreateBlockFormSubmissionResponse(input *BlockFormSubmissionResponse) error
- func CreateConsentResponse(input *ConsentResponse) error
- func CreateFileInDB(input *File) error
- func CreateModule(input *Module) error
- func CreateNote(input *Note) error
- func CreateProject(input *Project) error
- func CreateSite(input *Site) error
- func CreateUser(input *User) error
- func DeleteBlock(blockID int64) error
- func DeleteBlockEmbedByBlockID(blockID int64) error
- func DeleteBlockExternalByBlockID(blockID int64) error
- func DeleteBlockFileByBlockID(blockID int64) error
- func DeleteBlockFormByBlockID(blockID int64) error
- func DeleteBlockFormQuestion(questionID int64) error
- func DeleteBlockFormQuestionOption(id int64) error
- func DeleteBlockFormQuestionsForBlock(blockID int64) error
- func DeleteBlockFormSubmission(submissionID int64) error
- func DeleteBlockFormSubmissionResponses(submissionID int64) error
- func DeleteBlockTextByBlockID(blockID int64) error
- func DeleteConsentFormForProject(projectID int64) error
- func DeleteConsentResponsesForProject(projectID int64) error
- func DeleteConsentesponse(responseID int64) error
- func DeleteConsentesponseForParticipant(userID, projectID int64) error
- func DeleteFileFromBucket(key string) error
- func DeleteFileFromDB(id int64) error
- func DeleteJournalNotesForUser(userID int64) error
- func DeleteModule(moduleID int64) error
- func DeleteNoteByID(noteID int64) error
- func DeleteNotesForUser(userID int64) error
- func DeleteProject(projectID int64) error
- func DeleteProjectNotesForProject(projectID int64) error
- func DeleteProjectNotesForUser(userID, projectID int64) error
- func DeleteSiteByID(siteID int64) error
- func DeleteUser(userID int64) error
- func GetFileFromBucket(key string) ([]byte, error)
- func HandleSaveBlockForm(content *BlockForm) error
- func IsBlockInModule(moduleID, blockID int64) bool
- func IsModuleInProject(projectID, moduleID int64) bool
- func IsUserInProject(participantID, projectID int64) bool
- func LinkBlockAndModule(moduleID int64, blockID int64, order int64) error
- func LinkModuleAndProject(projectID, moduleID, order int64) error
- func LinkUserAndProject(userID, projectID int64) error
- func ListFilesInBucket() ([]types.Object, error)
- func Log(level string, key, message string, options *LogOptions)
- func LogOutUser(userID int64) error
- func RemoveAllProgressForParticipantAndBlock(participantID, blockID int64) error
- func RemoveAllProgressForParticipantAndFlow(participantID, projectID int64) error
- func RemoveAllProgressForParticipantAndModule(participantID, moduleID int64) error
- func RemoveUserFromProjectCompletely(userID, projectID int64) error
- func SaveBlockEmbed(input *BlockEmbed) error
- func SaveBlockExternal(input *BlockExternal) error
- func SaveBlockFile(input *BlockFile) error
- func SaveBlockForm(input *BlockForm) error
- func SaveBlockText(input *BlockText) error
- func SaveBlockUserStatusForParticipant(input *BlockUserStatus) error
- func SaveConsentFormForProject(input *ConsentForm) error
- func SetupAPI() *chi.Mux
- func SetupConfig() *apiConfig
- func UnlinkAllBlocksFromModule(moduleID int64) error
- func UnlinkAllModulesFromProject(projectID int64) error
- func UnlinkBlockAndModule(moduleID int64, blockID int64) error
- func UnlinkModuleAndProject(projectID, moduleID int64) error
- func UnlinkUserAndProject(userID, projectID int64) error
- func UpdateBlock(input *Block) error
- func UpdateBlockFormQuestion(input *BlockFormQuestion) error
- func UpdateBlockFormQuestionOption(input *BlockFormQuestionOption) error
- func UpdateBlockFormSubmission(input *BlockFormSubmission) error
- func UpdateBlockFormSubmissionResponse(input *BlockFormSubmissionResponse) error
- func UpdateFileInDB(input *File) error
- func UpdateFileVisibilityFromAdminOnly(fileID int64, visibility string) error
- func UpdateModule(input *Module) error
- func UpdateNote(input *Note) error
- func UpdateProject(input *Project) error
- func UpdateSite(input *Site) error
- func UpdateUser(input *User) error
- func UpdateUserAndProjectStatus(userID, projectID int64, status string) error
- func UploadFileToBucket(key string, data []byte) error
- type Block
- type BlockEmbed
- type BlockExternal
- type BlockFile
- type BlockForm
- type BlockFormQestionResponseInput
- type BlockFormQuestion
- type BlockFormQuestionOption
- type BlockFormSubmission
- type BlockFormSubmissionResponse
- type BlockText
- type BlockUserStatus
- type ConsentForm
- type ConsentResponse
- type CountReturn
- type File
- type Flow
- type LogOptions
- type Module
- type Note
- type NoteSelectOptions
- type Project
- type ProjectAPIReturnNonAdmin
- type ProjectUserLinkRequest
- type ReportBlockStatusCount
- type ReportSubmissionCount
- type ReportSubmissionResponses
- type ReportSubmissionResponsesQuestion
- type ReportSubmissionResponsesResponse
- type ReportUserLastUpdatedAgo
- type ReportValueCount
- type Site
- type Token
- type User
- func AttemptLoginForUser(emailOrCode, password string) (*User, error)
- func GetAllUsersInProject(projectID int64) ([]User, error)
- func GetAllUsersOnPlatform() ([]User, error)
- func GetUserByEmail(email string) (*User, error)
- func GetUserByID(userID int64) (*User, error)
- func GetUserByParticipantCode(participantCode string) (*User, error)
Constants ¶
const ( BlockTypeExternal = "external" BlockTypeEmbed = "embed" BlockTypeForm = "form" BlockTypeText = "text" BlockTypeFile = "file" )
const ( BlockEmbedTypeExternalPDF = "external_pdf" BlockEmbedTypeInternalPDF = "internal_pdf" BlockEmbedTypeYoutube = "youtube" )
const ( BlockFormTypeSurvey = "survey" BlockFormTypeQuiz = "quiz" BlockFormQuestionTypeExplanation = "explanation" // just text, no response allowed BlockFormQuestionTypeMultiple = "multiple" // multiple choice BlockFormQuestionTypeSingle = "single" // single choice BlockFormQuestionTypeShort = "short" // short text BlockFormQuestionTypeLong = "long" // long text BlockFormQuestionTypeLikert5 = "likert5" // likert5 BlockFormQuestionTypeLikert7 = "likert7" // likert7 BlockFormSubmissionResultsNA = "na" BlockFormSubmissionResultsNeedsInput = "needs_input" BlockFormSubmissionResultsPassed = "passed" BlockFormSubmissionResultsFailed = "failed" BlockFormSubmissionResponseIsCorrectNA = "na" BlockFormSubmissionResponseIsCorrectPending = "pending" BlockFormSubmissionResponseIsCorrectYes = "yes" BlockFormSubmissionResponseIsCorrectNo = "no" )
const ( Yes = "yes" No = "no" SortASC = "ASC" SortDESC = "DESC" )
const ( ConsentResponseStatusAccepted = "accepted" ConsentResponseStatusAcceptedForOther = "accepted_for_other" ConsentResponseStatusDeclined = "declined" )
const ( MaxFileSizeMB = 128 FileVisibilityAdmin = "admin" FileVisibilityUsers = "users" FileVisibilityProject = "project" FileVisibilityPublic = "public" FileLocationSourceAWS = "aws" FileLocationSourceOther = "other" )
const ( BlockUserStatusNotStarted = "not_started" BlockUserStatusStarted = "started" BlockUserStatusCompleted = "completed" )
const ( LogLevelTrace = "TRACE" LogLevelDebug = "DEBUG" LogLevelInfo = "INFO" LogLevelWarn = "WARN" LogLevelError = "ERROR" LogLevelFatal = "FATAL" LogLevelPanic = "PANIC" )
const ( ModuleStatusActive = "active" ModuleStatusPending = "pending" ModuleStatusDisabled = "disabled" )
const ( NoteTypeJournal = "journal" NoteTypeProject = "project" NoteVisibilityPrivate = "private" NoteVisibilityAdmins = "admins" )
const ( ProjectStatusPending = "pending" ProjectStatusActive = "active" ProjectStatusDisabled = "disabled" ProjectStatusCompleted = "completed" ProjectUserLinkStatusNotStarted = "not_started" ProjectUserLinkStatusStarted = "started" ProjectUserLinkStatusCompleted = "completed" ProjectShowStatusSite = "site" ProjectShowStatusDirect = "direct" ProjectShowStatusNo = "no" ProjectSignupStatusOpen = "open" ProjectSignupStatusWithCode = "with_code" ProjectSignupStatusClosed = "closed" ProjectParticipantVisibilityCode = "code" ProjectParticipantVisibilityEmail = "email" ProjectParticipantVisibilityFull = "full" ProjectFlowRuleFree = "free" // no limitations ProjectFlowRuleInOrderInModule = "in_order_in_module" // must progress in module order but any module can be accessed ProjectFlowRuleInOrderInProject = "in_order_in_project" // must progress in project order ProjectCompleteRuleContinued = "continued_access" // continued access ProjectCompleteRuleBlocked = "blocked" // when complete or end, no more access ProjectStartRuleAny = "any" // begins when active ProjectStartRuleDate = "date" // begins on date ProjectStartRuleThreshold = "threshold" // begins when threshold hit )
const ( SiteStatusPending = "pending" SiteStatusActive = "active" SiteStatusDisabled = "disabled" SiteProjectListOptionsAll = "show_all" SiteProjectListOptionsActive = "show_active" SiteProjectListOptionsNone = "show_none" )
const ( UserStatusActive = "active" UserStatusPending = "pending" UserStatusLocked = "locked" UserStatusDisabled = "disabled" UserSystemRoleUser = "user" UserSystemRoleAdmin = "admin" UserSystemRoleParticipant = "participant" )
Variables ¶
This section is empty.
Functions ¶
func CalculateDuration ¶
CalculateDuration gets the duration from a certain date time to now. Timezone is not important for this one and we always calculate from now. Shamelessly adapted from icza at https://stackoverflow.com/questions/36530251/golang-time-since-with-months-and-years. Support him through his profile: https://stackoverflow.com/users/1705598/icza
func CheckConfiguration ¶
func CheckConfiguration()
func CheckProjectParticipantStatusForParticipant ¶
CheckProjectParticipantStatusForParticipant checks the participant's status in a project
func CreateBlockFormQuestion ¶
func CreateBlockFormQuestion(input *BlockFormQuestion) error
CreateBlockFormQuestion creates a new question
func CreateBlockFormQuestionOption ¶
func CreateBlockFormQuestionOption(input *BlockFormQuestionOption) error
CreateBlockFormQuestionOption creates a new option
func CreateBlockFormSubmission ¶
func CreateBlockFormSubmission(input *BlockFormSubmission) error
CreateBlockFormSubmission creates a new submission to link in individual responses
func CreateBlockFormSubmissionResponse ¶
func CreateBlockFormSubmissionResponse(input *BlockFormSubmissionResponse) error
CreateBlockFormSubmissionResponse creates a new individual question response
func CreateConsentResponse ¶
func CreateConsentResponse(input *ConsentResponse) error
CreateConsentResponse creates a new response
func CreateFileInDB ¶
CreateFileInDB creates a file entry in the DB
func CreateModule ¶
CreateModule creates a module as a standalone "box"
func CreateSite ¶
CreateSite creates a site; this should be called relatively infrequently
func DeleteBlockEmbedByBlockID ¶
DeleteBlockEmbedByBlockID deletes the block content
func DeleteBlockExternalByBlockID ¶
DeleteBlockExternalByBlockID deletes the block content
func DeleteBlockFileByBlockID ¶
DeleteBlockFileByBlockID deletes the block content
func DeleteBlockFormByBlockID ¶
DeleteBlockFormByBlockID deletes a form and all of the questions / options / responses
func DeleteBlockFormQuestion ¶
DeleteBlockFormQuestion deletes a question and all responses / options
func DeleteBlockFormQuestionOption ¶
DeleteBlockFormQuestionOption deletes an option
func DeleteBlockFormQuestionsForBlock ¶
DeleteBlockFormQuestionsForBlock deletes all questions and all responses / options for a block
func DeleteBlockFormSubmission ¶
DeleteBlockFormSubmission deletes a submission and connected responses
func DeleteBlockFormSubmissionResponses ¶
DeleteBlockFormSubmissionResponses deletes all of the responses for a submission
func DeleteBlockTextByBlockID ¶
DeleteBlockTextByBlockID deletes the block content
func DeleteConsentFormForProject ¶
DeleteConsentFormForProject deletes the consent form for a project and all responses
func DeleteConsentResponsesForProject ¶
DeleteConsentResponsesForProject deletes all responses for a project
func DeleteConsentesponse ¶
DeleteConsentesponse deletes a single response
func DeleteConsentesponseForParticipant ¶
DeleteConsentesponseForParticipant deletes a response for a specific participant; this could be dangerous depending on the study protocol!
func DeleteFileFromBucket ¶
DeleteFileFromBucket deletes a file from a bucket
func DeleteFileFromDB ¶
DeleteFileFromDB deletes a file's metadata from the DB
func DeleteJournalNotesForUser ¶
DeleteJournalNotesForUser deletes all journal notes for a user
func DeleteModule ¶
DeleteModule removes a module from flows and then deletes the module
func DeleteNotesForUser ¶
DeleteNotesForUser deletes all notes tied to a user
func DeleteProject ¶
DeleteProject deletes a project. Note that this probably
func DeleteProjectNotesForProject ¶
DeleteProjectNotesForProject deletes all notes on a project; should only be called if a project is deleted
func DeleteProjectNotesForUser ¶
DeleteProjectNotesForUser deletes the notes for a user tied to a specific project
func DeleteSiteByID ¶
DeleteSiteByID deletes a site. WARNING: Think REALLY HARD before calling this, as the ramifications could be... difficult. It would be better to just drop the database if you are intentionally trying to delete a site and its data
func DeleteUser ¶
DeleteUser completely deletes a user, and should really only be used in tests
func GetFileFromBucket ¶
GetFileFromBucket gets the raw bytes of an object from a bucket
func HandleSaveBlockForm ¶
func IsBlockInModule ¶
IsBlockInModule checks if a block is in a module for a flow
func IsModuleInProject ¶
IsModuleInProject checks if a module is in a project flow
func IsUserInProject ¶
IsUserInProject is a helper to determine if a user is in a project or not
func LinkBlockAndModule ¶
LinkBlockAndModule links a block and a module
func LinkModuleAndProject ¶
LinkModuleAndProject saves a connection between a module and a project
func LinkUserAndProject ¶
LinkUserAndProject links a user to a project
func ListFilesInBucket ¶
ListFilesInBucket will list the files in the bucket. Note that this isn't the ideal way to list all files for the account, as the files should be handled in the db
func Log ¶
func Log(level string, key, message string, options *LogOptions)
Log sends a log to output
func LogOutUser ¶
func RemoveAllProgressForParticipantAndBlock ¶
RemoveAllProgressForParticipantAndBlock removes a participant's progress in a block
func RemoveAllProgressForParticipantAndFlow ¶
RemoveAllProgressForParticipantAndFlow removes all progress saved for a user in a project flow
func RemoveAllProgressForParticipantAndModule ¶
RemoveAllProgressForParticipantAndModule removes a participant's progress in a module
func SaveBlockEmbed ¶
func SaveBlockEmbed(input *BlockEmbed) error
SaveBlockEmbed saves the block content
func SaveBlockExternal ¶
func SaveBlockExternal(input *BlockExternal) error
SaveBlockExternal saves the block content
func SaveBlockFile ¶
SaveBlockFile saves the block content
func SaveBlockForm ¶
SaveBlockForm creates or updates the limited sub-meta-data
func SaveBlockText ¶
SaveBlockText saves the block content
func SaveBlockUserStatusForParticipant ¶
func SaveBlockUserStatusForParticipant(input *BlockUserStatus) error
SaveBlockUserStatusForParticipant creates or updates a participant's block status in the flow
func SaveConsentFormForProject ¶
func SaveConsentFormForProject(input *ConsentForm) error
SaveConsentFormForProject creates or updates a consent form for a project
func SetupConfig ¶
func SetupConfig() *apiConfig
SetupConfig is a call to configure the basic required configuration options for the API
func UnlinkAllBlocksFromModule ¶
UnlinkAllBlocksFromModule unlinks all blocks from a module
func UnlinkAllModulesFromProject ¶
UnlinkAllModulesFromProject removes all modules from a project
func UnlinkBlockAndModule ¶
UnlinkBlockAndModule unlinks a block and a module
func UnlinkModuleAndProject ¶
UnlinkModuleAndProject removes the module from a project
func UnlinkUserAndProject ¶
UnlinkUserAndProject unlinks a user and a project
func UpdateBlockFormQuestion ¶
func UpdateBlockFormQuestion(input *BlockFormQuestion) error
UpdateBlockFormQuestion updates most fields in the question
func UpdateBlockFormQuestionOption ¶
func UpdateBlockFormQuestionOption(input *BlockFormQuestionOption) error
UpdateBlockFormQuestionOption updates most fields for an option
func UpdateBlockFormSubmission ¶
func UpdateBlockFormSubmission(input *BlockFormSubmission) error
UpdateBlockFormSubmission updates a submission's information; note that we allow changing most of the fields, but really the only fields that should change it the results field
func UpdateBlockFormSubmissionResponse ¶
func UpdateBlockFormSubmissionResponse(input *BlockFormSubmissionResponse) error
UpdateBlockFormSubmissionResponse updates an individual response; note that we allow changing most of the fields, but really the only fields that should change are the isCorrect and text fields
func UpdateFileInDB ¶
UpdateFileInDB updates a file's metadata in the DB
func UpdateFileVisibilityFromAdminOnly ¶
UpdateFileVisibilityFromAdminOnly is a simple helper for when a block saves with a file; only the file id is set, so if the file visibility is set to admin, we need to set it to project; if it's not admin only, then we don't change it (we don't want to make it more restrictive)
func UpdateProject ¶
UpdateProject updates an existing project
func UpdateUserAndProjectStatus ¶
UpdateUserAndProjectStatus updates the project status for a user
func UploadFileToBucket ¶
UploadFileToBucket uploads a file to a bucket
Types ¶
type Block ¶
type Block struct { ID int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` Summary string `json:"summary" db:"summary"` BlockType string `json:"blockType" db:"blockType"` Content interface{} `json:"content,omitempty"` FoundInFlows int64 `json:"foundInFlows" db:"foundInFlows"` AllowReset string `json:"allowReset" db:"allowReset"` UserStatus string `json:"userStatus,omitempty" db:"userStatus"` LastUpdatedOn string `json:"lastUpdatedOn,omitempty" db:"lastUpdatedOn"` ProjectID int64 `json:"projectId,omitempty" db:"projectId"` ProjectName string `json:"projectName,omitempty" db:"projectName"` ModuleID int64 `json:"moduleId,omitempty" db:"moduleId"` ModuleName string `json:"moduleName,omitempty" db:"moduleName"` }
Block is a block of content, which has the details filled out in linked tables
func GetBlockByID ¶
GetBlockByID gets a single block by id
func GetBlocksForModule ¶
GetBlocksForModule gets all of the blocks for a module
func GetBlocksForSite ¶
GetBlocksForSite gets the blocks for the site, usually used in admin views for linking and setting up flows
func GetModuleBlockForParticipant ¶
func GetModuleBlockForParticipant(participantID, projectID, moduleID, blockID int64) (*Block, error)
GetModuleBlockForParticipant gets a single block for a participant; we take in all three levels to ensure that the permissions are correct
type BlockEmbed ¶
type BlockEmbed struct { BlockID int64 `json:"blockId" db:"blockId"` EmbedLink string `json:"embedLink" db:"embedLink"` EmbedType string `json:"embedType" db:"embedType"` FileID int64 `json:"fileId" db:"fileId"` }
BlockEmbed is the `presentation` block type
func GetBlockEmbedByBlockID ¶
func GetBlockEmbedByBlockID(blockID int64) (*BlockEmbed, error)
GetBlockEmbedByBlockID gets the block content
func GetBlockFileByBlockID ¶
func GetBlockFileByBlockID(blockID int64) (*BlockEmbed, error)
GetBlockFileByBlockID gets the block content
type BlockExternal ¶
type BlockExternal struct { BlockID int64 `json:"blockId" db:"blockId"` ExternalLink string `json:"externalLink" db:"externalLink"` }
BlockExternal is the `external` block type
func GetBlockExternalByBlockID ¶
func GetBlockExternalByBlockID(blockID int64) (*BlockExternal, error)
GetBlockExternalByBlockID gets the block content
type BlockFile ¶
type BlockFile struct { BlockID int64 `json:"blockId" db:"blockId"` FileID int64 `json:"fileId" db:"fileId"` }
BlockFile is the `file` block type
type BlockForm ¶
type BlockForm struct { BlockID int64 `json:"blockId" db:"blockId"` FormType string `json:"formType" db:"formType"` AllowResubmit string `json:"allowResubmit" db:"allowResubmit"` Questions []BlockFormQuestion `json:"questions"` }
BlockForm is a form block, such as a survey or quiz for a check on learning
func GetBlockFormByBlockID ¶
GetBlockFormByBlockID gets the form metadata but not the rest of the data
type BlockFormQestionResponseInput ¶
type BlockFormQestionResponseInput struct {
Responses []BlockFormSubmissionResponse `json:"responses"`
}
BlockFormQestionResponseInput is a helper input for sending many responses at once to the API
type BlockFormQuestion ¶
type BlockFormQuestion struct { ID int64 `json:"id" db:"id"` BlockID int64 `json:"blockId" db:"blockId"` QuestionType string `json:"questionType" db:"questionType"` Question string `json:"question" db:"question"` FormOrder int64 `json:"formOrder" db:"formOrder"` // needed for the return Options []BlockFormQuestionOption `json:"options"` }
BlockFormQuestion is a question in a form
func GetBlockFormQuestionsForBlockID ¶
func GetBlockFormQuestionsForBlockID(blockID int64) ([]BlockFormQuestion, error)
GetBlockFormQuestionsForBlockID gets the questions and options for a block
type BlockFormQuestionOption ¶
type BlockFormQuestionOption struct { ID int64 `json:"id" db:"id"` QuestionID int64 `json:"questionId" db:"questionId"` OptionText string `json:"optionText" db:"optionText"` OptionOrder int64 `json:"optionOrder" db:"optionOrder"` OptionIsCorrect string `json:"optionIsCorrect" db:"optionIsCorrect"` }
BlockFormQuestionOption are the options for a single or multiple choice question
func GetBlockFormQuestionOptionForQuestion ¶
func GetBlockFormQuestionOptionForQuestion(questionID int64) ([]BlockFormQuestionOption, error)
GetBlockFormQuestionOptionForQuestion gets the options for a question
type BlockFormSubmission ¶
type BlockFormSubmission struct { ID int64 `json:"id" db:"id"` BlockID int64 `json:"blockId" db:"blockId"` UserID int64 `json:"userId" db:"userId"` SubmittedOn string `json:"submittedOn" db:"submittedOn"` Results string `json:"results" db:"results"` // needed for the return Responses []BlockFormSubmissionResponse `json:"responses"` }
BlockFormSubmission is a completed submission which will like in responses
func GetBlockFormSubmissionByID ¶
func GetBlockFormSubmissionByID(id int64) (*BlockFormSubmission, error)
GetBlockFormSubmissionByID gets a specific response
func GetBlockFormSubmissionsForBlock ¶
func GetBlockFormSubmissionsForBlock(blockID int64) ([]BlockFormSubmission, error)
GetBlockFormSubmissionsForBlock gets all submissions for a block
func GetBlockFormSubmissionsForUser ¶
func GetBlockFormSubmissionsForUser(userID, blockID int64) ([]BlockFormSubmission, error)
GetBlockFormSubmissionByID gets submissions for a user
type BlockFormSubmissionResponse ¶
type BlockFormSubmissionResponse struct { ID int64 `json:"id" db:"id"` SubmissionID int64 `json:"submissionId" db:"submissionId"` QuestionID int64 `json:"questionId" db:"questionId"` OptionID int64 `json:"optionId" db:"optionId"` TextResponse string `json:"textResponse" db:"textResponse"` IsCorrect string `json:"isCorrect" db:"isCorrect"` QuestionText string `json:"questionText" db:"questionText"` QuestionType string `json:"questionType" db:"questionType"` }
BlockFormSubmissionResponse is a user's response to a question in a form; it can be either an option (single/multi) or text (optionId is 0 and question type is short/long)
func GetBlockFormSubmissionResponsesForBlock ¶
func GetBlockFormSubmissionResponsesForBlock(blockID int64) ([]BlockFormSubmissionResponse, error)
GetBlockFormSubmissionResponsesForBlock gets all submissions for a block without being tied to a user
func GetBlockFormSubmissionResponsesForSubmission ¶
func GetBlockFormSubmissionResponsesForSubmission(submissionID int64) ([]BlockFormSubmissionResponse, error)
GetBlockFormSubmissionResponsesForSubmission gets all of the responses for a submission
type BlockText ¶
type BlockText struct { BlockID int64 `json:"blockId" db:"blockId"` Text string `json:"text" db:"text"` }
BlockText is the `text` block type
func GetBlockTextByBlockID ¶
GetBlockTextByBlockID gets the block content
type BlockUserStatus ¶
type BlockUserStatus struct { UserID int64 `json:"userId" db:"userId"` ProjectID int64 `json:"projectId" db:"projectId"` ModuleID int64 `json:"moduleId" db:"moduleId"` BlockID int64 `json:"blockId" db:"blockId"` UserStatus string `json:"userStatus" db:"userStatus"` LastUpdatedOn string `json:"lastUpdatedOn" db:"lastUpdatedOn"` // these are needed for the save ProjectUserStatus string `json:"projectUserStatus,omitempty" db:"projectUserStatus"` ProjectCompleteMessage string `json:"projectCompleteMessage,omitempty" db:"projectCompleteMessage"` }
BlockUserStatus represents a specific block/status entry
type ConsentForm ¶
type ConsentForm struct { ProjectID int64 `json:"projectId" db:"projectId"` ContentInMarkdown string `json:"contentInMarkdown" db:"contentInMarkdown"` ContactInformationDisplay string `json:"contactInformationDisplay" db:"contactInformationDisplay"` InstitutionInformationDisplay string `json:"institutionInformationDisplay" db:"institutionInformationDisplay"` OverrideSaveIfParticipants bool `json:"overrideSaveIfParticipants,omitempty"` // used to allow updating a consent form after the project started }
ConsentForm is the consent form for a project
func GetConsentFormForProject ¶
func GetConsentFormForProject(projectID int64) (*ConsentForm, error)
GetConsentFormForProject gets the project's consent form
type ConsentResponse ¶
type ConsentResponse struct { ID int64 `json:"id" db:"id"` ProjectID int64 `json:"projectId" db:"projectId"` SubmittedOn string `json:"submittedOn" db:"submittedOn"` ConsentStatus string `json:"consentStatus" db:"consentStatus"` ParticipantComments string `json:"participantComments" db:"participantComments"` ResearcherComments string `json:"researcherComments" db:"researcherComments"` ParticipantProvidedFirstName string `json:"participantProvidedFirstName" db:"participantProvidedFirstName"` ParticipantProvidedLastName string `json:"participantProvidedLastName" db:"participantProvidedLastName"` ParticipantProvidedContactInformation string `json:"participantProvidedContactInformation" db:"participantProvidedContactInformation"` ParticipantID int64 `json:"participantId" db:"participantId"` // will be 0 if the project specifies to not link them ProjectCode string `json:"projectCode,omitempty"` // used for signup when the project needs a code // these are used when the project must be anonymous, so a new account is created during consent // and tied to a participant code User *User `json:"user"` }
ConsentResponse is the response to a consent form
func GetConsentResponseByID ¶
func GetConsentResponseByID(responseID int64) (*ConsentResponse, error)
GetConsentResponseByID gets a single response
func GetConsentResponsesForProject ¶
func GetConsentResponsesForProject(projectID int64) ([]ConsentResponse, error)
GetConsentResponsesForProject gets all of the responses for a project
type CountReturn ¶
type CountReturn struct {
Count int64 `json:"count" db:"count"`
}
CountReturn is a helpers for DB calls that just need a count
type File ¶
type File struct { ID int64 `json:"id" db:"id"` RemoteKey string `json:"remoteKey" db:"remoteKey"` Display string `json:"display" db:"display"` Description string `json:"description" db:"description"` FileType string `json:"fileType" db:"fileType"` UploadedOn string `json:"uploadedOn" db:"uploadedOn"` UploadedBy int64 `json:"uploadedBy" db:"uploadedBy"` Visibility string `json:"visibility" db:"visibility"` FileSize int64 `json:"fileSize" db:"fileSize"` LocationSource string `json:"locationSource" db:"locationSource"` }
File is a DB entry for a file that is hosted somewhere
func GetFileFromDB ¶
GetFileFromDB gets a file's metadata from the DB
func GetFilesFromDB ¶
GetFilesFromDB gets a list of files from the DB; since this can be pretty large, we add sort and offset
type Flow ¶
type Flow struct { UserID int64 `json:"userId" db:"userId"` ProjectID int64 `json:"projectId" db:"projectId"` FlowOrder int64 `json:"flowOrder" db:"flowOrder"` ModuleID int64 `json:"moduleId" db:"moduleId"` ModuleName string `json:"moduleName" db:"moduleName"` ModuleDescription string `json:"moduleDescription" db:"moduleDescription"` BlockID int64 `json:"blockId" db:"blockId"` BlockName string `json:"blockName" db:"blockName"` BlockSummary string `json:"blockSummary" db:"blockSummary"` BlockType string `json:"blockType" db:"blockType"` UserStatus string `json:"userStatus" db:"userStatus"` LastUpdatedOn string `json:"lastUpdatedOn" db:"lastUpdatedOn"` }
Flow represents the flow of a project from a participant's viewpoint; keep in mind this is not a direct translation of the Flows table; it needs to support the joins that come from the Flows, Links, and Status tables
func GetProjectFlowForParticipant ¶
GetProjectFlowForParticipant gets the entire flow for a project for a participant to lay out the flow and status for each section. Note the explicit lack of a module or project status; that can be calculated based upon this data.
type LogOptions ¶
type LogOptions struct { ExtraData map[string]interface{} // the two can be helpful when things are tough to debug, but shouldn't be required CallingFile string CallingFunc string }
LogOptions are optional options and fields for logging
type Module ¶
type Module struct { ID int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` Status string `json:"status" db:"status"` Description string `json:"description" db:"description"` FlowOrder int64 `json:"flowOrder" db:"flowOrder"` // used in getting for a project ProjectsCount int64 `json:"projectsCount" db:"projectsCount"` // used in getting for platform to identify if it's in a project }
Module is a module that contains Blocks and are organized into Flows for a Project
func GetAllModulesForSite ¶
GetAllModulesForSite gets all the modules on the site, needed for the building of the flows interface
func GetModuleByID ¶
GetModuleByID gets a single module
func GetModulesForProject ¶
GetModulesForProject gets all of the modules for a project
type Note ¶
type Note struct { ID int64 `json:"id" db:"id"` UserID int64 `json:"userId" db:"userId"` CreatedOn string `json:"createdOn" db:"createdOn"` NoteType string `json:"noteType" db:"noteType"` ProjectID int64 `json:"projectId" db:"projectId"` ModuleID int64 `json:"moduleId" db:"moduleId"` BlockID int64 `json:"blockId" db:"blockId"` Visibility string `json:"visibility" db:"visibility"` Title string `json:"title" db:"title"` Body string `json:"body" db:"body"` // needed for the gets ProjectName string `json:"projectName" db:"projectName"` ModuleName string `json:"moduleName" db:"moduleName"` BlockName string `json:"blockName" db:"blockName"` }
Note represents a note that a user can enter into the system, often as a part of a training or project
func GetAllNotesForUser ¶
func GetAllNotesForUser(userID int64, noteType string, filter *NoteSelectOptions) ([]Note, error)
GetAllNotesForUser gets non-project notes for a user
type NoteSelectOptions ¶
type NoteSelectOptions struct { NoteType string `json:"noteType"` ProjectID int64 `json:"projectId"` ModuleID int64 `json:"moduleId"` BlockID int64 `json:"blockId"` }
NoteSelectOptions is a helper to store all the possible combinations of values in a selector rather than building a whole bunch of strings or funcs
type Project ¶
type Project struct { ID int64 `json:"id" db:"id"` SiteID int64 `json:"siteId" db:"siteId"` Name string `json:"name" db:"name"` ShortCode string `json:"shortCode" db:"shortCode"` ShortDescription string `json:"shortDescription" db:"shortDescription"` Description string `json:"description" db:"description"` Status string `json:"status" db:"status"` ShowStatus string `json:"showStatus" db:"showStatus"` SignupStatus string `json:"signupStatus" db:"signupStatus"` MaxParticipants int64 `json:"maxParticipants" db:"maxParticipants"` ParticipantVisibility string `json:"participantVisibility" db:"participantVisibility"` ParticipantMinimumAge int64 `json:"participantMinimumAge" db:"participantMinimumAge"` ConnectParticipantToConsentForm string `json:"connectParticipantToConsentForm" db:"connectParticipantToConsentForm"` ParticipantCount int64 `json:"participantCount" db:"participantCount"` CompleteMessage string `json:"completeMessage" db:"completeMessage"` FlowRule string `json:"flowRule" db:"flowRule"` CompleteRule string `json:"completeRule" db:"completeRule"` StartRule string `json:"startRule" db:"startRule"` StartDate string `json:"startDate" db:"startDate"` EndDate string `json:"endDate" db:"endDate"` // needed for the participant and admin views ParticipantID int64 `json:"participantId,omitempty" db:"participantId"` ParticipantStatus string `json:"participantStatus,omitempty" db:"participantStatus"` }
Project is a major research project, which will have flows associated with it. Participants work through the project flows. Projects can be viewed as meta-info about the activities conducted in the project. The shortCode is used with the `SignupStatus` field and should NOT be returned in GETs for non-admins
func GetProjectByID ¶
GetProjectByID gets a single project by its id
func GetProjectForParticipantByID ¶
GetProjectForParticipantByID gets a project along with the user's project status
func GetProjectsForParticipant ¶
GetProjectsForParticipant gets the lis of projects for a participant
func GetProjectsForSite ¶
GetProjectsForSite gets all of the projects for a site, optionally filtered by status
type ProjectAPIReturnNonAdmin ¶
type ProjectAPIReturnNonAdmin struct { ID int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` ShortDescription string `json:"shortDescription" db:"shortDescription"` Description string `json:"description" db:"description"` Status string `json:"status" db:"status"` SignupStatus string `json:"signupStatus" db:"signupStatus"` ParticipantMinimumAge int64 `json:"participantMinimumAge" db:"participantMinimumAge"` ParticipantVisibility string `json:"participantVisibility" db:"participantVisibility"` ParticipantStatus string `json:"participantStatus,omitempty" db:"participantStatus"` }
ProjectAPIReturnNonAdmin is a much-reduced project return struct for non-admins
type ProjectUserLinkRequest ¶
type ProjectUserLinkRequest struct {
Code string `json:"code"`
}
ProjectUserLinkRequest holds extra request options for joining a project, such as if a code is needed
type ReportBlockStatusCount ¶
type ReportBlockStatusCount struct { ModuleID int64 `json:"moduleId" db:"moduleId"` ModuleName string `json:"moduleName" db:"moduleName"` BlockID int64 `json:"blockId" db:"blockId"` BlockName string `json:"blockName" db:"blockName"` CompletedCount int64 `json:"completedCount" db:"completedCount"` NotStartedCount int64 `json:"notStartedCount" db:"notStartedCount"` StartedCount int64 `json:"startedCount" db:"startedCount"` }
ReportBlockStatusCount is a report on a user's status in a block
func ReportGetCountOfStatusForProject ¶
func ReportGetCountOfStatusForProject(projectID int64) ([]ReportBlockStatusCount, error)
ReportGetCountOfStatusForProject gets the status of the users grouped for a project
type ReportSubmissionCount ¶
type ReportSubmissionCount struct { ModuleID int64 `json:"moduleId" db:"moduleId"` ModuleName string `json:"moduleName" db:"moduleName"` BlockID int64 `json:"blockId" db:"blockId"` BlockName string `json:"blockName" db:"blockName"` BlockType string `json:"blockType" db:"blockType"` Count int64 `json:"count" db:"count"` }
ReportSubmissionCount is the count of number of submissions
func ReportGetSubmissionCountForProject ¶
func ReportGetSubmissionCountForProject(projectID int64) ([]ReportSubmissionCount, error)
ReportGetSubmissionCountForProject gets the count of submissions for a project
type ReportSubmissionResponses ¶
type ReportSubmissionResponses struct { BlockID int64 `json:"blockId" db:"blockId"` BlockName string `json:"blockName" db:"blockName"` SubmissionCount int64 `json:"submissionCount" db:"submissionCount"` Questions []ReportSubmissionResponsesQuestion `json:"questions" db:"questions"` }
ReportSubmissionResponses is the responses
type ReportSubmissionResponsesQuestion ¶
type ReportSubmissionResponsesQuestion struct { QuestionID int64 `json:"questionId" db:"questionId"` QuestionText string `json:"questionText" db:"questionText"` QuestionType string `json:"questionType" db:"questionType"` Responses []ReportSubmissionResponsesResponse `json:"responses" db:"responses"` }
ReportSubmissionResponsesQuestion is a question in the response report
type ReportSubmissionResponsesResponse ¶
type ReportSubmissionResponsesResponse struct { OptionID int64 `json:"optionId" db:"optionId"` TextResponse string `json:"textResponse" db:"textResponse"` Count int64 `json:"count" db:"count"` }
ReportSubmissionResponsesResponse is a response to a question in the report
type ReportUserLastUpdatedAgo ¶
type ReportUserLastUpdatedAgo struct { DaysAgo int64 `json:"daysAgo" db:"daysAgo"` UserID int64 `json:"userId" db:"userId"` }
ReportUserLastUpdatedAgo holds the days ago versus the user
func ReportGetCountOfLastUpdatedForProject ¶
func ReportGetCountOfLastUpdatedForProject(projectID int64) ([]ReportUserLastUpdatedAgo, error)
ReportGetCountOfLastUpdatedForProject gets the report of users in a project by their last updated status
type ReportValueCount ¶
type ReportValueCount struct { Value string `json:"value" db:"value"` Count int64 `json:"count" db:"count"` }
ReportValueCount is a generic report count holder
func ReportGetCountOfUsersOnProjectByStatus ¶
func ReportGetCountOfUsersOnProjectByStatus(projectID int64) ([]ReportValueCount, error)
ReportGetCountOfUsersOnProjectByStatus gets the users on a project by their status
type Site ¶
type Site struct { ID int64 `json:"id" db:"id"` // in the current set up, there should only be one site CreatedOn string `json:"createdOn" db:"createdOn"` ShortName string `json:"shortName" db:"shortName"` Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` Domain string `json:"domain" db:"domain"` Status string `json:"status" db:"status"` // pending, active, disabled ProjectListOptions string `json:"projectListOptions" db:"projectListOptions"` // show_all, show_active, show_none SiteTechnicalContact string `json:"siteTechnicalContact" db:"siteTechnicalContact"` }
Site is an available location or installation
func GetSiteFromContext ¶
GetSiteFromContext is a helper to try to get the site from the context and, if it's not there, get it from the Cache or DB
type Token ¶
type Token struct { UserID int64 `json:"userId" db:"userId"` TokenType string `json:"tokenType" db:"tokenType"` CreatedOn string `json:"createdOn" db:"createdOn"` ExpiresOn string `json:"expiresOn" db:"expiresOn"` Token string `json:"token" db:"token"` }
Token is a token struct that holds information about various token needs, including password reset, email verification, and refresh
type User ¶
type User struct { ID int64 `json:"id" db:"id"` Title string `json:"title" db:"title"` FirstName string `json:"firstName" db:"firstName"` LastName string `json:"lastName" db:"lastName"` Pronouns string `json:"pronouns" db:"pronouns"` Email string `json:"email" db:"email"` Password string `json:"password,omitempty" db:"password"` DateOfBirth string `json:"dateOfBirth" db:"dateOfBirth"` ParticipantCode string `json:"participantCode" db:"participantCode"` Status string `json:"status" db:"status"` SystemRole string `json:"systemRole" db:"systemRole"` CreatedOn string `json:"createdOn" db:"createdOn"` LastLoginOn string `json:"lastLoginOn" db:"lastLoginOn"` Access string `json:"access,omitempty"` Refresh string `json:"refresh,omitempty"` // web clients should not store this in local storage and should instead use the cookies! Expires string `json:"expires,omitempty"` // these are used for the admin reports ProjectCount int64 `json:"projectCount,omitempty" db:"projectCount"` Projects []Project `json:"projects,omitempty" db:"projects"` ProjectStatus string `json:"projectStatus,omitempty" db:"projectStatus"` }
User is a person with a login that has permission to "do stuff". This is for researchers, site admins, and participants
func AttemptLoginForUser ¶
func GetAllUsersInProject ¶
GetAllUsersInProject gets all the users in a project along with their status
func GetAllUsersOnPlatform ¶
GetAllUsersOnPlatform gets all the users on the platform
func GetUserByEmail ¶
GetUserByEmail gets a user by an email
func GetUserByParticipantCode ¶
GetUserByParticipantCode gets a user by the participant code
Source Files
¶
- aws.go
- blocks.go
- blocks_embed.go
- blocks_external.go
- blocks_file.go
- blocks_form.go
- blocks_text.go
- config.go
- consent.go
- datetimes.go
- errors.go
- files.go
- flows.go
- general.go
- http.go
- log.go
- modules.go
- notes.go
- projects.go
- reports.go
- routes_admin_blocks.go
- routes_admin_consent.go
- routes_admin_files.go
- routes_admin_modules.go
- routes_admin_projects.go
- routes_admin_reports.go
- routes_admin_site.go
- routes_all_api_status.go
- routes_all_notes.go
- routes_all_projects.go
- routes_all_setup.go
- routes_all_site.go
- routes_all_users.go
- routes_participant_blocks.go
- routes_participant_consent.go
- routes_participant_files.go
- routes_participant_projects.go
- site.go
- tokens.go
- users.go