// The count is different so we have a modification.
return true;
} else {
- // Have a closer look and see if the draft files match the non draft files.
- foreach ($nondraftannotations as $index => $ndannotation) {
- foreach ($ndannotation as $key => $value) {
- if ($key != 'id' && $value != $draftannotations[$index]->$key) {
- return true;
+ $matches = 0;
+ // Have a closer look and see if the draft files match all the non draft files.
+ foreach ($nondraftannotations as $ndannotation) {
+ foreach ($draftannotations as $dannotation) {
+ foreach ($ndannotation as $key => $value) {
+ if ($key != 'id' && $value != $dannotation->{$key}) {
+ continue 2;
+ }
}
+ $matches++;
}
}
+ if ($matches !== count($nondraftannotations)) {
+ return true;
+ }
}
// Select all comments.
$draftcomments = page_editor::get_comments($grade->id, $i, true);
return true;
} else {
// Go for a closer inspection.
- foreach ($nondraftcomments as $index => $ndcomment) {
- foreach ($ndcomment as $key => $value) {
- if ($key != 'id' && $value != $draftcomments[$index]->$key) {
- return true;
+ $matches = 0;
+ foreach ($nondraftcomments as $ndcomment) {
+ foreach ($draftcomments as $dcomment) {
+ foreach ($ndcomment as $key => $value) {
+ if ($key != 'id' && $value != $dcomment->{$key}) {
+ continue 2;
+ }
}
+ $matches++;
}
}
+ if ($matches !== count($nondraftcomments)) {
+ return true;
+ }
}
}
return false;
$annotation->type = 'rectangle';
$annotation->colour = 'yellow';
- page_editor::add_annotation($annotation);
+ $yellowannotationid = page_editor::add_annotation($annotation);
// Add a comment as well.
$comment = new comment();
page_editor::add_annotation($annotation);
$annotations = page_editor::get_annotations($grade->id, 0, true);
- page_editor::remove_annotation($annotations[1]->id);
+ page_editor::remove_annotation($yellowannotationid);
$this->assertTrue($plugin->is_feedback_modified($grade, $data));
$plugin->save($grade, $data);