Documentation
¶
Overview ¶
Package d2l is a minimal Brightspace Valence API client authenticated with browser session cookies.
Index ¶
- Constants
- Variables
- type APIError
- type Attachment
- type Client
- func (c *Client) AbsURL(u string) string
- func (c *Client) BaseURL() string
- func (c *Client) CourseWebURL(orgUnit int) string
- func (c *Client) Courses(ctx context.Context) ([]Course, error)
- func (c *Client) DropboxFolders(ctx context.Context, orgUnit int) ([]DropboxFolder, error)
- func (c *Client) DropboxWebURL(orgUnit, folderID int) string
- func (c *Client) FinalGrade(ctx context.Context, orgUnit int) (*GradeValue, error)
- func (c *Client) Grades(ctx context.Context, orgUnit int) ([]GradeValue, error)
- func (c *Client) ModuleWebURL(orgUnit, moduleID int) string
- func (c *Client) MySubmissions(ctx context.Context, orgUnit, folderID int) ([]MySubmission, error)
- func (c *Client) News(ctx context.Context, orgUnit int) ([]NewsItem, error)
- func (c *Client) NewsAttachment(ctx context.Context, orgUnit, newsID, fileID int) (*http.Response, error)
- func (c *Client) OffSite(resp *http.Response) bool
- func (c *Client) TOC(ctx context.Context, orgUnit int) (*TOC, error)
- func (c *Client) TopicFile(ctx context.Context, orgUnit, topicID int) (*http.Response, error)
- func (c *Client) TopicWebURL(orgUnit, topicID int) string
- func (c *Client) WhoAmI(ctx context.Context) (*WhoAmI, error)
- type Course
- type DropboxFolder
- type FlatTopic
- type GradeValue
- type Module
- type MySubmission
- type NewsItem
- type Node
- type RichText
- type TOC
- type Topic
- type WhoAmI
Constants ¶
const ( ActivityFile = 1 ActivityLink = 2 ActivityDropbox = 3 ActivityQuiz = 4 ActivityLTI = 7 )
Activity types from the Valence content API.
Variables ¶
var ErrStalled = errors.New("connection stalled")
ErrStalled means a response stopped sending data.
ErrUnauthorized means the session is missing or expired.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
New builds a client that sends cookies for baseURL and refuses to follow redirects to the login page.
func (*Client) CourseWebURL ¶
CourseWebURL is the course home page.
func (*Client) DropboxFolders ¶
func (*Client) DropboxWebURL ¶
DropboxWebURL is the submission page for an assignment folder.
func (*Client) FinalGrade ¶
FinalGrade returns the user's final course grade, or nil when the course has none or it is not released yet.
func (*Client) ModuleWebURL ¶
ModuleWebURL is the content page for a module.
func (*Client) MySubmissions ¶
func (*Client) NewsAttachment ¶
func (c *Client) NewsAttachment(ctx context.Context, orgUnit, newsID, fileID int) (*http.Response, error)
NewsAttachment opens an announcement attachment. The caller closes the body.
func (*Client) OffSite ¶
OffSite reports whether resp came from a host other than Learn, which for an HTML page means a redirect to the sign-in page.
func (*Client) TopicFile ¶
TopicFile opens the file behind a File topic. The caller closes the body.
func (*Client) TopicWebURL ¶
TopicWebURL is the Learn page for a topic, for opening in a browser.
type Course ¶
type Course struct {
OrgUnit struct {
ID int `json:"Id"`
Name string `json:"Name"`
Code string `json:"Code"`
Type struct {
ID int `json:"Id"`
Code string `json:"Code"`
} `json:"Type"`
HomeURL string `json:"HomeUrl"`
} `json:"OrgUnit"`
Access struct {
IsActive bool `json:"IsActive"`
CanAccess bool `json:"CanAccess"`
StartDate *time.Time `json:"StartDate"`
EndDate *time.Time `json:"EndDate"`
LastAccessed *time.Time `json:"LastAccessed"`
} `json:"Access"`
PinDate *time.Time `json:"PinDate"`
}
Course is one enrollment returned by myenrollments.
type DropboxFolder ¶
type DropboxFolder struct {
ID int `json:"Id"`
Name string `json:"Name"`
DueDate *time.Time `json:"DueDate"`
IsHidden bool `json:"IsHidden"`
CustomInstructions RichText `json:"CustomInstructions"`
Availability *struct {
StartDate *time.Time `json:"StartDate"`
EndDate *time.Time `json:"EndDate"`
} `json:"Availability"`
Assessment *struct {
ScoreDenominator *float64 `json:"ScoreDenominator"`
} `json:"Assessment"`
}
type GradeValue ¶
type GradeValue struct {
GradeObjectIdentifier string `json:"GradeObjectIdentifier"`
GradeObjectName string `json:"GradeObjectName"`
GradeObjectTypeName string `json:"GradeObjectTypeName"`
DisplayedGrade string `json:"DisplayedGrade"`
PointsNumerator *float64 `json:"PointsNumerator"`
PointsDenominator *float64 `json:"PointsDenominator"`
WeightedNumerator *float64 `json:"WeightedNumerator"`
WeightedDenominator *float64 `json:"WeightedDenominator"`
Comments RichText `json:"Comments"`
}
type Module ¶
type Module struct {
ModuleID int `json:"ModuleId"`
Title string `json:"Title"`
SortOrder int `json:"SortOrder"`
IsHidden bool `json:"IsHidden"`
IsLocked bool `json:"IsLocked"`
LastModifiedDate *time.Time `json:"LastModifiedDate"`
Modules []Module `json:"Modules"`
Topics []Topic `json:"Topics"`
}
type MySubmission ¶
type MySubmission struct {
Submissions []struct {
ID int `json:"Id"`
SubmissionDate *time.Time `json:"SubmissionDate"`
} `json:"Submissions"`
Feedback *struct {
Score *float64 `json:"Score"`
} `json:"Feedback"`
}
Submission status for one dropbox folder, from mysubmissions. Status is left out: the docs disagree on whether it is a number or a string, and Submissions and Feedback say all the app needs.
type Topic ¶
type Topic struct {
TopicID int `json:"TopicId"`
Title string `json:"Title"`
TypeIdentifier string `json:"TypeIdentifier"` // "File" or "Link"
URL string `json:"Url"`
SortOrder int `json:"SortOrder"`
ActivityType int `json:"ActivityType"`
IsBroken bool `json:"IsBroken"`
IsHidden bool `json:"IsHidden"`
IsLocked bool `json:"IsLocked"`
Unread bool `json:"Unread"`
LastModifiedDate *time.Time `json:"LastModifiedDate"`
StartDateTime *time.Time `json:"StartDateTime"`
EndDateTime *time.Time `json:"EndDateTime"`
}