Moodle plugins directory: VPL Question | Moodle.org
![Logo](https://moodle.org/pluginfile.php/50/local_plugins/plugin_logo/2391/icon.png?preview=thumb)
VPL Question
VPL Question type
Version: 2.0.0 (April 2024)
Authors:
- Astor Bizard
- Florent Paccalet (legacy version).
This software is part of the Caseine project.
This software was developped with the support of the following organizations:
- Université Grenoble Alpes
- Institut Polytechnique de Grenoble
Introduction
VPL Questions are questions that can fit within a Moodle quiz. They are intended to create small to medium coding exercises, based on the Virtual Programming Lab plugin.
They are designed to offer a simple interface for students, while keeping the power and versatility of Virtual Programming Labs.
VPL Questions Architecture
A picture is worth a thousand words, so here is how it works (you can also read the thousand words right below the picture!):
A VPL Question is (as its name says) based on a VPL (Virtual Programming Lab).
The execution and evaluation of the question takes place inside that VPL, which allows powerful customizations.
A single VPL can be used for several questions, as long
as it is located in the same course.
In order to execute and evaluate student's code in the VPL, the question sends that code (injected within the required file, at the place of the {{ANSWER}} tag) in a new VPL submission. The submission also includes question-specific execution
files. The VPL then replaces its own execution files by the ones present in the submission.
This is what allows several questions to be based on the same VPL: as the execution files are question-specific, different execution behaviors (e.g. different
test cases) can be achieved on the same VPL. However, this can not be achieved for standard execution scripts.
Create a VPL Question
Step 1: Create a dedicated VPL
The first step to create a VPL Question is to create the VPL it will be using.
To do so, simply create a new VPL inside your course.
It is (strongly) recommended to create it inside a hidden section of the course, and make it available. The goal
is to hide it from students, while still allowing them to make submissions to it.
When the VPL is created, there are a few settings you will have to change before it can be used:
- Edit settings > Submission period: It is recommended to disable the deadline (Due date).
- Edit settings > Submission restrictions: Set the Maximum number of files to a large enough number, as submissions will include execution files.
- Edit settings > Common module settings: If you put the VPL inside a hidden section, make sure the Availability is set to Available but not shown on course page.
- Execution options > Common module settings: Set Run, Evaluate and Automatic grade to Yes.
- Execution files: Create a file named pre_vpl_run.sh, and paste the following code in it (this is the code that deals with submitted execution files):
for qvplfile in `ls -1`
do
file=${qvplfile%_qvpl}
test "$qvplfile" != "$file" && mv "$qvplfile" "$file"
done
- Required files: Create one (and only one) required file. You can write some basic code in it (like class declaration in java, an empty main function, ...).
You can also edit/add execution files. Please note that:
- Standard execution scripts will not be editable per-question. Please edit them from the VPL.
- Other execution files will be editable per-question. However, please create them first in the VPL (you won't be able to create them from a question).
IMPORTANT: Students submissions on this VPL will be discarded by the VPL Question (this behavior can be changed by an administrator in this plugin settings). This is why it is important to create a dedicated VPL (and not to use a VPL where students may want to retrieve their previous submissions).
Step 2: Create one or more VPL Questions
Once a dedicated is created by following the instructions above, you are now ready to create your VPL Questions !
To do so, create a question either from a Quiz or a Question bank, and select VPL Question:
Let's breakdown what you can do in the question editing form:
- General: You fill find here all standard settings for a question, like question name and description.
- VPL Question template: Here you can select the VPL you created earlier. This will allow you to edit the required file. Please make sure that it includes the {{ANSWER}} tag: this is where the student's code will be injected. Also, please note:
- Answer template: Here you can edit what will be pre-filled in the student's answer box. It can be left empty.
-
Teacher correction: Please write here your correction for the question. This is what will be used as the "Correct answer" for Quiz feedback.
If Validate is checked, the provided answer will be checked against test cases upon question save. This is very useful to check everything is working fine on VPL side, and that both your correction and your tests are correct. -
Execution files and evaluate settings: This is where you can edit the execution and evaluation behavior of the question. Once again, all modifications done here will only affect the current question.
- You can edit execution files (most commonly vpl_evaluate.cases). If there is an execution file that you created in the VPL but you do not need in this question, write UNUSED at the beginning of the file: it will be ignored.
Note: Execution files are only sent to the VPL upon question evaluation. If you need them during execution (Run), please set them as Files to keep when running in the VPL. - You can also change the behavior of the Pre-check button (make it act as the Debug button on the VPL, use the execution files above, or use other files). In the last case, you will be able to edit another set of execution files, this time specific to the Pre-check button.
- You can finally decide whether students need to achieve perfect VPL grade to get the question correct, or use relative VPL grade to get a proportional note on the question.
- You can edit execution files (most commonly vpl_evaluate.cases). If there is an execution file that you created in the VPL but you do not need in this question, write UNUSED at the beginning of the file: it will be ignored.
Known issues
-
Test cases hacking
Test cases, along with other execution files specific to a question, are sent to the VPL as submission files. Even if the VPL is hidden, it has to be available to students so that they can submit to it. This leads to a possibility for students to find access to the VPL, thus to the execution files they submitted. Please be aware of that possibility - what you decide to do about it is up to you.
This plugin should be compatible with version 4.2, even though I have not tested it yet.
in June 2020, Andreas Siebel pointed out "When I copy or clone a course with vp_questions, all questions will be invalid, because the id of the VPL activity has changed." You provided a fix in version 1.3.0 which allows changing the VPL of a VPL question after the import.
In my moodle course, I have roughly 100 VPL questions in which I must fix the VPL after the import / clone into a new course, which costs a lot of time an is error-prone. Over the years, many more VPL questions may be added to the repository and thus the time needed to fix the referenced VPL for each question will continuously increase. To make the situation worse, there may exist more than one VPL used in VPL questions which makes it difficult to choose the right VPL when editing a VPL question after the import / clone.
Would it be feasible to store not only the id of the referenced VPL in a VPL question but additionally the name of that VPL (only internally, not user-editable)? Then, during the processing of a question, if the referenced VPL could not be found based on its stored id, it could be searched based upon the internally stored name (which needed to be unique in the course) and maybe the id could also be updated along with it.
Alternatively, maybe we could have some button or menu entry to launch an update process after the import which tries to update the referenced VPL in VPL questions based upon the mechanism described above?
What do you think about it?
Thanks for the great work!
Kay
This is a nice idea!
VPL Questions have always had a problem when it came to copying.
I will think about these suggestions, it seems feasible
Best regards
Astor
VPL Question 1.7.0 indeed seems to fix the import problem. In my initial tests, the referenced VPL still was found in the imported questions. Unfortunately, the latest VPL plugin (Version 4.2) seems to produce some problems. In the preferences of a VPL question, under the section "Execution files and evaluate settings" everything is empty, though the referenced VPL is correctly chosen. Run and Pre-check do also not work. This happens only with VPL Plugin Version 4.2. Maybe, there is some fundamental change in Version 4.2 that needs an adjustment in the VPL Question plugin?
Thanks again for all the work you put in it.
Best regards
Kay
I will work on this as soon as possible.
In the meantime, I will put a notice in the plugin description and declare it not compatible with Moodle 4.2.
The compatibility issue with VPL v4.2.0 for Moodle 4.2 should be fixed by the latest release.
Best regards,
Astor
thank you for the quick fix. Unfortunately, on our site we use Moodle 4.1.5+ together with VPL 4.2.0. Would it be possible to have a fix for such a combination, too? If I understand it correctly, the latest release of VPL Question Plugin is only compatible with Moodle 4.2?
Best regards
Kay
I thought VPL v4.2.0 was only for Moodle 4.2, hence the confusion.
You can use VPL Question 1.8.0 on Moodle 4.1, as long as the VPL is v4.2.0 onward
Thank you for the notice, I will clarify the release accordingly.
Astor
I want to make sure that the Java GUI and HTML programs are compatible with the VPL Question plugin.
And if you can provide me with steps for successful running them in my Moodle VPL Question quiz.
VPL Questions are only compatible with console executions. If you need GUI, using a VPL activity might better suit your needs.
Best regards,
Astor
I have a problem with the latest version (1.9.0- for VPL up to v4.1 - 2024030701). (This was offered to me by the system as a new version).
After the installation I have no visible information in the section "execution files an evaluate settings" in the questions.
The questions cannot be executed with a visible result.
When I install the latest version everything works again. (1.8.1 for VPL 4.2 - 2023100301) The information in the section is also still available.
If your VPL is on version 4.2 or above, the latest version that you need is 1.9.0 for VPL 4.2+ (2024030700), as the name indicates
Best regards,
Astor
Unfortunately it still doesn't work for me.
A brief explanation. My system:
Moodle: 4.1.9+ (Build: 20240315)
VPL: 4.2.3 (2024011312)
VPL Question: 1.8.1 for VPL 4.2 (2023100301)
In the update overview, the following is displayed as new for the question type of this version: 1.9.0- for VPL up to v4.1
If I install the version "1.9.0 for VPL 4.2+ (2024030700)" manually, I am still shown that this version is newer: 1.9.0- for VPL up to v4.1
The problem with the display also reappears with the manually installed version.
When I look at the version requirements, I am a little surprised:
1.8.1 for VPL 4.2 (2023100301) > $plugin->requires = 2022041900; // Moodle 4.0.
1.9.0 for VPL 4.2+ (2024030700) > $plugin->requires = 2018051700; // Moodle 3.5.
I understand that the plugin versions management can be confusing, especially to users.
Given your current version, the latest compatible version of VPL Questions is "1.9.0 for VPL 4.2+ (2024030700)".
You see the "1.9.0- for VPL up to v4.1" as newer because its version number is higher than the latter.
Why is it so?
Well, Moodle store won't allow several versions to have the same version number.
So, I have to upload two versions with different version numbers, one of which will always be higher.
The version requirements are declarative minimal compatible version, which does not seem up-to-date ; I will fix it in the next upload.
My main concern about Moodle versions was also about Moodle store: I wanted both versions to show up for users, and the only way to do so was to declare that they support different Moodle versions.
Now, to sum it up for your usage:
Installing version "1.9.0 for VPL 4.2+ (2024030700)" will give you the latest version compatible with your system.
I hope this makes it a little clearer!
Best regards,
Astor