Commit 856e8d62 authored by Robert Lyon's avatar Robert Lyon

Bug 1626818: Only alert for empty feedback if assessment absent

When adding an annotation feedback comment via a view

behatnotneeded

Change-Id: I007507bd2c47ecbb5099d5392edb57ed487a8395
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 920ec51b
......@@ -131,3 +131,10 @@ function addAnnotationFeedbackSuccess(form, data) {
$(formname + '_' + messageid).value = '';
formSuccess(form, data);
}
function addAnnotationFeedbackError(form, data) {
id = form.id;
id = id.replace(/^add_/, '').replace(/_form/,'');
jQuery('#' + id).removeClass('closed').addClass('active');
formError(form, data);
}
......@@ -1241,6 +1241,7 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
'autofocus' => false,
'elements' => array(),
'jssuccesscallback' => 'addAnnotationFeedbackSuccess',
'jserrorcallback' => 'addAnnotationFeedbackError',
'successcallback' => 'add_annotation_feedback_form_submit',
'validatecallback' => 'add_annotation_feedback_form_validate',
);
......@@ -1729,7 +1730,15 @@ function add_annotation_feedback_form_validate(Pieform $form, $values) {
$form->set_error('message', get_string('accessdenied', 'error'));
}
if (empty($values['message'])) {
$elements = $form->get_property('elements');
$assessmentchanged = false;
if (isset($elements['assessment']) && isset($elements['assessment']['defaultvalue'])) {
if ((int) $values['assessment'] !== (int) $elements['assessment']['defaultvalue']) {
$assessmentchanged = true;
}
}
// Only error on feedback if we are not changing assessment
if (empty($values['message']) && !$assessmentchanged) {
$form->set_error('message', get_string('annotationfeedbackempty', 'artefact.annotation'));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment