Python content type
Hi,
I might create a new content type that would help people teaching python.
Be warned, there is a high probability that I will never do it. It's just something that I need, that I started to think about it, but I am not sure I will find time to do it and if I will success.
The idea is to allow the teacher to create an activity, the student must then write some python code that will be evaluated automatically and give him points if it's the good solution.
The author UI will contain :
- A textarea (with syntax highlighting) that would allow to set the default code.
- A textarea to add instruction ? Not sure about it as you can put instruction outside of the h5p activity.
- a textarea with the solution
- a number input field that would allow to set the max score
When the student submit it code, it is executed with the skulpt library. If the output match the solution output, then the max score is awarded.
If there is error in code, the error message is displayed.
There would also be an advanced checkbox. Checking that will display more option :
- a textarea containing code to execute before the student code
- a textarea where we can create code to execute after the student code. The purpose of this code is to check if the user solution is good and to give point. Multiple function (it's possible to add custom python function to skupt that will trigger javascript) will be avaible to the author :
→ a function to get the ouput (as a unique string or as an array of string)
→ a function to display a feedback message
→ a function to set score to the user
If you have any though to share, feel free to do it.
otacke
Tue, 03/30/2021 - 17:51
Permalink
Perfect! That might allow me
Perfect! That might allow me to cross one item from my list :-) https://github.com/otacke/h5p-todo/blob/master/README.md#code-feedback
Degrange
Fri, 04/16/2021 - 01:17
Permalink
:O
:O
otacke
Fri, 04/16/2021 - 16:46
Permalink
(No subject)
serettig
Fri, 04/16/2021 - 17:09
Permalink
Awesome idea!It would be
Awesome idea!
It would be great to make this so generic, so that it's easy to also use other languages, like Java, which is often used in educational settings.
it would be even better if you could add unit tests as a teacher that must be passed, so that you can also check for edge cases or check if the answer is truly generic.
Degrange
Fri, 04/16/2021 - 17:53
Permalink
unit tests will be sort of
unit tests will be sort of possible as the author will be able to create a python script to choose the grade given.
For other language, it need something able to execute this language in javascript. For python I use skulpt. I don't know if there is such things for other language.
Degrange
Fri, 04/16/2021 - 19:11
Permalink
It progress well but there is
It progress well but there is still a lots to do :
Degrange
Sat, 04/17/2021 - 04:14
Permalink
It progress well, it can now
It progress well, it can now handle input python function !
Degrange
Tue, 04/20/2021 - 03:31
Permalink
This is going well but taking
This is going well but taking more time than I though. Didn't got time to play and half of my vacation are over.
It can now automatically grade by comparing if the output is the same.
It's almost possible to grade by using custom logic.
Lets say it's 75% done.
otacke
Tue, 04/20/2021 - 10:16
Permalink
Those things "always" take
Those things "always" take longer than you expect ;-)
serettig
Tue, 04/20/2021 - 10:22
Permalink
The last 20% take 80% of the
The last 20% take 80% of the effort... ;) Good luck!
Degrange
Mon, 04/26/2021 - 13:30
Permalink
Sad news. I just discovered
Sad news. I just discovered that codemirror doesn't work well on mobile :/
It look like it work but if you actively try to use it it will have critical glitchs :/
And as H5P is mobile friendly, this mobably means my content-type can't be added officially :/
I could see to use code mirror 6 instead of codemirror 5 but that will require lots of works :(
Degrange
Mon, 04/26/2021 - 13:58
Permalink
Luckily I found a workaround
Luckily I found a workaround to make it work on mobile :)
Degrange
Fri, 04/23/2021 - 19:39
Permalink
I stopped a few day and it
I stopped a few day and it allowd me to see more clearly how my content-type options should be organised.
I was able to progress and it is now possible to choose values that will be return by the python input function. It is also possible to create multiple execution of the code for different set of input value.
I had a lots of trouble understanding Promise because I never needed them.
In this project there is a lots of use of Promise and I now understand why Promise where created. Everything make sense ! So I am happy about that :D
otacke
Sun, 04/25/2021 - 10:02
Permalink
Hi!Regarding Promises: Keep
Hi!
Regarding Promises: Keep in mind that the H5P core team still tries to supports IE11 (not sure for how long) and that it does not support Promises. You may want to add a Polyfill or fall back to callback functions if you're not using some library that requires it. If you're using Promises, then async/await may become your friends :-)
Best,
Oliver
Degrange
Sun, 04/25/2021 - 14:08
Permalink
Unfortunatly the Skulpt
Unfortunatly the Skulpt library that allow me to compile python code to javascript need promise (at least I need them to get input from user and to allow the user to stop infinite loop).
However, as I started from the question boiler plate, I do have the babel transpiler that serettig was talking (i just disabled part of it to debug easily but can enable it easily), so maybe it will allow polyfill to promise ? I don't know if I need somehow to also make the transpiller transpille the skulpt library code, i don't really know how babel etc. work it's the first time I used them. Or maybe I just find a polyfill library specifically for the promise and load them. Or maybe I should just detect IE 11 and display a message saying that this content type doesn't support it.
otacke
Mon, 04/26/2021 - 09:17
Permalink
Why do you need to disable
Why do you need to disable the transpiler for debugging? I think core-js is a good module to use for adding polyfills.
Degrange
Mon, 04/26/2021 - 13:28
Permalink
If I am not wrong, this
If I am not wrong, this prevent me from debugging my code as it's minimized ?
otacke
Mon, 04/26/2021 - 19:32
Permalink
Nope. It's a) not minimized
Nope. It's a) not minimized when you're using `npm run watch` which will conveniently build the distribution in the background and all you'll have to do is press F5 in your browser and it's b) providing a source map which will give you the proper faulty line of code in the error console.
Degrange
Mon, 04/26/2021 - 19:44
Permalink
Oh thanks ! At the start I
Oh thanks ! At the start I used the build command and though it was me changing a parameter in a file that disabled minification but it was in fact me switching to the watch command.
Degrange
Sat, 04/24/2021 - 20:12
Permalink
Here a demo : https://moodle
Here a demo : https://moodle.mathematiques.xyz/course/view.php?id=8 !
There is annoying bug that I need to check and everything is not finished. It's an alpha :p
YannickH
Fri, 06/24/2022 - 14:25
Permalink
status ?
Hi,
I'd be really interested by this plugin for teaching Python at university. What is the status please ? On the demo page, only the theird example works for me. I have a blank page for the first two.
Thanks a lot for creating this anyway !
Degrange
Fri, 06/24/2022 - 18:00
Permalink
Hi,I stopped / paused the
Hi,
I stopped / paused the developpment of this plugin.
However it should be functionnal. The only thing missing if I remember is the part to restore previous state.
You can download source here : https://github.com/DegrangeM/H5P.Python but you might need to do some search on how to add it to your LMS (and as it's been a while I didn't touched the code, I no longer remember it myself :D).
Also the third exemple require some javascript on the moodle page itself. But unless you want to do advanced things like that, you don't need to do javascript for just running and matching input / output or other things you would like.
YannickH
Fri, 06/24/2022 - 18:16
Permalink
ok thanks!
ok thanks!
serettig
Sun, 04/25/2021 - 10:17
Permalink
It's probably best to use a
It's probably best to use a transpiler like Babel at the moment until you can savely use modern JS in all browsers.
serettig
Mon, 04/26/2021 - 10:44
Permalink
Honestly, I would worry about
Honestly, I would worry about IE11 support in 2021. IE11 is not even supported by its manufacturer anymore, so I think third party sites don't need to as well.
otacke
Mon, 04/26/2021 - 20:43
Permalink
I fully agree about IE11
I fully agree about IE11 support personally and would have loved to ignore it years ago, but I still try to follow a project's policy if I contribute (cmp. https://github.com/h5p/h5p-editor-php-library/pull/121). Microsoft still supports IE11 for M365 until August 19, 2021 if I am not mistaken. Let's hope we hear some words from the H5P core team soon.
But either way: Yes, it's your content type, Degrange, and you don't need to support IE11 if you don't want to. The web world has Safari on iOS to worry about now anyway :-D
Best,
Oliver
Sreekanths22
Thu, 09/07/2023 - 10:26
Permalink
Sample H5P please
Hi Degrange
I would like to use this in Lumi to create some content. I am not familiar with codes to install libraries. (I thought it is just about downloading the zip file from your Github portal and uploading it to Lumi Install Libraries page. But that failed.)
Can you please share any sample h5p file you might have created for this content type? It will be of great help.
Thanks
Sreekanth
otacke
Thu, 09/07/2023 - 12:06
Permalink
Maybe https://www.youtube.com
Maybe https://www.youtube.com/watch?v=xEgBJaRUBGg&list=PL4lOawnmqTnHuQIBYz7K7LkdTybL3Ui7T&index=1 will help.
Sreekanths22
Thu, 09/07/2023 - 14:42
Permalink
Thanks Otacke. Will check.
Thanks Otacke. Will check.
And ever so grateful for your contributions to H5P, including the ones that are in Review stage.