db

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: 7 Imported by: 0

Documentation

Overview

Package db provides functions and structures for interacting with the SQLite database used to store information about student repositories, including grading attempts and scores.

Package db provides functions and structures for interacting with the SQLite database used to store information about student repositories, including grading attempts and scores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTable

func CreateTable(tableName string) error

CreateTable creates a new table in the database for storing repository data if it does not already exist. The database file is then stored on a repo under the configured organisation.

  • tableName: the name of the table to create

Returns a boolean indicating whether the table was created and an error if the operation fails.

func InitModuleTable

func InitModuleTable(participants [][]string, moduleName string) (err error)

InitModuleTable initializes a table for a module with participant data.

  • participants: a slice of slices, where each inner slice contains participant details
  • moduleName: the name of the module

Returns an error if the initialization fails.

func UpdateRemoteDatabase added in v0.6.3

func UpdateRemoteDatabase() (err error)

Syncs the local database changes with the remote.

func UpdateRepository

func UpdateRepository(moduleName string, repo Repository) (err error)

UpdateRepository updates the repository data in the database after a grading attempt.

  • moduleName: the name of the module
  • repo: the repository data to be updated

Returns an error if the update fails.

Types

type Repository

type Repository struct {
	ID              string        // ID is the unique identifier for the repository.
	FirstAttempt    bool          // FirstAttempt indicates if this is the student's first grading attempt.
	LastGradingTime time.Time     // LastGradingTime stores the timestamp of the last grading attempt.
	WaitingTime     time.Duration // WaitingTime is the required duration to wait before the next grading attempt.
	Score           int           // Score is the student's score in the current module.
	Attempts        int           // Attempts tracks the number of grading attempts made by the student.
}

Repository represents the data related to a student's repository, including grading history and current score.

func GetRepositoryData

func GetRepositoryData(moduleName string, repoID string) (repo Repository, err error)

GetRepositoryData retrieves the repository data for a specific module and repository ID.

  • moduleName: the name of the module
  • repoID: the unique identifier for the repository

Returns the repository data and an error if the operation fails.

type Templates

type Templates struct {
	RepoById        string // RepoById is the SQL template for querying repository data by ID.
	TableByName     string // TableByName is the SQL template for checking if a table exists by its name.
	CreateRepoTable string // CreateRepoTable is the SQL template for creating a new repository table.
	UpdateRepo      string // UpdateRepo is the SQL template for updating repository data after a grading attempt.
	NewRepoRow      string // NewRepoRow is the SQL template for inserting a new repository record into the table.
}

Templates contains SQL query templates used for interacting with the SQLite database.

Jump to

Keyboard shortcuts

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