Problem uploading

Problem sources

Let us consider the most typical use case. A contest admin decides to upload a new problem or modify an existing one. Depending on the OIOIOI installation there could be many sources of the problem. Such a source should inherit from the ProblemSource.

The complete list of available problem sources can be specified in the deployment/settings.py file under the PROBLEM_SOURCES name. The listed problem sources will be displayed as tabs of the problem upload view, provided that their is_available() method returns True.

Developers are expected to implement their custom problem sources by inheriting from the above-mentioned class, such code should be preferably placed in a problem_sources module in a given app.

Package sources

The most basic problem source is a PackageSource. It may be used when all the data necessary for creating a problem may be uploaded in a single file.

Since every instance of PackageSource is associated with a file of some kind, the file, together with some additional data, is represented as a separate model, namely the ProblemPackage. Such a design is quite natural when combined with the unpacking manager pipeline, which is described below.

Unpacking manager

When a user uploads a problem via the PackageSource, an unpacking environment is created and passed to a new Celery task, that is to unpackmgr_job().

The above-mentioned post-upload handlers are functions, which accept an environment (a dictionary) as their only argument and return the modified environment. Before the handlers are called, the following new env keys are produced: job_id: the Celery task id problem_id`: id of the ProblemPackage instance, which was created or modified

Normally, when you add a new Problem, you want to attach it to a specific Round of a given Contest. That is why the default implementation of PackageSource specifies one post-upload handler, namely create_problem_instance().

Problem package backends

The PackageSource class defines how problem data should be uploaded by a user, which keys should be present in the unpacking environment and what should be done after the new Problem is created. However, it is not involved in the actual unpacking and processing of the uploaded file. It only chooses an appropriate ProblemPackageBackend (choose_backend()) and delegates this responsibility to it.

oioioi.problems.package

oioioi.sinolpack.package

Provides ProblemPackageBackend implementation to deal with Sinol packages - standardized archives with problem data. Sinolpack is OIOIOI standard problem package format. The detailed archive content description can be found here: https://sio2project.mimuw.edu.pl/display/DOC/Preparing+Task+Packages.