/**
 * Dwoo {survey_name} function plugin
 *
 * Type:     function<br>
 * Name:     survey_title<br>
 * Date:     June 22, 2006<br>
 * Purpose:  Get the survey title from XML
 * @author   Gregor Anzelj
 * @version  1.0
 * @return Survey title instead of survey filename
 */
function Dwoo_Plugin_survey_title(Dwoo $dwoo, $survey, $lang = null)
{
    safe_require('artefact', 'survey');
    $return = ArtefactTypeSurvey::get_survey_title_from_xml($survey);
    if ($lang != null) {
        $return .= ' (' . substr($lang, 0, 2) . ')';
    }
    return $return;
}
Exemple #2
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'));
if (!$responses) {
    throw new NotFoundException(get_string('responsesnotfound', 'artefact.survey', ArtefactTypeSurvey::get_survey_title_from_xml($filename)));
}
$html = ArtefactTypeSurvey::build_user_responses_summary_html($filename, $responses);
$smarty = smarty();
$smarty->assign('PAGEHEADING', TITLE);
$smarty->assign('RESULTS', $survey->survey_returns_results($filename));
$smarty->assign('RESULTSHEADNIG', get_string('results', 'artefact.survey'));
$smarty->assign('CHART', $survey->survey_returns_chart($filename));
$smarty->assign('CHARTHEADNIG', get_string('chart', 'artefact.survey'));
$smarty->assign('id', $id);
$smarty->assign('html', $html);
$smarty->display('artefact:survey:results.tpl');
Exemple #3
0
function convert_blocks_used_in_views($type)
{
    $instances = get_column('block_instance', 'id', 'blocktype', $type);
    foreach ($instances as $instance) {
        $oldconfig = unserialize(get_field('block_instance', 'configdata', 'id', $instance));
        $configdata = array('includetitle' => 1, 'artefactid' => $oldconfig['artefactids'], 'showresponses' => null, 'showresults' => 1, 'showchart' => 1, 'palette' => 'default', 'legend' => 'key', 'fonttype' => 'sans', 'fontsize' => 10, 'height' => 250, 'width' => 400);
        if ($type == 'multipleintelligences') {
            $filename = 'survey.multipleintelligences.xml';
        }
        if ($type == 'learningstyles') {
            $filename = 'survey.learningstyles.xml';
        }
        $title = get_field('artefact', 'title', 'id', $oldconfig['artefactids']);
        $data = (object) array('id' => $instance, 'blocktype' => 'survey', 'title' => get_string('Survey', 'artefact.survey') . ': ' . ArtefactTypeSurvey::get_survey_title_from_xml($filename), 'configdata' => serialize($configdata));
        update_record('block_instance', $data, 'id');
    }
}
Exemple #4
0
require_once get_config('docroot') . 'artefact/lib.php';
safe_require('artefact', 'survey');
// Unset SESSION values
// So when we call htdocs/artefact/survey/analysis/index.php script, it would not automatically generate CSV export file
$SESSION->set('survey', '');
// Delete selected survey...
if ($delete = param_integer('delete', 0)) {
    $survey = artefact_instance_from_id($delete);
    $survey->delete();
    $SESSION->add_ok_msg(get_string('surveydeleted', 'artefact.survey'));
}
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
list($count, $data) = ArtefactTypeSurvey::get_survey_list($limit, $offset);
foreach ($data as $survey) {
    $survey->title = ArtefactTypeSurvey::get_survey_title_from_xml($survey->title);
    $flagicons = getlanguageportfolio_languages();
    $flagicon = $survey->note;
    if (isset($flagicon) && !empty($flagicon)) {
        $survey->flagicon = $flagicons[$survey->note]['style'];
    } else {
        $survey->flagicon = 'background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAHElEQVQ4jWP8//8/AyWAiSLdowaMGjBqwCAyAABjmgMdtjw0ugAAAABJRU5ErkJggiANCg==) no-repeat left center; padding-left: 20px;';
    }
}
// Function for comparing, used by usort...
function cmp($a, $b)
{
    return strcmp($a->title, $b->title);
}
usort($data, 'cmp');
// Web browser supports base64 images?