course

package
v0.0.0-...-1bc63cf Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: GPL-3.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSessionsText

func GetSessionsText(db *sql.DB, sessionID int) (string, error)

GetSessionsText gets the session text for the session id. Should only ever be one possible value unless there's a bug or someone does a manual insert.

func GetSessionsYoutube

func GetSessionsYoutube(db *sql.DB, sessionID int) (string, string, error)

GetSessionsYoutube gets the data for a YouTube session by the session id.

func ModulePage

func ModulePage(w http.ResponseWriter, r *http.Request)

ModulePage endpoint returns the module page.

func Page

func Page(w http.ResponseWriter, r *http.Request)

Page returns the HTML page with all of the modules for a course.

func SessionAnswer

func SessionAnswer(w http.ResponseWriter, r *http.Request)

SessionAnswer ...

func SessionPage

func SessionPage(w http.ResponseWriter, r *http.Request)

SessionPage endpoint returns the actual session data. Could be any type of session.

Types

type Course

type Course struct {
	Name        string
	Description string
	Slug        string
	Category    string
}

Course contains the data for a single course

func GetCourse

func GetCourse(db *sql.DB, slug string) (Course, error)

GetCourse gets the current course from the database.

func GetCourses

func GetCourses(db *sql.DB) ([]Course, error)

GetCourses gets all of the courses from the database.

type Module

type Module struct {
	Name        string
	Description string
	ImageLink   string
	Slug        string
}

Module struct stores module data for rendering.

func GetModule

func GetModule(db *sql.DB, slug string) (Module, error)

GetModule gets the current module from the database.

func GetModules

func GetModules(db *sql.DB, slug string) ([]Module, error)

GetModules gets all of the modules from the database.

func GetModulesByCourseSlug

func GetModulesByCourseSlug(db *sql.DB, slug string) ([]Module, error)

GetModulesByCourseSlug gets all of the modules associated with a course by the slug of the course.

type ModulePageData

type ModulePageData struct {
	Title      string
	ModuleSlug string
	Course     Course
	// Modules in sidebar
	Module   Module
	Modules  []Module
	Sessions []Session
	Paths    []helpers.Path
}

ModulePageData stores all data for rendering the module HTML page.

type MultipleChoiceData

type MultipleChoiceData struct {
	Title     string
	Paths     []helpers.Path
	Course    Course
	Module    Module
	Session   Session
	Sessions  []Session
	Questions []Question
}

MultipleChoiceData is used for rendering a Multiple-choice session. Should not be used by other structs.

type Option

type Option struct {
	Text      string `json:"text"`
	IsCorrect bool   `json:"is_correct"`
	Checked   bool
}

Option struct contains question data for rendering.

type PageData

type PageData struct {
	Title      string
	CourseSlug string
	Courses    []Course
	Course     Course
	Modules    []Module
	Paths      []helpers.Path
}

PageData contains the data to render the HTML course page.

type Question

type Question struct {
	ID      int
	Text    string
	Options []Option
}

Question struct contains question data for rendering.

func GetSessionsMultipleChoice

func GetSessionsMultipleChoice(db *sql.DB, sessionID int) ([]Question, error)

GetSessionsMultipleChoice gets the data for a Multiple-choice session by the session id.

type Session

type Session struct {
	ID          int
	Name        string
	Slug        string
	SessionType int
}

Session struct contains session data both for rendering and for logic such as deciding the session type.

func GetSession

func GetSession(db *sql.DB, sessionSlug string) (Session, int, error)

GetSession gets the session data by the session slug.

func GetSessionsByModuleID

func GetSessionsByModuleID(db *sql.DB, moduleID int) ([]Session, error)

GetSessionsByModuleID gets all of the sessions associated with one module.

func GetSessionsByModuleSlug

func GetSessionsByModuleSlug(db *sql.DB, moduleSlug, courseSlug string) ([]Session, error)

GetSessionsByModuleSlug gets all of the sessions related to a module by the module slug from the database.

type TextData

type TextData struct {
	Title    string
	Paths    []helpers.Path
	Course   Course
	Module   Module
	Session  Session
	Sessions []Session
	Text     string
}

TextData is used for rendering a text session. Should not be used by other structs.

type YoutubeData

type YoutubeData struct {
	Title    string
	Paths    []helpers.Path
	Course   Course
	Module   Module
	Session  Session
	Sessions []Session
	Text     string
	Youtube  string
}

YoutubeData is used for rendering a YouTube session. Should not be used by other structs.

Jump to

Keyboard shortcuts

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