diff --git a/admin/settings/misc.php b/admin/settings/misc.php
index 2fbb60e5510..0e62dcac434 100644
--- a/admin/settings/misc.php
+++ b/admin/settings/misc.php
@@ -16,6 +16,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$rqsetting->plugin = 'qtype_random';
$temp->add($rqsetting);
$temp->add(new admin_setting_configcheckbox('experimentalsplitrestore', get_string('experimentalsplitrestore', 'admin'), get_string('configexperimentalsplitrestore', 'admin'), 0));
+ $temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0));
$ADMIN->add('misc', $temp);
diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php
index d27909f1e79..6a6cda85aa6 100644
--- a/lang/en_utf8/admin.php
+++ b/lang/en_utf8/admin.php
@@ -118,6 +118,7 @@ $string['configenablehtmlpurifier'] = 'Use HTML Purifier instead of KSES for cle
$string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
$string['configenablerssfeedsdisabled'] = 'It is not available because RSS feeds are disabled in all the Site. To enable them, go to the Variables settings under Admin Configuration.';
$string['configenablerssfeedsdisabled2'] = 'RSS feeds are disabled at the server level. You need to enable them first in Server/RSS.';
+$string['configenablesafebrowserintegration'] = 'This adds the choice \'Require Safe Exam Browser\' to the \'Browser security\' field on the quiz settings form. See http://www.safeexambrowser.org/ for more information.';
$string['configenablestats'] = 'If you choose \'yes\' here, Moodle\'s cronjob will process the logs and gather some statistics. Depending on the amount of traffic on your site, this can take awhile. If you enable this, you will be able to see some interesting graphs and statistics about each of your courses, or on a sitewide basis.';
$string['configenabletrusttext'] = 'By default Moodle will always thoroughly clean text that comes from users to remove any possible bad scripts, media etc that could be a security risk. The Trusted Content system is a way of giving particular users that you trust the ability to include these advanced features in their content without interference. To enable this system, you need to first enable this setting, and then grant the Trusted Content permission to a specific Moodle role. Texts created or uploaded by such users will be marked as trusted and will not be cleaned before display.';
$string['configenrolmentplugins'] = 'Please choose the enrolment plugins you wish to use. Don\'t forget to configure the settings properly.
You have to indicate which plugins are enabled, and one plugin can be set as the default plugin for interactive enrolment. To disable interactive enrolment, set \"enrollable\" to \"No\" in required courses.';
@@ -358,6 +359,7 @@ $string['enablegroupings'] = 'Enable groupings';
$string['enablehtmlpurifier'] = 'Enable HTML Purifier';
$string['enablerecordcache'] = 'Enable Record Cache';
$string['enablerssfeeds'] = 'Enable RSS feeds';
+$string['enablesafebrowserintegration'] = 'Enable Safe Exam Browser integration';
$string['enablestats'] = 'Enable statistics';
$string['enabletrusttext'] = 'Enable Trusted Content';
$string['encoding'] = 'Encoding';
diff --git a/lang/en_utf8/help/quiz/browsersecurity.html b/lang/en_utf8/help/quiz/browsersecurity.html
new file mode 100644
index 00000000000..61573dc4f56
--- /dev/null
+++ b/lang/en_utf8/help/quiz/browsersecurity.html
@@ -0,0 +1,56 @@
+
Browser security
+
+This option offers various ways to try to restrict how students may try to 'cheat'
+while attempting a quiz. However, this is not a simple issue, and what in one situation
+is considered 'cheating' may, in another situation, just be effective use of information
+technology. (For example, the ability to quickly find answers using a search engine.)
+
+Note also that this is not just at problem of technology with a technical solution.
+Cheating has been going on since long before computers, and while computers make certain
+actions, like copy and paste, easier, they also make it easier for teachers to detect
+cheating - for example using the quiz reports. The options provided here are not fool-proof,
+and while they do make some forms of cheating harder for students, they also make it more
+inconvenient for students to attempt the quizzes, and they are not fool-proof.
+
+You should alos consider other ways to make it harder for students to cheat at your quiz:
+
+- You can use a large question bank, which the quiz picking a selection of questions randomly,
+so different students see different, but similar questions.
+- You can use the shuffle answers option, so that the right answer to question 1 is not always option A.
+- You can ask questions that required students to analyse the given information, rather than just recalling facts.
+
+
+With the above warnings in mind, here is the description of the available options.
+
+None
+
+No impediments are put in the way of students attempting the quiz.
+
+Full screen pop-up with some JavaScript security
+
+There is a limit to what the quiz, with runs on a web server, can do to restrict
+what the student sitting at their computer can do while attempting the quiz. However,
+this option does what is possible:
+
+ - The quiz will only start if the student has a JavaScript-enabled web-browser.
+ - The quiz appears in a fullscreen popup window that covers all the other windows and has no navigation controls.
+ - The students are prevented, as far as is possible, from using facilities like copy and paste.
+
+
+Require the use of Safe Exam Browser
+
+This option will only appear if your adminstrator has enabled it.
+
+Safe Exam Browser is a customised web browser that must be
+downloaded an installed on the computer that the student uses to attempt the quiz. The restrictions placed on
+students are similar to those in pop-up window case, but because Safe Exam Browser is software running
+on the student's computer, it can do a much more effective job of restricting their actions. If you select this option:
+
+ - Students will only be able to attempt the quiz if they are using Safe Exam Browser.
+ - The browser window will be fullscreen (without any navigation elements).
+ - The window cannot be closed until the test is submitted.
+ - Shortcuts keys such as Win, Ctrl+Alt+Del, Alt+F4, F1, Ctrl+P, Printscreen, are disabled.
+ - Copy and paste, and the context menu, are disabled.
+ - Switching to other applications is disabled.
+ - Surfing to other web sites is prohibited.
+
diff --git a/lang/en_utf8/quiz.php b/lang/en_utf8/quiz.php
index 6b6e5e996b7..92c1131d684 100644
--- a/lang/en_utf8/quiz.php
+++ b/lang/en_utf8/quiz.php
@@ -72,6 +72,7 @@ $string['bestgrade'] = 'Best grade';
$string['blackboard'] = 'Blackboard';
$string['blackboard_6'] = 'Blackboard V6+';
$string['braceerror'] = 'Could not find {...} around answers';
+$string['browsersecurity'] = 'Browser security';
$string['bothattempts'] = 'Show students with and without attempts';
$string['calculated'] = 'Calculated';
$string['calculatedquestion'] = 'Calculated Question not supported at line $a. The question will be ignored';
@@ -400,6 +401,7 @@ $string['pleaseclose'] = 'Your request has been processed. You can now close thi
$string['popup'] = 'Show quiz in a "secure" window';
$string['popupblockerwarning'] = 'This section of the test is in secure mode, this means that you need to take the quiz in a secure window. Please turn off your popup blocker. Thank you.';
$string['popupnotice'] = 'Students will see this quiz in a secure window';
+$string['popupwithjavascriptsupport'] = 'Full screen pop-up with some JavaScript security';
$string['preview'] = 'Preview';
$string['previewquestion'] = 'Preview question';
$string['previewquiz'] = 'Preview $a';
@@ -485,6 +487,7 @@ $string['reports'] = 'Reports';
$string['reportsimplestat'] = 'Simple statistics';
$string['requirepassword'] = 'Require password';
$string['requirepasswordmessage'] = 'To attempt this quiz you need to know the quiz password';
+$string['requiresafeexambrowser'] = 'Require the use of Safe Exam Browser';
$string['requiresubnet'] = 'Require network address';
$string['response'] = 'Response';
$string['responses'] = 'Responses';
@@ -506,6 +509,8 @@ $string['reviewresponse'] = 'Review response';
$string['reviewresponsetoq'] = 'Review response (question $a)';
$string['rqp'] = 'Remote Question';
$string['rqps'] = 'Remote Questions';
+$string['safebrowsererror']='This quiz has been set up so that it may only be attempted using the Safe Exam Browser. You cannot attempt it form this web browser.';
+$string['safebrowsernotice']='This quiz has been configured so that students may only attempt it using the Safe Exam Browser.';
$string['save'] = 'Save';
$string['saveandedit'] = 'Save changes and edit questions';
$string['savedfromdeletedcourse'] = 'Saved from deleted course \"$a\"';
diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php
index 1c8658885cc..8e146b2c932 100644
--- a/mod/quiz/attempt.php
+++ b/mod/quiz/attempt.php
@@ -77,7 +77,7 @@
$strattemptnum = get_string('attempt', 'quiz', $attemptnumber);
$strquizzes = get_string("modulenameplural", "quiz");
- $popup = $quiz->popup && !$ispreviewing; // Controls whether this is shown in a javascript-protected window.
+ $popup = $quiz->popup && !$ispreviewing; // Controls whether this is shown in a javascript-protected window or with a safe browser.
/// We intentionally do not check open and close times here. Instead we do it lower down.
/// This is to deal with what happens when someone submits close to the exact moment when the quiz closes.
@@ -89,6 +89,11 @@
print_error('nomoreattempts', 'quiz', "view.php?id={$cm->id}");
}
+/// Check safe browser
+ if (!$ispreviewing && $quiz->popup == 2 && !quiz_check_safe_browser()) {
+ print_error('safebrowsererror', 'quiz', "view.php?id={$cm->id}");
+ }
+
/// Check subnet access
if (!$ispreviewing && !empty($quiz->subnet) && !address_in_subnet(getremoteaddr(), $quiz->subnet)) {
print_error("subneterror", "quiz", "view.php?id=$cm->id");
@@ -412,10 +417,12 @@
require_js($CFG->wwwroot . '/mod/quiz/quiz.js');
$pagequestions = explode(',', $pagelist);
$headtags = get_html_head_contributions($pagequestions, $questions, $states);
- if (!empty($popup)) {
+ if (!$ispreviewing && $quiz->popup) {
define('MESSAGE_WINDOW', true); // This prevents the message window coming up
print_header($course->shortname.': '.format_string($quiz->name), '', '', '', $headtags, false, '', '', false, ' class="securewindow"');
- include('protect_js.php');
+ if ($quiz->popup == 1) {
+ include('protect_js.php');
+ }
} else {
$strupdatemodule = has_capability('moodle/course:manageactivities', $coursecontext)
? update_module_button($cm->id, $course->id, get_string('modulename', 'quiz'))
@@ -439,8 +446,10 @@
print_single_button($CFG->wwwroot.'/mod/quiz/attempt.php', $buttonoptions, get_string('startagain', 'quiz'));
echo '';
/// Notices about restrictions that would affect students.
- if ($quiz->popup) {
+ if ($quiz->popup == 1) {
notify(get_string('popupnotice', 'quiz'));
+ } else if ($quiz->popup == 2) {
+ notify(get_string('safebrowsernotice', 'quiz'));
}
if ($timestamp < $quiz->timeopen || ($quiz->timeclose && $timestamp > $quiz->timeclose)) {
notify(get_string('notavailabletostudents', 'quiz'));
diff --git a/mod/quiz/attempt_close_js.php b/mod/quiz/attempt_close_js.php
index 3ba2d5b6dcf..096afe6cf78 100644
--- a/mod/quiz/attempt_close_js.php
+++ b/mod/quiz/attempt_close_js.php
@@ -2,7 +2,7 @@
id, $message);
+ }
}
}
@@ -124,11 +124,12 @@
/// Print the page header
$pagequestions = explode(',', $pagelist);
$headtags = get_html_head_contributions($pagequestions, $questions, $states);
- if (!empty($popup)) {
+ if (!$ispreviewing && $quiz->popup) {
define('MESSAGE_WINDOW', true); // This prevents the message window coming up
print_header($course->shortname.': '.format_string($quiz->name), '', '', '', $headtags, false, '', '', false, '');
- /// Include Javascript protection for this page
- include('protect_js.php');
+ if ($quiz->popup == 1) {
+ include('protect_js.php');
+ }
} else {
$strupdatemodule = has_capability('moodle/course:manageactivities', $coursecontext)
? update_module_button($cm->id, $course->id, get_string('modulename', 'quiz'))
diff --git a/mod/quiz/view.php b/mod/quiz/view.php
index 98772963f68..24cf62b1958 100644
--- a/mod/quiz/view.php
+++ b/mod/quiz/view.php
@@ -57,7 +57,7 @@
//only check pop ups if the user is not a teacher, and popup is set
- $bodytags = (has_capability('mod/quiz:attempt', $context) && $quiz->popup)?'onload="popupchecker(\'' . get_string('popupblockerwarning', 'quiz') . '\');"':'';
+ $bodytags = (has_capability('mod/quiz:attempt', $context) && $quiz->popup == 1)?'onload="popupchecker(\'' . get_string('popupblockerwarning', 'quiz') . '\');"':'';
$PAGE->print_header($course->shortname.': %fullname%','',$bodytags);
echo '
';
@@ -405,7 +405,7 @@
$attempturl = "attempt.php?id=$cm->id";
// Prepare options depending on whether the quiz should be a popup.
- if (!empty($quiz->popup)) {
+ if ($quiz->popup == 1) {
$window = 'quizpopup';
$windowoptions = "left=0, top=0, height='+window.screen.height+', " .
"width='+window.screen.width+', channelmode=yes, fullscreen=yes, " .
@@ -421,7 +421,9 @@
echo "if (confirm('".addslashes_js($strconfirmstartattempt)."')) ";
}
echo "window.open('$attempturl','$window','$windowoptions');", '" />';
- } else {
+ } else if ($quiz->popup == 2 && !quiz_check_safe_browser()) {
+ notify(get_string('safebrowsererror', 'quiz'));
+ }else {
print_single_button("attempt.php", array('id'=>$cm->id), $buttontext, 'get', '', false, '', false, $strconfirmstartattempt);
}
@@ -483,7 +485,7 @@ function make_review_link($linktext, $quiz, $attempt, $context) {
}
$url = "review.php?q=$quiz->id&attempt=$attempt->id";
- if ($quiz->popup) {
+ if ($quiz->popup == 1) {
$windowoptions = "left=0, top=0, channelmode=yes, fullscreen=yes, scrollbars=yes, resizeable=no, directories=no, toolbar=no, titlebar=no, location=no, status=no, menubar=no";
return link_to_popup_window('/mod/quiz/' . $url, 'quizpopup', $linktext, '+window.screen.height+', '+window.screen.width+', '', $windowoptions, true);
} else {