Skip to content

Commit

Permalink
Merge pull request #1 from talview/DEL-2240
Browse files Browse the repository at this point in the history
Del 2240: Updated changes for disabling proview for specific users
  • Loading branch information
manquer authored Jun 2, 2020
2 parents 2a5a851 + 49a94ae commit c583d7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit c583d7d

Please sign in to comment.