pknulms

package module
v0.0.0-...-b54480e Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2018 License: MIT Imports: 12 Imported by: 1

README

pknulms

GoDoc Go Report Card

Go LMS client for Pukyong National University.

Getting Started

Installation
$ go get github.com/hallazzang/pknulms
Example

Here's a brief example:

package main

import (
    "fmt"
    "os"

    "github.com/hallazzang/pknulms"
)

func main() {
    client := pknulms.MustNewClient()

    if !client.MustLogin("YOUR_STUDENT_NO", "YOUR_PASSWORD") { // You should replace these values
        panic("Login failed.")
    }

    for i, n := range client.MustGetNotificationsByPage(1) {
        fmt.Printf("%2d: %s\n", i+1, n.Title)
    }
}

It should print recent notifications like this:

 1: 수업자료_14장-15장
 2: 8. 6장 큐 연습문제
 3: 6.  7장 트리 (Tree)
 4: Ch.10 Input Output Organization
 5: Ch.09 Memory Organization
 6: Ch.08 Computer Arithmetic
 7: Ch.07 Microsequencer Control Unit Design
 8: 7. 미로문제 풀이 프로그래밍
 9: 6. 5장 스택 연습문제
10: 강의자료6
11: 실습제출5
12: 5. 6장 큐 (Updated 10/31, 11/2)
13: 4. 5장 스택(Stack)
14: 강의자료5
15: 실습제출4
16: 강의자료4
17: 실습제출3
18: 5. 4장 리스트 연습문제
19: 4. 배열을 이용한 리스트 테스트 프로그래밍
20: 강의자료3

Documentation

The documentation can be found on GoDoc.

Documentation

Overview

Package pknulms implements LMS client for Pukyong National University.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a wrapper for a single http.Client instance.

func MustNewClient

func MustNewClient() *Client

MustNewClient attempts to create a new client, panics when an error has occurred.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new LMS client.

func (*Client) GetNotificationContent

func (c *Client) GetNotificationContent(n *Notification) (string, error)

GetNotificationContent returns content of given notification. The result contains HTML codes, not plain text.

func (*Client) GetNotifications

func (c *Client) GetNotifications(start, count int) (result []*Notification, e error)

GetNotifications returns a slice of notifications for given start offset and count. Note that start offset begins from 1 so the FIRST notification would be at offset 1, not 0. Weirdly, it seems that the count must be >= 8 because of some mysterious reasons.

func (*Client) GetNotificationsByPage

func (c *Client) GetNotificationsByPage(page int) (result []*Notification, e error)

GetNotificationsByPage returns a slice of notifications for given page. The default page size(notifications per page) is 20. If you want to change the page size, you can use GetNotifications.

func (*Client) Login

func (c *Client) Login(id, pw string) (bool, error)

Login logs client into LMS.

func (*Client) Logout

func (c *Client) Logout() error

Logout logs client out from LMS.

func (*Client) MustGetNotificationContent

func (c *Client) MustGetNotificationContent(n *Notification) string

MustGetNotificationContent returns content of given notification. The result contains HTML codes, not plain text.

func (*Client) MustGetNotifications

func (c *Client) MustGetNotifications(start, count int) []*Notification

MustGetNotifications returns a slice of notifications for given start offset and count, panics when an error has occurred. Note that start offset begins from 1 so the FIRST notification would be at offset 1, not 0.

func (*Client) MustGetNotificationsByPage

func (c *Client) MustGetNotificationsByPage(page int) []*Notification

MustGetNotificationsByPage returns a slice of notifications for given page, panics when an error has occurred.

func (*Client) MustLogin

func (c *Client) MustLogin(id, pw string) bool

MustLogin attempts to login, panics when an error has occurred.

func (*Client) MustLogout

func (c *Client) MustLogout()

MustLogout attempts to logout, panics when an error has occurred.

func (*Client) MustSendNote

func (c *Client) MustSendNote(to, title, content string)

MustSendNote sends note to a person with given title and content, panics when an error has occurred.

func (*Client) SendNote

func (c *Client) SendNote(to, title, content string) error

SendNote sends note to a person with given title and content.

type Lecture

type Lecture struct {
	Key  string
	Name string
}

Lecture represents a single lecture.

type Notification

type Notification struct {
	ID             int
	Link           string
	Type           string
	Title          string
	Datetime       string
	Submitted      bool
	Lecture        *Lecture
	Professor      string
	PreviewContent string
}

Notification represents a single notification. Datetime field might hold different datetime format for different type of notifications. Submitted field holds a boolean value whether the assignment has assigned or not if the Type of notification is assignment(in string form, "과제") else always false.

func (*Notification) String

func (n *Notification) String() string

String returns a string representation of a notification in form of {Type: Title}.

Jump to

Keyboard shortcuts

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