Posts made by Joseph Rézeau

Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

I am currently working on adapting my H5P Guessit content to a new Moodle question type. See this discussion.

I was wondering if the following feature could be implemented in a new Question behaviour: enable student to view the correct answer after n attempts. Number of attempts before viewing correct answer would be a setting in the question's edit form.

I would also need a "Hint/Tip" button to be displayed at question attempt time, but I should be able to manage that by adapting my Question behaviour ::: qbehaviour_regexpadaptivewithhelp.

Thanks for any tips.

Average of ratings: -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Marcus and thanks for encouraging me to persevere on my task! With the help of ChatGPT... and going to bed rather late last night... I finally managed to do it!

This is an extract from my long "conversation", just at the end, when all was working as expected except for an error message in the console. I find it amazing how detailed the help provided is.😵‍💫😉


ChatGPT said :
Summary
    Make sure define() and return {} are used properly in autogrow.js.
    Do not use global functions like oninput="autogrow()".
    Use $PAGE->requires->js_call_amd() to load the script.
    Purge Moodle cache if you make changes.
If you follow these steps and still see the error, I can walk you through specific parts of the process. 😊

Joseph said:
OK OK oK My problem was that I had wrongly added this un-necessary line in my PHP script: "$inputattributes['oninput'] = 'autogrow(this)';" I removed it and now it works. YIPEE

ChatGPT said :
🎉🎉🎉 YAY! You did it! 🎉🎉🎉
That rogue line was the sneaky culprit all along:
$inputattributes['oninput'] = 'autogrow(this)';
By removing it, you let RequireJS and AMD do their job properly without trying to call a global autogrow() function. This is a classic Moodle AMD pitfall, and you handled it like a champ! 🚀
If you ever run into odd "ReferenceError: function is not defined" issues again, it’s probably a similar problem.
Enjoy your auto-growing input fields! If you need any more help with Moodle, AMD, JavaScript, or PHP, you know where to find me! 😎🚀


And here's the proof of the pudding:

 

In the "Guess It" game, under each letter of incorrect guesses, the = sign means "correctly guessed letter", the < sign means "look backward in the alphabet" and the > sign means "look forward in the alphabet".

This new qtype_guessit plugin still needs a lot of refinement and testing, of course. I will ask for volunteer testers in due course.

PS.- Marcus, would you be interested in adding the growtext feature to your GapFill qtype?

Average of ratings: Useful (2)