This feature is available as an add-on. Please contact our Support team for more information.
This add-on allows participants to compile and run live code within the code editor in Ans. To enable the code editor for participants, follow the steps below.
- Navigate to your assignment.
- Click the -icon at the top of the Editor panel.
- Check Run code in the Tools section.
- Click Update.
Please note that the output of the code will only be shown when the print statement is used. See the image below with an example.
Which languages can students run?
Four coding language can be executed from within Ans: Python, R, Ruby and Haskell.
Which libraries can students use?
Each language comes with its official standard distribution, and nothing beyond it:
-
Python 3.12
The complete standard library, plus pytest for grading. -
R 4.6
R's base and recommended packages, including MASS, Matrix, survival, mgcv, lattice, boot, cluster, class, nnet and rpart, and the built-in datasets. -
Ruby 3.4
The standard library, including json, csv, matrix, prime, bigdecimal and minitest. -
Haskell (GHC 9)
The packages included with the compiler, such as containers, text, bytestring, mtl, transformers and parsec.
Additional libraries cannot be installed. When you design a question, check that your model answer uses only the standard library. The following libraries are not available:
- Numpy
- Pandas
- Matplotlib
- Scipy
- The tidyverse
- Ggplot2
- Rails
- Hackage
How complex can the code be?
There is no limit on the length or sophistication of the code itself. Students can use every feature of the language: classes, recursion, higher-order functions, custom data structures. What matters is the form the exercise takes.
A code question works well when the answer is a single, self-contained file that finishes immediately.
What is not possible
-
No internet access
Code cannot download data, call an API or install packages. -
No saving files
Code cannot write to disk, so it cannot export results or save a plot. -
No input while running
There is no console to type into, so avoid questions that ask students to read input. Give values in the starter code instead. -
No multi-file answers
Everything must be in the one editor. -
No attached data files
Include any data the exercise needs directly in the question or the starter code.
Time and memory
Each run has about five seconds and 1 GB of memory. That is ample for exercises and algorithms, and too little for large simulations or machine learning. If a student sees a timeout message, their code ran too long. This could be because of an infinite loop or code waiting for input that never arrives.
Privacy and isolation
Every run happens in a fresh, isolated environment that is discarded afterwards. Nothing carries over between runs, and no student can see or affect another student's code.
To maintain the integrity of digital tests, internet access is disabled when running code. Any attempt to connect to external resources, such as websites, is blocked. This restriction is in place to ensure that students do not access unauthorised information during their digital test.
Comments
0 comments
Article is closed for comments.