Ejemplo n.º 1
0
$result->execute();
$result->bind_result($screen, $theme, $tmp_username, $q_id, $leadin, $user_answer);
while ($result->fetch()) {
    if ($old_q_id != $q_id or $old_screen < $screen) {
        $comment_flag = 0;
        do {
            $q_no++;
        } while ($q_id != $paper_structure[$q_no - 1] and $q_no < 6000);
        echo '<w:p><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:b-cs/><w:color w:val="000000"/><w:sz w:val="22"/><w:sz-cs w:val="22"/></w:rPr><w:t>';
        echo $q_no . '. ' . StringUtils::wordToUtf8(strip_tags($leadin));
        echo '</w:t></w:r></w:p>';
    }
    $user_answer = str_replace('<', '&lt;', $user_answer);
    $user_answer = str_replace('>', '&gt;', $user_answer);
    $response = trim(strtolower($user_answer));
    if ($response != NULL and $response != 'n/a' and strlen($response) > 1) {
        $buffer = '';
        for ($character = 0; $character < strlen($user_answer); $character++) {
            if (ord($user_answer[$character]) > 31 and ord($user_answer[$character]) < 127) {
                $buffer .= $user_answer[$character];
            }
        }
        echo '<w:p><w:pPr><w:listPr><w:ilvl w:val="0"/><w:ilfo w:val="1"/><wx:t wx:val="·" wx:wTabBefore="360" wx:wTabAfter="270"/><wx:font wx:val="Symbol"/></w:listPr><w:spacing w:before="100" w:before-autospacing="on" w:after="100" w:after-autospacing="on"/><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:color w:val="000000"/><w:sz w:val="22"/><w:sz-cs w:val="22"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:color w:val="000000"/><w:sz w:val="22"/><w:sz-cs w:val="22"/></w:rPr><w:t>' . StringUtils::wordToUtf8($buffer) . '</w:t></w:r></w:p>';
        $comment_flag = 1;
    }
    $old_leadin = $leadin;
    $old_screen = $screen;
    $old_q_id = $q_id;
}
echo '<w:sectPr><w:hdr w:type="odd"><w:p><w:pPr><w:tabs><w:tab w:val="right" w:pos="9000"/></w:tabs><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:t>' . StringUtils::wordToUtf8($paper) . '</w:t></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:tab wx:wTab="5475" wx:tlc="none" wx:cTlc="121"/><w:t>' . date("d/m/Y") . '</w:t></w:r></w:p></w:hdr><w:ftr w:type="odd"><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:t>- </w:t></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:fldChar w:fldCharType="begin"/></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:instrText> PAGE </w:instrText></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:noProof/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:t>1</w:t></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:fldChar w:fldCharType="end"/></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:sz w:val="18"/><w:sz-cs w:val="18"/></w:rPr><w:t> -</w:t></w:r></w:p></w:ftr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1134" w:right="1418" w:bottom="1134" w:left="1418" w:header="709" w:footer="709" w:gutter="0"/><w:cols w:space="708"/><w:docGrid w:line-pitch="360"/></w:sectPr></wx:sub-section></wx:sect></w:body></w:wordDocument>';
$mysqli->close();
Ejemplo n.º 2
0
function displayQuestion($q_id, $theme, $scenario, $leadin, $q_type, $correct, $q_media, $q_media_width, $q_media_height, $options, $log, $correct_buf, $screen, $question_number, $candidates)
{
    global $old_likert_scale, $old_display_method, $table_on;
    // Remove spaces
    $theme = str_replace('&nbsp;', ' ', $theme);
    $scenario = str_replace('&nbsp;', ' ', $scenario);
    $leadin = str_replace('&nbsp;', ' ', $leadin);
    $old_likert_scale = str_replace('&nbsp;', ' ', $old_likert_scale);
    // Remove nasty non-utf8 chars
    $theme = StringUtils::wordToUtf8(strip_tags($theme));
    $scenario = StringUtils::wordToUtf8(strip_tags($scenario));
    $leadin = StringUtils::wordToUtf8(strip_tags($leadin));
    $theme = str_replace('&amp;amp;', '&amp;', $theme);
    $scenario = str_replace('&amp;amp;', '&amp;', $scenario);
    $leadin = str_replace('&amp;amp;', '&amp;', $leadin);
    $old_likert_scale = trim(strip_tags(str_replace('&amp;amp;', '&amp;', $old_likert_scale)));
    if ($theme != '') {
        if ($table_on == 1) {
            echo '</w:tbl>';
        }
        echo '<w:p><w:pPr><w:pStyle w:val="Heading2"/></w:pPr><w:r><w:t>' . $theme . '</w:t></w:r></w:p><w:p/>';
        $table_on = 0;
    }
    if ($q_type != 'extmatch') {
        switch ($q_type) {
            case 'dichotomous':
                if ($table_on == 1) {
                    echo '</w:tbl>';
                }
                echo "<w:p><w:r><w:t>{$question_number}. {$leadin}</w:t></w:r></w:p><w:p/>";
                if ($old_display_method == 'YN_Positive' or $old_display_method == 'YN_NegativeAbstain') {
                    echo '<w:p><w:pPr><w:tabs><w:tab w:val="center" w:pos="650"/><w:tab w:val="center" w:pos="1700"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:rPr><w:b/></w:rPr><w:t>Yes</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:rPr><w:b/></w:rPr><w:t>No</w:t></w:r></w:p>';
                } else {
                    echo '<w:p><w:pPr><w:tabs><w:tab w:val="center" w:pos="600"/><w:tab w:val="center" w:pos="1600"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:rPr><w:b/></w:rPr><w:t>True</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:rPr><w:b/></w:rPr><w:t>False</w:t></w:r></w:p>';
                }
                $i = 0;
                foreach ($options as $individual_option) {
                    $i++;
                    if ($log[$screen][$q_id][$i]['u'] == '') {
                        $log[$screen][$q_id][$i]['u'] = 0;
                    }
                    if ($log[$screen][$q_id][$i]['t'] == '') {
                        $log[$screen][$q_id][$i]['t'] = 0;
                    }
                    if ($log[$screen][$q_id][$i]['f'] == '') {
                        $log[$screen][$q_id][$i]['f'] = 0;
                    }
                    echo '<w:p wsp:rsidR="00E97566" wsp:rsidRDefault="00E97566" wsp:rsidP="00E97566"/><w:p wsp:rsidR="00E97566" wsp:rsidRDefault="00E97566" wsp:rsidP="00E97566"><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="500"/><w:tab w:val="left" w:pos="550"/><w:tab w:val="decimal" w:pos="1450"/><w:tab w:val="left" w:pos="1500"/><w:tab w:val="left" w:pos="2400"/></w:tabs><w:ind w:left="2340" w:hanging="2340"/></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>' . $log[$screen][$q_id][$i]['t'] . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][$i]['t'] / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>' . $log[$screen][$q_id][$i]['f'] . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][$i]['f'] / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                }
                echo '<w:p/>';
                $table_on = 0;
                break;
            case 'mcq':
                if ($table_on == 1) {
                    echo '</w:tbl>';
                }
                echo "<w:p><w:r><w:t>{$question_number}. {$leadin}</w:t></w:r></w:p><w:p/>";
                $i = 0;
                foreach ($options as $individual_option) {
                    $i++;
                    if (!isset($log[$screen][$q_id][1][$i]) or $log[$screen][$q_id][1][$i] == '') {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>0</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(0%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    } else {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>' . $log[$screen][$q_id][1][$i] . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][1][$i] / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    }
                }
                if ($old_display_method == 'vertical_other') {
                    echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>' . count($log[$screen][$q_id][1]['other']) . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round(count($log[$screen][$q_id][1]['other']) / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>Other:</w:t></w:r></w:p>';
                    foreach ($log[$screen][$q_id][1]['other'] as $other_text) {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="2268"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="900" wx:tlc="none" wx:cTlc="19"/></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/></w:r><w:r><w:tab wx:wTab="1185" wx:tlc="none" wx:cTlc="25"/><w:t>' . StringUtils::wordToUtf8($other_text) . '</w:t></w:r></w:p>';
                    }
                }
                if (!isset($log[$screen][$q_id][1]['u'])) {
                    echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:rPr><w:color w:val="999999"/></w:rPr><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>0</w:t></w:r><w:r><w:rPr><w:color w:val="999999"/></w:rPr><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(0%)</w:t></w:r><w:r><w:rPr><w:color w:val="999999"/></w:rPr><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>(unanswered)</w:t></w:r></w:p>';
                } else {
                    $unanswered = $log[$screen][$q_id][1]['u'];
                    echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:rPr><w:color w:val="999999"/></w:rPr><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>' . $log[$screen][$q_id][1]['u'] . '</w:t></w:r><w:r><w:rPr><w:color w:val="999999"/></w:rPr><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][1]['u'] / $candidates * 100) . '%)</w:t></w:r><w:r><w:rPr><w:color w:val="999999"/></w:rPr><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>(unanswered)</w:t></w:r></w:p>';
                }
                echo '<w:p/>';
                $table_on = 0;
                break;
            case 'likert':
                $unanswered = 0;
                $old_size = substr_count($old_likert_scale, '|');
                $current_properties = explode('|', $old_display_method);
                $new_size = substr_count($old_display_method, '|');
                $na = $current_properties[$new_size];
                if ($old_likert_scale != $old_display_method or $table_on == 0) {
                    if ($table_on == 1) {
                        echo '</w:tbl>';
                    }
                    echo '<w:tbl><w:tblPr><w:tblStyle w:val="TableGrid"/><w:tblW w:w="0" w:type="auto"/><w:tblLook w:val="01E0"/></w:tblPr><w:tblGrid><w:gridCol w:w="470"/><w:gridCol w:w="4350"/><w:gridCol w:w="500"/><w:gridCol w:w="780"/><w:gridCol w:w="780"/><w:gridCol w:w="780"/><w:gridCol w:w="1290"/><w:gridCol w:w="780"/></w:tblGrid>';
                    echo '<w:tr><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>No</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>Question</w:t></w:r></w:p></w:tc>';
                    if ($na == 'true') {
                        echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>N/A</w:t></w:r></w:p></w:tc>';
                    }
                    for ($point = 0; $point < $new_size; $point++) {
                        echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>' . str_replace(array('<br>', '<br />'), '</w:t></w:r><w:r><w:br/></w:r><w:r><w:rPr><w:b/></w:rPr><w:t>', strip_tags($current_properties[$point], '<br>,<br />')) . '</w:t></w:r></w:p></w:tc>';
                    }
                    echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>Unanswered</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:b/></w:rPr></w:pPr><w:r><w:rPr><w:b/></w:rPr><w:t>Mean</w:t></w:r></w:p></w:tc></w:tr>';
                    $table_on = 1;
                }
                echo '<w:tr><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $question_number . '.</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $leadin . '</w:t></w:r></w:p></w:tc>';
                $i = 0;
                $sub_total = 0;
                foreach ($options as $individual_option) {
                    $i++;
                    if ($i > 1 or $na == 'true') {
                        if (!isset($log[$screen][$q_id][1][$individual_option])) {
                            echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>0</w:t></w:r></w:p></w:tc>';
                        } else {
                            echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $log[$screen][$q_id][1][$individual_option] . ' (' . round($log[$screen][$q_id][1][$individual_option] / $candidates * 100) . '%)</w:t></w:r></w:p></w:tc>';
                        }
                        if ($individual_option >= 1 and $individual_option <= 10) {
                            if (isset($log[$screen][$q_id][1][$individual_option])) {
                                $sub_total += $individual_option * $log[$screen][$q_id][1][$individual_option];
                            }
                        }
                    }
                }
                if (isset($log[$screen][$q_id][1]['n/a'])) {
                    $unanswered = $log[$screen][$q_id][1]['n/a'];
                }
                if (!isset($log[$screen][$q_id][1]['u'])) {
                    echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>0</w:t></w:r></w:p></w:tc>';
                } else {
                    $unanswered += $log[$screen][$q_id][1]['u'];
                    echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $log[$screen][$q_id][1]['u'] . ' (' . round($log[$screen][$q_id][1]['u'] / $candidates * 100) . '%)</w:t></w:r></w:p></w:tc>';
                }
                if ($candidates - $unanswered == 0) {
                    echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>0</w:t></w:r></w:p></w:tc></w:tr>';
                } else {
                    echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . number_format($sub_total / ($candidates - $unanswered), 1) . '</w:t></w:r></w:p></w:tc></w:tr>';
                }
                $old_likert_scale = $old_display_method;
                break;
            case 'mrq':
                if ($table_on == 1) {
                    echo '</w:tbl>';
                }
                echo "<w:p><w:r><w:t>{$question_number}. {$leadin}</w:t></w:r></w:p><w:p/>";
                $i = 0;
                foreach ($options as $individual_option) {
                    $i++;
                    if ($candidates == 0) {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>0</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(0%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    } else {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>' . $log[$screen][$q_id][$i]['y'] . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][$i]['y'] / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    }
                }
                if ($old_display_method == 'other') {
                    echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1800"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="795" wx:tlc="none" wx:cTlc="17"/><w:t>' . count($log[$screen][$q_id][1]['other']) . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round(count($log[$screen][$q_id][1]['other']) / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="720" wx:tlc="none" wx:cTlc="15"/></w:r><w:r><w:t>Other:</w:t></w:r></w:p>';
                    foreach ($log[$screen][$q_id][1]['other'] as $other_text) {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="2268"/></w:tabs></w:pPr><w:r><w:tab wx:wTab="900" wx:tlc="none" wx:cTlc="19"/></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/></w:r><w:r><w:tab wx:wTab="1185" wx:tlc="none" wx:cTlc="25"/><w:t>' . StringUtils::wordToUtf8($other_text) . '</w:t></w:r></w:p>';
                    }
                }
                $table_on = 0;
                break;
            case 'rank':
                if ($table_on == 1) {
                    echo '</w:tbl>';
                }
                echo "<w:p><w:r><w:t>{$question_number}. {$leadin}</w:t></w:r></w:p><w:p/>";
                $rank_no = 0;
                foreach ($correct_buf as $individual_correct) {
                    if ($individual_correct > $rank_no and $individual_correct < 9990) {
                        $rank_no = $individual_correct;
                    }
                }
                $i = 0;
                foreach ($options as $individual_option) {
                    echo "<w:p><w:r><w:t>" . StringUtils::wordToUtf8($individual_option) . "</w:t></w:r></w:p><w:p/>";
                    echo '<w:tbl><w:tblPr><w:tblStyle w:val="TableGrid"/><w:tblW w:w="0" w:type="auto"/><w:tblLook w:val="01E0"/></w:tblPr><w:tblGrid><w:gridCol w:w="1500"/><w:gridCol w:w="1500"/><w:gridCol w:w="1500"/></w:tblGrid>';
                    for ($rank_position = 1; $rank_position <= $rank_no; $rank_position++) {
                        if (!isset($log[$screen][$q_id][$i][$rank_position])) {
                            $log[$screen][$q_id][$i][$rank_position] = 0;
                        }
                        echo '<w:tr><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $log[$screen][$q_id][$i][$rank_position] . '</w:t></w:r></w:p></w:tc>';
                        echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>(' . number_format($log[$screen][$q_id][$i][$rank_position] / $candidates * 100, 0) . '%)</w:t></w:r></w:p></w:tc>';
                        echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $rank_position;
                        if ($rank_position == 1) {
                            echo 'st';
                        } elseif ($rank_position == 2) {
                            echo 'nd';
                        } elseif ($rank_position == 3) {
                            echo 'rd';
                        } else {
                            echo 'th';
                        }
                        echo '</w:t></w:r></w:p></w:tc></w:tr>';
                    }
                    echo '</w:tbl>';
                    $i++;
                }
                $table_on = 0;
                break;
            case 'matrix':
                if ($table_on == 1) {
                    echo '</w:tbl>';
                }
                echo "<w:p><w:r><w:t>{$question_number}. {$leadin}</w:t></w:r></w:p><w:p/>";
                // Define the table grid
                echo '<w:tbl><w:tblPr><w:tblStyle w:val="TableGrid"/><w:tblW w:w="0" w:type="auto"/><w:tblLook w:val="01E0"/></w:tblPr><w:tblGrid><w:gridCol w:w="2500"/>';
                foreach ($options as $option) {
                    echo '<w:gridCol w:w="1500"/>';
                }
                echo '</w:tblGrid>';
                // Write out the header row of the table
                echo '<w:tr><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:r><w:t></w:t></w:r></w:p></w:tc>';
                foreach ($options as $option) {
                    echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/><w:shd w:val="clear" w:color="auto" w:fill="E0E0E0"/></w:tcPr><w:p><w:r><w:t>' . $option . '</w:t></w:r></w:p></w:tc>';
                }
                echo '</w:tr>';
                // Write out the contents of the table
                $row_data = explode('|', $scenario);
                $option_no = count($options);
                $row_no = 0;
                foreach ($row_data as $row) {
                    echo '<w:tr><w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $row . '</w:t></w:r></w:p></w:tc>';
                    for ($i = 1; $i <= $option_no; $i++) {
                        if (isset($log[$screen][$q_id][$row_no][$i])) {
                            echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>' . $log[$screen][$q_id][$row_no][$i] . '(' . number_format($log[$screen][$q_id][$row_no][$i] / $candidates * 100, 0) . '%)</w:t></w:r></w:p></w:tc>';
                        } else {
                            echo '<w:tc><w:tcPr><w:tcW w:w="0" w:type="auto"/></w:tcPr><w:p><w:r><w:t>0 (0%)</w:t></w:r></w:p></w:tc>';
                        }
                    }
                    echo '</w:tr>';
                    $row_no++;
                }
                echo '</w:tbl>';
                break;
        }
    } else {
        $tmp_media_array = explode('|', $q_media);
        $tmp_media_width_array = explode('|', $q_media_width);
        $tmp_media_height_array = explode('|', $q_media_height);
        $tmp_ext_scenarios = explode('|', $scenario);
        $tmp_answers_array = explode('|', $correct_buf[0]);
        echo "<w:p><w:r><w:t>{$question_number}. {$leadin}</w:t></w:r></w:p><w:p/>";
        for ($i = 1; $i <= substr_count($scenario, '|') + 1; $i++) {
            if ($tmp_ext_scenarios[$i - 1]) {
                echo "<w:p><w:r><w:t>" . $tmp_ext_scenarios[$i - 1] . "</w:t></w:r></w:p><w:p/>";
            }
            $option_no = 1;
            foreach ($options as $individual_option) {
                if ($tmp_answers_array[$i - 1] == $option_no) {
                    if ($log[$screen][$q_id][$i][$option_no] == '') {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1843"/></w:tabs><w:ind w:left="1843" w:hanging="1843"/></w:pPr><w:r><w:tab wx:wTab="585" wx:tlc="none" wx:cTlc="12"/><w:t>0</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(0%)</w:t></w:r><w:r><w:tab wx:wTab="270" wx:tlc="none" wx:cTlc="5"/><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    } else {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1843"/></w:tabs><w:ind w:left="1843" w:hanging="1843"/></w:pPr><w:r><w:tab wx:wTab="585" wx:tlc="none" wx:cTlc="12"/><w:t>' . $log[$screen][$q_id][$i][$option_no] . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][$i][$option_no] / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="270" wx:tlc="none" wx:cTlc="5"/><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    }
                } else {
                    if ($log[$screen][$q_id][$i][$option_no] == '') {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1843"/></w:tabs><w:ind w:left="1843" w:hanging="1843"/></w:pPr><w:r><w:tab wx:wTab="585" wx:tlc="none" wx:cTlc="12"/><w:t>0</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(0%)</w:t></w:r><w:r><w:tab wx:wTab="270" wx:tlc="none" wx:cTlc="5"/><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    } else {
                        echo '<w:p><w:pPr><w:tabs><w:tab w:val="decimal" w:pos="900"/><w:tab w:val="left" w:pos="1080"/><w:tab w:val="left" w:pos="1843"/></w:tabs><w:ind w:left="1843" w:hanging="1843"/></w:pPr><w:r><w:tab wx:wTab="585" wx:tlc="none" wx:cTlc="12"/><w:t>' . $log[$screen][$q_id][$i][$option_no] . '</w:t></w:r><w:r><w:tab wx:wTab="180" wx:tlc="none" wx:cTlc="3"/><w:t>(' . round($log[$screen][$q_id][$i][$option_no] / $candidates * 100) . '%)</w:t></w:r><w:r><w:tab wx:wTab="270" wx:tlc="none" wx:cTlc="5"/><w:t>' . StringUtils::wordToUtf8($individual_option) . '</w:t></w:r></w:p>';
                    }
                }
                $option_no++;
            }
        }
    }
}
Ejemplo n.º 3
0
        echo '<w:p wsp:rsidR="00A11D0F" wsp:rsidRPr="00687E9E" wsp:rsidRDefault="00A11D0F" wsp:rsidP="00687E9E"><w:pPr><w:pStyle w:val="Heading2"/></w:pPr><w:r wsp:rsidRPr="00687E9E"><w:t>' . StringUtils::wordToUtf8($theme) . '</w:t></w:r></w:p>';
        $table_open = 0;
    }
    if ($table_open == 0) {
        echo '<w:tbl><w:tblPr><w:tblW w:w="9242" w:type="dxa"/><w:tblInd w:w="108" w:type="dxa"/><w:tblBorders><w:top w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="000000"/><w:left w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="000000"/><w:bottom w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="000000"/><w:right w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="000000"/><w:insideH w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="000000"/><w:insideV w:val="single" w:sz="4" wx:bdrwidth="10" w:space="0" w:color="000000"/></w:tblBorders><w:tblLook w:val="04A0"/></w:tblPr><w:tblGrid><w:gridCol w:w="8755"/><w:gridCol w:w="487"/></w:tblGrid>' . "\n\n";
        $table_open = 1;
    }
    $leadin = StringUtils::wordToUtf8(StringUtils::clean_and_trim(strip_tags($leadin)));
    $leadin = parse_leadin_word_2003($leadin, $q_parts);
    // Lead-in
    echo '<w:tr wsp:rsidR="00A11D0F" wsp:rsidRPr="00A11D0F" wsp:rsidTr="00A11D0F">';
    echo '<w:tc>';
    echo '<w:tcPr><w:tcW w:w="8755" w:type="dxa"/></w:tcPr><w:p>' . $leadin;
    echo '</w:p>';
    echo '</w:tc>';
    $old_feedback = $feedback;
    // Rating score
    echo '<w:tc>';
    echo '<w:tcPr><w:tcW w:w="487" w:type="dxa"/></w:tcPr><w:p wsp:rsidR="00A11D0F" wsp:rsidRPr="00A11D0F" wsp:rsidRDefault="00A11D0F" wsp:rsidP="00A11D0F"><w:pPr><w:spacing w:after="0" w:line="240" w:line-rule="auto"/><w:rPr><w:rFonts w:ascii="Calibri" w:h-ansi="Calibri"/></w:rPr></w:pPr><w:r wsp:rsidRPr="00A11D0F"><w:rPr><w:rFonts w:ascii="Calibri" w:h-ansi="Calibri"/></w:rPr><w:t>' . $rating . '</w:t></w:r></w:p>';
    echo '</w:tc>';
    echo '</w:tr>';
    $old_userID = $userID;
}
$result->close();
$mysqli->close();
if ($old_userID != '') {
    echo '<w:p wsp:rsidR="00472B21" wsp:rsidRDefault="00472B21" wsp:rsidP="00472B21"><w:pPr><w:spacing w:after="0"/><w:rPr><w:b/></w:rPr></w:pPr></w:p><w:p wsp:rsidR="000E6B7A" wsp:rsidRPr="000E6B7A" wsp:rsidRDefault="00472B21" wsp:rsidP="00ED0EA8"><w:pPr><w:rPr><w:b/></w:rPr></w:pPr><w:r wsp:rsidRPr="000E6B7A"><w:rPr><w:b/></w:rPr><w:t>Feedback:</w:t></w:r></w:p>';
    echo '<w:p wsp:rsidR="000E6B7A" wsp:rsidRPr="00A11D0F" wsp:rsidRDefault="00273482" wsp:rsidP="00ED0EA8"><w:r><w:t>' . StringUtils::wordToUtf8($old_feedback) . '</w:t></w:r></w:p>';
    echo '</w:tbl></wx:sub-section>';
}
echo '<w:sectPr wsp:rsidR="0005490A" wsp:rsidRPr="0005490A" wsp:rsidSect="00A4626D"><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/><w:cols w:space="708"/><w:docGrid w:line-pitch="360"/></w:sectPr></w:body></w:wordDocument>';