Module

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Module provides structures and functions for managing and executing modules, which consist of multiple exercises. The package includes features for setting up environments, running exercises in isolated containers, and grading the results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GradingConfig added in v0.2.0

type GradingConfig struct {
	ModuleName     string
	ExerciseName   string
	TracesPath     string
	CloneDirectory string
}

type Module

type Module struct {
	Name            string                       // Name is the module's display name.
	MinimumGrade    int                          // MinimumGrade is the minimum score required to pass the module.
	Exercises       map[string]Exercise.Exercise // Exercises is a map of all exercises belonging to the module.
	SubjectPath     string                       // SubjectPath is the path to the module's subject file (markdown or html).
	DockerImageName string                       // Name of the docker image containing the environment for grading this module.
}

Module represents a module containing multiple exercises. It includes the module's name, the minimum grade required to pass, a map of exercises, the path to the subject file and the name of the Docker image which is to be used to run the code in.

func NewModule

func NewModule(name string, minimumGrade int, exercises map[string]Exercise.Exercise, subjectPath string, dockerImageName string) (module Module)

NewModule initializes and returns a Module struct.

  • name: module display name
  • minimumGrade: the minimum score required to pass the module
  • exercises: map of all Exercise.Exercise objects belonging to the module
  • subjectPath: path to the module's subject file

func (*Module) GetScore

func (m *Module) GetScore(results map[string]bool) (score int, passed bool)

GetScore calculates the total score based on the results of the exercises and determines if the module is passed.

  • results: a map of exercise names to their pass/fail results

Returns the total score and a boolean indicating whether the module is passed.

func (*Module) Run

func (m *Module) Run(repoID string) (results map[string]bool, tracesPath string, err error)

Run executes the exercises, spawning a Docker container for each of them to prevent running malicious code on your machine. It returns the results and the path to the trace logs.

  • repoID: the ID of the repository to be cloned
  • testDirectory: the directory where the repository will be cloned

Returns a map of exercise names to their pass/fail results and the path to the trace logs.

Jump to

Keyboard shortcuts

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