Commit b1c09465 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1632863: Allowing change of assessment to be recorded



When we do an annotation feedback either by page or matrix

behatnotneeded

Change-Id: I6b874641cd260523cffd541c828dbec8a939c47b
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 8ceb68d3
......@@ -122,4 +122,5 @@ $string['private'] = 'Private';
$string['public'] = 'Public';
$string['enteredon'] = 'entered on';
$string['noreflectionentryfound'] = "Cannot find reflection entry for annotation.";
$string['nofeedback'] = "There is no feedback for this annotation yet.";
\ No newline at end of file
$string['nofeedback'] = "There is no feedback for this annotation yet.";
$string['assessmentchangedto'] = "Assessment: %s";
......@@ -471,6 +471,7 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
// the fileid. We need to delete by the resourceid.
delete_records('artefact_file_embedded', 'resourceid', $this->id);
delete_records('artefact_annotation_feedback', 'artefact', $this->id);
delete_records('framework_assessment_feedback', 'artefact', $this->id);
parent::delete();
db_commit();
}
......@@ -845,6 +846,15 @@ class ArtefactTypeAnnotationfeedback extends ArtefactType {
);
}
}
if ($statechange = get_record('framework_assessment_feedback', 'artefact', $item->id)) {
safe_require('module', 'framework');
$state = Framework::get_state_array($statechange->newstatus, true);
$states = Framework::get_evidence_statuses($statechange->framework);
// We need to amend a bit of text to the feedback message
$item->description .= '<div class="assessment text-small">' .
get_string('assessmentchangedto', 'artefact.annotation', $states[$statechange->newstatus]) .
' <span class="assessmentfeedback ' . $state['classes'] . '"></span></div>';
}
}
$extradata = array(
......@@ -1711,7 +1721,9 @@ function add_annotation_feedback_form_validate(Pieform $form, $values) {
}
function add_annotation_feedback_form_submit(Pieform $form, $values) {
global $USER;
$data = (object) array(
'title' => get_string('Annotation', 'artefact.annotation'),
'description' => $values['message'],
......@@ -1775,6 +1787,20 @@ function add_annotation_feedback_form_submit(Pieform $form, $values) {
);
// update row
update_record('framework_evidence', (object) $fordb, (object) array('id' => $values['evidence']));
$framework = get_field('framework_evidence', 'framework', 'id', $values['evidence']);
// check if assessment status changed
$elements = $form->get_property('elements');
$assessmentchanged = false;
if (isset($elements['assessment']) && isset($elements['assessment']['defaultvalue'])) {
if ((int) $values['assessment'] !== (int) $elements['assessment']['defaultvalue']) {
// We need to log this assessment change
insert_record('framework_assessment_feedback', (object) array('framework' => $framework,
'artefact' => $annotationfeedback->get('id'),
'oldstatus' => $elements['assessment']['defaultvalue'],
'newstatus' => $values['assessment'],
'usr' => $USER->get('id')));
}
}
}
$url = $annotation->get_view_url($view->get('id'), true, false);
......
......@@ -1574,6 +1574,7 @@ function delete_user($userid) {
delete_records('usr_account_preference', 'usr', $userid);
delete_records('usr_activity_preference', 'usr', $userid);
delete_records('usr_infectedupload', 'usr', $userid);
delete_records('framework_assessment_feedback', 'usr', $userid);
delete_records('usr_institution', 'usr', $userid);
delete_records('usr_institution_request', 'usr', $userid);
delete_records('usr_password_request', 'usr', $userid);
......
......@@ -84,5 +84,21 @@
<KEY NAME="frameworkfk" TYPE="foreign" FIELDS="framework" REFTABLE="framework" REFFIELDS="id" />
</KEYS>
</TABLE>
<TABLE NAME="framework_assessment_feedback">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="framework" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="artefact" TYPE="int" LENGTH="10" NOTNULL="true" />
<FIELD NAME="oldstatus" TYPE="int" LENGTH="1" NOTNULL="true" />
<FIELD NAME="newstatus" TYPE="int" LENGTH="1" NOTNULL="true" />
<FIELD NAME="usr" TYPE="int" LENGTH="10" NOTNULL="true" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="frameworkfk" TYPE="foreign" FIELDS="framework" REFTABLE="framework" REFFIELDS="id" />
<KEY NAME="artefactfk" TYPE="foreign" FIELDS="artefact" REFTABLE="artefact" REFFIELDS="id" />
<KEY NAME="usrfk" TYPE="foreign" FIELDS="usr" REFTABLE="usr" REFFIELDS="id" />
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
......@@ -36,5 +36,24 @@ function xmldb_module_framework_upgrade($oldversion=0) {
add_key($table, $key);
}
if ($oldversion < 2016101400) {
log_debug('Adding "framework_assessment_feedback" table');
$table = new XMLDBTable('framework_assessment_feedback');
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
$table->addFieldInfo('framework', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('artefact', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addFieldInfo('oldstatus', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL);
$table->addFieldInfo('newstatus', XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL);
$table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
create_table($table);
$key = new XMLDBKey('artefactfk');
$key->setAttributes(XMLDB_KEY_FOREIGN, array('framework'), 'framework', array('id'));
$key->setAttributes(XMLDB_KEY_FOREIGN, array('artefact'), 'artefact', array('id'));
$key->setAttributes(XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));
add_key($table, $key);
}
return true;
}
......@@ -240,6 +240,7 @@ class Framework {
db_begin();
delete_records('framework_evidence', 'framework', $this->id);
delete_records('framework_evidence_statuses', 'framework', $this->id);
delete_records('framework_assessment_feedback', 'framework', $this->id);
delete_records_sql('DELETE FROM {framework_standard_element} WHERE standard IN (' . join(',', array_map('intval', $standards)) . ')');
delete_records('framework_standard', 'framework', $this->id);
delete_records('framework', 'id', $this->id);
......@@ -660,6 +661,8 @@ class Framework {
* @param string $reviewer The user marking the evidence as completed
*/
public static function save_evidence($id = null, $framework = null, $element = null, $view = null, $annotation = null, $state = self::EVIDENCE_BEGUN, $reviewer = null) {
global $USER;
// need to check we have at least one indicator of uniqueness
$uniqueness = false;
if (!empty($id)) {
......@@ -678,13 +681,42 @@ class Framework {
'state' => $state);
if ($id) {
// get view
$view = get_field('framework_evidence', 'view', 'id', $id);
$evidence = get_record('framework_evidence', 'id', $id);
$view = $evidence->view;
// update row
if (!empty($element)) {
$fordb['element'] = $element;
}
$fordb['reviewer'] = ((int) $state === self::EVIDENCE_COMPLETED) ? $reviewer : null;
update_record('framework_evidence', (object) $fordb, (object) array('id' => $id));
if ($evidence->state != $state) {
// need to add a blank annotationion feedback and assessment evidence combo
safe_require('blocktype', 'annotation');
$block = new BlockInstance($evidence->annotation);
$configdata = $block->get('configdata');
$data = (object) array(
'title' => get_string('Annotation', 'artefact.annotation'),
'description' => '',
'onannotation' => $configdata['artefactid'],
);
$viewobj = new View($view);
$data->view = $viewobj->get('id');
$data->owner = $viewobj->get('owner');
$data->group = $viewobj->get('group');
$data->institution = $viewobj->get('institution');
$data->author = $USER->get('id');
$data->private = 0;
$annotationfeedback = new ArtefactTypeAnnotationfeedback(0, $data);
$annotationfeedback->commit();
// We need to log this assessment change
insert_record('framework_assessment_feedback', (object) array('framework' => $id,
'artefact' => $annotationfeedback->get('id'),
'oldstatus' => $evidence->state,
'newstatus' => $state,
'usr' => $USER->get('id')));
}
}
else {
// insert
......
......@@ -12,6 +12,6 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2016082200;
$config->release = '1.0.2';
$config->version = 2016101400;
$config->release = '1.0.3';
......@@ -124,4 +124,22 @@
display: inline-block;
width: 5px;
}
}
\ No newline at end of file
}
.assessment {
color: #333;
.assessmentfeedback {
&.begun {
color: #5b9aa9;
}
&.incomplete {
color: $brand-danger;
}
&.partial {
color: $brand-warning;
}
&.completed {
color: $brand-success;
}
}
}
Supports Markdown
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