Skip to content

Commit

Permalink
Refactor back button hiding logic for SB exams and update plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
rohansharmasitoula committed Oct 28, 2024
1 parent 5610ed3 commit b742356
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
34 changes: 30 additions & 4 deletions classes/local/api/tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,36 @@ public static function insert_tracking()
if (strpos($PAGE->url, ('mod/quiz/attempt')) &&
$quizaccess_proctor_setting &&
$quizaccess_proctor_setting->proctortype == 'noproctor' &&
$quizaccess_proctor_setting->tsbenabled &&
strpos($_SERVER ['HTTP_USER_AGENT'], "Proview-SB") === FALSE) {
self::redirect_to_wrapper($template, $quiz);
return;
$quizaccess_proctor_setting->tsbenabled
) {
if(strpos($_SERVER ['HTTP_USER_AGENT'], "Proview-SB") === FALSE){
self::redirect_to_wrapper($template, $quiz);
return;
}
else{
$PAGE->requires->js_amd_inline('
require(["jquery"], function($) {
$(document).ready(function() {
console.log("Document is ready. Checking links...");
document.querySelectorAll('a').forEach(link => {
const urlContainsIndex = link.href.includes('mod/quiz/view.php');
const textContainsBack = link.textContent.trim().toLowerCase().includes('back');

if (urlContainsIndex && textContainsBack) {
console.log(`Hiding link: ${link.href} with text: ${link.textContent}`);
// Hide the element by setting its display style to none
link.style.display = 'none';
} else {
console.log(`Link not hidden: ${link.href} with text: ${link.textContent}`);
}
});

console.log("Link checking complete.");
});
});
');
}
}
if (strpos($PAGE->url, ('mod/quiz/report'))) {
Expand Down
14 changes: 0 additions & 14 deletions templates/tracker.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@
});
window.location.href = '{{root_dir}}local/proview/frame.php?'+params.toString();
}
// Hide back Button from quiz if exam is launched in SB Starts
// NOTE: This will only work for English Language due to string matching
if (window.navigator.userAgent.match(/Proview-SB/)) {
console.log("User Agent: ", window.navigator.userAgent);
document.querySelectorAll('a').forEach(link => {
const urlContainsIndex = link.href.includes('moodle/mod/quiz/view.php');
const textContainsBack = link.textContent.trim().toLowerCase().includes('back');
if (urlContainsIndex && textContainsBack) {
// Hide the element by setting its display style to none
link.style.display = 'none';
}
});
}
// Hide back Button from quiz if exam is launched in SB Starts
}
if(current.match('mod/quiz/view') ) {
if(window.self != window.top && window.parent.previousUrl) { //checking if the request is coming from summary
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 = 2024102601;
$plugin->version = 2024102805;
$plugin->requires = 2020061500;
$plugin->release = '3.3.7 (Build: 2024102601)';
$plugin->release = '3.3.7 (Build: 2024102805)';
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'local_proview';

Expand Down

0 comments on commit b742356

Please sign in to comment.