Commit cf91f026 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge changes I3a544769,If6cdce5c,I007507bd

* changes:
  Bug 1631209: Updating view mtime on annotation feedback/assessment
  Bug 1626818: Also allow the comment modal to stay open on error
  Bug 1626818: Only alert for empty feedback if assessment absent
parents 2fe22220 190f032d
......@@ -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);
}
......@@ -298,6 +298,9 @@ class ArtefactTypeAnnotation extends ArtefactType {
update_record('artefact_annotation', $data, 'annotation');
}
if ($this->get('view')) {
set_field('view', 'mtime', db_format_timestamp(time()), 'id', $this->get('view'));
}
db_commit();
$this->dirty = false;
}
......@@ -436,56 +439,8 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
if ($block->get('view')) {
// We found the annotation we're inputting feedback for.
// Rebuild the block's list and break out of the loop.
set_field('view', 'mtime', db_format_timestamp(time()), 'id', $block->get('view'));
$block->rebuild_artefact_list();
// Otherwise, we can do this but any images that were deleted while editing will still exist.
// if (count_records_select('view_artefact', "view = {$block->get('view')} AND block = {$block->get('id')} AND artefact = {$this->get('id')}") == 0) {
// // Insert the feedback record in the view_artefact table.
// $va = new StdClass;
// $va->view = $block->get('view');
// $va->block = $block->get('id');
// // this is the feedback id that was just inserted/updated.
// $va->artefact = $this->get('id');
// insert_record('view_artefact', $va);
// }
//
// // Get any artefacts (i.e. images) that may have been embedded
// // in the feedback text.
// $feedbackartefacts = artefact_get_references_in_html($this->get('description'));
// if (count($feedbackartefacts) > 0) {
//
// // Get list of allowed artefacts.
// // Please note that images owned by other users that are place on feedback
// // will not be part of the view_artefact because the owner of the
// // annotation does not own the image being placed on the feedback.
// // Therefore, when exported as Leap2A, these images will not come through.
// require_once('view.php');
// $searchdata = array(
// 'extraselect' => array(array('fieldname' => 'id', 'type' => 'int', 'values' => $feedbackartefacts)),
// 'userartefactsallowed' => true, // If this is a group view, the user can add personally owned artefacts
// );
// $view = $block->get_view();
// list($allowedfeedbackartefacts, $count) = View::get_artefactchooser_artefacts(
// $searchdata,
// $view->get('owner'),
// $view->get('group'),
// $view->get('institution'),
// true
// );
// foreach ($feedbackartefacts as $id) {
// $va = new StdClass;
// $va->view = $block->get('view');
// $va->block = $block->get('id');
// if (isset($allowedfeedbackartefacts[$id]) || isset($old[$id])) {
// // only insert artefacts that the view can actually own
// // and which are not already in the view_artefact table.
// $va->artefact = $id;
// if (count_records_select('view_artefact', "view = {$block->get('view')} AND block = {$block->get('id')} AND artefact = {$id}") == 0) {
// insert_record('view_artefact', $va);
// }
// }
// }
// }
}
break;
......@@ -1241,6 +1196,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 +1685,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'));
}
......
......@@ -19,6 +19,9 @@ function addFeedbackError(form, data) {
jQuery('.mce-toolbar.mce-first').siblings().toggleClass('hidden');
mce.focus();
}
if (jQuery('#feedback-form').hasClass('modal-docked')) {
jQuery('#feedback-form').removeClass('closed').addClass('active');
}
formError(form, data);
}
......
......@@ -680,6 +680,8 @@ class Framework {
'annotation' => $annotation,
'state' => $state);
if ($id) {
// get view
$view = get_field('framework_evidence', 'view', 'id', $id);
// update row
if (!empty($element)) {
$fordb['element'] = $element;
......@@ -695,6 +697,11 @@ class Framework {
$fordb['ctime'] = db_format_timestamp(time());
$id = insert_record('framework_evidence', (object) $fordb, 'id', true);
}
// We need to update mtime for the view
require_once('view.php');
$view = new View($view);
$view->set('mtime', time());
$view->commit();
return $id;
}
......
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