Job
Job
Jobs are a bit like RPC. The client can send jobs to the server which are then executed. Jobs are saved in the database and can therefore be used to extract insight. But are most likely not interesting.
type JobStatus = 'new' | 'started' | 'ongoing' | 'done' | 'draft' | 'error'
type JobType =
| 'importTrivia'
| 'recalculateQuestionCount'
| 'deleteQuestions'
| 'addUserToMandant'
| 'updateQuestionCountInMandant'
| 'updateUserCountInMandant'
| 'createMissingHistoryEntries'
| 'createCode'
| 'getCode'
| 'changeBanStatus'
| 'joinCourse'
| 'grantUserAccess'
| 'recalculateTopicChildren'
| 'setForkStatus'
| 'removePuffer'
| 'updateParticipationScore'
| 'updateMultipleParticipationScores'
| 'calcRocketPoints'
| 'exportQuestionPool'
| 'updateQuestionScores'
| 'giveFeedback'
// Do not remove semicolon above
interface Job {
id: string
type: JobType
status: JobStatus
userId: string
data?: any
result?: any
error?: string
createdAt?: any
startedAt?: any
errorAt?: any
doneAt?: any
code?: string
}
interface GrantUserAccessJob extends Job {
type: 'grantUserAccess'
data: {
type: UserAccessType
userId: string
targetId: string
reason: {
type: 'task' | 'share' | string
data: any
}
}
}
interface RemovePufferJob extends Job {
type: 'removePuffer'
data: {
topicId: string
// TODO: Implement
// mandantId: string
sessionId: string
// userId: string
// questionId: string
}
}
interface CalcRocketPointsJob extends Job {
type: 'calcRocketPoints'
data: {
userId: string
courseId?: string
questionId?: string
dontSpawnChildJobs?: boolean
}
}
interface UpdateParticipationScoreJob extends Job {
type: 'updateParticipationScore'
data: {
userId: string
questionId?: string
dontRecalculateRocketPoints?: boolean
useCache?: boolean
}
}
interface UpdateMultipleParticipationScoresJob extends Job {
type: 'updateMultipleParticipationScores'
data: {
userIds?: string[]
questionIds?: string[]
dontSpawnChildJobs?: boolean
}
}
interface JoinCourseJob extends Job {
type: 'joinCourse'
data: {
userId?: string
courseId: string
role: number
}
}
interface ExportQuestionPoolJob extends Job {
type: 'exportQuestionPool'
data: {
questionPoolId: string
format: 'qpl-qti'
}
}
interface UpdateQuestionScoresJob extends Job {
type: 'updateQuestionScores'
data: {
questionId: string
scores: string[]
}
}
interface GiveFeedbackJobData {
courseId: string
taskId?: string
feedbacks: Partial<Feedback>[]
createHistoryEntry: boolean
asCopy?: boolean
}
interface GiveFeedbackJob extends Job {
type: 'giveFeedback'
data: GiveFeedbackJobData
}