Commit a4262300 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic

Bug #1742347 : save Note & Annotation text in version

behatnotneeded

Change-Id: I11e15b3bb79a413f0d99d46ab38f5d7555eec315
parent 4228bdac
......@@ -134,6 +134,9 @@ class PluginBlocktypeAnnotation extends MaharaCoreBlocktype {
list($feedbackcount, $annotationfeedback) = ArtefactTypeAnnotationfeedback::get_annotation_feedback_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty->assign('annotationfeedback', $annotationfeedback);
}
if ($versioning) {
$text = $configdata['text'];
}
$smarty->assign('text', $text);
$smarty->assign('artefactid', $artefactid);
$smarty->assign('annotationfeedbackcount', $feedbackcount);
......
......@@ -31,15 +31,18 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
safe_require('artefact', 'file');
safe_require('artefact', 'comment');
$artefact = $instance->get_artefact_instance($configdata['artefactid']);
$viewid = $instance->get('view');
$text = ArtefactTypeFolder::append_view_url($artefact->get('description'), $viewid);
if ($versioning) {
$text = $configdata['text'];
}
else {
$text = ArtefactTypeFolder::append_view_url($artefact->get('description'), $viewid);
}
$smarty = smarty_core();
$smarty->assign('text', $text);
......
......@@ -1124,9 +1124,11 @@ class BlockInstance {
$artefacts = get_records_sql_array(
'SELECT a.id, a.title FROM {artefact} a WHERE a.id in ( '. join(',', array_fill(0, count($ids), '?')) . ')', $ids
);
uasort($artefacts, array("BlockInstance", "my_files_cmp"));
foreach ($artefacts as $artefact) {
$result[] = $artefact->id;
if ($artefacts) {
uasort($artefacts, array("BlockInstance", "my_files_cmp"));
foreach ($artefacts as $artefact) {
$result[] = $artefact->id;
}
}
}
return $result;
......
......@@ -7169,7 +7169,7 @@ class View {
public function format_versioning_data($data) {
if (empty($data)) {
return $data;
return false;
}
$data = json_decode($data);
......@@ -7213,7 +7213,7 @@ class View {
$this->columns[$v->row][$v->column]['blockinstances'][] = $bi;
}
}
$html = $this->build_rows(false, false, true);
$html = $this->build_rows(false, false, $data);
$data->html = $html;
return $data;
}
......
......@@ -60,6 +60,15 @@ if ($blocks) {
}
}
}
if ($oldblock->get('blocktype') == 'annotation' || $oldblock->get('blocktype') == 'textbox') {
$configdata = $oldblock->get('configdata');
if (!empty($configdata['artefactid'])) {
safe_require('artefact', 'file');
$artefactid = $configdata['artefactid'];
$artefact = $oldblock->get_artefact_instance($artefactid);
$bi->configdata['text'] = $artefact->get('description');
}
}
$version->blocks[$k] = $bi;
}
}
......
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