connector

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package connector provides LTI Advantage services built upon a successful Launch. The package provides for a "base" Connector that can be upgraded to provide either or both Assignment & Grades Services and Names & Roles Provisioning Services.

Index

Constants

View Source
const (
	ActivityInitialized = "Initialized"
	ActivityStarted     = "Started"
	ActivityInProgress  = "InProgress"
	ActivitySubmitted   = "Submitted"
	ActivityCompleted   = "Completed"
)

AGS activityProgress constants.

View Source
const (
	GradingFullyGraded   = "FullyGraded"
	GradingPending       = "Pending"
	GradingPendingManual = "PendingManual"
	GradingFailed        = "Failed"
	GradeNotReady        = "NotReady"
)

AGS gradingProgress constants.

View Source
const (
	// AccessTokenTimeoutSeconds determines the JWT Expiration validity period in seconds.
	AccessTokenTimeoutSeconds = 3600
	// ClockSkewAllowanceMinutes determines the JWT IssuedAt clock skew allowance in minutes.
	ClockSkewAllowanceMinutes = 2
)

Variables

View Source
var (
	// ErrUnsupportedService is returned when the connector cannot be upgraded to either NRPS
	// or AGS because the platform does not appear to support the service.
	ErrUnsupportedService = errors.New("platform/LMS does not support the requested service")
)

Functions

This section is empty.

Types

type AGS

type AGS struct {
	LineItem  *url.URL
	LineItems *url.URL
	Scopes    []string
	NextPage  *url.URL
	Target    *Connector
}

AGS implements Assignment & Grades Services functions.

func (*AGS) CreateLineItem

func (a *AGS) CreateLineItem(lineItem LineItem) (LineItem, error)

CreateLineItem creates a new gradebook column in the launched context's lineitems container.

func (*AGS) DeleteLineItem

func (a *AGS) DeleteLineItem(lineItemToDeleteEndpoint string) error

DeleteLineItem removes a lineitem specified by the argument from the context's gradebook.

func (*AGS) GetLineItem

func (a *AGS) GetLineItem() (LineItem, error)

GetLineItem gets the currently launched AGS lineitem.

func (*AGS) GetLineItems

func (a *AGS) GetLineItems() ([]LineItem, error)

GetLineItems gets all the lineitems for the launched context, i.e. all columns in the course gradebook.

func (*AGS) GetPagedResults

func (a *AGS) GetPagedResults(limit int, userID string) ([]Result, bool, error)

GetPagedResults fetches the platform-assigned grades for a lineitem. Note: Platforms are not required to support a Results service 'limit' parameter, see: https://www.imsglobal.org/spec/lti-ags/v2p0/#container-request-filters-0 It checks for next page links, fetching and appending them to the output.

func (*AGS) GetResults

func (a *AGS) GetResults() ([]Result, error)

GetResults gets the launched limeitem's Results for all users enrolled in that lineitem's context (i.e. course).

func (*AGS) GetUserResults

func (a *AGS) GetUserResults(userID string) ([]Result, error)

GetUserResults is the same as GetResults with the addition of a user ID to filter the Results service responses.

func (*AGS) PutScore

func (a *AGS) PutScore(s Score, useLaunchUserID bool) error

PutScore posts a grade (LTI spec uses term 'score') for the launched resource to the platform's gradebook. The useLaunchUserID argument specifies if the launching user's ID is used; supply false to send the user ID embedded in the score argument.

func (*AGS) UpdateLineItem

func (a *AGS) UpdateLineItem(lineItem LineItem, notLaunchedLineItemEndpoint string) (LineItem, error)

UpdateLineItem sends an encoded LineItem used by the platform to update its definition of the launched lineitem, or the lineitem at the optional notLaunchedLineItemEndpoint parameter if updating the launched lineitem is not desired.

type Connector

type Connector struct {
	LaunchID    string
	LaunchToken jwt.Token
	SigningKey  *rsa.PrivateKey
	AccessToken datastore.AccessToken
	// contains filtered or unexported fields
}

A Connector implements the base that underpins LTI 1.3 Advantage, i.e. AGS or NRPS.

func New

func New(cfg datastore.Config, launchID, keyID string) (*Connector, error)

