Exemple #1
0
session_start();
if (!defined("__APP_PATH__")) {
    define("__APP_PATH__", realpath(dirname(__FILE__) . "/"));
}
// require_once( __APP_PATH__ . "/inc/constants.php" );
//Code to convert from .svg to .png by jSon array
$result = '{
      "274:130":"000",
      "274:129":"000",
      "274:128":"000",
      "274:127":"000",
      "274:126":"000",
      "274:125":"000"
    }';
$data = json_decode($result, true);
do_graph("Equipment Count", 600, $data);
function do_graph($title, $width, $items)
{
    $border = 50;
    // border space around bars
    $caption_gap = 4;
    // space between bar and its caption
    $bar_width = 20;
    // width of each bar
    $bar_gap = 40;
    // space between each bar
    $title_font_id = 5;
    // font id for the main title
    $bar_caption_font_id = 5;
    // font id for each bar's title
    // Image height depends on the number of items
Exemple #2
0
function answers($parent_id, $anz_nutzer, $question_type)
{
    global $graph_switch, $auth, $ausgabeformat, $has_template;
    // Rueckgabearray, damit die Daten noch aufzutrennen sind...
    $ret_array = array("id" => $parent_id, "txt" => "", "antwort_texte" => array(), "frage" => "", "has_residual" => 0, "antwort_durchschnitt" => "", "summe_antworten" => "", "anzahl_teilnehmer" => $anz_nutzer, "auswertung" => array());
    $summary = array();
    $query = "SELECT COUNT(*)\n              FROM evalanswer\n              JOIN evalanswer_user USING (evalanswer_id)\n              WHERE parent_id = ?";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($parent_id));
    $answers_sum = $statement->fetchColumn();
    $antwort_nummer = 0;
    $edit = "";
    $txt = "";
    $gesamte_antworten = 0;
    $antwort_durchschnitt = 0;
    $has_residual = user_answers_residual($parent_id);
    $i = 1;
    $edit .= "<tr class=\"table_row_even\"><td width=\"1%\">&nbsp;</td><td width=\"70%\"><font size=\"-1\"><b>" . _("Antworten") . "</b></font></td><td width=\"29%\"><font size=\"-1\"><b>" . _("Auswertung") . "</b></font></td></tr>\n";
    $query = "SELECT evalanswer_id, `text`, value, residual FROM evalanswer WHERE parent_id = ? ORDER BY position";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($parent_id));
    while ($answer = $statement->fetch(PDO::FETCH_ASSOC)) {
        $antwort_nummer++;
        $answer_counter = user_answers($answer['evalanswer_id']);
        if ($answer['residual'] == 0) {
            $gesamte_antworten += $answer_counter;
            $antwort_durchschnitt += $answer_counter * $antwort_nummer;
        }
        $prozente_wo_residual = 0;
        if ($has_residual && $answers_sum - $has_residual > 0) {
            $prozente_wo_residual = ROUND($answer_counter * 100 / ($anz_nutzer - $has_residual));
        }
        $prozente = 0;
        if ($answers_sum > 0) {
            $prozente = ROUND($answer_counter * 100 / $anz_nutzer);
        }
        $edit .= "<tr " . ($i == 1 ? 'class="content_body"' : '') . "><td width=\"1%\"><font size=\"-1\"><b>" . $antwort_nummer . ".&nbsp;</b></font></td><td width=\"70%\"><font size=\"-1\">" . ($answer['text'] != '' ? formatReady($answer['text']) : $answer['value']) . "</font></td>";
        if ($has_residual) {
            $edit .= "<td width=\"29%\"><font size=\"-1\">" . $answer_counter . " (" . $prozente . "%) " . ($answer['residual'] == 0 ? "(" . $prozente_wo_residual . "%)<b>*</b>" : "") . "</font></td></tr>\n";
        } else {
            $edit .= "<td width=\"29%\"><font size=\"-1\">" . $answer_counter . " (" . $prozente . "%)</font></td></tr>\n";
        }
        array_push($summary, array($antwort_nummer . "(" . $prozente . "%)", $answer_counter));
        array_push($ret_array["antwort_texte"], $answer['text'] != '' ? formatReady($answer['text']) : $answer['value']);
        array_push($ret_array["auswertung"], array($answer_counter, $prozente, $answer['residual'] == 0 ? $prozente_wo_residual : null));
        if ($has_residual) {
            $ret_array["has_residual"] = 1;
        }
        $i = 0;
    }
    do_graph($summary, $parent_id);
    if ($gesamte_antworten > 0 && $antwort_durchschnitt > 0) {
        $antwort_durchschnitt = ROUND($antwort_durchschnitt / $gesamte_antworten, 3);
    }
    $ret_array["antwort_durchschnitt"] = $antwort_durchschnitt;
    $ret_array["summe_antworten"] = $gesamte_antworten;
    $txt .= "  <tr>\n";
    $txt .= "    <td width=\"70%\" valign=\"TOP\">\n";
    $txt .= "      <table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
    $txt .= $edit . "\n";
    $txt .= "        <tr class=\"blank\"><td colspan=\"3\"><font size=\"-1\">&nbsp;</font></td></tr>";
    $txt .= "        <tr class=\"blank\"><td colspan=\"3\"><font size=\"-1\"><b>&#x2211;</b>=" . $gesamte_antworten . " " . _("Antworten") . "</font></td></tr>";
    $txt .= "        <tr class=\"blank\">";
    if ($question_type == "multiplechoice") {
        $txt .= "        <td colspan=\"3\">";
    } else {
        $txt .= "<td colspan=\"2\"><font size=\"-1\"><b>&#x2205;</b>-" . _("Antwort") . ": " . $antwort_durchschnitt . ($has_residual == 0 ? "" : "<b>*</b>") . "</font></td><td>";
    }
    $txt .= "          <font size=\"-1\">" . _("Anzahl der Teilnehmer") . ": " . $anz_nutzer . "</font></td></tr>";
    if ($has_residual) {
        $txt .= "        <tr class=\"blank\"><td colspan=\"3\"><font size=\"-1\"><b>*</b>" . _("Werte ohne Enthaltungen") . ".</font></td></tr>";
    }
    $txt .= "      </table>";
    $txt .= "    </td>\n";
    $txt .= "    <td width=\"30%\" valign=\"TOP\" align=\"RIGHT\">\n";
    if (do_template("show_graphics")) {
        $txt .= '<IMG SRC="' . GetDownloadLink('evalsum' . $parent_id . $auth->auth['uid'] . '.' . Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT, 'evalsum' . $parent_id . $auth->auth['uid'] . '.' . Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT, 2) . '">' . "\n";
    } else {
        $txt .= "&nbsp;\n";
    }
    $txt .= "    </td>\n";
    $txt .= "  </tr>\n";
    $ret_array['txt'] = $txt;
    return $ret_array;
}