Skip to content

Configuration


You will learn:

  • How to configure Hakutest via configuration file
  • How to configure Hakutest via CLI flags

Overview

While Hakutest can be configured via the web interface (Settings), it also provides several methods to change the settings programmatically. This can be useful for automating tasks, integrating with other systems, or managing multiple Hakutest instances.

Configuration file

Hakutest settings are stored in the YAML configuration file config.yaml. Its location depends on the operating system you are using:

Linux

The configuration file is in $XDG_CONFIG_HOME/hakutest.

This path defaults to $HOME/.config/hakutest if $XDG_CONFIG_HOME is not set as defined in the XDG Base Directory Specification.

Windows

The configuration file is in one of the following paths:

  • %USERPROFILE%/hakutest
  • %AppData%/hakutest
  • %LocalAppData%/hakutest

Configuration file fields

FieldDescriptionValue
general.debugRun Hakutest in debug modetrue or false
general.disable_trayRun Hakutest without a system tray icontrue or false
general.langLanguage of the Hakutest interfaceAny of supported languages
general.portPort on which Hakutest server is startedInteger between 1024 to 65535
result.overwriteWhether to overwrite the results when a student resubmits answerstrue or false
result.showWhether to show the student the result page after submitting their answerstrue or false
result.pathDirectory in which Hakutest stores student resultsExisting directory path
test.pathDirectory in which Hakutest stores testsExisting directory path
security.studentSecurity policy applied to student interfaceno_verificationFor everyone without verification.

credentialsBy username and password.

hostonlyOnly this device
security.teacherSecurity policy applied to teacher interfaceno_verificationFor everyone without verification.

credentialsBy username and password.

hostonlyOnly this device
security.dialectDialect of the database containing the user datasqlite, mysql, or postgres
security.dsnDSN (Data Source Name) of the database containing the user dataFor sqlite dialect — path to the database file.

For mysql and postgres dialects — a connection string.

IMPORTANT

If a field is missing from the configuration file (including the case where the entire config is not present), its default value is as follows:

yaml
general:
    debug: false
    disable_tray: false
    port: 8080
    lang: en
result:
    overwrite: true
    path: $XDG_DATA_HOME/hakutest/results
    show: false
test:
    path: $XDG_DATA_HOME/hakutest/tests
security:
    dsn: $XDG_CACHE_HOME/hakutest/users.db
    dialect: sqlite
    teacher: hostonly
    student: no_verification

Please also note that paths depend on the operating system used.

Example

Below is an example of a configuration file:

yaml
general:
    debug: false
    disable_tray: false
    port: 8080
    lang: en
result:
    overwrite: true
    path: /home/user/.local/share/hakutest/results
    show: false
test:
    path: /home/user/.local/share/hakutest/tests
security:
    dsn: /home/user/.cache/hakutest/users.db
    dialect: sqlite
    teacher: hostonly
    student: no_verification

TIP

On Linux, sending Hakutest a SIGUSR1 signal forces it to reload configuration from file:

shell
pkill -USR1 hakutest

CLI flags

You can also change the Hakutest settings via CLI flags. The flags are exactly the same as the fields in the configuration file, see above.

Below are several examples of overriding configuration via CLI flags:

shell
# Override language
hakutest --general.lang en

# Override port
hakutest --general.port 3000

# Override security policy for student
hakutest --security.student credentials

# Multiple overrides
hakutest --general.debug --results.overwrite --general.port 5000

Hakutest is released under the MIT License.