SecNex

Quizzes

Quiz model in ClueQuest Go SDK

Schema

FieldTypeDescriptionExtra Info
IDuuid.UUIDUnique identifier for the quiz.Primary Key
NamestringName of the quiz.unique, not null
DisplayNamestringDisplay name of the quiz.not null
CreatedByuuid.UUIDIdentifier of the user who created the quiz.Relation to User model
UpdatedByuuid.UUIDIdentifier of the user who last updated the quiz.Relation to User model
CreatedAttime.TimeTimestamp of when the quiz was created.Set automatically to current time at creation
UpdatedAttime.TimeTimestamp of the last update to the quiz.Set automatically to current time at update
DeletedAtgorm.DeletedAtTimestamp of when the quiz was deleted (if applicable).It is needed for soft deletion.

Model

quiz.go
type Quiz struct {
	ID        uuid.UUID      `gorm:"type:uuid;primaryKey;default:uuid_generate_v4()" json:"id"`
	Name      string         `gorm:"not null" json:"name"`
	Config    interface{}    `gorm:"type:jsonb" json:"config"`
	CreatedBy uuid.UUID      `gorm:"type:uuid;not null" json:"created_by"`
	UpdatedBy uuid.UUID      `gorm:"type:uuid" json:"updated_by"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`

	Creator User `gorm:"foreignKey:CreatedBy;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"creator,omitempty"`
	Updater User `gorm:"foreignKey:UpdatedBy;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" json:"updater,omitempty"`
}

Relationships

  • Creator: Many-to-one relationship with the User model. A quiz is created by a single user.
  • Updater: Many-to-one relationship with the User model. A quiz is last updated by a single user.