Finish button at the question set
Submitted by developer246 on Wed, 01/24/2024 - 10:30
Forums:
Hi everyone,
I'm currently working with the H5P plugin in WordPress on my localhost environment. I'm facing an issue with the finish button, which currently appears only when all questions are answered. I need it to be visible at all times, allowing users to finish the question set even if not all questions are answered (let students to skip some questions).
If anyone has experience dealing with this situation or could provide guidance on ensuring the finish button is always present I would greatly appreciate it.
Thank you!
Summary:
Finish button is only appearing if all questions are answered, need it to be always visible
Content types:
otacke
Thu, 01/25/2024 - 22:22
Permalink
Hi!This will either require
Hi!
This will either require overriding some of the functionality of Question Set using the alter_scripts hook (see https://h5p.org/node/2692 and sub pages for details on customizing) or even forking the content type, because not everything that would need to be overridden might be exposed.
Best,
Oliver
developer246
Fri, 01/26/2024 - 11:00
Permalink
Thank you, alter_scripts hook
Thank you, alter_scripts hook helped!
otacke
Fri, 01/26/2024 - 14:15
Permalink
Please feel free to share
Please feel free to share your solution as well in case others want to achieve the same. Open source is a give-and-take thing.
developer246
Fri, 01/26/2024 - 15:22
Permalink
I created h5pmods.php file,
if (isset($libraries['H5P.QuestionSet'])) {
$scripts[] = (object) array(
'path' => '/custom-questionset.js',
'version' => '?ver=1.2.3'
);
}
}
add_action('h5p_alter_library_scripts', 'h5pmods_alter_scripts', 10, 3);
edited custom-questionset.js file (disabled hideButton('finish)) and then activated created plugin (h5pmods) in wordpress.
This really helped: https://github.com/h5p/h5pmods-wordpress-plugin/blob/master/h5pmods.php#...
otacke
Fri, 01/26/2024 - 23:14
Permalink
I guess the interesting
I guess the interesting information would be in custom-questionset.js :-)
developer246
Tue, 02/06/2024 - 08:52
Permalink
var _updateButtons = function
if (params.disableBackwardsNavigation) {
if (questionInstances[currentQuestion].getAnswerGiven() &&
questionInstances.length-1 !== currentQuestion) {
questionInstances[currentQuestion].showButton('next');
}
else {
questionInstances[currentQuestion].hideButton('next');
}
}
if (questionInstances[currentQuestion]) {
questionInstances[currentQuestion].showButton('finish');
}
};
developer246
Tue, 02/06/2024 - 13:53
Permalink
This is a modified version of
This is a modified version of original function from questionset.js