diff --git a/bin/exam.py b/bin/exam.py index 5e08baf81..546cde9f5 100644 --- a/bin/exam.py +++ b/bin/exam.py @@ -163,6 +163,7 @@ def __init__(self,name='Untitled Exam'): 'showresultspage': 'oncompletion', 'onleave': Event('onleave','none','You have not finished the current question'), 'preventleave': True, + 'typeendtoleave': False, 'startpassword': '', 'allowAttemptDownload': False, 'downloadEncryptionKey': '', @@ -192,7 +193,7 @@ def fromDATA(builder, data): if haskey(data,'navigation'): nav = data['navigation'] - tryLoad(nav,['allowregen','navigatemode','reverse','browse','allowsteps','showfrontpage','showresultspage','preventleave','startpassword','allowAttemptDownload','downloadEncryptionKey'],exam.navigation) + tryLoad(nav,['allowregen','navigatemode','reverse','browse','allowsteps','showfrontpage','showresultspage','preventleave','typeendtoleave','startpassword','allowAttemptDownload','downloadEncryptionKey'],exam.navigation) if 'onleave' in nav: tryLoad(nav['onleave'],['action','message'],exam.navigation['onleave']) @@ -282,6 +283,7 @@ def toxml(self): 'showfrontpage': strcons_fix(self.navigation['showfrontpage']), 'showresultspage': strcons_fix(self.navigation['showresultspage']), 'preventleave': strcons_fix(self.navigation['preventleave']), + 'typeendtoleave': strcons_fix(self.navigation['typeendtoleave']), 'startpassword': strcons(self.navigation['startpassword']), 'allowAttemptDownload': strcons_fix(self.navigation['allowAttemptDownload']), 'downloadEncryptionKey': strcons(self.navigation['downloadEncryptionKey']) diff --git a/locales/en-GB.json b/locales/en-GB.json index fc80b0587..26fff9c82 100644 --- a/locales/en-GB.json +++ b/locales/en-GB.json @@ -19,6 +19,7 @@ "extension.not found": "Couldn't load the extension {{name}}.", "modal.confirm": "Confirm", "modal.confirm end exam": "Write {{endConfirmation}} in the box to confirm:", + "modal.end exam button": "End exam", "modal.alert": "Alert", "modal.ok": "OK", "modal.cancel": "Cancel", diff --git a/runtime/scripts/exam.js b/runtime/scripts/exam.js index 7d34c0192..e30f0c471 100644 --- a/runtime/scripts/exam.js +++ b/runtime/scripts/exam.js @@ -105,8 +105,8 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ { tryGetAttribute(settings, xml, 'settings/navigation', - ['allowregen','navigatemode','reverse','browse','allowsteps','showfrontpage','showresultspage','preventleave','startpassword','allowAttemptDownload','downloadEncryptionKey'], - ['allowRegen','navigateMode','navigateReverse','navigateBrowse','allowSteps','showFrontPage','showResultsPage','preventLeave','startPassword','allowAttemptDownload','downloadEncryptionKey']); + ['allowregen','navigatemode','reverse','browse','allowsteps','showfrontpage','showresultspage','preventleave','typeendtoleave','startpassword','allowAttemptDownload','downloadEncryptionKey'], + ['allowRegen','navigateMode','navigateReverse','navigateBrowse','allowSteps','showFrontPage','showResultsPage','preventLeave','typeendtoleave','startPassword','allowAttemptDownload','downloadEncryptionKey']); //get navigation events and actions var navigationEventNodes = xml.selectNodes('settings/navigation/event'); for( var i=0; i' + message; } if(Numbas.display) { - Numbas.display.showConfirmEndExam( - message, - function() { - exam.end(true); - } - ); + if (exam.settings.typeendtoleave) { + Numbas.display.showConfirmEndExam( + message, + function() { + exam.end(true); + } + ); + } + else { + Numbas.display.showConfirm( + message, + function() { + exam.end(true); + } + ); + } } else { exam.end(true); } diff --git a/schema/exam_schema.7.1.json b/schema/exam_schema.7.1.json index d570a419d..8d3e6396f 100644 --- a/schema/exam_schema.7.1.json +++ b/schema/exam_schema.7.1.json @@ -303,6 +303,10 @@ "title": "Confirm before leaving the exam while it's running?", "type": "boolean" }, + "typeendtoleave": { + "title": "Require written confirmation before leaving the exam", + "type": "boolean" + }, "reverse": { "title": "Allow move to previous question?", "type": "boolean" diff --git a/tests/locales.js b/tests/locales.js index 0ec4062cf..e1b1401c7 100644 --- a/tests/locales.js +++ b/tests/locales.js @@ -1475,7 +1475,8 @@ Numbas.locale = { "die.error": "Error", "extension.not found": "Couldn't load the extension {{name}}.", "modal.confirm": "Confirm", - "modal.confirm end exam": "Write '{{endConfirmation}}' in the box below to confirm.", + "modal.confirm end exam": "Write {{endConfirmation}} in the box to confirm:", + "modal.end exam button": "End exam", "modal.alert": "Alert", "modal.ok": "OK", "modal.cancel": "Cancel", @@ -1559,7 +1560,9 @@ Numbas.locale = { "control.style options": "Display options", "control.move to next question": "Move to the next question", "control.show introduction": "Introduction", - "control.end confirmation": "end", + "control.confirm end.correct": "You may now end the exam.", + "control.confirm end.incorrect": "This is not the expected text.", + "control.confirm end.password": "end", "display.answer widget.unknown widget type": "The answer widget type {{name}} is not recognised.", "display.part.jme.error making maths": "Error making maths display", "display.error making html": "Error making HTML in {{contextDescription}}: {{-message}}", @@ -1934,7 +1937,8 @@ Numbas.locale = { "worksheet.reconfigure": "Generate different sheets", "worksheet.show sheet": "Preview the sheet with ID:", "worksheet.answersheet show question content": "Show question content in answer sheets?" -}} +} +} , "en-school": {translation: { diff --git a/tests/numbas-runtime.js b/tests/numbas-runtime.js index dd4242cbe..13d315bfc 100644 --- a/tests/numbas-runtime.js +++ b/tests/numbas-runtime.js @@ -23269,8 +23269,8 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ { tryGetAttribute(settings, xml, 'settings/navigation', - ['allowregen','navigatemode','reverse','browse','allowsteps','showfrontpage','showresultspage','preventleave','startpassword','allowAttemptDownload','downloadEncryptionKey'], - ['allowRegen','navigateMode','navigateReverse','navigateBrowse','allowSteps','showFrontPage','showResultsPage','preventLeave','startPassword','allowAttemptDownload','downloadEncryptionKey']); + ['allowregen','navigatemode','reverse','browse','allowsteps','showfrontpage','showresultspage','preventleave','typeendtoleave','startpassword','allowAttemptDownload','downloadEncryptionKey'], + ['allowRegen','navigateMode','navigateReverse','navigateBrowse','allowSteps','showFrontPage','showResultsPage','preventLeave','typeendtoleave','startPassword','allowAttemptDownload','downloadEncryptionKey']); //get navigation events and actions var navigationEventNodes = xml.selectNodes('settings/navigation/event'); for( var i=0; i' + message; } if(Numbas.display) { - Numbas.display.showConfirmEndExam( - message, - function() { - exam.end(true); - } - ); + if (exam.settings.typeendtoleave) { + Numbas.display.showConfirmEndExam( + message, + function() { + exam.end(true); + } + ); + } + else { + Numbas.display.showConfirm( + message, + function() { + exam.end(true); + } + ); + } } else { exam.end(true); } diff --git a/themes/default/templates/modals.html b/themes/default/templates/modals.html index 415dc8389..30b167e04 100644 --- a/themes/default/templates/modals.html +++ b/themes/default/templates/modals.html @@ -47,7 +47,7 @@