Skip to content
Permalink
Browse files

Admin: Add configuration setting quiz_prevent_copy_paste to prevent c…

…opying questions/answers text with the keyboard or the right-click menu - refs BT#15208
  • Loading branch information...
ywarnier committed Jan 26, 2019
1 parent 206dbbc commit f4653e53d57b5fe34b060d83eeecf8a43e441e6c
@@ -71,6 +71,9 @@
$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[] = '<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['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.

0 comments on commit f4653e5

Please sign in to comment.
You can’t perform that action at this time.