items

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package items provides API services for items managing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AskHintRequest

type AskHintRequest struct {
	TaskToken *token.Task
	HintToken *token.Hint
	// contains filtered or unexported fields
}

AskHintRequest represents a JSON request body format needed by items.askHint()

func (*AskHintRequest) Bind

func (requestData *AskHintRequest) Bind(r *http.Request) error

Bind of AskHintRequest checks that the asked hint is present

func (*AskHintRequest) UnmarshalJSON

func (requestData *AskHintRequest) UnmarshalJSON(raw []byte) error

UnmarshalJSON unmarshals the items/askHint request data from JSON

type Item

type Item struct {
	// Nullable
	URL *string `json:"url"`
	// Nullable
	Options *string `json:"options" validate:"null|options"`
	// default: false
	EntryFrozenTeams bool `json:"entry_frozen_teams"`
	// default: false
	NoScore bool `json:"no_score"`
	// Identifier to reference the task.
	// Unique
	// Nullable
	TextID                 *string `json:"text_id"`
	DisplayDetailsInParent bool    `json:"display_details_in_parent"`
	ReadOnly               bool    `json:"read_only"`
	// enum: List,Grid
	ChildrenLayout string `json:"children_layout"`
	// enum: forceYes,forceNo,default
	FullScreen   string `json:"full_screen" validate:"oneof=forceYes forceNo default"`
	HintsAllowed bool   `json:"hints_allowed"`
	FixedRanks   bool   `json:"fixed_ranks"`

	// enum: None,All,AllButOne,Categories,One,Manual
	// default: All
	ValidationType string `json:"validation_type" validate:"oneof=None All AllButOne Categories One Manual"`

	// enum: All,Half,One,None
	// default: None
	EntryMinAdmittedMembersRatio string    `json:"entry_min_admitted_members_ratio" validate:"oneof=All Half One None"`
	EnteringTimeMin              time.Time `json:"entering_time_min"`
	EnteringTimeMax              time.Time `json:"entering_time_max"`
	EntryMaxTeamSize             int32     `json:"entry_max_team_size"`
	TitleBarVisible              bool      `json:"title_bar_visible"`
	AllowsMultipleAttempts       bool      `json:"allows_multiple_attempts"`
	// enum: User,Team
	EntryParticipantType string `json:"entry_participant_type" validate:"oneof=User Team"`
	// Nullable
	//
	// MySQL time (max value is 838:59:59), cannot be set for skills
	// pattern: ^\d{1,3}:[0-5]?\d:[0-5]?\d$
	// example: 838:59:59
	Duration *string `json:"duration" validate:"omitempty,duration,cannot_be_set_for_skills,duration_requires_explicit_entry"`
	// should be true when the duration is not null, cannot be set for skill items
	RequiresExplicitEntry   bool `json:"requires_explicit_entry" validate:"cannot_be_set_for_skills,duration_requires_explicit_entry"`
	ShowUserInfos           bool `json:"show_user_infos"`
	UsesAPI                 bool `json:"uses_api"`
	PromptToJoinGroupByCode bool `json:"prompt_to_join_group_by_code"`
}

Item represents input fields that are common to itemCreate & itemUpdate

type ItemWithDefaultLanguageTag

type ItemWithDefaultLanguageTag struct {
	Item `json:"item,squash"` // nolint:staticcheck SA5008: unknown JSON option "squash"
	// new `default_language_tag` of the item can only be set to a language
	// for that an `items_strings` row exists
	// minLength: 1
	// maxLength: 6
	DefaultLanguageTag string `json:"default_language_tag" validate:"min=1,max=6"`
}

ItemWithDefaultLanguageTag represents common item fields plus 'default_language_tag'

type ItemWithRequiredType

type ItemWithRequiredType struct {
	Item `json:"item,squash"` // nolint:staticcheck SA5008: unknown JSON option "squash"
	// Can be equal to 'Skill' only if the parent's type is 'Skill'
	// required: true
	// enum: Chapter,Task,Skill
	Type string `json:"type" validate:"set,oneof=Chapter Task Skill,type_skill"`
}

ItemWithRequiredType represents common item fields plus the required type field

type NewItemRequest

type NewItemRequest struct {
	// `default_language_tag` of the item
	// required: true
	LanguageTag string `json:"language_tag" validate:"set,language_tag"`

	Parent          itemParent `json:"parent"`
	AsRootOfGroupID int64      `json:"as_root_of_group_id,string" validate:"as_root_of_group_id"`

	// Nullable fields are of pointer types
	ItemWithRequiredType `json:"item,squash"` // nolint:staticcheck SA5008: unknown JSON option "squash"

	Children []itemChild `json:"children" validate:"children,children_allowed,dive,child_type_non_skill"`
	// contains filtered or unexported fields
}

NewItemRequest is the expected input for new created item swagger:model itemCreateRequest

type Permission

type Permission struct {
	ItemID                     int64
	CanViewGeneratedValue      int
	CanGrantViewGeneratedValue int
	CanWatchGeneratedValue     int
	CanEditGeneratedValue      int
}

Permission represents item permissions + ItemID

type RawCommonItemFields

type RawCommonItemFields struct {
	// items
	ID                     int64
	Type                   string
	DisplayDetailsInParent bool
	ValidationType         string
	EntryParticipantType   string
	EnteringTimeMin        database.Time
	EnteringTimeMax        database.Time
	AllowsMultipleAttempts bool
	Duration               *string
	NoScore                bool
	DefaultLanguageTag     string
	RequiresExplicitEntry  bool

	*database.RawGeneratedPermissionFields
}

RawCommonItemFields represents DB data fields that are common for itemView & itemChildrenView

type RawItemResultFields

type RawItemResultFields struct {
	// results
	AttemptID        *int64
	ScoreComputed    float32
	Validated        bool
	StartedAt        *database.Time
	LatestActivityAt database.Time
	EndedAt          *database.Time

	// attempts
	AttemptAllowsSubmissionsUntil database.Time
}

RawItemResultFields represents DB data fields for item results used by itemNavigationView & itemChildrenView

type RawListItem

type RawListItem struct {
	*RawCommonItemFields

	// from items_strings: in the user’s default language or (if not available) default language of the item
	StringLanguageTag string  `sql:"column:language_tag"`
	StringTitle       *string `sql:"column:title"`
	StringImageURL    *string `sql:"column:image_url"`
	StringSubtitle    *string `sql:"column:subtitle"`

	// items_items
	Category string
	Order    int32 `sql:"column:child_order"`

	// max from results of the current participant
	BestScore float32

	*RawItemResultFields
	*RawWatchedGroupStatFields
}

RawListItem contains raw fields common for itemChildrenView & itemParentsView

type RawWatchedGroupStatFields

type RawWatchedGroupStatFields struct {
	CanWatchForGroupResults  bool
	WatchedGroupCanView      int
	WatchedGroupAvgScore     float32
	WatchedGroupAllValidated bool
}

RawWatchedGroupStatFields represents DB data fields for watched group stats used by itemNavigationView & itemChildrenView

type Service

type Service struct {
	*service.Base
}

Service is the mount point for services related to `items`

func (*Service) SetRoutes

func (srv *Service) SetRoutes(router chi.Router)

SetRoutes defines the routes for this package in a route group

Jump to

Keyboard shortcuts

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