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

Del 2240: Updated changes for disabling proview for specific users #1

Merged
merged 4 commits into from
Jun 2, 2020
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
20 changes: 20 additions & 0 deletions classes/injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ class injector {
* @return null
*/
public static function inject() {
global $USER, $COURSE, $DB;
$is_proctored = true;
$group_list = $USER->groupmember[$COURSE->id]; //fetching the group for the current course.

//Logic for enabling specific user to use proctered assessment STARTS
if( !empty($group_list) ) {
foreach ($group_list as $group) {
$group_members = $DB->get_record('groups_members', ['id' => $group]);//request to get groupmembership details.

$group_details = $DB->get_record('groups', ['id' => $group_members->groupid]);// request to get group details.

if($group_details->name === 'proview_disabled') {
$is_proctored =false;
}
}
if(!$is_proctored) {
return;
}
}
//Logic for enabling specific user to use proctered assessment ENDS
if (self::$injected) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ function receiveMessage(event) {
//Javascript function to start proview invoked upon postmessage from iframe
function startProview(authToken, session, proview_url, clear, skipHardwareTest, previewStyle) {
let url = proview_url || '//cdn.proview.io/init.js';
//Setting src attribute as error page URL so if the proview is not loaded error page will be shown
document.getElementById('contentIFrame').src = 'https://pages.talview.com/proview/error/index.html';
let iframeWindow = document.getElementById('contentIFrame').contentWindow;
(function(i,s,o,g,r,a,m){i['TalviewProctor']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
Expand Down Expand Up @@ -121,12 +123,10 @@ function stopProview(url) {
window.location.href = url;
})
}

}
(function() {
const urlParams = new URLSearchParams(window.location.search);
window.iframeUrl = urlParams.get('url');
document.getElementById('contentIFrame').src = iframeUrl;
startProview(urlParams.get('token'),urlParams.get('profile'),urlParams.get('proview_url'))
})();
</script>
Expand Down