Пример #1
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;
}
Пример #2
0
function answers($parent_id, $anz_nutzer, $question_type)
{
    global $graph_switch, $auth, $ausgabeformat, $fo_file, $has_template, $pattern, $replace;
    // 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;
    $gesamte_antworten = 0;
    $edit = "";
    $txt = "";
    $antwort_durchschnitt = 0;
    $has_residual = user_answers_residual($parent_id);
    $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 = 0;
        if ($answers_sum > 0) {
            $prozente = ROUND($answer_counter * 100 / $anz_nutzer);
        }
        $prozente_wo_residual = 0;
        if ($has_residual && $answers_sum - $has_residual > 0) {
            $prozente_wo_residual = ROUND($answer_counter * 100 / ($anz_nutzer - $has_residual));
        }
        $edit .= "                <fo:table-row>\n";
        $edit .= "                  <fo:table-cell ><fo:block font-size=\"8pt\">" . $antwort_nummer . ". " . xml_escape($answer['text'] != "" ? $answer['text'] : $answer['value']) . "</fo:block></fo:table-cell>\n";
        if ($has_residual) {
            $edit .= "                  <fo:table-cell ><fo:block font-size=\"8pt\">" . $answer_counter . " (" . $prozente . "%) " . ($answer['residual'] == 0 ? "(" . $prozente_wo_residual . "%)*" : "") . "</fo:block></fo:table-cell>\n";
        } else {
            $edit .= "                  <fo:table-cell ><fo:block font-size=\"8pt\">" . $answer_counter . " (" . $prozente . "%)</fo:block></fo:table-cell>\n";
        }
        $edit .= "                </fo:table-row>\n";
        array_push($ret_array["antwort_texte"], $answer['text'] != "" ? $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;
        }
    }
    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 .= $edit;
    if ($question_type == "multiplechoice") {
        $txt .= "                <fo:table-row>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\">" . _("Anzahl der Teilnehmer") . ": " . $anz_nutzer . "</fo:block></fo:table-cell>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n";
        $txt .= "                </fo:table-row>\n";
        $txt .= "                <fo:table-row>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"><fo:inline font-family=\"Symbol\">&#x2211;</fo:inline> " . $gesamte_antworten . " " . _("Antworten") . ".</fo:block></fo:table-cell>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n";
        $txt .= "                </fo:table-row>\n";
    } else {
        $txt .= "                <fo:table-row>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\">" . _("Anzahl der Teilnehmer") . ": " . $anz_nutzer . "</fo:block></fo:table-cell>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n";
        $txt .= "                </fo:table-row>\n";
        $txt .= "                <fo:table-row>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"><fo:inline font-family=\"Symbol\">&#x2205;</fo:inline>-" . _("Antwort") . ": " . $antwort_durchschnitt . ($has_residual == 0 ? "" : "*") . "</fo:block></fo:table-cell>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"><fo:inline font-family=\"Symbol\">&#x2211;</fo:inline> " . $gesamte_antworten . " " . _("Antworten") . ".</fo:block></fo:table-cell>\n";
        $txt .= "                </fo:table-row>\n";
    }
    if ($has_residual) {
        $txt .= "                <fo:table-row>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\">*" . _("Werte ohne Enthaltungen") . ".</fo:block></fo:table-cell>\n";
        $txt .= "                  <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n";
        $txt .= "                </fo:table-row>\n";
    }
    $ret_array["txt"] = $txt;
    return $ret_array;
}