Admin: Add configuration setting quiz_prevent_copy_paste to prevent copying questions/answers text with the keyboard or the right-click menu - refs BT#15208

pull/2790/head
Yannick Warnier 7 years ago
parent 206dbbcec9
commit f4653e53d5
  1. 3
      main/exercise/exercise_result.php
  2. 3
      main/exercise/exercise_submit.php
  3. 25
      main/inc/lib/javascript/jquery.nocopypaste.js
  4. 3
      main/install/configuration.dist.php

@ -71,6 +71,9 @@ $interbreadcrumb[] = [
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
if (api_get_configuration_value('quiz_prevent_copy_paste')) {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'jquery.nocopypaste.js"></script>';
}
if ($origin != 'learnpath') {
// So we are not in learnpath tool

@ -63,6 +63,9 @@ $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
if (api_get_configuration_value('quiz_prevent_copy_paste')) {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'jquery.nocopypaste.js"></script>';
}
if (api_get_setting('enable_record_audio') === 'true') {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';

@ -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;
});
});

@ -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.

Loading…
Cancel
Save