Skip to content

Commit

Permalink
Fix TSB Redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
devang1281 committed Aug 7, 2023
1 parent cd586eb commit d6e0dd5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
56 changes: 27 additions & 29 deletions classes/local/injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ public static function inject() {
}
// Logic for enabling proview for course level and quiz level ends.

// Logic for enabling specific user to use proctored assessment STARTS
if ($COURSE && $COURSE->id && get_config('local_proview', 'auto_password_injection_enabled')) {
// Logic for enabling specific user to use proctored assessment STARTS
// Fetching the group details for the proview_disabled group.
$groupdetails = $DB->get_record('groups', ['courseid' => $COURSE->id, 'name' => 'proview_disabled']);

Expand All @@ -157,36 +157,34 @@ public static function inject() {
}
}
// Logic for enabling specific user to use proctored assessment ENDS.

// // Logic for enabling Talview Safe Exam Browser if proctoring is enabled and quiz title contains TSB keyword STARTS
// if ($PAGE->cm) {
// $quiz = $DB->get_record('quiz', array('id' => $PAGE->cm->instance));
// // print $PAGE->url."\n";
// if ((strpos ($PAGE->url, ('mod/quiz/attempt')) !== FALSE
// || strpos ($PAGE->url, ('mod/quiz/summary')) !== FALSE)
// && (($quizaccess_proctor_setting_enabled
// && $quizaccess_proctor_setting->tsbenabled)
// || (!$quizaccess_proctor_setting_enabled
// && $string_match
// && strpos ($quiz->name, ('[TSB]')) !== FALSE))
// && $_SERVER ['HTTP_USER_AGENT'] != "Proview-SB") {
// // echo $_SERVER ['HTTP_USER_AGENT'];
// $tsbURL = "tsb://".explode("://",$PAGE->url)[1];
// if (!headers_sent()) {
// header('Location: '.$tsbURL);
// } else {
// echo ("<script>location.href='$tsbURL'</script>");
// }
// die;
// }
// }
// // Logic for enabling Talview Safe Exam Browser if proctoring is enabled and quiz title contains TSB keyword ENDS
if (self::$injected) {
return;
}
// Logic for enabling Talview Safe Exam Browser if proctoring is enabled and quiz title contains TSB keyword STARTS
if ($PAGE->cm) {
$quiz = $DB->get_record('quiz', array('id' => $PAGE->cm->instance));
if ((strpos ($PAGE->url, ('mod/quiz/attempt')) !== FALSE
|| strpos ($PAGE->url, ('mod/quiz/summary')) !== FALSE)
&& (($quizaccess_proctor_setting_enabled
&& $quizaccess_proctor_setting->tsbenabled)
|| (!$quizaccess_proctor_setting_enabled
&& $string_match
&& strpos ($quiz->name, ('[TSB]')) !== FALSE))
&& strpos($_SERVER ['HTTP_USER_AGENT'], "Proview-SB") === FALSE ){
$redirectURL = "tsb://".explode("://",$PAGE->url)[1];
$tsbURL = "https://pages.talview.com/tsb?redirect_url=".$redirectURL."&user=".$_SERVER ['HTTP_USER_AGENT'];
// $PAGE->requires->js_amd_inline("document.location.replace('" . $tsbURL . "')");
if (!headers_sent()) {
header('Location: '.$tsbURL);
} else {
echo ("<script>location.href='$tsbURL'</script>");
}
die;
}
self::$injected = true;
}

// Logic for enabling Talview Safe Exam Browser if proctoring is enabled and quiz title contains TSB keyword ENDS
if (self::$injected) {
return;
}
self::$injected = true;
$t = new api\tracker();
$t::insert_tracking();
return;
Expand Down
8 changes: 6 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2023080101;
$plugin->version = 2023080601;
$plugin->requires = 2020061500;
$plugin->release = '2.1.0 (Build: 2023080101)';
$plugin->release = '2.2.0 (Build: 2023080601)';
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'local_proview';

$plugin->dependencies = array(
'quizaccess_proctor' => ANY_VERSION,
);

0 comments on commit d6e0dd5

Please sign in to comment.