Gitlab CSE Unil

Commit ae833d60 authored by M. Chardon's avatar M. Chardon
Browse files

correction bug annotation frame publication perte lien

parent 95c08e27
......@@ -141,7 +141,7 @@ class annotation {
$this->displaylock = $annotationRef->displaylock;
$this->displayrotation = $annotationRef->displayrotation;
$this->borderstyle = $annotationRef->borderstyle;
$this->parent_annot = $annotationRef->parent_annot;
//$this->parent_annot = $annotationRef->parent_annot;
$this->answerrequested = $annotationRef->answerrequested;
$this->pdfdisplay = $annotationRef->pdfdisplay;
}
......
......@@ -395,9 +395,17 @@ class page_editor {
// Copy all the draft annotations to non-drafts.
$records = $DB->get_records(self::BDDTABLEANNOTATION, array(self::GRADEID => $gradeid, self::DRAFLIB => 1));
foreach ($records as $record) {
$newid = self::create_annotation_for_release($record, $parentlink);
$oldid = $record->id;
$newid = self::create_annotation_for_release($record);
$parentlink[$oldid] = $newid;
}
$newAnnotationsRelease = $DB->get_records(self::BDDTABLEANNOTATION, array(self::GRADEID => $gradeid, self::DRAFLIB => 0));
foreach ($newAnnotationsRelease as $annotation) {
if ($annotation->parent_annot > 0 && $parentlink[$annotation->parent_annot]) {
$annotation->parent_annot = $parentlink[$annotation->parent_annot];
$DB->update_record(self::BDDTABLEANNOTATION, $annotation);
}
}
} else {
$records = $DB->get_records(self::BDDTABLEANNOTATION, array(self::GRADEID => $gradeid, self::DRAFLIB => 1));
$draftid = [];
......@@ -425,9 +433,19 @@ class page_editor {
continue;
}
//need to be created
$oldid = $record->id;
$newid = self::create_annotation_for_release($record, $parentlink);
$parentlink[$oldid] = $newid;
}
//maj parent ling
$newAnnotationsRelease = $DB->get_records(self::BDDTABLEANNOTATION, array(self::GRADEID => $gradeid, self::DRAFLIB => 0));
foreach ($newAnnotationsRelease as $annotation) {
if (!$annotation->parent_annot || $annotation->parent_annot < 0 || in_array($annotation->draft_id, $draftid) || !$parentlink[$annotation->parent_annot]) {
continue;
}
$annotation->parent_annot = $parentlink[$annotation->parent_annot];
$DB->update_record(self::BDDTABLEANNOTATION, $annotation);
}
}
return true;
......@@ -439,14 +457,14 @@ class page_editor {
* @param array $parentlink array with parent's annotation's id
* @return int new annotation id
*/
private static function create_annotation_for_release($annotationRecord, $parentlink) {
private static function create_annotation_for_release($annotationRecord) {
$oldid = $annotationRecord->id;
unset($annotationRecord->id);
$annotationRecord->draft = 0;
$annotationRecord->draft_id = $oldid;
if ($annotationRecord->parent_annot > 0) {
$annotationRecord->parent_annot = $parentlink[$annotationRecord->parent_annot];
}
/* if ($annotationRecord->parent_annot > 0) {
$annotationRecord->parent_annot = $parentlink[$annotationRecord->parent_annot];
} */
// Force these.
if (!($annotationRecord instanceof annotation)) {
$annotation = new annotation($annotationRecord);
......
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