1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-03 23:07:27 +02:00

Merge branch 'wip-MDL-56271-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski 2017-01-16 08:01:23 +00:00
commit bd17f93f28

@ -125,15 +125,19 @@ class feedback_item_captcha extends feedback_item_base {
false,
false);
} else {
// Add recaptcha element that is used during the form validation.
$form->add_form_element($item,
['recaptcha', $inputname, $name],
['recaptcha', $inputname . 'recaptcha', $name],
false,
false);
// Add hidden element with value "1" that will be saved in the values table after completion.
$form->add_form_element($item, ['hidden', $inputname, 1], false);
$form->set_element_type($inputname, PARAM_INT);
}
// Add recaptcha validation to the form.
$form->add_validation_rule(function($values, $files) use ($item, $form) {
$elementname = $item->typ . '_' . $item->id;
$elementname = $item->typ . '_' . $item->id . 'recaptcha';
$recaptchaelement = $form->get_form_element($elementname);
if (empty($values['recaptcha_response_field'])) {
return array($elementname => get_string('required'));