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

30 migrate proview to v7+ #32

Merged
merged 23 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0c6ef13
Migrate Proview from V5 to V7 and add Talview Safe Browser support
devang1281 Jun 16, 2023
9bf768e
Downgrade ubuntu version for moodle 3.9 support
devang1281 Jun 16, 2023
0427e4d
Add check to see if User agent is for TSB and update sentry/sdk version
devang1281 Jun 20, 2023
86dafb9
Update Ci/Cd to run on prs to release branch
devang1281 Jun 20, 2023
f9068aa
Open TSB only when quiz starts
devang1281 Jun 20, 2023
081ee53
Fix Plugin build for php v7.4
devang1281 Jul 3, 2023
de4b7d1
Do not append attempt number for live proctoring. Re-attempting same …
devang1281 Jul 10, 2023
f3360e0
Add the following configurations on plugin config page:
devang1281 Jul 10, 2023
8f31b2f
Start Consuming string_match config
devang1281 Jul 10, 2023
5625f7d
Upgrade Plugin to Release 2.0.0:
devang1281 Jul 10, 2023
dfc726c
Remove redundant print and echo statements
devang1281 Jul 10, 2023
77c4c0d
Update keywords for specifying proview types
devang1281 Jul 11, 2023
5cb16f6
Upgrade Plugin Version
devang1281 Jul 11, 2023
e96bb7d
Update proview_admin_url to proview_playback_url
devang1281 Jul 11, 2023
5e45df4
Take quiz level proctor settings from moodle-quizaccess_proctor if en…
devang1281 Jul 21, 2023
e588126
BugFix: Taking incorrect value form quizaccess_proctor
devang1281 Jul 26, 2023
0414303
Code Cleaning
devang1281 Aug 3, 2023
6eb0bf5
Closes #29
devang1281 Aug 3, 2023
0f59c96
Fix Performance concern by injecting business logic on required pages
devang1281 Aug 3, 2023
cd586eb
Auto inject quiz password only if enabled on admin level
devang1281 Aug 3, 2023
d6e0dd5
Fix TSB Redirection
devang1281 Aug 7, 2023
46a4f28
Deprecated older Proview Configurations:
devang1281 Aug 7, 2023
6ea5a82
Update session id for v7+
devang1281 Aug 7, 2023
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
5 changes: 4 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ on:
tags:
- "*"
# - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches:
- release/*

name: Upload Release Asset

jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
79 changes: 36 additions & 43 deletions classes/local/injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class injector {
* @return null
*/
private static function inject_password($PAGE, $quiz) {
if ($quiz->password) { // If the quiz is password protected then inject the js.
if ($quiz->password && get_config('local_proview', 'auto_password_injection_enabled')) { // If the quiz is password protected then inject the js.
$PAGE->requires->js_call_amd('local_proview/proview', 'init', array($quiz->password));
}
}
Expand All @@ -63,56 +63,30 @@ private static function inject_password($PAGE, $quiz) {
*/
public static function inject() {
global $USER, $COURSE, $DB, $PAGE;

$page_path = $PAGE->url->get_path();
if (!preg_match('/mod\/quiz\/(attempt|summary|startattempt|view|report)/',$page_path )) {
return;
}
$enabled = get_config('local_proview', 'enabled');
if (!$enabled) {
$quizaccess_proctor_setting_enabled = get_config('quizaccess_proctor', 'enableproctor');
if (!$enabled || !$quizaccess_proctor_setting_enabled) {
return;
}

// Logic for enabling proview for course level and quiz level starts.
try {
$list = new \core_course_list_element($COURSE);
$datas = $list->get_custom_fields();
$courselevelconfiguration = 0; // Field for storing course level configuration.
foreach ($datas as $data) {
if (empty($data->get_value())) {
continue;
}
if (strpos(($data->get_field()->get('name')), "Proview Configuration") !== false) {
$courselevelconfiguration = $data->get_value();
}
}
if ($PAGE->cm) {
$quiz = $DB->get_record('quiz', array('id' => $PAGE->cm->instance));
switch ($courselevelconfiguration) {
case 1: // Proview Enabled for complete course.
break;
case 2: // Proview Enabled for specific quizes.
if ($quiz && $quiz->id) {
if (!stripos (json_encode($quiz->name), "Proctor")) {
self::inject_password($PAGE, $quiz);
return;
}
}
break;
case 3: // Proview disabled for complete course.
self::inject_password($PAGE, $quiz);
return;
break;
default: // If course level configuration is not enabled then Quiz level configuration is enabled by default.
if ($quiz && $quiz->id) {
if (!stripos (json_encode($quiz->name), "Proctor")) {
self::inject_password($PAGE, $quiz);
return;
}
}
break;
$quizaccess_proctor_setting = $DB->get_record('quizaccess_proctor', array('quizid' => $quiz->id));
if ((!$quizaccess_proctor_setting) ||
($quizaccess_proctor_setting && $quizaccess_proctor_setting->proctortype == 'noproctor')) {
self::inject_password($PAGE, $quiz);
return;
}
}
// 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) {
// 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 @@ -131,12 +105,31 @@ public static function inject() {
}
}
// Logic for enabling specific user to use proctored assessment ENDS.
if (self::$injected) {
return;
}
// Logic for enabling Talview Safe Exam Browser if proctoring is enabled and TSB is enabled 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)
&& strpos($_SERVER ['HTTP_USER_AGENT'], "Proview-SB") === FALSE ){
$redirectURL = "tsb://".explode("://",$PAGE->url)[1];
$tsbURL = "https://pages.talview.com/tsb/index.html?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 TSB is enabled ENDS
if (self::$injected) {
return;
}
self::$injected = true;
$t = new api\tracker();
$t::insert_tracking();
return;
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
"description":"Plugin to enable Talview's Proview proctoring solution on Moodle.",
"require": {
"composer/installers": "~1.0",
"sentry/sdk": "^2.1"
"sentry/sdk": "^3.5"
},
"extra": {
"installer-name": "proview"
},
"config": {
"allow-plugins": {
"composer/installers": true,
"php-http/discovery": true
}
}
}
Loading