Example #1
0
    $extradata->blockid = $blockid;
}
if (empty($extradata->view) || empty($extradata->annotation) || empty($extradata->blockid)) {
    json_reply('local', get_string('annotationinformationerror', 'artefact.annotation'));
}
if (!can_view_view($extradata->view)) {
    json_reply('local', get_string('noaccesstoview', 'view'));
}
if (!artefact_in_view($extradata->annotation, $extradata->view)) {
    json_reply('local', get_string('accessdenied', 'error'));
}
if (!empty($extradata->artefact) && !artefact_in_view($extradata->artefact, $extradata->view)) {
    json_reply('local', get_string('accessdenied', 'error'));
}
if ($ispagination) {
    // This is not really working yet. Need to do more work on artefact/artefact.php
    $options = ArtefactTypeAnnotationfeedback::get_annotation_feedback_options();
    $options->limit = $limit;
    $options->offset = $offset;
    $options->view = $extradata->view;
    $options->annotation = $extradata->annotation;
    $options->artefact = $extradata->artefact;
    $options->block = $extradata->blockid;
    $annotationfeedback = ArtefactTypeAnnotationfeedback::get_annotation_feedback($options);
    json_reply(false, array('data' => $annotationfeedback));
} else {
    $view = new View($extradata->view);
    $annotationartefact = artefact_instance_from_id($extradata->annotation);
    list($feedbackcount, $annotationfeedback) = ArtefactTypeAnnotationfeedback::get_annotation_feedback_for_view($annotationartefact, $view, $extradata->blockid);
    json_reply(false, array('data' => $annotationfeedback));
}
Example #2
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     $smarty = smarty_core();
     $artefactid = '';
     $text = '';
     $feedbackcount = 0;
     $instance->set('artefactplugin', 'annotation');
     $configdata = $instance->get('configdata');
     if (!empty($configdata['artefactid'])) {
         safe_require('artefact', 'file');
         $artefactid = $configdata['artefactid'];
         $artefact = $instance->get_artefact_instance($artefactid);
         $viewid = $instance->get('view');
         $text = $artefact->get('description');
         require_once get_config('docroot') . 'lib/view.php';
         $view = new View($viewid);
         list($feedbackcount, $annotationfeedback) = ArtefactTypeAnnotationfeedback::get_annotation_feedback_for_view($artefact, $view, $instance->get('id'), true, $editing);
         $smarty->assign('annotationfeedback', $annotationfeedback);
     }
     $smarty->assign('text', $text);
     $smarty->assign('artefactid', $artefactid);
     $smarty->assign('annotationfeedbackcount', $feedbackcount);
     $html = $smarty->fetch('blocktype:annotation:annotation.tpl');
     return $html;
 }