Index: lams_learning/web/includes/javascript/gate-check.js =================================================================== diff -u --- lams_learning/web/includes/javascript/gate-check.js (revision 0) +++ lams_learning/web/includes/javascript/gate-check.js (revision 272283f9e61f61403d2b4120ce8ee296de371c1e) @@ -0,0 +1,65 @@ +function checkNextGateActivity(finishButtonId, userId, toolSessionId, lessonId, submitFunction){ + // we need bootstrap tooltip, not jQuery UI one + // if it has not been isolated yet, try to do it now + if (typeof $.fn.bootstrapTooltip != 'function') { + $.fn.bootstrapTooltip = $.fn.tooltip.noConflict(); + } + + $(document).ready(function(){ + let finishButton = $('#' + finishButtonId); + + if (finishButton.length == 0){ + return; + } + + finishButton + .bootstrapTooltip({ + 'trigger' : 'manual' + }) + .click(function(event){ + // disable the button + finishButton.prop('disabled', true); + + // check if there is a gate after this activity + // if so, check if learner can pass + $.ajax({ + 'url' : '/lams/learning/learner/isNextGateActivityOpen.do?userId=' + userId + '&toolSessionId=' + toolSessionId + '&lessonId=' + lessonId, + 'cache' : false, + 'dataType' : 'json', + 'success' : function(response) { + if (response.status == 'open') { + // learner can pass + finishButton.prop('disabled', false); + submitFunction(); + return; + } + + if (response.status == 'closed') { + // if there are other events bound to click, do not make them run + event.stopImmediatePropagation(); + + let timeoutFunction = null; + if (response.message) { + // tooltips should say whatever we got in the response + finishButton.attr({ + 'title' : response.message, + 'data-original-title' : response.message + }).bootstrapTooltip('show'); + + timeoutFunction = function(){ + finishButton.bootstrapTooltip('hide').prop('disabled', false); + }; + } else { + timeoutFunction = function(){ + finishButton.prop('disabled', false); + }; + } + + // show tooltip for several seconds + setTimeout(timeoutFunction, 5000); + } + } + }); + }); + }); +} \ No newline at end of file Index: lams_tool_assessment/web/pages/learning/results.jsp =================================================================== diff -u -r58f8a894e785390508199bfb43acefd77ee63d0a -r272283f9e61f61403d2b4120ce8ee296de371c1e --- lams_tool_assessment/web/pages/learning/results.jsp (.../results.jsp) (revision 58f8a894e785390508199bfb43acefd77ee63d0a) +++ lams_tool_assessment/web/pages/learning/results.jsp (.../results.jsp) (revision 272283f9e61f61403d2b4120ce8ee296de371c1e) @@ -61,57 +61,16 @@ +