diff --git a/main/exercise/exercise_result.php b/main/exercise/exercise_result.php index 66305be1c2..dbfedb7ea2 100755 --- a/main/exercise/exercise_result.php +++ b/main/exercise/exercise_result.php @@ -71,6 +71,9 @@ $interbreadcrumb[] = [ $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; +if (api_get_configuration_value('quiz_prevent_copy_paste')) { + $htmlHeadXtra[] = ''; +} if ($origin != 'learnpath') { // So we are not in learnpath tool diff --git a/main/exercise/exercise_submit.php b/main/exercise/exercise_submit.php index e93db8597e..fc4210cf0b 100755 --- a/main/exercise/exercise_submit.php +++ b/main/exercise/exercise_submit.php @@ -63,6 +63,9 @@ $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js'); $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; +if (api_get_configuration_value('quiz_prevent_copy_paste')) { + $htmlHeadXtra[] = ''; +} if (api_get_setting('enable_record_audio') === 'true') { $htmlHeadXtra[] = ''; diff --git a/main/inc/lib/javascript/jquery.nocopypaste.js b/main/inc/lib/javascript/jquery.nocopypaste.js new file mode 100644 index 0000000000..ea2da2464d --- /dev/null +++ b/main/inc/lib/javascript/jquery.nocopypaste.js @@ -0,0 +1,25 @@ +/** + * When included, this snippet prevents contextual menus and keystrokes that + * make it possible to cut/paste/copy text from the page. + * This is useful for very secure exams. + * @author Alberto Torreblanca + */ +$(document).ready(function(){ + $(document).on("cut copy paste contextmenu",function(e) { + e.preventDefault(); + }); + $(document).keydown(function(e) { + var forbiddenKeys = new Array('c', 'x', 'v', 'p', 's'); + var keyCode = (e.keyCode) ? e.keyCode : e.which; + var isCtrl; + isCtrl = e.ctrlKey + if (isCtrl) { + for (i = 0; i < forbiddenKeys.length; i++) { + if (forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) { + return false; + } + } + } + return true; + }); +}); diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 8ed65f9124..414eae065d 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -557,6 +557,9 @@ $_configuration['send_all_emails_to'] = [ //$_configuration['allow_quiz_show_previous_button_setting'] = false; // Allow to teachers review exercises question with audio notes //$_configuration["allow_teacher_comment_audio"] = false; +// Block copy/paste/save/print keys and right-clicks in exercises +//$_configuration['quiz_prevent_copy_paste'] = false; + // Hide search form in session list //$_configuration['hide_search_form_in_session_list'] = false; // Allow exchange of messages from teachers/bosses about a user.