Example #1
0
} catch (Exception $e) {
}
// Get survey filename and return empty responses
$filename = $survey->get('title');
$responses = unserialize($survey->get('description'));
$CONFIG = ArtefactTypeSurvey::get_chart_config($filename);
$CONFIG['ctime'] = strftime(get_string('strfdaymonthyearshort'), $survey->get('ctime'));
// Created
$CONFIG['mtime'] = strftime(get_string('strfdaymonthyearshort'), $survey->get('mtime'));
// Modified
// If language survey, add the language abbreviation at the end of survey title...
if ($survey->get('note') != null) {
    $CONFIG['title'] = $CONFIG['title'] . ' (' . substr($survey->get('note'), 0, -5) . ')';
}
//log_debug($CONFIG);
$DATA = ArtefactTypeSurvey::get_chart_data_from_responses($filename, $responses);
//log_debug($DATA);
if (is_null($CONFIG['charttype'])) {
    $message = get_string('surveyerror', 'artefact.survey', $filename);
    $_SESSION['messages'][] = array('type' => 'error', 'msg' => $message);
}
switch (strtolower($CONFIG['charttype'])) {
    case 'bar':
        draw_bar_chart($WIDTH, $HEIGHT, $DATA, $CONFIG, $LEGEND, $FONT, $PALETTE);
        break;
    case 'stacked':
        draw_stacked_chart($WIDTH, $HEIGHT, $DATA, $CONFIG, $LEGEND, $FONT, $PALETTE);
        break;
    case 'area':
    case 'line':
    case 'plot':
Example #2
0
 public static function prepare_chart_data($owner)
 {
     safe_require('artefact', 'survey');
     $surveys = array('competence.kadis.interpersonal.xml', 'competence.kadis.organisational.xml', 'competence.kadis.flexibility.xml', 'competence.kadis.problemsolving.xml', 'competence.kadis.leadership.xml', 'competence.kadis.reliability.xml');
     $surveysdata = array();
     foreach ($surveys as $survey) {
         if (record_exists('artefact', 'title', $survey, 'owner', $owner)) {
             $surveysdata[] = get_records_sql_array("\n\t\t\t\t\tSELECT a.id, a.title, a.description, a.mtime\n\t\t\t\t\tFROM {artefact} a\n\t\t\t\t\tWHERE a.owner = ? AND a.title = ?\n\t\t\t\t\tORDER BY a.ctime DESC, a.mtime DESC\n\t\t\t\t\tLIMIT 1;", array($owner, $survey));
         }
     }
     $DATA = array();
     if (!empty($surveysdata)) {
         foreach ($surveysdata as $surveydata) {
             $filename = $surveydata[0]->title;
             $responses = unserialize($surveydata[0]->description);
             $SINGLE = ArtefactTypeSurvey::get_chart_data_from_responses($filename, $responses);
             $SINGLE[0]['value'] = self::set_achieved_level($SINGLE[0]['value'], $SINGLE[0]['key']);
             $DATA = array_merge($DATA, $SINGLE);
         }
     }
     return $DATA;
 }