diff --git a/physics/templates/physics/exam_take.html b/physics/templates/physics/exam_take.html index 8af452fa..357a6d56 100755 --- a/physics/templates/physics/exam_take.html +++ b/physics/templates/physics/exam_take.html @@ -36,7 +36,7 @@

{{ question.stem|safe }}

- +
+ - + + setTimeout(function(){ el.style.opacity = '0'; }, 1600); + } catch (e) { console && console.error && console.error(e); } + }); + {% endblock %} diff --git a/physics/templates/physics/partials/exam_take_fragment.html b/physics/templates/physics/partials/exam_take_fragment.html index 6e5c406b..8194fb65 100644 --- a/physics/templates/physics/partials/exam_take_fragment.html +++ b/physics/templates/physics/partials/exam_take_fragment.html @@ -170,8 +170,15 @@ if(hxTrigger && hxTrigger.indexOf('saved') !== -1){ handled = true; if(window.htmx && typeof htmx.off === 'function') htmx.off('htmx:afterRequest', htmxHandler); - document.getElementById('goto-button').value = destIndex; - $('#goto-button').click(); + try{ + const pageUrl = `{% if cid %}{% url 'physics:exam_take' pk=exam.pk sk=0 cid=cid passcode=passcode %}{% else %}{% url 'physics:exam_take_user' pk=exam.pk sk=0 %}{% endif %}`.replace('/0/', '/' + destIndex + '/'); + window.location = pageUrl; + }catch(e){ + if(document.getElementById('goto-button')){ + document.getElementById('goto-button').value = destIndex; + $('#goto-button').click(); + } + } } }catch(e){/* ignore */} } @@ -181,13 +188,13 @@ } // As a fallback listen for the custom 'saved' event - const onSavedFallback = function(){ if(handled) return; handled = true; document.removeEventListener('saved', onSavedFallback); document.getElementById('goto-button').value = destIndex; $('#goto-button').click(); }; + const onSavedFallback = function(){ if(handled) return; handled = true; document.removeEventListener('saved', onSavedFallback); try{ const pageUrl = `{% if cid %}{% url 'physics:exam_take' pk=exam.pk sk=0 cid=cid passcode=passcode %}{% else %}{% url 'physics:exam_take_user' pk=exam.pk sk=0 %}{% endif %}`.replace('/0/', '/' + destIndex + '/'); window.location = pageUrl; }catch(e){ if(document.getElementById('goto-button')){ document.getElementById('goto-button').value = destIndex; $('#goto-button').click(); } } }; document.addEventListener('saved', onSavedFallback); tmp.click(); // final timeout fallback - setTimeout(function(){ if(!handled){ try{ document.removeEventListener('saved', onSavedFallback); if(window.htmx && typeof htmx.off === 'function') htmx.off('htmx:afterRequest', htmxHandler); document.getElementById('goto-button').value = destIndex; $('#goto-button').click(); }catch(e){} } }, 1500); + setTimeout(function(){ if(!handled){ try{ document.removeEventListener('saved', onSavedFallback); if(window.htmx && typeof htmx.off === 'function') htmx.off('htmx:afterRequest', htmxHandler); const pageUrl = `{% if cid %}{% url 'physics:exam_take' pk=exam.pk sk=0 cid=cid passcode=passcode %}{% else %}{% url 'physics:exam_take_user' pk=exam.pk sk=0 %}{% endif %}`.replace('/0/', '/' + destIndex + '/'); window.location = pageUrl; }catch(e){ try{ if(document.getElementById('goto-button')){ document.getElementById('goto-button').value = destIndex; $('#goto-button').click(); } }catch(e){} } } }, 1500); return; } }