Documentation
¶
Overview ¶
Package webreg is a client for USC Web Registration (webreg.usc.edu).
WebReg is a server-rendered application: catalog, course bin, and checkout data are parsed from its pages, while course-bin changes use its small section API. The server keeps an active term per session, so every term-scoped method selects its term before reading or changing state.
Index ¶
- type BinState
- type CalendarEvent
- type Checkout
- type CheckoutGroup
- type CheckoutResult
- type Client
- func (c *Client) Add(ctx context.Context, term string, sectionID int) error
- func (c *Client) Calendar(ctx context.Context, term string) ([]CalendarEvent, error)
- func (c *Client) Checkout(ctx context.Context, term string) (*Checkout, error)
- func (c *Client) CourseBin(ctx context.Context, term string) (*CourseBin, error)
- func (c *Client) Courses(ctx context.Context, term string, query CourseQuery) ([]Course, error)
- func (c *Client) Programs(ctx context.Context, term string) ([]School, error)
- func (c *Client) Remove(ctx context.Context, term string, sectionID int) error
- func (c *Client) Schedule(ctx context.Context, term string, sectionID int) error
- func (c *Client) SelectTerm(ctx context.Context, term string) error
- func (c *Client) SetGradeOption(ctx context.Context, term string, sectionID int, code string) (string, error)
- func (c *Client) Submit(ctx context.Context, term string) (*CheckoutResult, error)
- func (c *Client) Terms(ctx context.Context) ([]Term, error)
- func (c *Client) Unschedule(ctx context.Context, term string, sectionID int) error
- type Course
- type CourseBin
- type CourseQuery
- type Doer
- type Error
- type GradeChoice
- type GradeOption
- type Program
- type School
- type Seats
- type Section
- type Term
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinState ¶
BinState is a course-bin section's schedule and registration state. Checkout registers scheduled, unregistered sections and drops registered, unscheduled ones.
type CalendarEvent ¶
type CalendarEvent struct {
ID string `json:"id"`
Title string `json:"title"`
SectionID string `json:"section_id,omitempty"`
Status string `json:"status"`
Start time.Time `json:"start"`
End time.Time `json:"end"`
}
CalendarEvent is one meeting or blocked time on myCalendar. Status is Scheduled, Registered, Blocked, or Conflicted.
type Checkout ¶
type Checkout struct {
Term string `json:"term"`
Ready bool `json:"ready"`
Message string `json:"message,omitempty"`
Groups []CheckoutGroup `json:"groups"`
}
Checkout is the pending registration WebReg will submit for a term: scheduled, unregistered sections to add and unscheduled, registered sections to drop, grouped as WebReg presents them.
type CheckoutGroup ¶
type CheckoutGroup struct {
Action string `json:"action"`
Heading string `json:"heading"`
Courses []Course `json:"courses"`
}
CheckoutGroup is one checkout heading, e.g. Action "REGISTER", and its courses.
type CheckoutResult ¶
type CheckoutResult struct {
Term string `json:"term"`
Succeeded bool `json:"succeeded"`
Status string `json:"status"`
Messages []string `json:"messages,omitempty"`
}
CheckoutResult is WebReg's registration response. WebReg does not process partial registrations: on failure nothing was changed.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads and changes WebReg state with an authenticated session. A client is sequential: WebReg's active term is shared session state.
func Open ¶
Open signs in through USC SSO and returns an authenticated client. See auth.Options for supplying credentials and keeping the session between runs. It never prompts; authentication failures are *auth.SiteError values.
func (*Client) Add ¶
Add places a section in the course bin. It does not register; schedule the section and submit checkout to register.
func (*Client) Calendar ¶
Calendar returns a term's weekly calendar of scheduled, registered, and conflicting meetings. Dates are a representative week, not term dates.
func (*Client) Courses ¶
Courses lists a term's courses for a program or a single course code, following WebReg's pagination. Each section reports whether it is already in the course bin.
func (*Client) Schedule ¶
Schedule marks a course-bin section to be registered at checkout, or keeps a registered section from being dropped.
func (*Client) SelectTerm ¶
SelectTerm makes term WebReg's active term for this session.
func (*Client) SetGradeOption ¶
func (c *Client) SetGradeOption(ctx context.Context, term string, sectionID int, code string) (string, error)
SetGradeOption changes a course-bin section's grade option to code, one of the section's GradeOption.Choices (for example L, PN, or V). Unregistered sections change immediately; registered sections submit a change request that takes effect when checkout is submitted. It returns WebReg's response, such as "Updated-PN".
func (*Client) Submit ¶
Submit registers and drops the sections Checkout lists. This is the same irreversible action as WebReg's Submit button. Callers should show the preview from Checkout and obtain the student's confirmation first.
type Course ¶
type Course struct {
Code string `json:"code"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Prerequisites []string `json:"prerequisites,omitempty"`
Sections []Section `json:"sections"`
}
Course is a WebReg course and the sections shown for it on one page.
type CourseBin ¶
type CourseBin struct {
Term string `json:"term"`
RegisteredSections int `json:"registered_sections"`
ScheduledSections int `json:"scheduled_sections"`
AsOf string `json:"as_of,omitempty"`
Courses []Course `json:"courses"`
}
CourseBin is a term's myCourseBin: courses the student is planning or registered in, each section with its schedule/registration state.
type CourseQuery ¶
type CourseQuery struct {
Program string // subject code, e.g. BUAD
Course string // course code, e.g. BUAD-302
}
CourseQuery selects WebReg catalog courses. Set exactly one field.
type Error ¶
Error describes a WebReg request the server rejected. Message is a short server explanation when one was safe to include.
type GradeChoice ¶
GradeChoice is a grade-option code such as L (letter) and its label.
type GradeOption ¶
type GradeOption struct {
Current string `json:"current,omitempty"`
Choices []GradeChoice `json:"choices,omitempty"`
ChangeRequest bool `json:"change_request"`
// contains filtered or unexported fields
}
GradeOption is a course-bin section's grading basis and the choices WebReg offers. ChangeRequest is true for registered sections, whose change is submitted as a request instead of applied directly.
type Seats ¶
type Seats struct {
Registered int `json:"registered"`
Capacity int `json:"capacity"`
Closed bool `json:"closed"`
Text string `json:"text"`
}
Seats is the section's registration count as WebReg displays it.
type Section ¶
type Section struct {
ID int `json:"id"`
// Clearance is WebReg's letter beside the section ID: "R" sections are
// open to registration and "D" sections need department clearance.
Clearance string `json:"clearance,omitempty"`
Session string `json:"session,omitempty"`
Type string `json:"type,omitempty"`
Units string `json:"units,omitempty"`
Seats Seats `json:"seats"`
Times []string `json:"times,omitempty"`
Days []string `json:"days,omitempty"`
Instructors []string `json:"instructors,omitempty"`
Locations []string `json:"locations,omitempty"`
Notes []string `json:"notes,omitempty"`
InCourseBin *bool `json:"in_course_bin,omitempty"`
CourseBin *BinState `json:"course_bin,omitempty"`
GradeOption *GradeOption `json:"grade_option,omitempty"`
}
Section is one WebReg section row. Fields that only one page shows are omitted elsewhere: InCourseBin comes from catalog pages, CourseBin and GradeOption from the course bin.