fbnd

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: MIT Imports: 9 Imported by: 0

README

fbnd

A small library to parse the publicly available website of timetables for degree programs of the Faculty of Electrical Engineering and Computer Science, abbreviated FB03, at the Hochschule Niederrhein.

Command line tool

The accompanying command line tool to view timetables directly inside your terminal can be found here.

FAQ

Why is it called fbnd?

  • fbnd as in FB03 as in Fachbereich Null Drei.

Note

This is not an official tool of the Hochschule Niederrhein.

This is only a personal project of mine that I did, because I wanted to view the timetable in my terminal.

License

This project is licensed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Course

type Course struct {
	NameLong       string `json:"nameLong"`
	NameShort      string `json:"nameShort"`
	ProfessorLong  string `json:"professorLong"`
	ProfessorShort string `json:"professorShort"`
	Room           string `json:"room"`
	Lesson         Lesson `json:"lesson"`
	Time           Time   `json:"time"`
}

Course represents a single course of a timetable for a DegreeProgram.

type Degree

type Degree string

Degree is used to describe a DegreeProgram, either Bachelor or Master.

const (
	Bachelor Degree = "Bachelor"
	Master   Degree = "Master"
)

type DegreeProgram

type DegreeProgram struct {
	ID       ID       `json:"id"`
	Name     string   `json:"name"`
	Degree   Degree   `json:"degree"`
	Semester Semester `json:"semester"`
}

DegreeProgram represents a degree program for which a timetable is available.

func DegreePrograms

func DegreePrograms(cycle SemesterCycle) ([]DegreeProgram, error)

DegreePrograms returns all degree programs for which timetables are available and that fall into the given cycle. If the HTML could not be parsed, an error is returned.

type ID

type ID string

ID is the internal ID of each DegreeProgram returned by DegreePrograms. It is needed to fetch the timetable for a given DegreeProgram.

type Lesson

type Lesson string

Lesson is used to describe the type of the accompanying Course.

const (
	Lecture         Lesson = "V"
	Exercise        Lesson = "U"
	Internship      Lesson = "P"
	Seminar         Lesson = "S"
	SeminarLecture  Lesson = "SL"
	LanguageLecture Lesson = "F"
	Tutorial        Lesson = "T"
	BlockCourse     Lesson = "BL"
)

func (Lesson) String

func (l Lesson) String() string

type Semester

type Semester struct {
	Cycle SemesterCycle `json:"cycle"`
	Year  int           `json:"year"`
	Term  int           `json:"term"`
}

Semester is used to describe the accompanying DegreeProgram.

type SemesterCycle

type SemesterCycle string

SemesterCycle represents the type of a Semester, either Summer or Winter.

const (
	Summer SemesterCycle = "Summer"
	Winter SemesterCycle = "Winter"
)

type Time

type Time struct {
	Weekday   time.Weekday `json:"weekday"`
	HourStart int          `json:"hourStart"`
	HourEnd   int          `json:"hourEnd"`
}

Time represents the day, start and end of a Course.

type Timetable

type Timetable struct {
	// Can be nil, use FillDegreeProgram to fill the value, or if you obtained
	// the right DegreeProgram through calling DegreePrograms prior to calling
	// TimetableForDegreeProgram you can set the instance yourself.
	DegreeProgram *DegreeProgram `json:"degreeProgram"`
	Days          []TimetableDay `json:"days"`
	// contains filtered or unexported fields
}

Timetable contains all days for which courses exist as well as a DegreeProgram for which the timetable is valid.

func TimetableForDegreeProgram

func TimetableForDegreeProgram(id ID) (*Timetable, error)

TimetableForDegreeProgram returns a Timetable that contains all courses for the given degree program. The days inside Timetable are sorted by their weekday and the courses inside each day are sorted by their start hour. The ID can be obtained by calling DegreePrograms.

func (*Timetable) FillDegreeProgram

func (t *Timetable) FillDegreeProgram() error

FillDegreeProgram calls DegreePrograms at most one time to obtain the correct DegreeProgram. The reason that t.DegreeProgram can be nil is as follows: If the function TimetableForDegreeProgram is called there is no way to know which semester the passed in ID belongs to; the server defaults to Winter. Now if the ID belongs to Winter then the DegreeProgram can be found and parsed within one request but if it belongs to Summer then the response we get does not contain the DegreeProgram, only the timetable for it and another request has to be made.

type TimetableDay

type TimetableDay struct {
	Weekday time.Weekday `json:"weekday"`
	Courses []Course     `json:"courses"`
}

TimetableDay contains all courses for a Weekday for an accompanying Timetable.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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