Documentation
¶
Overview ¶
Package brightspace reads USC Brightspace through its Valence API.
Index ¶
- type Announcement
- type AnnouncementFeed
- type Assignment
- type Attachment
- type Client
- func (c *Client) AllAnnouncements(ctx context.Context, since string) (AnnouncementFeed, error)
- func (c *Client) Announcements(ctx context.Context, courseID int, since string) ([]Announcement, error)
- func (c *Client) Assignments(ctx context.Context, courseID int) ([]Assignment, error)
- func (c *Client) Content(ctx context.Context, courseID int) (TableOfContents, error)
- func (c *Client) Courses(ctx context.Context) ([]Course, error)
- func (c *Client) Download(ctx context.Context, contentURL string) (io.ReadCloser, error)
- func (c *Client) DownloadSubmissionFile(ctx context.Context, courseID, folderID, submissionID, fileID int) (io.ReadCloser, error)
- func (c *Client) Enrollments(ctx context.Context) ([]Course, error)
- func (c *Client) Grades(ctx context.Context, courseID int) (Grades, error)
- func (c *Client) Submissions(ctx context.Context, courseID, folderID int) ([]Submission, error)
- func (c *Client) Topic(ctx context.Context, courseID, topicID int) (Topic, error)
- func (c *Client) WhoAmI(ctx context.Context) (User, error)
- type Course
- type CourseError
- type Doer
- type Error
- type Grade
- type Grades
- type Module
- type Submission
- type SubmissionFile
- type TableOfContents
- type Topic
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Announcement ¶
type Announcement struct {
CourseID int `json:"course_id"`
CourseCode *string `json:"course_code"`
ID int `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
StartDate *string `json:"start_date"`
EndDate *string `json:"end_date"`
CreatedDate *string `json:"created_date"`
LastModifiedDate *string `json:"last_modified_date"`
IsPinned bool `json:"is_pinned"`
IsHidden bool `json:"is_hidden"`
Attachments []Attachment `json:"attachments"`
}
Announcement is a normalized Brightspace news item.
type AnnouncementFeed ¶
type AnnouncementFeed struct {
Announcements []Announcement `json:"announcements"`
Errors []CourseError `json:"errors,omitempty"`
}
AnnouncementFeed is the announcements of every enrolled course. Courses whose news could not be read, such as closed past courses, are listed in Errors instead of failing the whole feed.
type Assignment ¶
type Assignment struct {
ID int `json:"id"`
Name string `json:"name"`
DueDate *string `json:"due_date"`
AvailableFrom *string `json:"available_from"`
AvailableUntil *string `json:"available_until"`
Points *float64 `json:"points"`
}
Assignment is a Brightspace dropbox folder.
type Attachment ¶
Attachment is an announcement attachment's metadata.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls Brightspace with an authenticated session.
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) AllAnnouncements ¶
AllAnnouncements returns the announcements of every course offering the user is enrolled in, each labeled with its course code.
func (*Client) Announcements ¶
func (c *Client) Announcements(ctx context.Context, courseID int, since string) ([]Announcement, error)
Announcements returns news items for courseID, optionally since an ISO-8601 time.
func (*Client) Assignments ¶
Assignments returns Brightspace dropbox folders for courseID.
func (*Client) Download ¶
Download returns the authenticated body of a Brightspace content URL. Only same-origin URLs are accepted so USC cookies never reach another host.
func (*Client) DownloadSubmissionFile ¶
func (c *Client) DownloadSubmissionFile(ctx context.Context, courseID, folderID, submissionID, fileID int) (io.ReadCloser, error)
DownloadSubmissionFile returns the body of a file from one of the current user's dropbox submissions.
func (*Client) Enrollments ¶
Enrollments returns every org unit the user is enrolled in: classes and also departments, semesters, and groups. Type tells them apart.
func (*Client) Submissions ¶
Submissions returns the current user's submissions to a dropbox folder, oldest first. For students Brightspace scopes this list to their own entity; the mysubmissions route is not authorized for browser sessions.
type Course ¶
type Course struct {
ID int `json:"id"`
Code *string `json:"code"`
Title string `json:"title"`
Section *string `json:"section"`
Type string `json:"type"`
Role string `json:"role"`
RawName string `json:"raw_name"`
}
Course is a normalized Brightspace enrollment.
type CourseError ¶
CourseError is a course a multi-course read had to skip.
type Grade ¶
type Grade struct {
ID string `json:"id"`
Name string `json:"name"`
GradeType string `json:"grade_type"`
MaxPoints *float64 `json:"max_points"`
Weight *float64 `json:"weight"`
IsBonus bool `json:"is_bonus"`
ExcludeFromFinal bool `json:"exclude_from_final"`
Score *float64 `json:"score"`
ScoreMax *float64 `json:"score_max"`
DisplayedGrade *string `json:"displayed_grade"`
Feedback *string `json:"feedback"`
LastModified *string `json:"last_modified"`
}
Grade joins a grade item with the current user's value for that item.
type Module ¶
type Module struct {
ID int `json:"id"`
Title string `json:"title"`
Description *string `json:"description"`
LastModified *string `json:"last_modified"`
Topics []Topic `json:"topics"`
Modules []Module `json:"modules"`
}
Module is a Brightspace content module and its nested child modules.
type Submission ¶
type Submission struct {
ID int `json:"id"`
SubmittedBy string `json:"submitted_by"`
Date *string `json:"date"`
Comment string `json:"comment"`
Files []SubmissionFile `json:"files"`
}
Submission is one of the current user's submissions to a dropbox folder.
type SubmissionFile ¶
type SubmissionFile struct {
ID int `json:"id"`
Name string `json:"name"`
Size int64 `json:"size"`
}
SubmissionFile is a file attached to a dropbox submission.
type TableOfContents ¶
TableOfContents is the normalized course-content tree.
func (TableOfContents) Flatten ¶
func (t TableOfContents) Flatten() []Topic
Flatten lists every topic in order, each labeled with its module path such as "Week 1 > Readings".
type Topic ¶
type Topic struct {
ID int `json:"id"`
Title string `json:"title"`
Type int `json:"type"`
URL string `json:"url"`
DueDate *string `json:"due_date"`
LastModified *string `json:"last_modified"`
// Module is the topic's module path, set only by Flatten.
Module string `json:"module,omitempty"`
}
Topic is a Brightspace content topic.