brightspace

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package brightspace reads USC Brightspace through its Valence API.

Index

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

type Attachment struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	Size *int   `json:"size"`
}

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 New

func New(httpClient Doer) *Client

New creates a client from an authenticated HTTP client.

func Open

func Open(ctx context.Context, options auth.Options) (*Client, error)

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

func (c *Client) AllAnnouncements(ctx context.Context, since string) (AnnouncementFeed, error)

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

func (c *Client) Assignments(ctx context.Context, courseID int) ([]Assignment, error)

Assignments returns Brightspace dropbox folders for courseID.

func (*Client) Content

func (c *Client) Content(ctx context.Context, courseID int) (TableOfContents, error)

Content returns the full nested content table of contents for courseID.

func (*Client) Courses

func (c *Client) Courses(ctx context.Context) ([]Course, error)

Courses returns the classes the user is enrolled in.

func (*Client) Download

func (c *Client) Download(ctx context.Context, contentURL string) (io.ReadCloser, error)

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

func (c *Client) Enrollments(ctx context.Context) ([]Course, error)

Enrollments returns every org unit the user is enrolled in: classes and also departments, semesters, and groups. Type tells them apart.

func (*Client) Grades

func (c *Client) Grades(ctx context.Context, courseID int) (Grades, error)

Grades returns grade items joined with the current user's grade values.

func (*Client) Submissions

func (c *Client) Submissions(ctx context.Context, courseID, folderID int) ([]Submission, error)

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.

func (*Client) Topic

func (c *Client) Topic(ctx context.Context, courseID, topicID int) (Topic, error)

Topic returns a content topic by ID from courseID's table of contents.

func (*Client) WhoAmI

func (c *Client) WhoAmI(ctx context.Context) (User, error)

WhoAmI returns the authenticated Brightspace user.

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

type CourseError struct {
	CourseID int    `json:"course_id"`
	Error    string `json:"error"`
}

CourseError is a course a multi-course read had to skip.

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is the HTTP surface the client needs. auth.Session satisfies it.

type Error

type Error struct {
	Label  string
	Status int
	Body   string
}

Error is a Brightspace request that failed with an HTTP status.

func (*Error) Error

func (e *Error) Error() string

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 Grades

type Grades struct {
	CourseID int     `json:"course_id"`
	Grades   []Grade `json:"grades"`
}

Grades is the normalized gradebook for a course.

func (Grades) Graded

func (g Grades) Graded() Grades

Graded returns only the items that have a score.

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

type TableOfContents struct {
	CourseID int      `json:"course_id"`
	Modules  []Module `json:"modules"`
}

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.

type User

type User struct {
	ID         string `json:"id"`
	FirstName  string `json:"first_name"`
	LastName   string `json:"last_name"`
	UniqueName string `json:"unique_name"`
}

User is the signed-in Brightspace user.

Jump to

Keyboard shortcuts

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