ethan-ou/vscode-gift-pack

Previews for Gift Media plug-in format

fuhrmanator opened this issue · 12 comments

Hello - there's a plugin for exporting/importing GIFT with media, which involves a zip file. The binary files (media) stored in a folder relative to the GIFT source. Read more here: https://moodle.org/plugins/qformat_giftmedia

It could be very cool if GIFT pack supported this in the preview. I think it means that @@PLUGINFILE@@ has to be translated by the previewer as the folder of the GIFT file.

The examples on the plugins page show media with sound (MP3), but I don't think you have to make VSCode play sounds in the preview -- maybe just show it's a sound file? Anyway, probably most people will use images as media, but sounds could work eventually.

It might not be a worthwhile investment. It seems this plug-in has not had a release in three years and is possibly abandoned. The lead developer has retired and nobody has stepped up in an obvious way. From the Github's readme:

WARNING : I am now retired and I stopped all Moodle related activities. This repository is here just for history and this work is not maintained any more. Feel free to fork it and modify it to suit your needs or improve compatibility with recent Moodle versions. Additionaly you can consider contacting the Moodle team and become the new maintainer of this plugin. Thanks

The other tricky part is you'd want to reference the files somehow to get a useful preview (at least, I'd want that as a user). Using something like @@PLUGINFILE@@/myfolder/mysubfolder/mymedia.mp3 you'd need to recreate the folder structure on your computer to access the files.

This might make it more trouble than it's worth. It'll lead users to create folders to store their GIFT projects, and it may be tricky to keep that connection when the user uploads the files onto Moodle.

There may also be security issues on loading local files into the preview, but I wouldn't be sure of the details unless we went to implementation.

Good idea though. I've heard of people wanting more native integration for media in Moodle. The technology behind it is the only hurdle.

yes, you would have to reference the files relative to the GIFT source. A regex would do it before putting the URLs into the previewer DOM.

Since markdown editor previewers already do this in VSCode with images (GIF, JPG, PNG, SVG), I don't see why it would be a big security risk. I have no idea for MP3, etc.

What do you believe is the best thing to do for this feature in your opinion?

Consider the following:

  1. Create a repository in GitHub
  2. Make a folder within the repository called sample-quiz
  3. Add a subfolder called images and another called sounds
  4. Create a sample-quiz.txt file in the folder
  5. Place pictures in the images subfolder and audio files in the sounds subfolder
  6. Parse the subfolders relative to the location of the quiz text file

This way the standard example would be displayed correctly.

I spent the last year working on an e-book for a course written in Quarto, which is the next generation for R-Markdown. It uses pandoc to convert things.

I think I could write a filter in pandoc to support converting GIFT (in code fences) into HTML previews of quiz questions. I already did something like this in a very crude way to convert GIFT to LaTeX https://github.com/fuhrmanator/gift2latex. With my e-book project, I got comfortable using Lua (for the pandoc filters) but it's possible to do filters with Python, TypeScript, etc. There would have to be a GIFT command-line version of the parser that would return JSON, which can be used in the pandoc filter or whatever to produce HTML or other formats. The diagram-generator filter works basically that way with PlantUML (although it's simpler because the result is just an image). To render a quiz, it requires more work.

I feel that with Moodle, the XML Quiz schema is not as strict as it should be - which makes any of this a little harder.

Yes, the XML format of Moodle is very naïve and was never refactored, probably because it would break a lot of code (e.g., the question tag is overloaded and even a category is a question). You can read about it here. It's one of the reasons I prefer GIFT for managing questions outside of Moodle.

It's a shame Moodle do not want to explore the idea of versioning their schemas.

That makes sense. If I get deeper involved with the creation of assets for Moodle maybe I'll be able to contribute in a meaningful way.