In this section you'll see how to fetch the student input in order to perform the evaluation and provide feedback.
The task problems are identified using their problem ids, which are specified at the new problem addition. Using these problem ids, you'll either store the content of the problem field somewhere, or include it in an existing template.
The following exercise defines an additional code box with problem id
getinput API is used with problem id as argument and returns the value of the associated input field.
The following command will fetch the
studentcode problem and store the code into a
getinput studentcode > studentcode.py
The API will, by default, return the binary content of file in case of a file upload problem. Additional syntax using
problemid:value will give you explicit access to the filename as it was uploaded and binary file content. For instance, the following command will store the
studentupload problem filename inside variable
Sometimes you'll only ask students for a little piece of code which will be part of a partial implementation. You'll then need to put the student input into what is called a template file.
Problem input can be inserted easily into existing code by inserting
@[indent_chars]@problem_id@[ident_chars]@ tags into those files. For instance, the following Python template will be used to load a student implemented into an existing function:
def signature(arg1, arg2): print("Start of student code...") @ @studentcode@@ print("End of student code...")
parsetemplate API is used with a template file as argument as well as the optional
--output OUTPUTFILE argument if the output file shoud be different than the input file.
For instance, the following command will parse the
template.py file into a new
parsetemplate --output studentcode.py template.py
Let's take a tour
Use the two code and file upload inputs defined below along with the sandbox to find out in details the
parsetemplate features. Your script output will be shown in feedback.
|Author(s)||The INGInious authors|
|Submission limit||No limitation|