A REST API that provides access to the evaluation backend by clients.
The web API requires a PHP runtime version at least 7. Which one depends on
actual configuration, there is a choice between mod_php inside Apache,
php-fpm with Apache or Nginx proxy or running it as standalone uWSGI script.
It is common that there are some PHP extensions, that have to be installed on
the system. Namely ZeroMQ binding (php-zmq
package or similar), MySQL module
(php-mysqlnd
package) and ldap extension module for CAS authentication
(php-ldap
package). Make sure that the extensions are loaded in your php.ini
file (/etc/php.ini
or files in /etc/php.d/
).
The API depends on some other projects and libraries. For managing them
Composer is used. It can be installed from system
repositories or downloaded from the website, where detailed instructions are as
well. Composer reads composer.json
file in the project root and installs
dependencies to the vendor/
subdirectory.
- Clone the git repository
- Run
composer install
- Create a database and fill in the access information in
app/config/config.local.neon
(for an example, seeapp/config/config.local.neon.example
) - Setup the database schema by running
php www/index.php migrations:migrate
- Fill database with initial values by running
php www/index.php db:fill init
, after this database will contain:- Instance with administrator registered as local account with credentials username:
admin@admin.com
, password:admin
- Runtime environments which ReCodEx can handle
- Default single hardware group which might be used for workers
- Pipelines for runtime environments which can be used when building exercises
- Instance with administrator registered as local account with credentials username:
The API can be configured in config.neon
and config.local.neon
files in
app/config
directory of the API project source tree. The first file is
predefined by authors and should not be modified. The second one is not present
and could be created by copying config.local.neon.example
template in the
config directory. Local configuration have higher precedence, so it will
override default values from config.neon
.
Descriptions of particular config items are managed in static global config file in form of comments. Global config.neon
should never be changed, local changes should be made to config.local.neon
.
The simplest way to get started is to start the built-in PHP server in the root directory of your project:
php -S localhost:4000 -t www
Then visit http://localhost:4000
in your browser to see the welcome page.
For Apache or Nginx, setup a virtual host to point to the www/
directory of the project and you should be ready to go.
It is critical that whole app/
, log/
and temp/
directories are not accessible directly via a web browser. See security warning. Also it is highly recommended to set up a HTTPS certificate for public access to the
API.
In case of any issues first remove the Nette cache directory temp/cache/
and
try again. This solves most of the errors. If it does not help, examine API logs
from log/
directory of the API source or logs of your webserver.
The tests require sqlite3
to be installed and accessible through $PATH.
Run them with the following command (feel free to adjust the path to php.ini):
php vendor/bin/tester -c /etc/php/php.ini tests
The ReCodEx API requires some commands to be run periodically to allow sending notifications of assignment deadlines and cleaning up uploaded files. The recommended way of ensuring this is using a crontab like this:
04 00 * * * php www/index.php notifications:assignment-deadlines "1 day"
02 00 * * * php www/index.php db:cleanup:uploads
Adminer is full-featured database management tool written in PHP and it is part of this Sandbox.
To use it, browse to the subdirectory /adminer
in your project root (i.e. http://localhost:4000/adminer
).
Feel free to read the documentation on our wiki.
- ReCodEx REST API: MIT License
- Nette: New BSD License or GPL 2.0 or 3.0
- Adminer: Apache License 2.0 or GPL 2