Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional secure browser configurations #109

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions classes/local/api/tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public static function storeFallbackDetails($attempt_no, $proview_url, $proctor_
]);
return $response;
}
private static function redirect_to_wrapper($proctoring_payload, $quiz)
private static function redirect_to_wrapper($proctoring_payload, $quiz, $quizaccess_proctor_setting)
{
// TODO Add check if wrapper URL already exists
rohansharmasitoula marked this conversation as resolved.
Show resolved Hide resolved
$wrapper_response = self::create_sb_wrapper($proctoring_payload, $quiz);
$wrapper_response = self::create_sb_wrapper($proctoring_payload, $quiz, $quizaccess_proctor_setting);
// redirect($wrapper_response->signed_short_url);
echo "<script> window.location='$wrapper_response->signed_url';</script>";
return;
Expand All @@ -107,14 +107,24 @@ private static function create_sb_wrapper($proctoring_payload, $quiz)
$auth_response = self::generate_auth_token($api_base_url, $auth_payload);
$auth_token = $auth_response['access_token'];
$url = $api_base_url . '/proview/wrapper/create';

$blacklisted_softwares_mac = isset($quiz->blacklisted_softwares_mac) ? (array) $quiz->blacklisted_softwares_mac : [];
$blacklisted_softwares_windows = isset($quiz->blacklisted_softwares_win) ? (array) $quiz->blacklisted_softwares_win : [];

$data = array(
'session_external_id' => $proctoring_payload->session_id,
'attendee_external_id' => $proctoring_payload->profile_id,
'redirect_url' => $PAGE->url->__toString(),
'expiry' => date(DATE_ISO8601, $quiz->timeclose == 0 ? strtotime("+3 days") : $quiz->timeclose ),
'is_secure_browser' => true
'expiry' => date(DATE_ISO8601, $quiz->timeclose == 0 ? strtotime("+3 days") : $quiz->timeclose),
'is_secure_browser' => true,
rohansharmasitoula marked this conversation as resolved.
Show resolved Hide resolved
"secure_browser" => [
"blacklisted_softwares_mac" => $blacklisted_softwares_mac,
"blacklisted_softwares_windows" => $blacklisted_softwares_windows,
"is_record_screen" => isset($quiz->sb_content_protection) ? boolval($quiz->sb_content_protection) : false,
"is_minimize" => isset($quiz->sb_kiosk_mode) ? boolval($quiz->sb_kiosk_mode) : false,
],
);
// var_dump($data);

try {
$curl->setHeader(array('Content-Type: application/json', 'Authorization: Bearer ' . $auth_token));
$response = $curl->post($url, json_encode($data));
Expand All @@ -127,6 +137,7 @@ private static function create_sb_wrapper($proctoring_payload, $quiz)




private static function generate_auth_token($api_base_url, $payload)
{
$curl = new \curl();
Expand Down Expand Up @@ -197,7 +208,7 @@ public static function insert_tracking()
$quizaccess_proctor_setting->proctortype == 'noproctor' &&
$quizaccess_proctor_setting->tsbenabled &&
strpos($_SERVER ['HTTP_USER_AGENT'], "Proview-SB") === FALSE) {
self::redirect_to_wrapper($template, $quiz);
self::redirect_to_wrapper($template, $quiz, $quizaccess_proctor_setting);
return;
}

Expand Down
9 changes: 9 additions & 0 deletions datastore.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@
$template->profile_id = $USER->id;
$template->instructions = $quizaccess_proctor_setting->instructions;
$template->reference_link= $quizaccess_proctor_setting->reference_link;
if ($quizaccess_proctor_setting->tsbenabled === "1" ) {
$template->tsb_enabled = true;
$template->sb_blacklisted_software_windows= isset($quizaccess_proctor_setting->blacklisted_softwares_win) ? $quizaccess_proctor_setting->blacklisted_softwares_win : '';
$template->sb_blacklisted_software_mac= isset($quizaccess_proctor_setting->blacklisted_softwares_mac) ? $quizaccess_proctor_setting->blacklisted_softwares_mac : '';
$template->minimize_permitted= isset($quizaccess_proctor_setting->sb_kiosk_mode) ? !boolval($quizaccess_proctor_setting->sb_kiosk_mode) : true;
$template->screen_protection= isset($quizaccess_proctor_setting->sb_content_protection) ? boolval($quizaccess_proctor_setting->sb_content_protection) : false;
}else{
$template->tsb_enabled = false;
}
$template->session_id = $template->session_type === "live_proctor" ? $quizid.'-'.$USER->id : $quizid.'-'.$USER->id.'-'.$attempt; // Do not append attempt number for live proctoring. Re-attempting same quiz not supported in live proctoring.
$template->proview_url = trim(get_config('local_proview', 'proview_url'));
$template->token = trim(get_config('local_proview', 'token'));
Expand Down
47 changes: 35 additions & 12 deletions frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ function receiveMessage(event) {


function startProview(
authToken,
profileId,
session,
session_type = "ai_proctor",
proview_url,
authToken,
profileId,
session,
session_type,
proview_url,
additionalInstruction,
reference_link,
proview_playback_url,
skipHardwareTest,
previewStyle,
clear) {
blacklistedSoftwaresWindows,
blacklistedSoftwaresMac,
isScreenProtectionEnabled,
minimizeOption,
tsbenabled
) {
const referenceLinksArray = reference_link.match(/\[([^\]]+)\]\(([^)]+)\)/g)?.map(markdownLink => {
const match = markdownLink.match(/\[([^\]]+)\]\(([^)]+)\)/);
if (match) {
Expand All @@ -117,9 +120,14 @@ function startProview(
session_type: session_type,
additionalInstruction: additionalInstruction,
referenceLinks: JSON.stringify(referenceLinksArray),
clear: clear || false,
skipHardwareTest: skipHardwareTest || false,
previewStyle: previewStyle || 'position: fixed; bottom: 0px;',
clear: false,
skipHardwareTest: false,
previewStyle: 'position: fixed; bottom: 0px;',
enforceTSB: tsbenabled,
blacklistedSoftwaresWindows: blacklistedSoftwaresWindows,
blacklistedSoftwaresMac: blacklistedSoftwaresMac,
isScreenProtectionEnabled: isScreenProtectionEnabled,
minimizeOption: minimizeOption,
initCallback: createCallback(proview_playback_url, profileId, session_type)/* onProviewStart */
});
}
Expand Down Expand Up @@ -220,7 +228,22 @@ function run(){
response=xmlhttp.responseText;
response=JSON.parse(response);
window.quizPassword = response.quiz_password;
startProview(response.token, response.profile_id, response.session_id, response.session_type, response.proview_url, response.instructions, response.reference_link, response.proview_playback_url);
console.log(response);
rohansharmasitoula marked this conversation as resolved.
Show resolved Hide resolved
startProview(
response.token,
response.profile_id,
response.session_id,
response.session_type,
response.proview_url,
response.instructions,
response.reference_link,
response.proview_playback_url,
response.sb_blacklisted_software_windows,
response.sb_blacklisted_software_mac,
response.screen_protection,
response.minimize_permitted,
response.tsb_enabled
);
}
}
xmlhttp.open("GET", "datastore.php?quiz_id=" + urlParams.get('quizId') + "&sesskey=" + "<?php echo $sesskey?>" , true);
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2024102805;
$plugin->version = 2024110401;
$plugin->requires = 2020061500;
$plugin->release = '3.3.7 (Build: 2024102805)';
$plugin->release = '3.3.7 (Build: 2024110401)';
rohansharmasitoula marked this conversation as resolved.
Show resolved Hide resolved
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'local_proview';

Expand Down
Loading