school

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentOTP

func CurrentOTP(raw string, now time.Time) (string, error)

func IsNoLessonData

func IsNoLessonData(err error) bool

func SetDebugLogger

func SetDebugLogger(fn func(format string, args ...any))

func SortCurriculum

func SortCurriculum(items []CurriculumItem)

func SortExams

func SortExams(items []ExamItem)

func SortHomework

func SortHomework(items []HomeworkItem)

func SortScores

func SortScores(items []ScoreItem)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(creds Credentials, programs ...Program) *Client

func (*Client) FetchCurriculum

func (c *Client) FetchCurriculum(ctx context.Context, semesterID int) (Semester, []CurriculumItem, error)

func (*Client) FetchExams

func (c *Client) FetchExams(ctx context.Context, semesterIDs ...int) ([]ExamItem, error)

func (*Client) FetchHomework

func (c *Client) FetchHomework(ctx context.Context) ([]HomeworkItem, error)

func (*Client) FetchScores

func (c *Client) FetchScores(ctx context.Context) (ScoreReport, error)

func (*Client) FetchSemesters

func (c *Client) FetchSemesters(ctx context.Context) ([]Semester, error)

type Credentials

type Credentials struct {
	Username string
	Password string
	TOTP     string
}

func ResolveCredentials

func ResolveCredentials(username, password, totp string) (Credentials, error)

func ResolveCredentialsForProgram

func ResolveCredentialsForProgram(program Program, username, password, totp string) (Credentials, error)

type CurriculumItem

type CurriculumItem struct {
	SemesterID int      `json:"semesterId"`
	LessonID   int      `json:"lessonId,omitempty"`
	LessonCode string   `json:"lessonCode,omitempty"`
	CourseCode string   `json:"courseCode,omitempty"`
	CourseName string   `json:"courseName,omitempty"`
	Credits    float64  `json:"credits,omitempty"`
	Teachers   []string `json:"teachers,omitempty"`
	Schedule   string   `json:"schedule,omitempty"`
}

func (CurriculumItem) TeacherList

func (i CurriculumItem) TeacherList() string

type ExamItem

type ExamItem struct {
	CourseName string `json:"courseName,omitempty"`
	LessonCode string `json:"lessonCode,omitempty"`
	ExamType   string `json:"examType,omitempty"`
	DateTime   string `json:"dateTime,omitempty"`
	Location   string `json:"location,omitempty"`
	Seat       string `json:"seat,omitempty"`
	Status     string `json:"status,omitempty"`
}

type HomeworkItem

type HomeworkItem struct {
	ID             string `json:"id,omitempty"`
	Title          string `json:"title,omitempty"`
	CourseName     string `json:"courseName,omitempty"`
	LessonCode     string `json:"lessonCode,omitempty"`
	SemesterCode   string `json:"semesterCode,omitempty"`
	ExternalItemID string `json:"externalItemId,omitempty"`
	StartAt        string `json:"startAt,omitempty"`
	EndAt          string `json:"endAt,omitempty"`
	Status         string `json:"status,omitempty"`
}

type Program

type Program string
const (
	ProgramUndergraduate Program = "undergraduate"
	ProgramGraduate      Program = "graduate"
)

func DetectCredentialPrograms

func DetectCredentialPrograms() []Program

func (Program) IsGraduate

func (p Program) IsGraduate() bool

type ScoreItem

type ScoreItem struct {
	SemesterID   int     `json:"semesterId"`
	SemesterName string  `json:"semesterName,omitempty"`
	CourseName   string  `json:"courseName,omitempty"`
	LessonCode   string  `json:"lessonCode,omitempty"`
	CourseCode   string  `json:"courseCode,omitempty"`
	Credits      float64 `json:"credits,omitempty"`
	GradePoint   float64 `json:"gradePoint,omitempty"`
	Score        string  `json:"score,omitempty"`
	GradeText    string  `json:"gradeText,omitempty"`
}

type ScoreReport

type ScoreReport struct {
	Summary json.RawMessage `json:"summary,omitempty"`
	Items   []ScoreItem     `json:"items"`
}

type Semester

type Semester struct {
	ID         int    `json:"id"`
	Code       string `json:"code,omitempty"`
	SemesterCn string `json:"semesterCn,omitempty"`
	SemesterEn string `json:"semesterEn,omitempty"`
	StartDate  string `json:"startDate,omitempty"`
	EndDate    string `json:"endDate,omitempty"`
	IsLast     bool   `json:"isLast,omitempty"`
}

func PickSemester

func PickSemester(semesters []Semester, semesterID int) (Semester, error)

func (Semester) Name

func (s Semester) Name() string

Jump to

Keyboard shortcuts

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