| Línea 210... |
Línea 210... |
| 210 |
*
|
210 |
*
|
| 211 |
* @param \mod_quiz_mod_form $quizform the quiz settings form that is being built.
|
211 |
* @param \mod_quiz_mod_form $quizform the quiz settings form that is being built.
|
| 212 |
* @param \MoodleQuickForm $mform the wrapped MoodleQuickForm.
|
212 |
* @param \MoodleQuickForm $mform the wrapped MoodleQuickForm.
|
| 213 |
*/
|
213 |
*/
|
| 214 |
protected static function add_seb_templates(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) {
|
214 |
protected static function add_seb_templates(\mod_quiz_mod_form $quizform, \MoodleQuickForm $mform) {
|
| - |
|
215 |
$context = $quizform->get_context();
|
| 215 |
if (self::can_use_seb_template($quizform->get_context()) || self::is_conflicting_permissions($quizform->get_context())) {
|
216 |
if (self::can_use_seb_template($context) || self::is_conflicting_permissions($context)) {
|
| 216 |
$element = $mform->createElement(
|
217 |
$element = $mform->createElement(
|
| 217 |
'select',
|
218 |
'select',
|
| 218 |
'seb_templateid',
|
219 |
'seb_templateid',
|
| 219 |
get_string('seb_templateid', 'quizaccess_seb'),
|
220 |
get_string('seb_templateid', 'quizaccess_seb'),
|
| 220 |
self::get_template_options()
|
221 |
self::get_template_options($context->instanceid)
|
| 221 |
);
|
222 |
);
|
| 222 |
} else {
|
223 |
} else {
|
| 223 |
$element = $mform->createElement('hidden', 'seb_templateid');
|
224 |
$element = $mform->createElement('hidden', 'seb_templateid');
|
| 224 |
}
|
225 |
}
|
| Línea 228... |
Línea 229... |
| 228 |
self::set_default($quizform, $mform, 'seb_templateid', 0);
|
229 |
self::set_default($quizform, $mform, 'seb_templateid', 0);
|
| 229 |
self::add_help_button($quizform, $mform, 'seb_templateid');
|
230 |
self::add_help_button($quizform, $mform, 'seb_templateid');
|
| Línea 230... |
Línea 231... |
| 230 |
|
231 |
|
| 231 |
// In case if the user can't use templates, but the quiz is configured to use them,
|
232 |
// In case if the user can't use templates, but the quiz is configured to use them,
|
| 232 |
// we'd like to display template, but freeze it.
|
233 |
// we'd like to display template, but freeze it.
|
| 233 |
if (self::is_conflicting_permissions($quizform->get_context())) {
|
234 |
if (self::is_conflicting_permissions($context)) {
|
| 234 |
self::freeze_element($quizform, $mform, 'seb_templateid');
|
235 |
self::freeze_element($quizform, $mform, 'seb_templateid');
|
| 235 |
}
|
236 |
}
|
| Línea 236... |
Línea 237... |
| 236 |
}
|
237 |
}
|
| Línea 469... |
Línea 470... |
| 469 |
'seb_showtime' => 'selectyesno',
|
470 |
'seb_showtime' => 'selectyesno',
|
| 470 |
'seb_showkeyboardlayout' => 'selectyesno',
|
471 |
'seb_showkeyboardlayout' => 'selectyesno',
|
| 471 |
'seb_showwificontrol' => 'selectyesno',
|
472 |
'seb_showwificontrol' => 'selectyesno',
|
| 472 |
'seb_enableaudiocontrol' => 'selectyesno',
|
473 |
'seb_enableaudiocontrol' => 'selectyesno',
|
| 473 |
'seb_muteonstartup' => 'selectyesno',
|
474 |
'seb_muteonstartup' => 'selectyesno',
|
| - |
|
475 |
'seb_allowcapturecamera' => 'selectyesno',
|
| - |
|
476 |
'seb_allowcapturemicrophone' => 'selectyesno',
|
| 474 |
'seb_allowspellchecking' => 'selectyesno',
|
477 |
'seb_allowspellchecking' => 'selectyesno',
|
| 475 |
'seb_activateurlfiltering' => 'selectyesno',
|
478 |
'seb_activateurlfiltering' => 'selectyesno',
|
| 476 |
'seb_filterembeddedcontent' => 'selectyesno',
|
479 |
'seb_filterembeddedcontent' => 'selectyesno',
|
| 477 |
'seb_expressionsallowed' => 'textarea',
|
480 |
'seb_expressionsallowed' => 'textarea',
|
| 478 |
'seb_regexallowed' => 'textarea',
|
481 |
'seb_regexallowed' => 'textarea',
|
| Línea 498... |
Línea 501... |
| 498 |
'seb_showtime' => PARAM_BOOL,
|
501 |
'seb_showtime' => PARAM_BOOL,
|
| 499 |
'seb_showkeyboardlayout' => PARAM_BOOL,
|
502 |
'seb_showkeyboardlayout' => PARAM_BOOL,
|
| 500 |
'seb_showwificontrol' => PARAM_BOOL,
|
503 |
'seb_showwificontrol' => PARAM_BOOL,
|
| 501 |
'seb_enableaudiocontrol' => PARAM_BOOL,
|
504 |
'seb_enableaudiocontrol' => PARAM_BOOL,
|
| 502 |
'seb_muteonstartup' => PARAM_BOOL,
|
505 |
'seb_muteonstartup' => PARAM_BOOL,
|
| - |
|
506 |
'seb_allowcapturecamera' => PARAM_BOOL,
|
| - |
|
507 |
'seb_allowcapturemicrophone' => PARAM_BOOL,
|
| 503 |
'seb_allowspellchecking' => PARAM_BOOL,
|
508 |
'seb_allowspellchecking' => PARAM_BOOL,
|
| 504 |
'seb_activateurlfiltering' => PARAM_BOOL,
|
509 |
'seb_activateurlfiltering' => PARAM_BOOL,
|
| 505 |
'seb_filterembeddedcontent' => PARAM_BOOL,
|
510 |
'seb_filterembeddedcontent' => PARAM_BOOL,
|
| 506 |
'seb_expressionsallowed' => PARAM_RAW,
|
511 |
'seb_expressionsallowed' => PARAM_RAW,
|
| 507 |
'seb_regexallowed' => PARAM_RAW,
|
512 |
'seb_regexallowed' => PARAM_RAW,
|
| Línea 509... |
Línea 514... |
| 509 |
'seb_regexblocked' => PARAM_RAW,
|
514 |
'seb_regexblocked' => PARAM_RAW,
|
| 510 |
];
|
515 |
];
|
| 511 |
}
|
516 |
}
|
| Línea 512... |
Línea 517... |
| 512 |
|
517 |
|
| 513 |
/**
|
518 |
/**
|
| - |
|
519 |
* Check that we have conflicting permissions with the current SEB settings.
|
| - |
|
520 |
*
|
| - |
|
521 |
* Check if the existing settings of the quiz (if any) are conflicting with the
|
| 514 |
* Check that we have conflicting permissions.
|
522 |
* capabilities of the managing user.
|
| 515 |
*
|
- |
|
| 516 |
* In Some point we can have settings save by the person who use specific
|
523 |
*
|
| 517 |
* type of SEB usage (e.g. use templates). But then another person who can't
|
524 |
* E.g. a quiz is using an SEB template and a site admin is able to select this
|
| 518 |
* use template (but still can update other settings) edit the same quiz. This is
|
525 |
* option while a course manager cannot. Therefore it will return true for a course
|
| 519 |
* conflict of permissions and we'd like to build the settings form having this in
|
- |
|
| 520 |
* mind.
|
526 |
* manager and return false for a site admin.
|
| 521 |
*
|
527 |
*
|
| 522 |
* @param \context $context Context used with capability checking.
|
528 |
* @param \context $context Context used with capability checking.
|
| 523 |
*
|
529 |
*
|
| 524 |
* @return bool
|
530 |
* @return bool
|
| Línea 533... |
Línea 539... |
| 533 |
if (empty($settings)) {
|
539 |
if (empty($settings)) {
|
| 534 |
return false;
|
540 |
return false;
|
| 535 |
}
|
541 |
}
|
| Línea 536... |
Línea 542... |
| 536 |
|
542 |
|
| 537 |
if (!self::can_use_seb_template($context) &&
|
543 |
if (!self::can_use_seb_template($context) &&
|
| - |
|
544 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_TEMPLATE) {
|
| - |
|
545 |
return true;
|
| - |
|
546 |
}
|
| - |
|
547 |
|
| - |
|
548 |
if (!self::can_use_seb_client_config($context) &&
|
| 538 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_TEMPLATE) {
|
549 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_CLIENT_CONFIG) {
|
| 539 |
return true;
|
550 |
return true;
|
| Línea 540... |
Línea 551... |
| 540 |
}
|
551 |
}
|
| 541 |
|
552 |
|
| 542 |
if (!self::can_upload_seb_file($context) &&
|
553 |
if (!self::can_upload_seb_file($context) &&
|
| 543 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_UPLOAD_CONFIG) {
|
554 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_UPLOAD_CONFIG) {
|
| Línea 544... |
Línea 555... |
| 544 |
return true;
|
555 |
return true;
|
| 545 |
}
|
556 |
}
|
| 546 |
|
557 |
|
| 547 |
if (!self::can_configure_manually($context) &&
|
558 |
if (!self::can_configure_manually($context) &&
|
| Línea 548... |
Línea 559... |
| 548 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_CONFIG_MANUALLY) {
|
559 |
$settings->get('requiresafeexambrowser') == self::USE_SEB_CONFIG_MANUALLY) {
|
| 549 |
return true;
|
560 |
return true;
|
| Línea 564... |
Línea 575... |
| 564 |
if (self::can_configure_manually($context) || self::is_conflicting_permissions($context)) {
|
575 |
if (self::can_configure_manually($context) || self::is_conflicting_permissions($context)) {
|
| 565 |
$options[self::USE_SEB_CONFIG_MANUALLY] = get_string('seb_use_manually', 'quizaccess_seb');
|
576 |
$options[self::USE_SEB_CONFIG_MANUALLY] = get_string('seb_use_manually', 'quizaccess_seb');
|
| 566 |
}
|
577 |
}
|
| Línea 567... |
Línea 578... |
| 567 |
|
578 |
|
| 568 |
if (self::can_use_seb_template($context) || self::is_conflicting_permissions($context)) {
|
579 |
if (self::can_use_seb_template($context) || self::is_conflicting_permissions($context)) {
|
| 569 |
if (!empty(self::get_template_options())) {
|
580 |
if (!empty(self::get_template_options($context->instanceid))) {
|
| 570 |
$options[self::USE_SEB_TEMPLATE] = get_string('seb_use_template', 'quizaccess_seb');
|
581 |
$options[self::USE_SEB_TEMPLATE] = get_string('seb_use_template', 'quizaccess_seb');
|
| 571 |
}
|
582 |
}
|
| Línea 572... |
Línea 583... |
| 572 |
}
|
583 |
}
|
| 573 |
|
584 |
|
| 574 |
if (self::can_upload_seb_file($context) || self::is_conflicting_permissions($context)) {
|
585 |
if (self::can_upload_seb_file($context) || self::is_conflicting_permissions($context)) {
|
| Línea -... |
Línea 586... |
| - |
|
586 |
$options[self::USE_SEB_UPLOAD_CONFIG] = get_string('seb_use_upload', 'quizaccess_seb');
|
| 575 |
$options[self::USE_SEB_UPLOAD_CONFIG] = get_string('seb_use_upload', 'quizaccess_seb');
|
587 |
}
|
| - |
|
588 |
|
| Línea 576... |
Línea 589... |
| 576 |
}
|
589 |
if (self::can_use_seb_client_config($context) || self::is_conflicting_permissions($context)) {
|
| 577 |
|
590 |
$options[self::USE_SEB_CLIENT_CONFIG] = get_string('seb_use_client', 'quizaccess_seb');
|
| Línea 578... |
Línea 591... |
| 578 |
$options[self::USE_SEB_CLIENT_CONFIG] = get_string('seb_use_client', 'quizaccess_seb');
|
591 |
}
|
| 579 |
|
592 |
|
| 580 |
return $options;
|
593 |
return $options;
|
| 581 |
}
|
594 |
}
|
| 582 |
|
595 |
|
| 583 |
/**
|
596 |
/**
|
| - |
|
597 |
* Returns a list of templates.
|
| 584 |
* Returns a list of templates.
|
598 |
* @return array
|
| - |
|
599 |
*/
|
| 585 |
* @return array
|
600 |
protected static function get_template_options($cmid): array {
|
| - |
|
601 |
$templates = [];
|
| - |
|
602 |
$templatetable = template::TABLE;
|
| - |
|
603 |
$sebquizsettingstable = seb_quiz_settings::TABLE;
|
| - |
|
604 |
$select = "enabled = 1
|
| - |
|
605 |
OR EXISTS (
|
| - |
|
606 |
SELECT 1
|
| 586 |
*/
|
607 |
FROM {{$sebquizsettingstable}}
|
| 587 |
protected static function get_template_options(): array {
|
608 |
WHERE templateid = {{$templatetable}}.id
|
| 588 |
$templates = [];
|
609 |
AND cmid = ?
|
| 589 |
$records = template::get_records(['enabled' => 1], 'name');
|
610 |
)";
|
| Línea 626... |
Línea 647... |
| 626 |
'seb_showreloadbutton' => 1,
|
647 |
'seb_showreloadbutton' => 1,
|
| 627 |
'seb_showtime' => 1,
|
648 |
'seb_showtime' => 1,
|
| 628 |
'seb_showkeyboardlayout' => 1,
|
649 |
'seb_showkeyboardlayout' => 1,
|
| 629 |
'seb_showwificontrol' => 0,
|
650 |
'seb_showwificontrol' => 0,
|
| 630 |
'seb_enableaudiocontrol' => 0,
|
651 |
'seb_enableaudiocontrol' => 0,
|
| - |
|
652 |
'seb_allowcapturecamera' => 0,
|
| - |
|
653 |
'seb_allowcapturemicrophone' => 0,
|
| 631 |
'seb_muteonstartup' => 0,
|
654 |
'seb_muteonstartup' => 0,
|
| 632 |
'seb_allowspellchecking' => 0,
|
655 |
'seb_allowspellchecking' => 0,
|
| 633 |
'seb_activateurlfiltering' => 0,
|
656 |
'seb_activateurlfiltering' => 0,
|
| 634 |
'seb_filterembeddedcontent' => 0,
|
657 |
'seb_filterembeddedcontent' => 0,
|
| 635 |
'seb_expressionsallowed' => '',
|
658 |
'seb_expressionsallowed' => '',
|
| Línea 744... |
Línea 767... |
| 744 |
public static function can_configure_seb(\context $context): bool {
|
767 |
public static function can_configure_seb(\context $context): bool {
|
| 745 |
return has_capability('quizaccess/seb:manage_seb_requiresafeexambrowser', $context);
|
768 |
return has_capability('quizaccess/seb:manage_seb_requiresafeexambrowser', $context);
|
| 746 |
}
|
769 |
}
|
| Línea 747... |
Línea 770... |
| 747 |
|
770 |
|
| - |
|
771 |
/**
|
| - |
|
772 |
* Check if the current user can select to use the SEB client configuration.
|
| - |
|
773 |
*
|
| - |
|
774 |
* @param \context $context Context to check access in.
|
| - |
|
775 |
* @return bool
|
| - |
|
776 |
*/
|
| - |
|
777 |
public static function can_use_seb_client_config(\context $context): bool {
|
| - |
|
778 |
return has_capability('quizaccess/seb:manage_seb_usesebclientconfig', $context);
|
| - |
|
779 |
}
|
| - |
|
780 |
|
| 748 |
/**
|
781 |
/**
|
| 749 |
* Check if the current user can use preconfigured templates.
|
782 |
* Check if the current user can use preconfigured templates.
|
| 750 |
*
|
783 |
*
|
| 751 |
* @param \context $context Context to check access in.
|
784 |
* @param \context $context Context to check access in.
|
| 752 |
* @return bool
|
785 |
* @return bool
|
| Línea 790... |
Línea 823... |
| 790 |
*
|
823 |
*
|
| 791 |
* @param \context $context Context to check access in.
|
824 |
* @param \context $context Context to check access in.
|
| 792 |
* @return bool
|
825 |
* @return bool
|
| 793 |
*/
|
826 |
*/
|
| 794 |
public static function can_configure_manually(\context $context): bool {
|
827 |
public static function can_configure_manually(\context $context): bool {
|
| - |
|
828 |
if (!has_capability('quizaccess/seb:manage_seb_configuremanually', $context)) {
|
| - |
|
829 |
return false;
|
| - |
|
830 |
}
|
| - |
|
831 |
|
| 795 |
foreach (self::get_seb_config_elements() as $name => $type) {
|
832 |
foreach (self::get_seb_config_elements() as $name => $type) {
|
| 796 |
if (self::can_manage_seb_config_setting($name, $context)) {
|
833 |
if (self::can_manage_seb_config_setting($name, $context)) {
|
| 797 |
return true;
|
834 |
return true;
|
| 798 |
}
|
835 |
}
|
| 799 |
}
|
836 |
}
|
| Línea 881... |
Línea 918... |
| 881 |
'seb_showwificontrol' => [],
|
918 |
'seb_showwificontrol' => [],
|
| 882 |
],
|
919 |
],
|
| 883 |
'seb_enableaudiocontrol' => [
|
920 |
'seb_enableaudiocontrol' => [
|
| 884 |
'seb_muteonstartup' => [],
|
921 |
'seb_muteonstartup' => [],
|
| 885 |
],
|
922 |
],
|
| - |
|
923 |
'seb_allowcapturecamera' => [],
|
| - |
|
924 |
'seb_allowcapturemicrophone' => [],
|
| 886 |
'seb_allowspellchecking' => [],
|
925 |
'seb_allowspellchecking' => [],
|
| 887 |
'seb_activateurlfiltering' => [
|
926 |
'seb_activateurlfiltering' => [
|
| 888 |
'seb_filterembeddedcontent' => [],
|
927 |
'seb_filterembeddedcontent' => [],
|
| 889 |
'seb_expressionsallowed' => [],
|
928 |
'seb_expressionsallowed' => [],
|
| 890 |
'seb_regexallowed' => [],
|
929 |
'seb_regexallowed' => [],
|