uwquest

package module
v0.1.1-0...-4ec5ecd Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: MIT Imports: 10 Imported by: 0

README

Archive Notice

Due to changes to the UW Quest authentication API, and my lack of personal use of this repository, I am deprecating this client library—it will no longer be maintained.

uwquest

A Golang client for the UWaterloo Quest API.

Tags Go Report Card

Why?

I wanted to programmatically check my grades, and other stuff like that. Maybe get my grades emailed to me when they come out? But I didn't find any good Quest clients that could let me build those kinds of things.

So that's why I built this, with the hope that a time will come where anybody can build programs that use information from Quest.

Features

  • Quest login and authentication.
  • Fetching grades data from Quest.
  • Fetching class schedule information.
  • Unofficial transcripts?
  • Course add / drop / shopping carts?
  • ??? other stuff ???

Open an issue to request a new feature that you want to see added to uwquest!

Usage

To use the uwquest package as a library, just open up your Golang project directory, and run:

go get -u github.com/stevenxie/uwquest

Then, start coding!

For example, here's a program that will fetch your grades for the Fall 2018 term:

package main

import (
	"fmt"
	"log"

	"github.com/stevenxie/uwquest"
)

func main() {
	// Create a Quest client.
	quest, _ := uwquest.NewClient()

	// Login to Quest.
	if err := quest.Login("fhamphalladur", "mrgoose2018"); err != nil {
		log.Fatalf("Failed to login to Quest: %v", err)
	}

	// Fetch all study terms.
	terms, err := quest.Terms()
	if err != nil {
		log.Fatalf("Failed to fetch terms: %v", err)
	}

	// Find the term that's named "Fall 2018".
	var target *uwquest.Term
	for _, term := range terms {
		if term.Name == "Fall 2018" {
			target = term
		}
	}
	if target == nil {
		fmt.Println("No such term with the name 'Fall 2018' 😓")
	}

	// Fetch grade for the target term.
	grades, err := quest.Grades(target.ID)
	if err != nil {
		log.Fatalf("Failed to fetch grades: %v", err)
	}

	// Print grades.
	fmt.Println("Found grades for the Fall 2018 term:")
	for _, grade := range grades {
		fmt.Printf(" • %v\n", grade)
	}
}

This program will output something like:

Found grades for the Fall 2018 term:
 • CourseGrade{ID: 0, Name: CS 245, Description: Logic and Computation, GradingBasis: Numeric Grading Basis, Units: 0.500000, Grade: DNW, GradePoints: 16.000000}
 • CourseGrade{ID: 1, Name: CS 246, Description: Object-Oriented Software Devel, GradingBasis: Numeric Grading Basis, Units: 0.500000, Grade: 71, GradePoints: 35.500000}
 • CourseGrade{ID: 2, Name: MATH 128, Description: Calculus 2 for the Sciences, GradingBasis: Numeric Grading Basis, Units: 0.500000, Grade: 62, GradePoints: 31.000000}
 • CourseGrade{ID: 3, Name: MATH 136, Description: Linear Algebra 1 (Hon Math), GradingBasis: Numeric Grading Basis, Units: 0.500000, Grade: 60, GradePoints: 30.000000}

Example Programs

Check out the examples/ directory for example programs, like gradecheck. Some of these programs might be useful to you on their own, but if anything they'll be a good way to understand how to make something with this library.

gradecheck

gradecheck lists your grades.

It will check for the environment variables QUEST_USER and QUEST_PASS, and if they don't exist it will ask you for those missing values.

Installation:

Make sure you have Go installed.

## Download and install into $GOBIN:
$ go get github.com/stevenxie/uwquest/examples/gradecheck

## Run:
$ gradecheck

Contributing

Want to help develop this? Just clone this repository (or a fork of it):

git clone git@github.com:stevenxie/uwquest

Make sure to set up git-hooks and other dependencies with:

make setup

Disclaimer

Maybe you're looking at this and you're an employer. And... you think my grades are really bad.

Um.

Whoops?

I'll try harder next term, I promise.

Please... please still consider hiring me...

Documentation

Overview

Package uwquest provides methods for accessing data from the UWaterloo Quest Information System, primarily through the Client struct.

Index

Constants

View Source
const (
	BaseURL          = "https://quest.pecs.uwaterloo.ca/psc/SS/ACADEMIC/SA/c/"
	StudentCenterURL = BaseURL + "SA_LEARNER_SERVICES.SSS_STUDENT_CENTER.GBL"
	GradesURL        = BaseURL + "UW_SS_MENU.UW_SSR_SSENRL_GRDE.GBL"
	SchedulesURL     = BaseURL + "SA_LEARNER_SERVICES.SSR_SSENRL_LIST.GBL"
)

Quest endpoint URLs.

Variables

View Source
var ErrBadLogin = errors.New("uwquest: bad login (invalid user ID or password)")

ErrBadLogin is an error which identifies a login error.

Functions

This section is empty.

Types

type Class

type Class struct {
	Index           int
	Number, Section int
	Component       string
	Schedule        string
	Location        string
	Instructor      string
	StartEndDate    string
}

Class represents a class within a particular course.

func (*Class) String

func (c *Class) String() string

type Client

type Client struct {
	// Session refers the HTTP client session that performs Client's underlying
	// requests.
	//
	// This Session is authorized with the Quest API backend upon login.
	Session *http.Client

	// Jar is a cookiejar that contains Session's cookies.
	Jar *cookiejar.Jar
}

Client is capable of interacting with the UW Quest API.

func NewClient

func NewClient() (*Client, error)

NewClient returns a new Client.

It needs to be authenticated with the Quest backend using Login, before it can fetch other data from Quest.

func (*Client) Grades

func (c *Client) Grades(termIndex int) ([]*CourseGrade, error)

Grades fetches the grades for a particular term.

func (*Client) Login

func (c *Client) Login(user, pass string) error

Login authenticats the Client session with the Quest API backend.

Requires a username (WatIAM ID) and password.

func (*Client) Schedules

func (c *Client) Schedules(termIndex int) ([]*CourseSchedule, error)

Schedules fetches course schedules for a particular term.

func (*Client) Terms

func (c *Client) Terms() ([]*Term, error)

Terms fetches all the terms that a student has been enrolled for.

func (*Client) TermsWithSchedule

func (c *Client) TermsWithSchedule() ([]*Term, error)

TermsWithSchedule fetches the study terms for which Quest has course schedules available.

type CourseGrade

type CourseGrade struct {
	Index        int
	Name         string
	Description  string
	GradingBasis string
	Units        *float32 // may be nil
	Grade        string
	GradePoints  *float32 // may be nil
}

A CourseGrade represents the grades for a particular course.

func (*CourseGrade) String

func (cg *CourseGrade) String() string

type CourseSchedule

type CourseSchedule struct {
	Index        int
	Name         string
	Status       string
	Units        float32
	GradingBasis string
	Classes      []*Class
}

CourseSchedule represents the course schedule for a particular course.

func (*CourseSchedule) String

func (cs *CourseSchedule) String() string

type Term

type Term struct {
	Index       int
	Name        string
	Career      string
	Institution string
}

A Term represents a UW school term.

func (*Term) String

func (t *Term) String() string

Directories

Path Synopsis
Package examples is a directory that contains example Go programs that use package uwquest to access Quest data.
Package examples is a directory that contains example Go programs that use package uwquest to access Quest data.
gradecheck Module

Jump to

Keyboard shortcuts

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