$pdf->setSignature(K_DIGSIG_CERTIFICATE, K_DIGSIG_PRIVATE_KEY, K_DIGSIG_PASSWORD, K_DIGSIG_EXTRA_CERTS, K_DIGSIG_CERT_TYPE, array('Name' => K_DIGSIG_NAME, 'Location' => K_DIGSIG_LOCATION, 'Reason' => K_DIGSIG_REASON, 'ContactInfo' => K_DIGSIG_CONTACT));
}
// calculate some sizes
$cell_height_ratio = K_CELL_HEIGHT_RATIO + 0.1;
$page_width = $pdf->getPageWidth() - PDF_MARGIN_LEFT - PDF_MARGIN_RIGHT;
$data_cell_height = round($cell_height_ratio * PDF_FONT_SIZE_DATA / $pdf->getScaleFactor(), 2);
$main_cell_height = round($cell_height_ratio * PDF_FONT_SIZE_MAIN / $pdf->getScaleFactor(), 2);
$data_cell_width = round($page_width / $page_elements, 2);
$data_cell_width_third = round($data_cell_width / 3, 2);
$data_cell_width_half = round($data_cell_width / 2, 2);
// ---- module
$andmodwhere = '';
if ($expmode < 3) {
    $andmodwhere = 'module_id=' . $module_id . '';
}
$sqlm = F_select_modules_sql($andmodwhere);
if ($rm = F_db_query($sqlm, $db)) {
    while ($mm = F_db_fetch_array($rm)) {
        $module_id = $mm['module_id'];
        $module_name = $mm['module_name'];
        //$module_enabled = F_getBoolean($mm['module_enabled']);
        // ---- topic
        $where_sqls = 'subject_module_id=' . $module_id . '';
        if ($expmode < 2) {
            $where_sqls .= ' AND subject_id=' . $subject_id . '';
        }
        $sqls = F_select_subjects_sql($where_sqls);
        if ($rs = F_db_query($sqls, $db)) {
            while ($ms = F_db_fetch_array($rs)) {
                $subject_id = $ms['subject_id'];
                $subject_name = $ms['subject_name'];
Beispiel #2
0
/**
 * Export all questions of the selected subject to XML.
 * @author Nicola Asuni
 * @since 2006-03-06
 * @param $module_id (int)  module ID
 * @param $subject_id (int) topic ID
 * @param $expmode (int) export mode: 1 = selected topic; 2 = selected module; 3 = all modules.
 * @return XML data
 */
function F_xml_export_questions($module_id, $subject_id, $expmode)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_authorization.php';
    require_once '../../shared/code/tce_functions_auth_sql.php';
    $module_id = intval($module_id);
    $subject_id = intval($subject_id);
    $expmode = intval($expmode);
    $boolean = array('false', 'true');
    $type = array('single', 'multiple', 'text', 'ordering');
    $xml = '';
    // XML data to be returned
    $xml .= '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . K_NEWLINE;
    $xml .= '<tcexamquestions version="' . K_TCEXAM_VERSION . '">' . K_NEWLINE;
    $xml .= K_TAB . '<header';
    $xml .= ' lang="' . K_USER_LANG . '"';
    $xml .= ' date="' . date(K_TIMESTAMP_FORMAT) . '">' . K_NEWLINE;
    $xml .= K_TAB . '</header>' . K_NEWLINE;
    $xml .= K_TAB . '<body>' . K_NEWLINE;
    // ---- module
    $andmodwhere = '';
    if ($expmode < 3) {
        $andmodwhere = 'module_id=' . $module_id . '';
    }
    $sqlm = F_select_modules_sql($andmodwhere);
    if ($rm = F_db_query($sqlm, $db)) {
        while ($mm = F_db_fetch_array($rm)) {
            $xml .= K_TAB . K_TAB . '<module>' . K_NEWLINE;
            $xml .= K_TAB . K_TAB . K_TAB . '<name>';
            $xml .= F_text_to_xml($mm['module_name']);
            $xml .= '</name>' . K_NEWLINE;
            $xml .= K_TAB . K_TAB . K_TAB . '<enabled>';
            $xml .= $boolean[intval(F_getBoolean($mm['module_enabled']))];
            $xml .= '</enabled>' . K_NEWLINE;
            // ---- topic
            $where_sqls = 'subject_module_id=' . $mm['module_id'] . '';
            if ($expmode < 2) {
                $where_sqls .= ' AND subject_id=' . $subject_id . '';
            }
            $sqls = F_select_subjects_sql($where_sqls);
            if ($rs = F_db_query($sqls, $db)) {
                while ($ms = F_db_fetch_array($rs)) {
                    $xml .= K_TAB . K_TAB . K_TAB . '<subject>' . K_NEWLINE;
                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<name>';
                    $xml .= F_text_to_xml($ms['subject_name']);
                    $xml .= '</name>' . K_NEWLINE;
                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<description>';
                    $xml .= F_text_to_xml($ms['subject_description']);
                    $xml .= '</description>' . K_NEWLINE;
                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<enabled>';
                    $xml .= $boolean[intval(F_getBoolean($ms['subject_enabled']))];
                    $xml .= '</enabled>' . K_NEWLINE;
                    // ---- questions
                    $sql = 'SELECT *
						FROM ' . K_TABLE_QUESTIONS . '
						WHERE question_subject_id=' . $ms['subject_id'] . '
						ORDER BY question_enabled DESC, question_position, question_description';
                    if ($r = F_db_query($sql, $db)) {
                        while ($m = F_db_fetch_array($r)) {
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<question>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<enabled>';
                            $xml .= $boolean[intval(F_getBoolean($m['question_enabled']))];
                            $xml .= '</enabled>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<type>';
                            $xml .= $type[$m['question_type'] - 1];
                            $xml .= '</type>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<difficulty>';
                            $xml .= $m['question_difficulty'];
                            $xml .= '</difficulty>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<position>';
                            $xml .= $m['question_position'];
                            $xml .= '</position>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<timer>';
                            $xml .= $m['question_timer'];
                            $xml .= '</timer>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<fullscreen>';
                            $xml .= $boolean[intval(F_getBoolean($m['question_fullscreen']))];
                            $xml .= '</fullscreen>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<inline_answers>';
                            $xml .= $boolean[intval(F_getBoolean($m['question_inline_answers']))];
                            $xml .= '</inline_answers>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<auto_next>';
                            $xml .= $boolean[intval(F_getBoolean($m['question_auto_next']))];
                            $xml .= '</auto_next>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<description>';
                            $xml .= F_text_to_xml($m['question_description']);
                            $xml .= '</description>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<explanation>';
                            $xml .= F_text_to_xml($m['question_explanation']);
                            $xml .= '</explanation>' . K_NEWLINE;
                            // display alternative answers
                            $sqla = 'SELECT *
								FROM ' . K_TABLE_ANSWERS . '
								WHERE answer_question_id=\'' . $m['question_id'] . '\'
								ORDER BY answer_position,answer_isright DESC';
                            if ($ra = F_db_query($sqla, $db)) {
                                while ($ma = F_db_fetch_array($ra)) {
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<answer>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<enabled>';
                                    $xml .= $boolean[intval(F_getBoolean($ma['answer_enabled']))];
                                    $xml .= '</enabled>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<isright>';
                                    $xml .= $boolean[intval(F_getBoolean($ma['answer_isright']))];
                                    $xml .= '</isright>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<position>';
                                    $xml .= $ma['answer_position'];
                                    $xml .= '</position>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<keyboard_key>';
                                    $xml .= $ma['answer_keyboard_key'];
                                    $xml .= '</keyboard_key>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<description>';
                                    $xml .= F_text_to_xml($ma['answer_description']);
                                    $xml .= '</description>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<explanation>';
                                    $xml .= F_text_to_xml($ma['answer_explanation']);
                                    $xml .= '</explanation>' . K_NEWLINE;
                                    $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '</answer>' . K_NEWLINE;
                                }
                            } else {
                                F_display_db_error();
                            }
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '</question>' . K_NEWLINE;
                        }
                        // end while for questions
                    } else {
                        F_display_db_error();
                    }
                    $xml .= K_TAB . K_TAB . K_TAB . '</subject>' . K_NEWLINE;
                }
                // end while for topics
            } else {
                F_display_db_error();
            }
            $xml .= K_TAB . K_TAB . '</module>' . K_NEWLINE;
        }
        // end while for module
    } else {
        F_display_db_error();
    }
    $xml .= K_TAB . '</body>' . K_NEWLINE;
    $xml .= '</tcexamquestions>' . K_NEWLINE;
    return $xml;
}
Beispiel #3
0
}
echo '<script src="' . K_PATH_SHARED_JSCRIPTS . 'inserttag.js" type="text/javascript"></script>' . K_NEWLINE;
if (K_ENABLE_VIRTUAL_KEYBOARD) {
    echo '<script src="' . K_PATH_SHARED_JSCRIPTS . 'vk/vk_easy.js?vk_skin=default" type="text/javascript"></script>' . K_NEWLINE;
}
echo '<div class="container">' . K_NEWLINE;
echo '<div class="tceformbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_subjecteditor">' . K_NEWLINE;
echo '<div class="row">' . K_NEWLINE;
echo '<span class="label">' . K_NEWLINE;
echo '<label for="subject_module_id">' . $l['w_module'] . '</label>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '<span class="formw">' . K_NEWLINE;
echo '<input type="hidden" name="changecategory" id="changecategory" value="" />' . K_NEWLINE;
echo '<select name="subject_module_id" id="subject_module_id" size="0" onchange="document.getElementById(\'form_subjecteditor\').changecategory.value=1; document.getElementById(\'form_subjecteditor\').submit();" title="' . $l['w_module'] . '">' . K_NEWLINE;
$sql = F_select_modules_sql();
if ($r = F_db_query($sql, $db)) {
    $countitem = 1;
    while ($m = F_db_fetch_array($r)) {
        echo '<option value="' . $m['module_id'] . '"';
        if ($m['module_id'] == $subject_module_id) {
            echo ' selected="selected"';
        }
        echo '>' . $countitem . ". ";
        if (F_getBoolean($m['module_enabled'])) {
            echo '+';
        } else {
            echo '-';
        }
        echo ' ' . htmlspecialchars($m['module_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '&nbsp;</option>' . K_NEWLINE;
        $countitem++;
Beispiel #4
0
/**
 * Export all questions of the selected subject to TSV.
 * @param $module_id (int)  module ID
 * @param $subject_id (int) topic ID
 * @param $expmode (int) export mode: 1 = selected topic; 2 = selected module; 3 = all modules.
 * @return TSV data
 */
function F_tsv_export_questions($module_id, $subject_id, $expmode)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_authorization.php';
    require_once '../../shared/code/tce_functions_auth_sql.php';
    $module_id = intval($module_id);
    $subject_id = intval($subject_id);
    $expmode = intval($expmode);
    $qtype = array('S', 'M', 'T', 'O');
    $tsv = '';
    // TSV data to be returned
    // headers
    $tsv .= 'M=MODULE';
    // MODULE
    $tsv .= K_TAB . 'module_enabled';
    $tsv .= K_TAB . 'module_name';
    $tsv .= K_NEWLINE;
    $tsv .= 'S=SUBJECT';
    // SUBJECT
    $tsv .= K_TAB . 'subject_enabled';
    $tsv .= K_TAB . 'subject_name';
    $tsv .= K_TAB . 'subject_description';
    $tsv .= K_NEWLINE;
    $tsv .= 'Q=QUESTION';
    // QUESTION
    $tsv .= K_TAB . 'question_enabled';
    $tsv .= K_TAB . 'question_description';
    $tsv .= K_TAB . 'question_explanation';
    $tsv .= K_TAB . 'question_type';
    $tsv .= K_TAB . 'question_difficulty';
    $tsv .= K_TAB . 'question_position';
    $tsv .= K_TAB . 'question_timer';
    $tsv .= K_TAB . 'question_fullscreen';
    $tsv .= K_TAB . 'question_inline_answers';
    $tsv .= K_TAB . 'question_auto_next';
    $tsv .= K_NEWLINE;
    $tsv .= 'A=ANSWER';
    // ANSWER
    $tsv .= K_TAB . 'answer_enabled';
    $tsv .= K_TAB . 'answer_description';
    $tsv .= K_TAB . 'answer_explanation';
    $tsv .= K_TAB . 'answer_isright';
    $tsv .= K_TAB . 'answer_position';
    $tsv .= K_TAB . 'answer_keyboard_key';
    $tsv .= K_NEWLINE;
    $tsv .= K_NEWLINE;
    // ---- module
    $andmodwhere = '';
    if ($expmode < 3) {
        $andmodwhere = 'module_id=' . $module_id . '';
    }
    $sqlm = F_select_modules_sql($andmodwhere);
    if ($rm = F_db_query($sqlm, $db)) {
        while ($mm = F_db_fetch_array($rm)) {
            $tsv .= 'M';
            // MODULE
            $tsv .= K_TAB . intval(F_getBoolean($mm['module_enabled']));
            $tsv .= K_TAB . F_text_to_tsv($mm['module_name']);
            $tsv .= K_NEWLINE;
            // ---- topic
            $where_sqls = 'subject_module_id=' . $mm['module_id'] . '';
            if ($expmode < 2) {
                $where_sqls .= ' AND subject_id=' . $subject_id . '';
            }
            $sqls = F_select_subjects_sql($where_sqls);
            if ($rs = F_db_query($sqls, $db)) {
                while ($ms = F_db_fetch_array($rs)) {
                    $tsv .= 'S';
                    // SUBJECT
                    $tsv .= K_TAB . intval(F_getBoolean($ms['subject_enabled']));
                    $tsv .= K_TAB . F_text_to_tsv($ms['subject_name']);
                    $tsv .= K_TAB . F_text_to_tsv($ms['subject_description']);
                    $tsv .= K_NEWLINE;
                    // ---- questions
                    $sql = 'SELECT *
						FROM ' . K_TABLE_QUESTIONS . '
						WHERE question_subject_id=' . $ms['subject_id'] . '
						ORDER BY question_enabled DESC, question_position, question_description';
                    if ($r = F_db_query($sql, $db)) {
                        while ($m = F_db_fetch_array($r)) {
                            $tsv .= 'Q';
                            // QUESTION
                            $tsv .= K_TAB . intval(F_getBoolean($m['question_enabled']));
                            $tsv .= K_TAB . F_text_to_tsv($m['question_description']);
                            $tsv .= K_TAB . F_text_to_tsv($m['question_explanation']);
                            $tsv .= K_TAB . $qtype[$m['question_type'] - 1];
                            $tsv .= K_TAB . $m['question_difficulty'];
                            $tsv .= K_TAB . $m['question_position'];
                            $tsv .= K_TAB . $m['question_timer'];
                            $tsv .= K_TAB . intval(F_getBoolean($m['question_fullscreen']));
                            $tsv .= K_TAB . intval(F_getBoolean($m['question_inline_answers']));
                            $tsv .= K_TAB . intval(F_getBoolean($m['question_auto_next']));
                            $tsv .= K_NEWLINE;
                            // display alternative answers
                            $sqla = 'SELECT *
								FROM ' . K_TABLE_ANSWERS . '
								WHERE answer_question_id=\'' . $m['question_id'] . '\'
								ORDER BY answer_position,answer_isright DESC';
                            if ($ra = F_db_query($sqla, $db)) {
                                while ($ma = F_db_fetch_array($ra)) {
                                    $tsv .= 'A';
                                    // ANSWER
                                    $tsv .= K_TAB . intval(F_getBoolean($ma['answer_enabled']));
                                    $tsv .= K_TAB . F_text_to_tsv($ma['answer_description']);
                                    $tsv .= K_TAB . F_text_to_tsv($ma['answer_explanation']);
                                    $tsv .= K_TAB . intval(F_getBoolean($ma['answer_isright']));
                                    $tsv .= K_TAB . $ma['answer_position'];
                                    $tsv .= K_TAB . $ma['answer_keyboard_key'];
                                    $tsv .= K_NEWLINE;
                                }
                            } else {
                                F_display_db_error();
                            }
                        }
                        // end while for questions
                    } else {
                        F_display_db_error();
                    }
                }
                // end while for topics
            } else {
                F_display_db_error();
            }
        }
        // end while for module
    } else {
        F_display_db_error();
    }
    return $tsv;
}