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 parameters for enabling secure Browser #102

Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 9 additions & 5 deletions classes/local/api/tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public static function storeFallbackDetails($attempt_no, $proview_url, $proctor_
private static function redirect_to_wrapper($proctoring_payload, $quiz)
{
// 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);
return;
}

private static function create_sb_wrapper($proctoring_payload, $quiz)
private static function create_sb_wrapper($proctoring_payload, $quiz, $quizaccess_proctor_setting)
{
global $PAGE;
$curl = new \curl();
Expand All @@ -111,11 +111,15 @@ private static function create_sb_wrapper($proctoring_payload, $quiz)
'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
'is_secure_browser' => true,
'blacklisted_softwares_windows' => $quizaccess_proctor_setting->blacklisted_softwares_win,
'blacklisted_softwares_mac' => $quizaccess_proctor_setting->blacklisted_softwares_mac,
'is_minimize' => $quizaccess_proctor_setting->sb_kiosk_mode,
'is_record_screen' => $quizaccess_proctor_setting->sb_content_protection
);
var_dump($data);
try {
$curl->setHeader(array('Content-Type: application/json', 'app-id: b37ec896-f62b-4cbe-b39f-8dd21881dfd3', 'Authorization: Bearer ' . $auth_token));
$curl->setHeader(array('Content-Type: application/json', 'Authorization: Bearer ' . $auth_token));
$response = $curl->post($url, json_encode($data));
$decoded_response = json_decode($response, false);
return $decoded_response;
Expand Down Expand Up @@ -196,7 +200,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
7 changes: 7 additions & 0 deletions datastore.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
$template->profile_id = $USER->id;
$template->instructions = $quizaccess_proctor_setting->instructions;
$template->reference_link= $quizaccess_proctor_setting->reference_link;
$template->tsbenabled= $quizaccess_proctor_setting->tsbenabled;
if ($template->tsbenabled && $template->tsbenabled === "1" ) {
$template->sb_blacklisted_software_windows= $quizaccess_proctor_setting->blacklisted_softwares_win;
$template->sb_blacklisted_software_mac= $quizaccess_proctor_setting->blacklisted_softwares_mac;
$template->minimize_permitted= $quizaccess_proctor_setting->sb_kiosk_mode;
$template->screen_protection= $quizaccess_proctor_setting->sb_content_protection;
}
$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
33 changes: 30 additions & 3 deletions frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function receiveMessage(event) {
//Javascript function to start proview invoked upon postMessage from iframe


function startProview(
function startProview({
authToken,
profileId,
session,
Expand All @@ -92,9 +92,15 @@ function startProview(
additionalInstruction,
reference_link,
proview_playback_url,
enforceTSB,
blacklistedSoftwaresWindows,
blacklistedSoftwaresMac,
isScreenProtectionEnabled,
minimizeOption,
skipHardwareTest,
previewStyle,
clear) {
clear
}) {
const referenceLinksArray = reference_link.match(/\[([^\]]+)\]\(([^)]+)\)/g)?.map(markdownLink => {
const match = markdownLink.match(/\[([^\]]+)\]\(([^)]+)\)/);
if (match) {
Expand All @@ -120,6 +126,11 @@ function startProview(
clear: clear || false,
skipHardwareTest: skipHardwareTest || false,
previewStyle: previewStyle || 'position: fixed; bottom: 0px;',
enforceTSB: enforceTSB === "1" ? true : false,
blacklistedSoftwaresWindows: blacklistedSoftwaresWindows || "",
blacklistedSoftwaresMac: blacklistedSoftwaresMac || "",
minimizeOption: minimizeOption === "1" ? true : false,
isScreenProtectionEnabled: isScreenProtectionEnabled === "1" ? true : false,
initCallback: createCallback(proview_playback_url, profileId, session_type)/* onProviewStart */
});
}
Expand Down Expand Up @@ -220,7 +231,23 @@ 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);
startProview(
{
authToken: response.token,
profileId: response.profile_id,
session: response.session_id,
session_type: response.session_type,
proview_url: response.proview_url,
additionalInstruction: response.instructions,
reference_link: response.reference_link,
proview_playback_url: response.proview_playback_url,
enforceTSB: response.tsbenabled,
blacklistedSoftwaresWindows: response.sb_blacklisted_software_windows,
blacklistedSoftwaresMac: response.sb_blacklisted_software_mac,
isScreenProtectionEnabled: response.minimize_permitted,
minimizeOption: response.screen_protection
}
);
}
}
xmlhttp.open("GET", "datastore.php?quiz_id=" + urlParams.get('quizId') + "&sesskey=" + "<?php echo $sesskey?>" , true);
Expand Down
6 changes: 3 additions & 3 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2024082604;
$plugin->version = 2024092606;
$plugin->requires = 2020061500;
$plugin->release = '3.3.5 (Build: 2024082604)';
$plugin->release = '3.4.0 (Build: 2024092606)';
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'local_proview';

$plugin->dependencies = array(
'quizaccess_proctor' => 2024022802,
'quizaccess_proctor' => 2024092606,
);
Loading