New creates a *Connector. To function as expected, a valid launchID must be supplied.

func (*Connector) ClientID

func (c *Connector) ClientID() string

ClientID returns the client ID associated with the connector.

func (*Connector) GetAccessToken

func (c *Connector) GetAccessToken(scopes []string) error

GetAccessToken gets a scoped bearer token for use by a connector.

func (*Connector) PlatformKey

func (c *Connector) PlatformKey() (jwk.Set, error)

PlatformKey gets the Platform's public key from the Registration Keyset URI.

func (*Connector) SetSigningKey

func (c *Connector) SetSigningKey(pemPrivateKey string) error

SetSigningKey takes a PEM encoded private key and sets the signing key to the corresponding RSA private key.

func (*Connector) UpgradeAGS

func (c *Connector) UpgradeAGS() (*AGS, error)

UpgradeAGS provides a Connector upgraded for AGS calls.

func (*Connector) UpgradeNRPS

func (c *Connector) UpgradeNRPS() (*NRPS, error)

UpgradeNRPS provides a Connector upgraded for NRPS calls.

type LTIContext

type LTIContext struct {
	ID    string
	Label string
	Title string
}

A LTIContext represents a brief course description used in Names & Roles.

type LineItem

type LineItem struct {
	ID             string  `json:"id,omitempty"`
	StartDateTime  string  `json:"startDateTime,omitempty"`
	EndDateTime    string  `json:"endDateTime,omitempty"`
	ScoreMaximum   float64 `json:"scoreMaximum,omitempty"`
	Label          string  `json:"label,omitempty"`
	Tag            string  `json:"tag,omitempty"`
	ResourceID     string  `json:"resourceId,omitempty"`
	ResourceLinkID string  `json:"resourceLinkId,omitempty"`
}

A LineItem represents the specific resource associated with a LTI launch.

type Member

type Member struct {
	Status             string
	Name               string
	Picture            string
	GivenName          string `json:"given_name"`
	FamilyName         string `json:"family_name"`
	MiddleName         string `json:"middle_name"`
	Email              string
	UserID             string `json:"user_id"`
	LisPersonSourceDid string `json:"lis_person_sourcedid"`
	Roles              []string
}

A Member represents a participant in a LTI-enabled process.

type Membership

type Membership struct {
	ID      string
	Context LTIContext
	Members []Member
}

A Membership represents a course membership with a brief class description.

type NRPS

type NRPS struct {
	Endpoint *url.URL
	Limit    int
	NextPage *url.URL
	Target   *Connector
}

NRPS implements Names & Roles Provisioning Services functions.

func (*NRPS) GetLaunchingMember

func (n *NRPS) GetLaunchingMember() (Member, error)

GetLaunchingMember returns a Member struct representing the user that performed the launch. Status is not included in the launch message.

func (*NRPS) GetMembership

func (n *NRPS) GetMembership() (Membership, error)

GetMembership gets the launched course (referred to as a Context in LTI) membership from the platform. Using GetPagedMemberships as a helper, it checks for next page links, fetching and appending them to the output.

func (*NRPS) GetPagedMembership

func (n *NRPS) GetPagedMembership(limit int) (Membership, bool, error)

GetPagedMembership gets paged Memberships for the launched course.

type Result

type Result struct {
	ID            string
	ScoreOf       string
	UserID        string
	ResultScore   float64
	ResultMaximum float64
	Comment       string
}

A Result represents a grade assigned by the platform and retrieved by the tool.

type Score

type Score struct {
	Timestamp        string  `json:"timestamp"`
	ScoreGiven       float64 `json:"scoreGiven"`
	ScoreMaximum     float64 `json:"scoreMaximum"`
	Comment          string  `json:"comment"`
	ActivityProgress string  `json:"activityProgress"`
	GradingProgress  string  `json:"gradingProgress"`
	UserID           string  `json:"userId"`
}

A Score represents a grade assigned by the tool and sent to the platform.

type ServiceRequest

type ServiceRequest struct {
	Scopes      []string
	Method      string
	URI         *url.URL
	Body        io.Reader
	ContentType string
	Accept      string
}

A ServiceRequest structures service (AGS & NRPS) connections between tool and platform.

Jump to

Keyboard shortcuts

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