Add lp_prevents_beforeunload conf setting - refs BT#17345

Allows prevent to the user before leaving a learning path
pull/3285/head
Angel Fernando Quiroz Campos 5 years ago
parent 1fe57a4d12
commit d7a583ba77
  1. 3
      main/install/configuration.dist.php
  2. 14
      main/lp/scorm_api.php

@ -1540,6 +1540,9 @@ $_configuration['auth_password_links'] = [
//Allows teachers to edit survey questions after students have answered them
//$_configuration['survey_allow_answered_question_edit'] = false;
// Allows prevent to the user before leaving a learning path
//$_configuration['lp_prevents_beforeunload'] = false;
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email

@ -1147,13 +1147,22 @@ function addListeners(){
if (olms.lms_item_type=='sco') {
//window.addEventListener('beforeunload', lastCall);
window.addEventListener('beforeunload', function (e) {
var preventsBeforeUnload = <?php echo (int) api_get_configuration_value('lp_prevents_beforeunload') ?>;
if (preventsBeforeUnload) {
e.preventDefault();
}
$(window).on('beforeunload', function(e) {
console.log('beforeunload');
lastCall();
logit_lms('beforeunload called', 3);
return 'true';
if (preventsBeforeUnload) {
e.returnValue = 'true';
} else {
delete e['returnValue'];
}
});
$(window).on('unload', function(e) {
@ -1161,7 +1170,6 @@ function addListeners(){
savedata(olms.lms_item_id);
logit_lms('unload called', 3);
lastCall();
return 'true';
});
logit_lms('Added unload savedata() on window unload', 3);
}

Loading…
Cancel
Save