unjudge/cokapi
Cokapi provides a backend support for the c++ and Java visualization for PythonTutor
230
2015-01-24 - This is an experimental version of OPT that adds support for multiple target languages under one unified app. It relies on Node.js for the server and docker for sandboxing
To install node dependencies, run 'make deps'
This directory provides only backends. Look in ../v3/ for frontend code
Once you start up the Node.js server, then you can ping it with HTTP/HTTPS endpoints such as:
/exec_java /exec_java_jsonp
to run various language backends, passing arguments in via GET parameters. Each set of endpoints comes in a pair that returns either regular JSON data (e.g., /exec_java) or JSONP (e.g., /exec_java_jsonp) for cross-domain AJAX.
Look at variables such as JAVA_JSONP_ENDPOINT in ../v3/js/opt-frontend-common.js to see how the frontend calls the backends via JSONP using jQuery code like:
// the REAL call uses JSONP
// http://learn.jquery.com/ajax/working-with-jsonp/
assert(jsonp_endpoint);
$.ajax({
url: jsonp_endpoint,
// The name of the callback parameter, as specified by the YQL service
jsonp: "callback",
dataType: "jsonp",
data: {user_script : codeToExec,
options_json: JSON.stringify(backendOptionsObj)},
success: execCallback,
});
This repository contains all different grading containers for UNCode which are available on Docker Hub.
Not all the containers are used for UNCode, some of them where created for INGInious-containers, thus, only the ones we have developed and use are explained here.
The image below shows the hierarchy of the different containers:
The code related to this container is in the main repository. This container contains all the logic to run the submissions and send back the feedback to the student.
This container is not directly in charge of evaluating a student's submission, it contains code that all the other
containers use to evaluate the submission in the correct environment. The code is in grading/uncode
. This container
also contains the translations for different grading containers
This container is in charge of evaluating C/C++, Java 7/8 and Python3 submissions as well as custom input executions.
Here are accepted either single code submission or file project submissions. The code is in grading/multilang
.
As this container inherits from the multilang container, it does not add any different way to evaluate the submission,
the difference of this container is that it allows submission that uses python modules commonly used in data science,
such as Pandas, Numpy, among others. The Dockerfile
is in grading/data_science
.
Container in charge of grading notebook submissions, for that, it receives a .ipynb
file with the student's code. Thus,
this is a different grading environment which can be selected in the task settings on UNCode. The code is located in
grading/notebook
.
Submissions with Verilog and VHDL code are graded inside this container. The code is in grading/hdl
.
Each mentioned grading environment is developed with Python (with pip) 3.5+.
To build a container to test changes, run the next command:
docker build -t <container_tag> ./grading/<container_path>
In order to facilitate testing, development and deployment, there are several different ways to build and manage the images on this repository.
If you want to clean build an image (deleting the image if it exists before build) use clean-build-container.sh
./clean-build-container.sh <container-folder-name>
If you want to clean build all main images of uncode (uncode-base, multilang, hdl, notebook, data science)(deleting the images if they exists before build) use
clean-build-main-containers.sh
./clean-build-main-containers.sh
If you want to manage the images in order to manipulate the registries in DockerHub, run the following scripts:
To pull all the grading images with the specified tag (if flag -t i not passed the default tag is latest):
./pull-registry-images.sh -t <tag>
To tag all the grading images with the specified tag (if flag -t i not passed the default tag is latest):
./tag-registry-images.sh -t <tag>
To push all the grading images with the specified tag to unjudge registry on DockerHub(if flag -t i not passed the default tag is latest):
./push-registry-images.sh -t <tag>
Tests have been developed for the multilang container, in case you they have changed, you can run them as follows:
docker run -v <absolute_path_to_multilang>/grading/:/python_lib/grading \
-v <absolute_path_to_multilang>/tests/:/python_lib/tests \
ingi/inginious-c-multilang /bin/sh -c "mkdir -p /task/student; export PYTHONPATH=/python_lib:$PYTHONPATH; cd /python_lib && pip3 install pytest && pytest tests"
Where <absolute_path_to_multilang>
is the absolute path the multilang container code, for instance: /home/user/Desktop/INGInious-containers/grading/multilang
.
It must be the absolute path, otherwise it will fail to start.
It is possible to translate the messages returned from the containers. This adds support for internationalization (i18n). This is quite similar to the way it is done in the frontend.
This is done using the module gettext
which installs the function _()
in python to make it accessible in all the code, also, the messages are extracted and compiled using pybabel
.
The i18n related files per language, are located in grading/uncode/lang/
.
Note: Every time a Pull Request is done to master, an automatic check is done to verify that the i18n files are up to date.
1. Mark a message as translatable
To mark a message as translatable, use the function _("Message to translate")
, which encloses the string to translate.
2. Extract marked messages
To extract the marked messages as translatable from the files, run the next command.
pybabel extract -o messages.pot .
3. Update messages
To update the messages files for each language, run the next command. After that, you can add translate the messages in the language you want to translate in grading/uncode/lang/
.
pybabel update -i messages.pot -d grading/uncode/lang/
4. Compile messages
Finally, the messages need to be compiled to correctly load the translations, run the next command:
pybabel compile -d grading/uncode/lang/
For additional documentation, please refer to the Wiki.
See the UNCode GitHub Project for a list of proposed features for UNCode, known issues and how they are being tackled.
Go to CONTRIBUTING to see the guidelines and how to start contributing to UNCode.
Distributed under the AGPL-3.0 License. See LICENSE for more information.
In case of technical questions, please use the gitter communication channel.
In case you want to host your course on our deployment, email us on: uncode_fibog@unal.edu.co
UNCode: https://uncode.unal.edu.co
Project page: https://juezun.github.io/
docker pull unjudge/cokapi