fass

package
v0.0.0-...-9aff3ce Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSubmission

func BuildSubmission(course Course, exercise Exercise, user Token, submissionFilename string) error

func DistributeToken

func DistributeToken(token Token, to Mail, course Course, config Config) error

func Serve

func Serve(addr string)

Serve starts the FASS service.

func TokenHasValidFormat

func TokenHasValidFormat(t Token) bool

TokenHasValidFormat verifies that the given token follows the required format.

Types

type Config

type Config struct {
	ListenAddress string
	MailHost      string
	MailFrom      string
	MailUseAuth   bool
	MailAuthIdent string
	MailAuthUser  string
	MailAuthPass  string
}

func DefaultConfig

func DefaultConfig() Config

func LoadConfig

func LoadConfig() (config Config, err error)

func (Config) Store

func (c Config) Store() error

type Course

type Course struct {
	Identifier string `json:"-"`
	Name       string
	URL        string
	Path       string              `json:"-"`
	Exercises  map[string]Exercise `json:"-"`
	Users      []Token
}

Course represents a course with its exercise sheets and registered users.

func LoadCourse

func LoadCourse(coursePath string) (course Course, err error)

LoadCourse loads course data from disk.

func LoadCourses

func LoadCourses(dataPath string) (courses []Course, err error)

LoadCourses loads all courses from the given directory.

func (Course) IsUserAuthorized

func (c Course) IsUserAuthorized(token Token) bool

func (Course) Store

func (c Course) Store() error

type Exercise

type Exercise struct {
	Identifier string `json:"-"`
	Path       string `json:"-"`
	Deadline   time.Time
}

Exercise represents an exercise sheet.

func (Exercise) GetBuildOutput

func (e Exercise) GetBuildOutput(submissionFilename string) (io.Reader, error)

func (Exercise) GetFeedback

func (e Exercise) GetFeedback(submissionFilename string) (io.Reader, error)

func (Exercise) Store

func (e Exercise) Store() error

func (Exercise) StoreSubmission

func (e Exercise) StoreSubmission(submission io.Reader, filename string) ([]byte, error)

func (Exercise) WasBuildSuccessful

func (e Exercise) WasBuildSuccessful(submissionFilename string) bool

type Mail

type Mail = string

Mail addresses are represented as strings.

type Token

type Token = string

Token that is given to a user, it is commonly used for authenticating uploads.

func GenerateToken

func GenerateToken() Token

GenerateToken generates a fixed length token.

type TokenMapping

type TokenMapping map[Token]Mail

TokenMapping relates tokens to mail addresses. Be careful when handling since this is personal identifiable data.

func LoadTokenMapping

func LoadTokenMapping(mappingFilepath string) (TokenMapping, error)

func NewTokenMapping

func NewTokenMapping(mailAddresses io.Reader) (mapping TokenMapping)

NewTokenMapping creates a TokenMapping from the given io.Reader (typically a file). The input is expected to contain one mail address per line. Tokens are generated on the fly. A token is guaranteed to be unique within the returned mapping.

func (TokenMapping) Store

func (m TokenMapping) Store(filepath string) error

Store stores the mapping as file.

Jump to

Keyboard shortcuts

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