diff --git a/classes/observer.php b/classes/observer.php index c361803..0910cc8 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -92,6 +92,10 @@ public static function store(\core\event\base $event) $eventdata->proctoring_enabled = !($quiz_proctor_settings->proctortype == 'noproctor'); $eventdata->proctoring_type = ($quiz_proctor_settings->proctortype == 'noproctor') ? NULL : $quiz_proctor_settings->proctortype; $eventdata->tsb_enabled = boolval($quiz_proctor_settings->tsbenabled); + $eventdata->blacklisted_windows_softwares = $quiz_proctor_settings->blacklisted_softwares_win; + $eventdata->blacklisted_mac_softwares = $quiz_proctor_settings->blacklisted_softwares_mac; + $eventdata->minimize_permitted = boolval($quiz_proctor_settings->sb_kiosk_mode); + $eventdata->screen_protection = boolval($quiz_proctor_settings->sb_content_protection); $eventdata->attempts = 0; $eventdata->timeopen = (int)$quiz->timeopen; $eventdata->timeclose = (int)$quiz->timeclose; diff --git a/classes/quiz_settings.php b/classes/quiz_settings.php index 0072c88..562f279 100644 --- a/classes/quiz_settings.php +++ b/classes/quiz_settings.php @@ -82,7 +82,22 @@ protected static function define_properties(): array 'type' => PARAM_RAW, 'default' => '', ], - + 'blacklisted_softwares_win' => [ + 'type' => PARAM_TEXT, + 'default' => '', + ], + 'blacklisted_softwares_mac' => [ + 'type' => PARAM_TEXT, + 'default' => '', + ], + 'sb_kiosk_mode' => [ + 'type' => PARAM_INT, + 'default' => 0, + ], + 'sb_content_protection' => [ + 'type' => PARAM_INT, + 'default' => 1, + ], ]; } diff --git a/classes/settings_provider.php b/classes/settings_provider.php index 68ee664..e4d36eb 100644 --- a/classes/settings_provider.php +++ b/classes/settings_provider.php @@ -217,6 +217,50 @@ protected static function add_proctor_usage_options(\mod_quiz_mod_form $quizform 'tsbenabled', get_string('tsbenable', 'quizaccess_proctor')); self::insert_element($quizform, $mform, $tsb_enable_element); + + $sb_blacklisted_software_mac_element = $mform->createElement( + 'textarea', + 'blacklisted_softwares_mac', + get_string('blacklisted_softwares_mac', 'quizaccess_proctor'), + ['style' => 'width: 100%;'] + ); + + self::insert_element($quizform, $mform, $sb_blacklisted_software_mac_element); + self::set_type($quizform, $mform, 'blacklisted_softwares_mac', PARAM_TEXT); + self::set_default($quizform, $mform, 'blacklisted_softwares_mac', ''); + self::add_help_button($quizform, $mform, 'blacklisted_softwares_mac'); + + + $sb_blacklisted_software_windows_element = $mform->createElement( + 'textarea', + 'blacklisted_softwares_win', + get_string('blacklisted_softwares_win', 'quizaccess_proctor'), + ['style' => 'width: 100%;'] + ); + + self::insert_element($quizform, $mform, $sb_blacklisted_software_windows_element); + self::set_type($quizform, $mform, 'blacklisted_softwares_win', PARAM_TEXT); + self::set_default($quizform, $mform, 'blacklisted_softwares_win', ''); + self::add_help_button($quizform, $mform, 'blacklisted_softwares_win'); + + $sb_kiosk_mode_enable_element = $mform->createElement( + 'checkbox', + 'sb_kiosk_mode', + get_string('sb_kiosk_mode_enable', 'quizaccess_proctor')); + self::insert_element($quizform, $mform, $sb_kiosk_mode_enable_element); + + $sb_content_protection_enable_element = $mform->createElement( + 'checkbox', + 'sb_content_protection', + get_string('sb_content_protection_enable', 'quizaccess_proctor')); + self::insert_element($quizform, $mform, $sb_content_protection_enable_element); + self::set_default($quizform, $mform, 'sb_content_protection', 1); + + $mform->hideIf('blacklisted_softwares_mac', 'tsbenabled', 'notchecked'); + $mform->hideIf('blacklisted_softwares_win', 'tsbenabled', 'notchecked'); + $mform->hideIf('sb_kiosk_mode', 'tsbenabled', 'notchecked'); + $mform->hideIf('sb_content_protection', 'tsbenabled', 'notchecked'); + } /** diff --git a/db/install.php b/db/install.php index e8da124..0719e42 100644 --- a/db/install.php +++ b/db/install.php @@ -55,6 +55,10 @@ function xmldb_quizaccess_proctor_install() { $proctorsettings->timecreated = time(); $proctorsettings->timemodified = time(); $proctorsettings->reference_link = ''; + $proctorsettings->blacklisted_softwares_win = ''; + $proctorsettings->blacklisted_softwares_mac = ''; + $proctorsettings->sb_kiosk_mode = 0; + $proctorsettings->sb_content_protection = 1; $DB->insert_record('quizaccess_proctor', $proctorsettings); diff --git a/db/install.xml b/db/install.xml index 6425177..f6093b5 100644 --- a/db/install.xml +++ b/db/install.xml @@ -16,6 +16,10 @@ + + + + diff --git a/db/upgrade.php b/db/upgrade.php index 89b90b4..2ef2dcb 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -90,5 +90,39 @@ function xmldb_quizaccess_proctor_upgrade($oldversion) { // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2024092605) { + // Define the table and fields to be added to quizaccess_proctor. + $table = new xmldb_table('quizaccess_proctor'); + $fields = [ + new xmldb_field('blacklisted_softwares_win', XMLDB_TYPE_TEXT, null, null, null, null, null, 'reference_link'), + new xmldb_field('blacklisted_softwares_mac', XMLDB_TYPE_TEXT, null, null, null, null, null, 'blacklisted_softwares_win'), + new xmldb_field('sb_kiosk_mode', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0', 'blacklisted_softwares_mac'), + new xmldb_field('sb_content_protection', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '1', 'sb_kiosk_mode'), + ]; + + // Conditionally launch add fields. + foreach ($fields as $field) { + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + } + + // Update existing records if the first field has been added. + if ($dbman->field_exists($table, $fields[0])) { + $records = $DB->get_records('quizaccess_proctor'); + foreach ($records as $record) { + $record->sb_blacklisted_software_windows = ''; + $record->sb_blacklisted_software_mac = ''; + $record->sb_kiosk_mode_enable = 0; + $record->sb_content_protection_enable = 0; + $DB->update_record('quizaccess_proctor', $record); + } + } + + // Proctor savepoint reached. + upgrade_plugin_savepoint(true, 2024092605, 'quizaccess', 'proctor'); + } + + return true; } diff --git a/lang/en/quizaccess_proctor.php b/lang/en/quizaccess_proctor.php index b45b35d..0a873ae 100644 --- a/lang/en/quizaccess_proctor.php +++ b/lang/en/quizaccess_proctor.php @@ -51,4 +51,10 @@ $string['reference_link'] = 'Reference Link'; $string['reference_link_help'] = 'Kindly provide the reference links in the format `[caption](url)`. For example, `[moodle](https://www.moodle.com)` one per line.'; $string['invalid_reference_links'] = 'Please enter valid reference links in the format [caption](url). For example, [moodle](https://www.moodle.com) one per line.'; -$string['instructions'] = 'Instructions'; \ No newline at end of file +$string['blacklisted_softwares_mac'] = 'Blacklisted Softwares (Mac)'; +$string['blacklisted_softwares_win'] = 'Blacklisted Softwares (Windows)'; +$string['sb_kiosk_mode_enable'] = 'Enable Kiosk Mode'; +$string['sb_content_protection_enable'] = 'Enable Content Protection'; +$string['instructions'] = 'Instructions'; +$string['blacklisted_softwares_win_help'] = 'Kindly provide the list of blacklisted softwares for Windows in comma separated format. For example Teams, Zoom, etc.'; +$string['blacklisted_softwares_mac_help'] = 'Kindly provide the list of blacklisted softwares for Mac in comma separated format. For example, Teams, Zoom, etc.'; \ No newline at end of file diff --git a/rule.php b/rule.php index 3a20912..005f679 100644 --- a/rule.php +++ b/rule.php @@ -154,6 +154,10 @@ public static function save_settings($quiz) $settings->instructions = $quizsettings->get('instructions'); $settings->tsbenabled = $quizsettings->get('tsbenabled'); $settings->reference_link = $quizsettings->get('reference_link'); + $settings->blacklisted_softwares_win = $quizsettings->get('blacklisted_softwares_win'); + $settings->blacklisted_softwares_mac = $quizsettings->get('blacklisted_softwares_mac'); + $settings->sb_kiosk_mode = $quizsettings->get('sb_kiosk_mode'); + $settings->sb_content_procetion = $quizsettings->get('sb_content_protection'); } if (empty($quizsettings)) { $quizsettings = new quiz_settings(0, $settings); @@ -173,6 +177,12 @@ public static function save_settings($quiz) $proctordata->tsbenabled = (isset($quiz->tsbenabled) && $quiz->tsbenabled) ? 1 : 0; $proctordata->usermodified = $USER->id; $proctordata->reference_link = $quiz->reference_link; + $proctordata->blacklisted_softwares_win = $quiz->blacklisted_softwares_win; + $proctordata->blacklisted_softwares_mac = $quiz->blacklisted_softwares_mac; + $proctordata->sb_kiosk_mode = (isset($quiz->sb_kiosk_mode) && $quiz->sb_kiosk_mode) ? 1 : 0; + $proctordata->sb_content_protection = (isset($quiz->sb_content_protection) && $quiz->sb_content_protection) ? 1 : 0; + + // Add remaining SB params after updating DB if ($proctor = $DB->get_record('quizaccess_proctor', array('quizid' => $quiz->id))) { $proctordata->id = $proctor->id; $proctordata->timemodified = time(); @@ -227,7 +237,11 @@ public static function get_settings_sql($quizid): array 'proctor.proctortype AS proctortype, ' . 'proctor.tsbenabled AS tsbenabled, ' . 'proctor.instructions AS instructions,' - . 'proctor.reference_link AS reference_link ' + . 'proctor.reference_link AS reference_link, ' + . 'proctor.blacklisted_softwares_win AS blacklisted_softwares_win, ' + . 'proctor.blacklisted_softwares_mac AS blacklisted_softwares_mac, ' + . 'proctor.sb_kiosk_mode AS sb_kiosk_mode, ' + . 'proctor.sb_content_protection AS sb_content_protection ' , 'LEFT JOIN {quizaccess_proctor} proctor ON proctor.quizid = quiz.id ' , [] ]; diff --git a/version.php b/version.php index 6f97724..8e6e3f7 100644 --- a/version.php +++ b/version.php @@ -24,9 +24,9 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024042401; +$plugin->version = 2024101501; $plugin->requires = 2020061500; -$plugin->release = '1.4.0 (Build: 2024042401)'; +$plugin->release = '1.5.0 (Build: 2024101501)'; $plugin->component = 'quizaccess_proctor'; $plugin->maturity = MATURITY_STABLE;