7. Command-line Interface

Quizzera exposes a command-line interface (CLI) to most aspects of administering courses. This CLI tool can be operated anywhere where Python 3.x and pip, the Python package manager, are installed; the CLI tool connects with the Quizzera service using a web API.

7.1. Installation

To set up the CLI, when you have a clone of the repository, run the following:

$ cd cli
$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ python admin.py --help

If the help command runs without errors, then you have successfully installed the CLI tool. Throughout this documentation, the CLI tool will be referred to as quizzera-admin.

7.2. Configuration

The CLI configuration is given within a configuration file. An example is located under cli/example_config.yml and is reproduced below.

The configuration file location is given by the QUIZZERA_CONFIG environment variable and defaults to ~/.quizzera.yml. For example, to run the tool with a configuration file located at /etc/quizzera.yml, run

$ QUIZZERA_CONFIG=/etc/quizzera.yml quizzera-admin --help
Example CLI configuration
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
config:
  # Other environments can be provided in a similar format. For example, a
  # development environment may look like the following:
  # (Note: the primary key, development, is the environment name - set with the
  # ENV environment variable).
  development:
    # Default course to use in commands. Use the integer ID number.
    default_course: null

    # Username (generally, your NetID) to authenticate with.
    user: rpanchal

    # Secret key to authenticate with.
    secret: SECRET_KEY_FROM_API

    # Default timezone: affects timestamp inputs and displays.
    timezone: UTC

  production:
    default_course: 73
    user: lumbroso
    secret: null
    timezone: UTC

7.3. Commands

The commands available in the CLI tool are listed below.

7.3.1. quizzera-admin

Quizzera Command-Line Interface (CLI). This CLI can be used to interact with Quizzera as an administrator over the REST API.

quizzera-admin [OPTIONS] COMMAND [ARGS]...

7.3.1.1. add-extension

Provide an extension to users for a provided quiz. The extension can have a set timestamp or a number of days into the future.

Example:

# Grant an extension that ends two days from now to students for quiz 3.
$ quizzera-admin add-extension 3 --days 2 student_1

# Grant an extension that ends at a set time to students for quiz 3.
$ quizzera-admin add-extension 3 --timestamp '2018-04-20T16:20:00' student_1 student_2

# Force grant the extension by bypassing the confirmation prompt.
$ quizzera-admin add-extension 3 --force --timestamp '2018-04-20T16:20:00' student_1 student_2
quizzera-admin add-extension [OPTIONS] QUIZ [USERS]...

Options

--days <days>

Day to set for the extension.

--timestamp <timestamp>

Timestamp to set the extension deadline to.

--format <format>

Timestamp format - see datetime.strptime for specifications.

--force

Skip the confirmation prompt.

Arguments

QUIZ

Required argument

USERS

Optional argument(s)

7.3.1.2. change-quiz-time

Change a quiz’s ending time. If the ‘–start’ option is provided, then the start time is modified instead.

NOTE: example not provided as this function is deprecated in favor of add-course.

quizzera-admin change-quiz-time [OPTIONS] QUIZ

Options

--days <days>

Days to set for the quiz time.

--timestamp <timestamp>

Timestamp to set the quiz time to.

--format <format>

Timestamp format - see datetime.strptime for specifications.

--start

Change start time instead of end time.

--force

Skip the confirmation prompt.

Arguments

QUIZ

Required argument

7.3.1.3. clear-null-attempts

Clear the user’s null attempts on the question.

Example:

# Clear the null attempts of student_1 on question 4
$ quizzera-admin clear-null-attempts student_1 4

# Clear the null attempts of student_1 on question 4 without confirmation
$ quizzera-admin clear-null-attempts --force student_1 4
quizzera-admin clear-null-attempts [OPTIONS] USERNAME QUESTION

Options

--force

Skip the confirmation prompt.

Arguments

USERNAME

Required argument

QUESTION

Required argument

7.3.1.4. config

Display the current configuration, as well as an example time display and the information for the default course, if provided.

Example:

$ quizzera-admin config
quizzera-admin config [OPTIONS]

7.3.1.5. delete-attempt

Delete a user’s attempts by ID.

Example:

# Delete attempt 73
$ quizzera-admin delete-attempt 73

# Delete attempt 420 without confirmation
$ quizzera-admin delete-attempt --force 420
quizzera-admin delete-attempt [OPTIONS] ATTEMPT

Options

--force

Skip the confirmation prompt.

Arguments

ATTEMPT

Required argument

7.3.1.6. enroll

Enroll user(s) in a course, optionally as administrators.

Example:

# Enroll students in course 2
$ quizzera-admin enroll 2 student_1 student_2

# Enroll admins in course 2
$ quizzera-admin enroll --admin 2 admin_1 admin_2
quizzera-admin enroll [OPTIONS] COURSE [USERS]...

Options

--admin

If the user should be an admin in the course.

Arguments

COURSE

Required argument

USERS

Optional argument(s)

7.3.1.7. export

Export the grades from a course, optionally as CSV instead of the default JSON.

Example:

# Export grades for course 2.
$ quizzera-admin export 2

# Export grades for course 2 as styled JSON.
$ quizzera-admin export --style 2

# Export grades for course 2 as CSV.
$ quizzera-admin export --csv 2
quizzera-admin export [OPTIONS] COURSE

Options

--style

Style the output data.

--csv

Export the output as csv (instead of JSON).

Arguments

COURSE

Required argument

7.3.1.9. unenroll

Unenroll a user from a course.

Example:

# Unenroll a user from course 2
$ quizzera-admin unenroll 2 username

# Force unenroll a user from course 2
$ quizzera-admin unenroll --force 2 username
quizzera-admin unenroll [OPTIONS] COURSE USERNAME

Options

--force

Skip the confirmation prompt.

Arguments

COURSE

Required argument

USERNAME

Required argument