course

package
v0.0.0-...-96288a7 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Live
	Video
	EBook
)

Course type values

View Source
const (
	Youtube
)

Video type values

Variables

View Source
var (
	ErrNotFound = errors.New("course: not found")
)

Functions

func Create

func Create(ctx context.Context, m *CreateArgs) (string, error)

Create creates new course

func CreateContent

func CreateContent(ctx context.Context, m *CreateContentArgs) (string, error)

CreateContent creates new course content

func DeleteContent

func DeleteContent(ctx context.Context, contentID string) error

DeleteContent deletes a course's content

func GetIDByURL

func GetIDByURL(ctx context.Context, url string) (courseID string, err error)

func GetIDFromContent

func GetIDFromContent(ctx context.Context, contentID string) (courseID string, err error)

func GetURL

func GetURL(ctx context.Context, id string) (string, error)

GetURL gets course url

func GetUserID

func GetUserID(ctx context.Context, id string) (string, error)

GetUserID gets course user id

func InsertEnroll

func InsertEnroll(ctx context.Context, courseID, userID string) error

InsertEnroll inserts enroll

func IsEnroll

func IsEnroll(ctx context.Context, userID, courseID string) (bool, error)

IsEnroll checks is user enrolled a course

func SetImage

func SetImage(ctx context.Context, id string, img string) error

SetImage sets course image

func SetOption

func SetOption(ctx context.Context, id string, opt Option) error

SetOption sets course option

func Update

func Update(ctx context.Context, m *UpdateArgs) error

Update updates course

func UpdateContent

func UpdateContent(ctx context.Context, m *UpdateContentArgs) error

UpdateContent updates a course content

Types

type Assignment

type Assignment struct {
	ID    string
	Title string
	Desc  string
	Open  bool
}

Assignment model

func GetAssignments

func GetAssignments(ctx context.Context, courseID string) ([]*Assignment, error)

type Content

type Content struct {
	ID          string
	CourseID    string
	Title       string
	Desc        string
	VideoID     string
	VideoType   int
	DownloadURL string
}

Content type

func GetContent

func GetContent(ctx context.Context, contentID string) (*Content, error)

GetContent gets a course's content

func GetContents

func GetContents(ctx context.Context, id string) ([]*Content, error)

GetContents gets course's contents

type Course

type Course struct {
	ID        string
	Option    Option
	Title     string
	ShortDesc string
	Desc      string
	Image     string
	Owner     struct {
		ID    string
		Name  string
		Image string
	}
	Start        time.Time
	URL          string
	Type         int
	Price        float64
	Discount     float64
	EnrollDetail string
}

Course model

func Get

func Get(ctx context.Context, id string) (*Course, error)

Get gets course from id

func (x *Course) Link() string

Link returns id if url is invalid

type CreateArgs

type CreateArgs struct {
	UserID    string
	Title     string
	ShortDesc string
	LongDesc  string
	Image     *multipart.FileHeader
	Start     time.Time
}

type CreateContentArgs

type CreateContentArgs struct {
	ID        string
	Title     string
	LongDesc  string
	VideoID   string
	VideoType int
}

type Option

type Option struct {
	Public     bool
	Enroll     bool
	Attend     bool
	Assignment bool
	Discount   bool
}

Option type

type PublicCard

type PublicCard struct {
	ID       string
	Option   Option
	Title    string
	Desc     string
	Image    string
	Start    time.Time
	URL      string
	Type     int
	Price    float64
	Discount float64
}

func GetPublicCards

func GetPublicCards(ctx context.Context) ([]*PublicCard, error)
func (x *PublicCard) Link() string

Link returns course link

func (*PublicCard) ShowStart

func (x *PublicCard) ShowStart() bool

ShowStart returns true if course should show start date

type UpdateArgs

type UpdateArgs struct {
	ID        string
	Title     string
	ShortDesc string
	LongDesc  string
	Image     *multipart.FileHeader
	Start     time.Time
}

type UpdateContentArgs

type UpdateContentArgs struct {
	ContentID string
	Title     string
	Desc      string
	VideoID   string
}

Jump to

Keyboard shortcuts

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