aleks

package
v0.0.0-...-ea6a858 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package aleks provides a client library to access data provided by the McGraw-Hill Aleks service. Currently, two methods to retrieve Aleks placement report records are provided by an instantiated client. See the sample program in the cmd/placementreport package for an example of how this library can be used.

Index

Constants

View Source
const (
	// AleksEnvconfigPrefix indicates that all environment variables used
	// by this library will start with ALEKS_.
	AleksEnvconfigPrefix = "aleks"

	// AleksDefaultURL is used to access the Aleks service if an alternate
	// URL is not provided via either the parameterized NewClient
	// constructor or the no-parameters NewClientFromEnv constructor.
	AleksDefaultURL = "https://secure.aleks.com/xmlrpc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client contains the basic XML-RPC parameters required to make a call to the Aleks service.

func NewClient

func NewClient(url, username, password string) (*Client, error)

NewClient returns a new Aleks client given an optional URL and a required username and password.

func NewClientFromEnv

func NewClientFromEnv() (*Client, error)

NewClientFromEnv returns a new Aleks client from environment variables as follows:

  • ALEKS_URL (Optional - see the default in constants)
  • ALEKS_USERNAME (Required)
  • ALEKS_PASSWORD (Required)

It is important to note that the individual Aleks XMLRPC calls will generally required additional parameters.

func (*Client) GetPlacementReport

func (c *Client) GetPlacementReport(from, to string, classcodes ...string) (PlacementReport, []error)

GetPlacementReport calls the Aleks XML-RPC method of the same name for one or more class-codes and returns the results as a list of PlacementRecords. A collection of errors that occurred during this process is also collected and returned to the caller. Note that it is possible for both PlacementRecords and errors to be returned from the same call as valid PlacementRecords are not discarded due to errors in other records.

This method uses an individual thread to retrieve the data for each class-code and collects the results in a single PlacementReport to reduce the time it takes to retrieve large data sets. Requesting large numbers of class-codes will therefore result in a large number of threads.

func (*Client) GetPlacementReportFromEnv

func (c *Client) GetPlacementReportFromEnv() (PlacementReport, []error)

GetPlacementReportFromEnv returns PlacementRecords and errors as described by the documentation for GetPlacementReport but retrieves its configuration from environment variables as follows:

  • ALEKS_FROM_COMPLETION_DATE (Required - YYYY-MM-DD)
  • ALEKS_TO_COMPLETION_DATE (Required - YYYY-MM-DD)
  • ALEKS_CLASSCODES (Required - One or more class-codes with the format AAAAA-AAAAA in a comma separated string)

type PlacementRecord

type PlacementRecord struct {
	Name                         string
	StudentID                    string
	Email                        string
	LastLogin                    time.Time
	PlacementAssessmentNumber    int
	TotalNumberOfPlacementsTaken int
	StartTime                    time.Time
	EndTime                      time.Time
	ProctoredAssessment          string
	HoursInPlacement             float64
	PlacementResults             float64
}

PlacementRecord provides the results of an individual placement exam. The Aleks format returns 13 strings formatted as a CSV record. The 11 fields below are in the same order and (almost) have the same names as the columns in this CSV report - the "Start Date"/"Start Time" and "End Date"/"End Time" columns are combined into a single field below. In addition, all string columns are validated and converted to their appropriate types.

type PlacementReport

type PlacementReport []PlacementRecord

PlacementReport contains the PlacementRecords returned (if any) by the GetPlacementReport and GetPlacementReportFromEnv methods.

type RoundTripper

type RoundTripper struct {
	Trans http.RoundTripper
}

RoundTripper intercepts HTTP calls and alters the request as described by the #RoundTrip method.

func (*RoundTripper) RoundTrip

func (rt *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements https://golang.org/pkg/net/http/#RoundTripper. The XML-RPC specification requires the User-Agent and Host headers which the kolo/xmlrpc library doesn't honor. Aleks doesn't appear to care if they're missing but we're adding them here for completeness. More importantly, this intercepter replaces the default transport with one that has compression disabled. On the response side, the XML-RPC library doesn't deal with string values wrapped in CDATA tags so this RoundTripper also strips those tags from the result.

Jump to

Keyboard shortcuts

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