Skip to content

Configuration

Dudrie edited this page Oct 17, 2020 · 10 revisions

⚠ The wiki got moved to a new documentation. The information you find here might be outdated or inaccurate.


Structure of Directory

Within the tms/config/ directory containing the configuration files the following items have to be present:

  • production.yml: YAML file containing the general configuration for the server.
  • templates/: Directory containing the Pug template files (see below).

Those files are provided through a docker volume. See the installation guide for more information.

Every release contains either a link to the current sample configuration or a sample configuration itself. If it contains the later the server configuration might need an update according to the Configuration section of the release.

Options

The configuration object is of type ApplicationConfiguration.

ApplicationConfiguration

Option Required / Default Description
sessionTimeout Default: 120 Number - The time of inactivity in minutes after which the session of the user times out and he/she must log in again.
prefix (optional, no default) String - Prefix of the root path the application is hosted on. If the application is hosted on the root path this setting must be omitted. Otherwise it has to be set to the prefix (ie. for the path https://example.org/foo this setting has to be set to foo)
database Required DatabaseConfiguration - Configuration of the database. See below for more information.
defaultSettings (optional, defaults see "Settings" page) Settings to initialize parts of the server with. Those settings can also be configured through the client later on. See Settings for more information.

DatabaseConfiguration

The following table contains the options available for the database configuration, a short description and their default value (if they are optional).

Option Required / Default Description
databaseURL Required String - The URL which resolves to the database and the desired collection. Must be a MongoDB URL. Please note: Databases other than MongoDB might work if they are compatible to mongoose. However they are not tested and officially supported.
maxRetries Default: 2
config Default: {useNewUrlParser: true, useUnifiedTopology: true} ConnectionOptions - The auth property will not be respected. To set authentication details one must use the corresponding environment variables Further configuration options provided to the MongoDB connection. For more information see the mongoose documentation.

Environment Variables

All of the following environment variables are required unless stated otherwise.

Variable Description
TMS_MONGODB_USER String - Username to log into the mongoDB.
TMS_MONGODB_PW String - Password to log into the mongoDB.
TMS_SECRET String - Secret to encrypt sensitive fields in the documents in the DB (ie names of users, ...). This secret should be created like a secure password (no easy to guess words, ...).

Pug Templates

The Tutor-Management-System can generate various PDFs. These can be configured using the following templates. The templates must be inside an templates/ folder inside the config/ folder. All templates use the pug template engine and variables which will get substituted by the corresponding value on PDF generation. Every template section contains a description on it's usage, the variables used inside and an example. Please note that the templates do NOT need a html, body or head because they will be inserted into a body during PDF generation.

⚠ Please note that all template files must be present at the start of the server.

Attendance Template

Filename: attendance.pug

This template gets used on the creation of a PDF containing a list of students of a tutorial. On this list students can leave their signature if they are present.

Variable Description
tutorialSlot String - The slot of the tutorial which belongs to the sheet.
date DateTime - Date to which the attendance list belongs. Takes in the format after a comma. For more information on the available functions see the luxon documentation
tutorName String - Name of the tutor in the format <lastname>, <firstname>.
students { name: string }[] - Array containing objects of which each holds the name of one student.
Example
h3(style='text-align: center') Anwesenheitsliste

div(style='display: flex; width: 100%;')
  span Tutorium #{tutorialSlot}
  span(style='margin-left: auto; float: right;') Datum: #{date.toFormat('dd.MM.yyyy')}

div(style='margin-bottom: 16px;')
  span Tutor: #{tutorName}

table
  thead
    tr
      th Name
      th Unterschrift

  tbody
    each student in students
      tr
        td #{student.name}
        td

Credentials Template

Filename: credentials.pug

Variable Description
credentials { name: string; username: string; password: string }[] - Array containing objects which hold information about the user.
Example
h3(style='text-align: center') Zugangsdaten

table
  style(scoped).
    td {
      padding: 0.5em 1em;
      font-family: 'Courier New', Courier, monospace;
      line-height: 200%;
    }

  thead
    tr
      th Name
      th Nutzername
      th Password

  tbody
    each user in users
      tr
        td #{user.name}
        td #{user.username}
        if !!user.password
          td #{user.password}
        else
          td Kein tmp. Passwort

Mail template

Filename: mail.pug

This template is being used for the mails containing the credentials. The following variables will be substituted with their actual values by the server on sending the mails. All variables have to be enclosed with {{ }}.

Variable Description
name String - Name of the user which gets the email.
username String - Username of the user which gets the email.
password String - Password of the user which gets the email.

Here is an example of such a template containing the substitute variables.

Example template
| Hallo #{name},
|
| hier sind deine Zugangsdaten zum Tutor-Management-System:
|
| Nutzername: #{username}
| Passwort: #{password}
|
| Mit freundlichen Grüßen
| TMS Admin

Scheinexam Results Template

Filename: scheinexam.pug

Variable Description
scheinExamNo Number - Number of the Scheinexam of this PDF.
statuses { matriculationNo: string; state: PassedState }[] - Array containing the statuses of each student (with matriculation number) for the exam of the generated PDF. PassedState can be one of the following values: "passed", "notPassed", "notAttended"
Example
h3(style='text-align: center') Scheinklausur Nr. #{scheinExamNo}

table
  style(scoped).
    td {
      padding: 0.5em 1em;
      font-family: 'Courier New', Courier, monospace;
      line-height: 200%;
    }

  thead
    tr
      th Matrikelnummer
      th Bestanden / Nicht bestanden

  tbody
    each status in statuses
      tr
        td #{status.matriculationNo}
        if status.state === "passed"
          td Bestanden
        else if status.state === "notPassed"
          td Nicht bestanden
        else
          td Abwesend

Scheinstatus Results Template

Filename: scheinstatus.pug

Variable Description
statuses { matriculationNo: string; state: PassedState }[] - Array containing the Schein statuses of each student (with matriculation number). PassedState can be one of the following values: "passed", "notPassed"
Example
h3(style='text-align: center') Scheinliste

table
  style(scoped).
    td {
      padding: 0.5em 1em;
      font-family: 'Courier New', Courier, monospace;
      line-height: 200%;
    }

  thead
    tr
      th Matrikelnummer
      th Bestanden / Nicht bestanden

  tbody
    each status in statuses
      tr
        td #{status.matriculationNo}
        if status.state === "passed"
          td Bestanden
        else
          td Nicht bestanden