public static function render_instance(BlockInstance $instance, $editing = false) { safe_require('artefact', 'survey'); //require_once(dirname(dirname(dirname(__FILE__))) . '/dwoo/function.survey_name.php'); $configdata = $instance->get('configdata'); // this will make sure to unserialize it for us if (!isset($configdata['artefactid'])) { return ''; } $id = $configdata['artefactid']; $survey = $instance->get_artefact_instance($id); $showresponses = isset($configdata['showresponses']) ? $configdata['showresponses'] : false; $showresults = isset($configdata['showresults']) ? $configdata['showresults'] : true; $showchart = isset($configdata['showchart']) ? $configdata['showchart'] : true; $palette = isset($configdata['palette']) ? $configdata['palette'] : 'default'; $legend = isset($configdata['legend']) ? $configdata['legend'] : 'key'; $fonttype = isset($configdata['fonttype']) ? $configdata['fonttype'] : 'sans'; $fontsize = isset($configdata['fontsize']) ? $configdata['fontsize'] : 10; $height = isset($configdata['height']) ? $configdata['height'] : 250; $width = isset($configdata['width']) ? $configdata['width'] : 400; $smarty = smarty_core(); //$smarty->addPlugin('survey_name', 'Dwoo_Plugin_survey_name'); $smarty->assign('RESPONSES', $showresponses ? true : false); $smarty->assign('responseshtml', ArtefactTypeSurvey::build_user_responses_output_html($survey->get('title'), unserialize($survey->get('description')))); $smarty->assign('RESULTS', $showresults ? true : false); $smarty->assign('resultshtml', ArtefactTypeSurvey::build_user_responses_summary_html($survey->get('title'), unserialize($survey->get('description')))); $smarty->assign('CHART', $showchart ? true : false); $smarty->assign('charturl', get_config('wwwroot') . 'artefact/survey/chart.php?id=' . $id . '&width=' . $width . '&height=' . $height . '&palette=' . $palette . '&legend=' . $legend . '&fonttype=' . $fonttype . '&fontsize=' . $fontsize); return $smarty->fetch('blocktype:survey:survey.tpl'); }
$id = param_integer('id', 0); $is_survey = get_field('artefact', 'artefacttype', 'id', $id) == 'survey' ? true : false; /* $user_is_owner = ($USER->get('id') == get_field('artefact', 'owner', 'id', $id) ? true : false); $user_has_access = record_exists('artefact_access_usr', 'usr', $USER->get('id'), 'artefact', $id); */ if (!$is_survey) { throw new ArtefactNotFoundException(get_string('artefactnotsurvey', 'artefact.survey')); } /* if (!$user_is_owner && !$user_has_access) { throw new AccessDeniedException(get_string('accessdenied', 'error')); } */ $survey = null; try { $survey = artefact_instance_from_id($id); } catch (Exception $e) { } define('TITLE', $survey->get_survey_title_from_xml()); // Get survey filename and return empty responses $filename = $survey->get('title'); $responses = unserialize($survey->get('description')); $html = ArtefactTypeSurvey::build_user_responses_output_html($filename, $responses); $smarty = smarty(); $smarty->assign('PAGEHEADING', TITLE); //$smarty->assign('RESPONSES', $survey->survey_returns_responses($filename)); $smarty->assign('RESPONSES', true); $smarty->assign('id', $id); $smarty->assign('html', $html); $smarty->display('artefact:survey:responses.tpl');