I'm new to Moodle so I'm not sure if anything I'll be saying below will make any sense or already exists! I need to create a plugin for Moodle where the student will be able to upload their piece of work and subsequently receive automatic feedback on that submission (my code will be executed in the background to provide the automated feedback to the student). I will also need to be able to design a basic form (UI). Could anyone give me any advice of how I could accomplish this task?
Create plugin for student submissions
Number of replies: 57Re: Create plugin for student submissions
Well, there are several systems already in place in Moodle, but it depends what the piece of work is and what kind of 'automatic feedback' you require.
Students can submit an assignment and get a message in response to confirm the submission
Or students can take a quiz, with a wide variety of question formats, many of which provide some degree of instant marking and feedback.
However, there is no system that I am aware of that will take something like an Essay submission and give meaningful feedback around the quality of work and how it answers the question, that would require some fairly complex AI.
If you do need to develop something a bit different to those then those are probably the starting points to look at - Quiz question types, and the Assign module - that has submission and feedback plugins that you could take a look at to see how they work and how they hook into the main systems, but it was built in a way to accept new plugins for specific purposes.
Richard
Re: Create plugin for student submissions
Thanks for your message Richard. The system I want to implement is one that automatically marks student's programming code. They will submit a file containing their code then my system will automatically mark it by executing unit tests. The student will access a section under the specific course where they can submit their code. How would I implememt a plugin for this sort of task? Could you suggest how I would create this plugin on Moodle? I'm finding it difficult to find any resources on the web to help with creating a plugin.
Re: Create plugin for student submissions
Check out the Virtual Programming Lab plugin. I think it already does what you want. See it here: https://moodle.org/plugins/mod_vpl
Re: Create plugin for student submissions
Hi there, thank you for that suggestion. I've tried installing that plugin but it won't complete as Moodle keeps complaining that other plugins are partially installed (even though I'm using a new fresh version of Moodle!). How exactly does the evaluation (testing) of student's code work in the plugin? How would the lecturer tell the system what is right or wrong about the student's code?
Re: Create plugin for student submissions
Hi, me again! Could you or anyone else explain to me how I would create a plugin for my Moodle application? I understand that the plugin you suggested is very similar to what I require but I'd like to know how I'd create a plugin for this or any other scenario in the future..
Re: Create plugin for student submissions
It depends what type of plugin you are wanting to create - start here: https://docs.moodle.org/dev/Plugin_types and click on the link for the particular plugin type you want to create.
Re: Create plugin for student submissions
I've had a look through the list and the 'Assign submission plugins' would be most relevant for me. How would I go ahead and being creating a form/plugin to be displayed under a specific course that would allow submissions, provide feedback and other specific features..?
Apologies if my explanations sound rather stupid as I'm completely new to Moodle!
Re: Create plugin for student submissions
How do you mean by "under a course", or do you mean within a course.
Copy the folder with an existing assignment submission plugin (under mod/assign/submission) such as file, paste it and rename everything to match the name you want to use. Tweak it until most/all errors go away then work on the functionality.
We love questions, without questions people learn very little. However much of the trick to getting good answers is to keep the topic narrow and with plenty of details.
Marcus
Re: Create plugin for student submissions
Hi Marcus, ok so I shouldn't just start from scratch? how would this page be of help to me? (https://docs.moodle.org/dev/Assign_submission_plugins). I'm just so confused by all of this at the moment :S my end goal is to create a form that students can submit their programming code exercises then immediately receiving automated feedback which they can view on the form. I will code the automated feedback aspect myself so I'd need to incorporate that in the plugin too. The marking of the student's code will be done via automated unit tests which I would setup for each exercise. Hope that made any sense at all.. I'm just so confused with Moodle right now lol
Re: Create plugin for student submissions
That page looks really useful for what you are doing. There are arguments for and against starting from scratch. In the past I have found I modify an existing item, then I get frustrated with all the unnecessary stuff and start again from scratch. What would be useful is a set of template plugins that contain the bare minimumfeatures. There is an example of this for question types and I am currently building on a clone of it to include more details.
Original
https://github.com/jamiepratt/moodle-qtype_TEMPLATE
Expanded version (work in progress)
https://github.com/marcusgreen/moodle-qtype_TEMPLATE
Have you seen this?
https://github.com/trampgeek/moodle-qtype_coderunner
Re: Create plugin for student submissions
Thank you for your detailed replies Marcus, very informative. Would you mind showing me the steps of actually installing a basic plugin that would allow me to go and edit to make more specific to what I want..? I'm just very confused with how these plugins work in Moodle :S I'd be very grateful if you could show the steps so that I have something to work off.
Re: Create plugin for student submissions
I'm not sure I understand your question, do you mean you want to know how you would install a plugin to Moodle once it was created? If so this should help
https://docs.moodle.org/31/en/Installing_plugins
As a developer you can ignore the heading
Installing directly from the Moodle plugins directory
Essentially so long as the file names are correct and you put it in the right place in the folder structure all you have to do is click on the notifications menu in admin and say yes to whatever comes up.
If you have a go at installing and tweaking my gapfill question type it is what I know the most about, but any plugin will do. You could look at the 3rd party Mahara assignment plugin type as an example as well.
Re: Create plugin for student submissions
Sorry for my lack of clarity! :/ I've just downloaded and extracted the VPL plugin (as I'm quite interested to learn more about due to it being similar to the plugin I want to develop). I pasted the folder into the mod directory, then went into Notifications but nothing is said about it! I followed the installation link you provided.. have I done something wrong?
Re: Create plugin for student submissions
Ahh yes, I did that a few times when I was first working on plugins. You might find the reason explained somewhere in here
(or you might give up with all that complexity).
You need to ensure that the folder matches the expectations so that one should probably be in a folder simply called vpl. Make sure the actual code is under that (you might find it is in a folder underneath the one you can see depending on how it was wrapped or extracted). Post when you have done that.
MG
Re: Create plugin for student submissions
Thanks Marcus, I pasted the folder into the mod directory, re-named it to vpl and it worked!! Thank you so much. Only thing is now.. I'd like to create a plugin from scratch myself.. a very simply one to begin with so I can build on top of it.
Re: Create plugin for student submissions
Re: Create plugin for student submissions
Thanks Luis, maybe I should have been more specific in my question but I'd like this plugin to be able to be added as a resource or activity (i.e. the teacher clicking 'Add an activity or resource' with the option of my plugin appearing..). Would NEWMODULE allow this?
Re: Create plugin for student submissions
Yes, NEWMODULE is a template for just that.
Re: Create plugin for student submissions
it all makes sense to me, thanks so much for your help. Only thing is.. I followed the 7 steps in the link you gave me https://docs.moodle.org/dev/NEWMODULE_Tutorial but when I went into Notifications to install this plugin I get the following errors:
Do you know what could be causing the issue?
Re: Create plugin for student submissions
Well that error message suggests there's something wrong with the newmodule version.php file. Maybe a typo?
What have you got in version.php?
Re: Create plugin for student submissions
This is the contents of the version.php file:
$module->version = 2007040200; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
i got the whole zip file (project) from this link -> https://docs.moodle.org/dev/NEWMODULE_Documentation (NEWMOODLE.ZIP)
Re: Create plugin for student submissions
It should be:
$plugin->version = ...;
Not $module->version
The newmodule.zip file that you downloaded from that page is really ancient - it's for Moodle 1.9, which is older than the dinosaurs. It won't work in Moodle 3.x
Instead you should use the newmodule code from GitHub: https://github.com/moodlehq/moodle-mod_newmodule.
Download that version and read the readme.txt file. It explains how to rename and use it.
https://docs.moodle.org/dev/Activity_modules might also help...
Re: Create plugin for student submissions
trying out that newer code from GitHub now , confused about one thing though.. it says:
* Go to Settings > Site Administration > Development > XMLDB editor
and modify the module's tables.
Make sure, that the web server has write-access to the db/ folder.
You need at least one table, even if your module doesn't use it.
what does that actually mean? and what would I have to do?
Also, this point too....
* Modify version.php and set the initial version of you module.
I'm guessing just set it as something like 1?
Re: Create plugin for student submissions
But before you do that you need to work out what data your module is going to need to store in your Moodle database.
Your previous post said that: "students can submit their programming code exercises then immediately receiving automated feedback which they can view on the form". So you're probably going to need to store the code exercises that they submit somewhere. How are they going to submit the code? Are you going to give them a text box where they type the code and then you grade it when they submit it? If you do that then you need to store their submissions. So you need to create a table for that. You'll need to decide what goes in that table too: e.g. you'll store the actual submission (the code they submit) and you'll need the student id (mdl_user.id) for each submission as a foreign key so that you can identify which code submission belongs to which student. What else? Perhaps the submission date too?
You said that you will provide automated feedback so you also need to define what that feedback is and you need to store it somewhere. Then you need to define the rules that will determine what feedback to give. You need to store those rules somewhere. You'll probably need more tables for that...
But programming languages and practices change constantly. So what you are teaching today will probably change in a year or two. So you need to be able to change the above rules in your plugin. That suggests that you should not hard-code them in your plugin. Instead the plugin might need a "rules" interface where you can store your rules without having to modify your plugin code each time your programming course changes.
If I've got the right picture this is starting to look like a rather big project! So I would first sit down with a pen and paper and first work out the user interface that would make this work. You are going to have to find a way to read the code that students submit. Then you have to interpret their code. Then you have to apply the rules to determine if they've written the right code. Then you have to decide how to grade their submissions... Then you have to calculate the correct feedback response. Then you have to store their grade and the feedback obtained somewhere (the gradebook perhaps). So it's a lot of work.
Once you've written your spec and decided on your initial user interface take some time to read through the Moodle Developer documentation on https://docs.moodle.org/dev/Main_Page so that you can get familiar with how the Moodle code is structured and all the different API's that Moodle exposes to developers. You are probably going to need to use some of those API's in your code.
Re: Create plugin for student submissions
Thanks Luis for your detailed and very helpful response. Very much appreciate your time in helping me. About the XMLDB editor.. I stated the version number in the version.php file and my plugin was successfully installed! I haven't stated which tables I need yet.. so I have to declare all the tables and relationships I'll have in that file?
You're right about it being quite a big project to do..but I'm breaking it up in small segments so the first thing I will be trying to do is getting the UI implemented. If I'd like the ability for a student to upload a file (submission), how would I do that in my plugin? can I use the in-built submission features that come with Moodle? i.e. file upload, feedback boxes etc.. could you advise how I would accomplish this?
Re: Create plugin for student submissions
Yes, you describe your tables in the install.xml file. When you install the module Moodle uses that .xml file to create the tables in your Moodle database.
So when you are ready to add some tables to your module update the install.xml file with all the table details. Then you need to reinstall the module by increasing the version number in your version.php file:
So, change:
$plugin->version = 2016061200;
to:
$plugin->version = 2016061201;
Save the version.php file and then go to the Moodle Notifications page. Moodle will detect the new version number for your module and it will reinstall the module. Your new database tables will then be created during the reinstall.
Note: the plugin version numbering is usually a date stamp. See https://docs.moodle.org/dev/version.php for an explanation.
Re: Create plugin for student submissions
https://docs.moodle.org/dev/Form_API
https://docs.moodle.org/dev/lib/formslib.php
Re: Create plugin for student submissions
Also, this point too....
* Modify version.php and set the initial version of you module.
I'm guessing just set it as something like 1?
Yes, that would work. But the 1.0 (major_version.minor_version) format might be better so that you can keep track of major and minor releases. Perhaps read through the https://docs.moodle.org/dev/Moodle_versions document to get an understanding of how the Moodle versioning works.And then it's always good to look through the Moodle forums to see what other people have done and have questioned. You sometimes find very useful discussions like:
https://moodle.org/mod/forum/discuss.php?d=318866
https://moodle.org/mod/forum/discuss.php?d=264988
Re: Create plugin for student submissions
I forgot to mention Justin Hunt's version of the mod_newmodule template. It has a few extra improvements to the moodlehq version.
Re: Create plugin for student submissions
Would I be right in saying that the plugin I'm trying to create is a 'Local Plugin' as I only want to use it offline at the moment...
Re: Create plugin for student submissions
Local plugins aren't for "offline" usage. By "offline" I presume you mean "localhost", or not on your production server.
See https://docs.moodle.org/dev/Local_plugins
"Local plugins are used in cases when no standard Moodle plugin fits. Wherever possible, customisations should be written using one of the standard plug-in points like modules, blocks, auth plugins, themes, etc."
Re: Create plugin for student submissions
Sorry Marcus for spamming you with messages, should I find a plugin that does closely what I want and then start editing it? To be honest with you, the in-built Assignment plugin does most closely what I want.. is there a way I can duplicate that and make my own plugin from it?
Re: Create plugin for student submissions
If the existing Assignment module does mostly what you want then yes, it's a good idea to use it as a base for your plugin. Much easier and faster than creating a new one from scratch. Why reinvent the wheel?
First make a copy of the \mod\assign folder and rename it, example: \mod\coding (or whatever you decide to call it).
Then you need to carefully go through all the code in \mod\coding and rename all instances of "assign" to "coding". That will include the code but also some FILE names and FOLDER names.
Pay special attention to the \mod\coding\db\install.xml file. That file will define which database tables need to be created for your version of the module.
Give it a new version number ($module->version in version.php), e.g. 1.0.
Once you've finished with all the renaming install the new plugin and test it thoroughly. Once it's installed and working correctly you can start making your changes.
Re: Create plugin for student submissions
Ok, so I can't just use that existing \mod\assign folder for my plugin? so my mod directory will have both assign and coding folders for example? Is this because the changes I'll make wouldn't effect the main assignment (submission) of the site? Also, you refer to this module as a 'plugin'.. so I'd have both my main plugin and also this 'coding' plugin too?
Re: Create plugin for student submissions
Sorry I sometimes use the terms "module" and "plugin" interchangeably. They are the same thing.
I would not use the existing \mod\assign folder for your new plugin. That Assignment module (\mod\assign) is a core plugin and you should never modify Moodle core code. It makes it more difficult to upgrade Moodle in the future.
You should make a copy of the \mod\assign folder and then make your changes in that folder, as I described. This way the main Assignment module will not be affected. You will then have both modules and you can use both modules in your courses. So you can then add both an Assignment activity to your course and a Coding activity.
Re: Create plugin for student submissions
Thanks for all your replies, I'm not sure if I've confused myself here somewhere but here's the steps I've made so far:
- I've left the install.xml file be so that it creates the tables already defined (will obviously edit later).
- I've changed the version number in version.php from 2016052300 to 2016052301.
- I went into Site Administration -> Notifications and got an error that my original plugin (the main plugin that I've named codetests) already had higher version installed
- So I changed its version number also to 2016052301 from 1 (I specified it as 1 before you mentioned that it was incorrect)
- I then went back into Notifications and could now click Upgrade Moodle database but now getting these errors:
Re: Create plugin for student submissions
Well the section headed 'Debug info' tells you exactly what is wrong 'Missing mandatory en language pack'.
Like every other plugin you will find in Moodle, you need to make sure you include the English language strings that your plugin will use.
Make a file called mod/coding/lang/en/coding.php
Add the following line:
$string['pluginname'] = 'Coding activity';
(There are a few other language strings you will need, but this will, at least, get the plugin installed).
Re: Create plugin for student submissions
Thanks Dave for that but I realised the problem was that I hadn't re-named the file from assign.php to coding.php Do you know what the issue could be as I've explained here https://moodle.org/mod/forum/discuss.php?d=334412#p1348397
Re: Create plugin for student submissions
Sorry I gave you the wrong info regarding the versioning numbering. You should use this naming convention:
$plugin->version = 2016061200;Explained in another post above.
Re: Create plugin for student submissions
Is it just me or there's hardly any resources/guidance online to help new developers? I've been trying to fix the issue I'm having now and ones I've had before and there just isn't anything online to help me fix them
Re: Create plugin for student submissions
There are actually a lot of resources for developers. Ok, perhaps it's the volume of information that is a bit overwhelming for new developers. It does take time for new developers to get familiar with Moodle. Moodle is a complex system.
Have you gone through the Moodle Developer docs - https://docs.moodle.org/dev/Main_Page ?
You can try https://dev.moodle.org/course/view.php?id=2, but it is very out of date (although there are apparently plans to update it).
If you're willing to pay, http://www.moodlebites.com/ runs two Moodle developer courses twice a year (an intro course and a more advanced course).
Re: Create plugin for student submissions
Yes I think you're right about that, it definitely does feel overwhelming with all of the information out there! Hard to see what's actually relevant! Do you happen to know what could be the issue with the reply I mentioned about the errors when installing the 'coding' plugin?
Re: Create plugin for student submissions
Moodle is largely a co-operative development dependent on feedback from users. You have clearly learned a great deal in a short amount of time about Moodle development and so I reccomend you document that by adding to the Moodle development Wiki (something anyone can do).
https://docs.moodle.org/dev/Main_Page
It is often much easier to write about development when the problems are fresh in your own mind. I have done odd updates over the years
https://docs.moodle.org/dev/Special:Contributions/Marcusgreen
and done things things like the extended question type template I referred to earlier
https://github.com/marcusgreen/moodle-qtype_TEMPLATE
And documenting the database structure
As a by product of this documenting it will probably make the issues clearer in your own mind and make available a full description of the edge of your knowledge to allow other people to fill in the gaps.
Re: Create plugin for student submissions
I will certainly do so, I have been keeping note of everything I have been doing up-to-date. Thank you for mentioning that.
Re: Create plugin for student submissions
I've made some progress.. I forgot to rename the files in the backup and lang folders.. (not sure if there are any others too rename) I did that and it seemed to have installed the plugin correctly but when I clicked Continue after Upgrade Moodle Database I just got a blank white page. So I went into the course and could see that the option of the new plugin was there (Under Add an activity or resource) but when clicking Add it just brought up a blank white screen
Re: Create plugin for student submissions
Turn the Moodle Debugging up to the Developer level (Site administration / Development / Debugging). Then you should get messages with a clues as to what is wrong.
Re: Create plugin for student submissions
I've tried to do that but when I click Site Administration, it doesn't expand and I just see this wheel continuously turning (as seen by my screenshot). I'm plagued with errors! ><
Re: Create plugin for student submissions
Thanks Luis, I upped to the Developer level and an error said that it could not find the file codingmentplugin.php. So I re-named it to codingplugin.php and managed to 'successfully' install the plugin... but as the installation was going ahead and afterwards when I went into Add an activity or resource then added my plugin I got a bunch of errors coming up on the screen. I've attached a file showing the list of errors. Can I just check with you though.. I re-named the contents of the files by using find and replace on Notepad++.. I then made a search in the coding directory for the word assign to bring up all files with the name assign.. so I thought it was only necessary to rename assign.php to coding.php (including the other mentioned above)? Have I gone about this the right way? I'm guessing not considering the errors I'm having >< Just another point.. some html aspects of the plugin are appearing weirdly, as seen in my screenshot below:
Re: Create plugin for student submissions
Moodle uses "language packs" that allow you to translate your plugin into multiple languages. Those ... "errors" that you see are missing language strings.
As Davo explained in https://moodle.org/mod/forum/discuss.php?d=334412#p1348402 you need to add those missing strings to your english language pack. It's probably the /mod/coding/lang/en/coding.php file.
So add the missing strings like this:
$string['onlinetext'] = 'your description of onlinetext';
Then go to Site administration / Development / Purge all caches and click the Purge All Caches button. When you go back to the coding activity in your course that "Submission types" section should show the correct language strings instead of the placeholders.
Re: Create plugin for student submissions
Ow bugger, I've just tried that and still no luck so I just included the line: $string['onlinetext'] = 'your description of onlinetext'; then I Purged All Caches.. Could you explain why these texts were not transferred considering a copy of the assign folder was made..? Just seems a bit odd to me really
Re: Create plugin for student submissions
It's ok! I fixed all the errors by re-naming some files with assign as part of the name to coding. Was I correct in doing that? I don't want those errors to come back and haunt me! ha
Re: Create plugin for student submissions
Yes, you need to do a global search and replace, including the .php file names.
Re: Create plugin for student submissions
Found 2 more issues :S The maximum number of uploaded files dropdown box is empty.. when I submit a Coding exercise I get the following error:
And another error to add to the mix is when I delete an activity I get the following unmeaningful pop-up:/
Re: Create plugin for student submissions
Soled - by re-naming all files containing the word assign to coding
Re: Create plugin for student submissions
Sorry Luis for being a pain but I was wondering if you had an idea of what could be wrong with this new assign ('coding') plugin
Re: Create plugin for student submissions
What error are you referring to?
Re: Create plugin for student submissions
I decided to do exactly as you said, clone an existing plugin and modify it to what I needed.. can I just check with you though.. I would just add/modify statements using the Form API such as: $mform->addElement('select', 'assignsubmission_onlinepoodll_recordertype', get_string("recordertype", "assignsubmission_onlinepoodll"), $recorderoptions);
So, the statement will add a dropdown box, show its name using the get_string and populate it by using the $recorderoptions variable?
What I don't understand by looking at the code is how to add elements to other sections in the Assignment settings? I can only see how to add elements to the Submission types section (using the onlinepoodll plugin). How would I add elements to the other sections that will be specific to my plugin?