-
Notifications
You must be signed in to change notification settings - Fork 7
How to add a new subproblem for a task
Adding a new subproblem to UNCode is quite easy using plugins, a subproblem can be seen as a additional configuration for the task, on UNCode we used to add the option to submit multiple language submissions either in code or file, and notebook submissions. For this, please do the changes inside the multilang
plugin, as this plugin is in charge to add this new subproblems.
See the INGInious documentation to understand how you can do this. Also see the multilang
plugin where the subproblems are added.
In the common package (inginious.common) is located the tasks_problems
Which contains the classes for every kind of subproblem that is possible to add in a specific task, the you will find the next classes you can use to inherit from:
Problem
CodeProblem
CodeSingleLineProblem
FileProblem
MultipleChoiceProblem
MatchProblem
For the case of multilang
plugin, we have added the CodeMultipleLanguagesProblem
class that inherits from CodeProblem
, this class will handle the objects of our desired new subproblem. This is show in the next image:
Define a new type of subproblem overriding the method get_type
, where for this example the type is called code_multiple_languages
. Thus, submissions will have this new label and we can identify a submission to this type.
If you need to add some feature in the frontend that a student should see, as well as the professor, it’s necessary to continue and add some more things to the code. As there is a set of classes to control the type of subproblems objects, there are some classes that control the functioning of the interface of those type of subproblems. Those classes are allocated in the file inginious/frontend/common/task_problems.py
.
Actually, these classes render the html file that will be showed to the user. It must extend from the class previously created class (CodeMultipleLanguagesProblem
) and from some of the Displayable classes defined in this file, for this case, DisplayableCodeProblem
for the case of multilang
plugin.
Some methods most be override to add the new functionality: get_renderer
, get_type_name
, show_editbox
, show_input
. In this methods you have to use the TemplateHelper
to add the corresponding templates that will be shown to either the student or the instructor. For that, add two templates, on corresponding to the edit and other the one students see.
The frontend and control of the actions in the frontend are mostly done in inginious/frontend/static/js/studio.js
. Thus, a static js file must be added in the plugin to do something similar, to control the added templates.
-
studio_init_template_<subproblem_type>
, this function must start with the prefixstudio_init_template_
followed by the subproblem type, which in this example iscode_multiple_languages
. Thus the name of the function will bestudio_init_template_code_multiple_languages
. Inside this function, the type of the correct subproblem type is updated in frontend. This function is automatically called by the functionstudio_init_template
in the filestudio.js
. - (optional)
load_input_<subproblem_type>
: this function must start with the prefixload_input_
followed by the subproblem type, which in this example iscode_multiple_languages
. Thus, the name of the function will beload_input_template_code_multiple_languages
. This function is in charge of loading previous submissions selected in the submission history of the task. This function is automatically called by the functionload_input
in the fileinginious/frontend/static/js/task.js
.
After adding these functions, your subproblem type should be now working and you should be able to submit new type of tasks.
UNCode - Distributed and maintained by the Universidad Nacional de Colombia, Campus Bogotá.
Visit the UNCode web page.
Visit UNCode.
- Home
- User's Documentation
- Developer's Documentation
- Deploy UNCode
- Others