Example #1
0
function groups($parent_id)
{
    global $ausgabeformat, $global_counter, $local_counter, $question_type, $eval_id, $evalgroup_id;
    $query = "SELECT group_type FROM eval_group_template WHERE evalgroup_id = ?";
    $type_statement = DBManager::get()->prepare($query);
    $query = "SELECT LOCATE('Freitext', `text`) > 0 FROM evalquestion WHERE evalquestion_id = ?";
    $freetext_statement = DBManager::get()->prepare($query);
    $query = "SELECT evalquestion_id, `text`, type FROM evalquestion WHERE parent_id = ? ORDER BY position";
    $questions_statement = DBManager::get()->prepare($query);
    $query = "SELECT COUNT(DISTINCT user_id)\n              FROM evalanswer\n              JOIN evalanswer_user USING(evalanswer_id)\n              WHERE parent_id = ?";
    $question_users_statement = DBManager::get()->prepare($query);
    $query = "SELECT evalgroup_id, child_type, title, template_id FROM evalgroup WHERE parent_id = ? ORDER BY position";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($parent_id));
    while ($group = $statement->fetch(PDO::FETCH_ASSOC)) {
        // Heraussuchen, ob es sich um ein Freitext-Template handelt...
        $freetext_statement->execute(array($group['template_id']));
        $freetype = $freetext_statement->fetchColumn();
        $freetext_statement->closeCursor();
        if ($group['child_type'] == 'EvaluationGroup') {
            $global_counter += 1;
            $local_counter = 0;
            echo "  <tr><td class=\"" . ($ausgabeformat == 1 ? "table_header_bold" : "blank") . "\" align=\"LEFT\" colspan=\"2\">\n";
            if (do_template("show_group_headline")) {
                echo "    <b>" . $global_counter . ". " . formatReady($group['title']) . "</b>&nbsp;\n";
            } else {
                echo "&nbsp;";
            }
        } else {
            $local_counter += 1;
            $type_statement->execute(array($group['evalgroup_id']));
            $group_type = $type_statement->fetchColumn() ?: 'normal';
            $type_statement->closeCursor();
            echo "  <tr><td class=\"" . ($ausgabeformat == 1 ? "table_row_odd" : "blank") . "\" colspan=\"2\">\n";
            if (do_template("show_questionblock_headline")) {
                echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\"><b>" . $global_counter . "." . $local_counter . ". " . formatReady($group['title']) . "</b></td>";
                echo "<td align=\"RIGHT\">";
                if ($ausgabeformat == 1 && !$freetype) {
                    if ($group_type === 'normal') {
                        echo '<a href="' . URLHelper::getLink('?eval_id=' . $eval_id . '&evalgroup_id=' . $group['evalgroup_id'] . '&group_type=table&cmd=change_group_type#anker') . '">';
                        echo Icon::create('vote-stopped', 'clickable', ['title' => sprintf(_('Zum Darstellungstyp %s wechseln'), _('Tabelle'))])->asImg();
                        echo '</a>';
                    } else {
                        echo '<a href="' . URLHelper::getLink('?eval_id=' . $eval_id . '&evalgroup_id=' . $group['evalgroup_id'] . '&group_type=normal&cmd=change_group_type#anker') . '">';
                        echo Icon::create('vote', 'clickable', ['title' => sprintf(_('Zum Darstellungstyp %s wechseln'), _('Normal'))])->asImg();
                    }
                } else {
                    echo '&nbsp;';
                }
                echo "</td>";
                echo "</tr></table>\n";
            }
            if ($evalgroup_id == $group['evalgroup_id']) {
                echo "  <a name=\"anker\"></a>\n";
            }
        }
        echo "  </td></tr>";
        if ($group['child_type'] == 'EvaluationQuestion') {
            echo "  <tr><td class=\"blank\" colspan=\"2\">\n";
            echo "<table border=\"" . ($group_type == "normal" || $ausgabeformat == 1 ? "0" : "1") . "\" width=\"100%\" cellspacing=\"0\">\n";
            $local_question_counter = 0;
            $answer_arr = array();
            $questions_statement->execute(array($group['evalgroup_id']));
            while ($question = $questions_statement->fetch(PDO::FETCH_ASSOC)) {
                $question_type = $question['type'];
                $question_users_statement->execute(array($question['evalquestion_id']));
                $question_users = $question_users_statement->fetchColumn();
                $question_users_statement->closeCursor();
                $local_question_counter += 1;
                if (do_template("show_questions") && $group_type == "normal") {
                    echo "    <tr><td class=\"blank\" colspan=\"2\">\n";
                    echo "      <b>" . $global_counter . "." . $local_counter . "." . $local_question_counter . ". " . formatReady($question['text']) . "</b></font>\n";
                    echo "    </td></tr>\n";
                }
                if (!$freetype) {
                    // Keine Freitext-Eingabe
                    $ret = answers($question['evalquestion_id'], $question_users, $question['type']);
                    $ret["frage"] = $question['text'];
                    array_push($answer_arr, $ret);
                    if ($group_type == "normal") {
                        echo $ret["txt"];
                    }
                } else {
                    // Freitext
                    freetype_answers($question['evalquestion_id'], $question_users);
                }
            }
            $questions_statement->closeCursor();
            if (!$freetype && $group_type == "table") {
                $antworten_angezeigt = FALSE;
                $i = 0;
                $has_residual = 0;
                foreach ($answer_arr as $k1 => $questions) {
                    // Oberste Ebene, hier sind die Questions abgelegt
                    if (!$antworten_angezeigt) {
                        $i = 1;
                        echo "  <tr class=\"table_row_even\"><td><font size=\"-1\">&nbsp;</font></td>";
                        foreach ($questions["antwort_texte"] as $k2 => $v2) {
                            // 1. Unterebene, hier sind die Antworttexte abgelegt
                            echo "<td><font size=\"-1\">" . $v2 . "</font></td>";
                        }
                        echo "<td align=\"center\"><font size=\"-1\"><b>&#x2211;</b></font></td><td align=\"center\"><font size=\"-1\"><b>&#x2205;</b></font></td><td align=\"center\"><font size=\"-1\">" . _("Teilnehmer") . "</font></td>";
                        echo "</tr>";
                        $antworten_angezeigt = TRUE;
                    }
                    echo "<tr " . ($i == 1 ? 'class="content_body"' : '') . ">";
                    echo "  <td><font size=\"-1\">" . $questions["frage"] . "</font></td>";
                    foreach ($questions["auswertung"] as $k3 => $v3) {
                        echo "<td width=\"10%\" valign=\"TOP\"><font size=\"-1\">";
                        echo $v3[0] . " (" . $v3[1] . "%)";
                        // 2. Unterebene, hier sind die Zahlen abgelegt
                        if ($v3[2]) {
                            echo " (" . $v3[2] . "%)<b>*</b>";
                        }
                        echo "</font></td>";
                    }
                    $i = 0;
                    if ($questions["has_residual"]) {
                        $has_residual = 1;
                    }
                    echo "<td align=\"center\" width=\"3%\" valign=\"TOP\"><font size=\"-1\">" . $questions["summe_antworten"] . "</font></td><td align=\"center\" width=\"3%\" valign=\"TOP\"><font size=\"-1\">" . $questions["antwort_durchschnitt"] . ($questions["has_residual"] ? "<b>*</b>" : "") . "</font></td><td align=\"center\" width=\"6%\" valign=\"TOP\"><font size=\"-1\">" . $questions["anzahl_teilnehmer"] . "</font></td>";
                    echo "</tr>";
                }
                if ($has_residual) {
                    echo "<tr><td><font size=\"-1\"><b>*</b>" . _("Werte ohne Enthaltungen") . ".</font></td></tr>";
                }
            }
            echo "</table>\n";
            echo "</td></tr>\n";
        }
        groups($group['evalgroup_id']);
    }
}
Example #2
0
function groups($parent_id)
{
    global $cssSw, $ausgabeformat, $fo_file, $auth, $global_counter, $local_counter, $tmp_path_export, $pattern, $replace;
    $query = "SELECT group_type FROM eval_group_template WHERE evalgroup_id = ?";
    $type_statement = DBManager::get()->prepare($query);
    $query = "SELECT LOCATE('Freitext', `text`) > 0 FROM evalquestion WHERE evalquestion_id = ?";
    $freetext_statement = DBManager::get()->prepare($query);
    $query = "SELECT evalquestion_id, `text`, type FROM evalquestion WHERE parent_id = ? ORDER BY position";
    $questions_statement = DBManager::get()->prepare($query);
    $query = "SELECT COUNT(DISTINCT user_id)\n              FROM evalanswer\n              JOIN evalanswer_user USING(evalanswer_id)\n              WHERE parent_id = ?";
    $question_users_statement = DBManager::get()->prepare($query);
    $query = "SELECT evalgroup_id, child_type, title, template_id FROM evalgroup WHERE parent_id = ? ORDER BY position";
    $statement = DBManager::get()->prepare($query);
    $statement->execute(array($parent_id));
    while ($group = $statement->fetch(PDO::FETCH_ASSOC)) {
        // Heraussuchen, ob es sich um ein Freitext-Template handelt...
        $freetext_statement->execute(array($group['template_id']));
        $freetype = $freetext_statement->fetchColumn();
        $freetext_statement->closeCursor();
        if ($group['child_type'] == 'EvaluationGroup') {
            $global_counter += 1;
            $local_counter = 0;
            fputs($fo_file, "    <!-- Groupblock -->\n");
            fputs($fo_file, "    <fo:block font-variant=\"small-caps\" font-weight=\"bold\" text-align=\"start\" space-after.optimum=\"2pt\" background-color=\"lightblue\" space-before.optimum=\"10pt\">\n");
            if (do_template("show_group_headline")) {
                fputs($fo_file, "      " . $global_counter . ". " . xml_escape($group['title']) . "\n");
            }
            fputs($fo_file, "    </fo:block>\n");
        } else {
            $local_counter += 1;
            $type_statement->execute(array($group['evalgroup_id']));
            $group_type = $type_statement->fetchColumn() ?: 'normal';
            $type_statement->closeCursor();
            fputs($fo_file, "    <!-- Questionblock -->\n");
            fputs($fo_file, "    <fo:block font-variant=\"small-caps\" font-weight=\"bold\" text-align=\"start\" background-color=\"grey\" color=\"white\" space-after.optimum=\"10pt\">\n");
            if (do_template("show_questionblock_headline")) {
                fputs($fo_file, "      " . $global_counter . "." . $local_counter . ". " . xml_escape($group['title']) . "\n");
            }
            fputs($fo_file, "    </fo:block>\n");
        }
        if ($group['child_type'] == 'EvaluationQuestion') {
            $local_question_counter = 0;
            $answer_arr = array();
            $questions_statement->execute(array($group['evalgroup_id']));
            while ($question = $questions_statement->fetch(PDO::FETCH_ASSOC)) {
                $question_users_statement->execute(array($question['evalquestion_id']));
                $question_users = $question_users_statement->fetchColumn();
                $question_users_statement->closeCursor();
                if ($group_type == "normal") {
                    $local_question_counter += 1;
                    fputs($fo_file, "    <!-- Question -->\n");
                    fputs($fo_file, "    <fo:block text-align=\"start\" font-weight=\"bold\" space-before.optimum=\"10pt\" space-after.optimum=\"10pt\">\n");
                    if (do_template("show_questions")) {
                        fputs($fo_file, "      " . $global_counter . "." . $local_counter . "." . $local_question_counter . ". " . xml_escape($question['text']) . "\n");
                    }
                    fputs($fo_file, "    </fo:block>\n");
                    fputs($fo_file, "    <!-- table start -->\n");
                    fputs($fo_file, "    <fo:table table-layout=\"fixed\" border-width=\".1mm\" space-after.optimum=\"10pt\">\n");
                    if (!$freetype) {
                        fputs($fo_file, "      <fo:table-column column-width=\"100mm\"/>\n");
                        fputs($fo_file, "      <fo:table-column column-width=\"60mm\"/>\n");
                    } else {
                        fputs($fo_file, "      <fo:table-column column-width=\"160mm\"/>\n");
                    }
                    fputs($fo_file, "      <fo:table-body>\n");
                    fputs($fo_file, "        <fo:table-row >\n");
                    fputs($fo_file, "          <fo:table-cell ><fo:block start-indent=\"3mm\" end-indent=\"3mm\" padding-left=\"3mm\" padding-right=\"3mm\" padding-top=\"4mm\" padding-bottom=\"4mm\">\n");
                    fputs($fo_file, "            <!-- table start -->\n");
                    fputs($fo_file, "            <fo:table table-layout=\"fixed\">\n");
                    if (!$freetype) {
                        fputs($fo_file, "              <fo:table-column column-width=\"60mm\"/>\n");
                        fputs($fo_file, "              <fo:table-column column-width=\"40mm\"/>\n");
                    } else {
                        fputs($fo_file, "              <fo:table-column column-width=\"160mm\"/>\n");
                    }
                    fputs($fo_file, "              <fo:table-body>\n");
                }
                // ($group_type=="normal")
                if (!$freetype) {
                    // Keine Freitext-Eingabe
                    $ret = answers($question['evalquestion_id'], $question_users, $question['type']);
                    $ret["frage"] = $question['text'];
                    array_push($answer_arr, $ret);
                    if ($group_type == "normal") {
                        fputs($fo_file, $ret["txt"]);
                    }
                } else {
                    // Freitext
                    freetype_answers($question['evalquestion_id'], $question_users);
                }
                if ($group_type == "normal") {
                    fputs($fo_file, "              </fo:table-body>\n");
                    fputs($fo_file, "            </fo:table>\n");
                    fputs($fo_file, "            <!-- table end -->\n");
                    fputs($fo_file, "          </fo:block></fo:table-cell>\n");
                    if (!$freetype) {
                        fputs($fo_file, "          <fo:table-cell ><fo:block start-indent=\"3mm\" end-indent=\"3mm\" padding-left=\"3mm\" padding-right=\"3mm\" padding-top=\"4mm\" padding-bottom=\"4mm\">\n");
                        if (do_template("show_graphics")) {
                            fputs($fo_file, "            <fo:external-graphic content-width=\"70mm\" content-height=\"60mm\" src=\"url('file:///" . $tmp_path_export . "/evalsum" . $question['evalquestion_id'] . $auth->auth["uid"] . "." . $GLOBALS['EVAL_AUSWERTUNG_GRAPH_FORMAT'] . "')\"/>\n");
                        }
                        fputs($fo_file, "          </fo:block></fo:table-cell>\n");
                    }
                    fputs($fo_file, "        </fo:table-row>\n");
                    fputs($fo_file, "      </fo:table-body>\n");
                    fputs($fo_file, "    </fo:table>\n");
                    fputs($fo_file, "  <!-- table end -->\n");
                }
                // ($group_type=="normal")
            }
            if (!$freetype && $group_type == "table") {
                $antworten_angezeigt = FALSE;
                $i = 0;
                $has_residual = 0;
                $col_count = count($answer_arr[0]["antwort_texte"]);
                fputs($fo_file, "    <!-- table start -->\n");
                fputs($fo_file, "    <fo:table table-layout=\"fixed\" border-width=\".1mm\" border-style=\"solid\" space-after.optimum=\"10pt\">\n");
                fputs($fo_file, "              <fo:table-column/>\n");
                for ($a = 1; $a <= $col_count; $a++) {
                    fputs($fo_file, "              <fo:table-column  column-width=\"15mm\"/>\n");
                }
                fputs($fo_file, "              <fo:table-column  column-width=\"8mm\"/>\n");
                fputs($fo_file, "              <fo:table-column  column-width=\"8mm\"/>\n");
                fputs($fo_file, "              <fo:table-column  column-width=\"15mm\"/>\n");
                fputs($fo_file, "      <fo:table-body>\n");
                foreach ($answer_arr as $k1 => $questions) {
                    // Oberste Ebene, hier sind die Questions abgelegt
                    if (!$antworten_angezeigt) {
                        $i = 1;
                        fputs($fo_file, "        <fo:table-row >\n");
                        fputs($fo_file, "          <fo:table-cell ><fo:block space-before.optimum=\"10pt\">\n");
                        fputs($fo_file, "          </fo:block></fo:table-cell >");
                        foreach ($questions["antwort_texte"] as $k2 => $v2) {
                            // 1. Unterebene, hier sind die Antworttexte abgelegt
                            fputs($fo_file, "          <fo:table-cell ><fo:block space-before.optimum=\"10pt\" font-size=\"7pt\">\n");
                            fputs($fo_file, xml_escape($v2));
                            fputs($fo_file, "          </fo:block></fo:table-cell >");
                        }
                        fputs($fo_file, "          <fo:table-cell ><fo:block text-align=\"center\" space-before.optimum=\"10pt\" font-size=\"7pt\" font-family=\"Symbol\">\n");
                        fputs($fo_file, "&#x2211;");
                        fputs($fo_file, "          </fo:block></fo:table-cell >");
                        fputs($fo_file, "          <fo:table-cell ><fo:block text-align=\"center\" space-before.optimum=\"10pt\" font-size=\"7pt\" font-family=\"Symbol\">\n");
                        fputs($fo_file, "&#x2205;");
                        fputs($fo_file, "          </fo:block></fo:table-cell >");
                        fputs($fo_file, "          <fo:table-cell ><fo:block text-align=\"center\" space-before.optimum=\"10pt\" font-size=\"7pt\">\n");
                        fputs($fo_file, _("Teilnehmer"));
                        fputs($fo_file, "          </fo:block></fo:table-cell >");
                        fputs($fo_file, "        </fo:table-row>\n");
                        $antworten_angezeigt = TRUE;
                    }
                    fputs($fo_file, "        <fo:table-row >\n");
                    fputs($fo_file, "          <fo:table-cell ><fo:block font-size=\"6pt\" start-indent=\"3mm\">\n");
                    fputs($fo_file, $questions["frage"]);
                    fputs($fo_file, "          </fo:block></fo:table-cell >");
                    foreach ($questions["auswertung"] as $k3 => $v3) {
                        fputs($fo_file, "          <fo:table-cell ><fo:block font-size=\"7pt\">\n");
                        fputs($fo_file, $v3[0] . " (" . $v3[1] . "%)");
                        // 2. Unterebene, hier sind die Zahlen abgelegt
                        if ($v3[2]) {
                            fputs($fo_file, " (" . $v3[2] . "%)*");
                        }
                        fputs($fo_file, "          </fo:block></fo:table-cell >");
                    }
                    $i = 0;
                    if ($questions["has_residual"]) {
                        $has_residual = 1;
                    }
                    fputs($fo_file, "          <fo:table-cell ><fo:block text-align=\"center\" font-size=\"7pt\">\n");
                    fputs($fo_file, $questions["summe_antworten"]);
                    fputs($fo_file, "          </fo:block></fo:table-cell >");
                    fputs($fo_file, "          <fo:table-cell ><fo:block text-align=\"center\" font-size=\"7pt\">\n");
                    fputs($fo_file, $questions["antwort_durchschnitt"] . ($questions["has_residual"] ? "*" : ""));
                    fputs($fo_file, "          </fo:block></fo:table-cell >");
                    fputs($fo_file, "          <fo:table-cell ><fo:block text-align=\"center\" font-size=\"7pt\">\n");
                    fputs($fo_file, $questions["anzahl_teilnehmer"]);
                    fputs($fo_file, "          </fo:block></fo:table-cell >");
                    fputs($fo_file, "        </fo:table-row>\n");
                }
                fputs($fo_file, "        <fo:table-row >\n");
                fputs($fo_file, "          <fo:table-cell ><fo:block start-indent=\"3mm\" space-after.optimum=\"10pt\" font-size=\"7pt\">\n");
                if ($has_residual) {
                    fputs($fo_file, "* " . _("Werte ohne Enthaltungen") . ".");
                }
                fputs($fo_file, "          </fo:block></fo:table-cell >");
                fputs($fo_file, "        </fo:table-row >\n");
                fputs($fo_file, "      </fo:table-body>\n");
                fputs($fo_file, "    </fo:table>\n");
                fputs($fo_file, "  <!-- table end -->\n");
            }
        }
        groups($group['evalgroup_id']);
    }
}