本文整理汇总了PHP中F_getBoolean函数的典型用法代码示例。如果您正苦于以下问题:PHP F_getBoolean函数的具体用法?PHP F_getBoolean怎么用?PHP F_getBoolean使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了F_getBoolean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: F_testComment
/**
* Display a textarea for user's comment.<br>
* @param $test_id (int) test ID
* @return string XHTML code
* @since 4.0.000 (2006-10-01)
*/
function F_testComment($test_id)
{
require_once '../config/tce_config.php';
global $db, $l;
$test_id = intval($test_id);
$td = F_getTestData($test_id);
$user_id = intval($_SESSION['session_user_id']);
$str = '';
// user's comment
if (F_getBoolean($td['test_comment_enabled'])) {
// get user's test comment
$comment = '';
$sql = 'SELECT testuser_comment
FROM ' . K_TABLE_TEST_USER . '
WHERE testuser_user_id=' . $user_id . '
AND testuser_test_id=' . $test_id . '
LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$comment = $m['testuser_comment'];
}
} else {
F_display_db_error();
}
$str .= '<label for="testcomment">' . $l['w_comment'] . '</label><br />';
$str .= '<textarea cols="' . K_ANSWER_TEXTAREA_COLS . '" rows="4" name="testcomment" id="testcomment" class="answertext" title="' . $l['h_testcomment'] . '">' . $comment . '</textarea><br />' . K_NEWLINE;
}
return $str;
}
示例2: foreach
// print question
$pdf->Bookmark($l['w_statistics']);
$pdf->printQuestionStats($ts['qstats'], $display_mode);
}
}
if ($mode > 2) {
// print testuser details
if ($testuser_id == 0) {
foreach ($ts['testuser'] as $tstusr) {
if (!$pubmode or F_getBoolean($tstusr['test']['test_report_to_users'])) {
$pdf->AddPage();
$pdf->printTestUserInfo($tstusr, $onlytext, $pubmode);
}
}
} else {
if (!$pubmode or F_getBoolean($ts['testuser']['\'' . $testuser_id . '\'']['test']['test_report_to_users'])) {
$pdf->AddPage();
$pdf->printTestUserInfo($ts['testuser']['\'' . $testuser_id . '\''], $onlytext, $pubmode);
}
}
}
$pdf->lastpage(true);
$pdf->SetAutoPageBreak(false);
$pdf->SetFont('helvetica', '', 5);
$pdf->SetTextColor(0, 127, 255);
$msg = "Powered by TCExam (www.tcexam.org)";
$lnk = "http://www.tcexam.org";
$pdf->SetXY(15, $pdf->getPageHeight(), true);
$pdf->Cell(0, 0, $msg, 0, 0, 'R', 0, $lnk, 0, false, 'B', 'B');
// set PDF file name
$pdf_filename = 'tcexam_report';
示例3: F_select_modules_sql
echo '<select name="module_id" id="module_id" size="0" onchange="document.getElementById(\'form_moduleeditor\').submit()" title="' . $l['h_module_name'] . '">' . K_NEWLINE;
echo '<option value="0" style="background-color:#009900;color:white;"';
if ($module_id == 0) {
echo ' selected="selected"';
}
echo '>+</option>' . 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'] == $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']) . ' </option>' . K_NEWLINE;
$countitem++;
}
if ($countitem == 1) {
echo '<option value="0"> </option>' . K_NEWLINE;
}
} else {
echo '</select></span></div>' . K_NEWLINE;
F_display_db_error();
}
echo '</select>' . K_NEWLINE;
示例4: F_tsv_export_questions
/**
* 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']));
//.........这里部分代码省略.........
示例5: getFormRowCheckBox
/**
* Print check box row form.
* @param $field_name (string) Name of the form field.
* @param $name (string) Label.
* @param $description (string) Label description (tooltip).
* @param $tip (string) Help to be displayed on the right of the input field.
* @param $value (string) Initial value.
* @param $selected (boolean) set to true if selected.
* @param $disabled (boolean) set to true to disable the field
* @param $prefix (string) code to be displayed after label.
* @return string
*/
function getFormRowCheckBox($field_name, $name, $description = '', $tip = '', $value = '', $selected = false, $disabled = false, $prefix = '')
{
require_once dirname(__FILE__) . '/../config/tce_config.php';
global $l;
if (strlen($description) == 0) {
$description = $name;
}
$str = '';
// string to return
$str .= '<div class="row">' . K_NEWLINE;
$str .= '<span class="label">' . K_NEWLINE;
$hidden = '';
if ($disabled) {
// add hidden field to be submitted
$hidden = '<input type="hidden" name="' . $field_name . '" id="' . $field_name . '" value="' . htmlspecialchars($value, ENT_COMPAT, $l['a_meta_charset']) . '" />' . K_NEWLINE;
$field_name = 'DISABLED_' . $field_name;
}
$str .= '<label for="' . $field_name . '" title="' . $description . '">' . $name . '</label>' . K_NEWLINE;
if (!empty($prefix)) {
$str .= $prefix;
}
$str .= '</span>' . K_NEWLINE;
$str .= '<span class="formw">' . K_NEWLINE;
$str .= '<input type="checkbox"';
if ($disabled) {
$str .= ' readonly="readonly" class="disabled"';
}
$str .= ' name="' . $field_name . '" id="' . $field_name . '" value="' . $value . '"';
if (F_getBoolean($selected)) {
$str .= ' checked="checked"';
}
$str .= ' title="' . $description . '" />';
$str .= $hidden;
if (strlen($tip) > 0) {
$str .= ' <span class="labeldesc">' . $tip . '</span>';
}
$str .= '</span>' . K_NEWLINE;
$str .= '</div>' . K_NEWLINE;
return $str;
}
示例6: while
// display multiple answers
while (list($key, $answer_id) = each($answers_ids)) {
++$answ_id;
// add answer ID to QR-Code data
$barcode_test_data[$question_order][1][$answ_id] = $answer_id;
// display each answer option
$sqla = 'SELECT *
FROM ' . K_TABLE_ANSWERS . '
WHERE answer_id=' . $answer_id . '
LIMIT 1';
if ($ra = F_db_query($sqla, $db)) {
if ($ma = F_db_fetch_array($ra)) {
$rightanswer = '';
if ($mq['question_type'] == 4) {
$rightanswer = $ma['answer_position'];
} elseif (F_getBoolean($ma['answer_isright'])) {
$rightanswer = 'X';
}
// start transaction
$pdf->startTransaction();
$block_page = $pdf->getPage();
$print_block = 2;
// 2 tries max
while ($print_block > 0) {
// ------------------------------
$pdf->Cell(2 * $data_cell_width_third, $data_cell_height, '', 0, 0, 'C', 0);
// print correct answer in hidden white color
/* to display the correct results, from PDF viewer, go to "Accessibility" ->
"Page Display preferences", check "Replace Document Colors",
uncheck "Only change the color of black text or line art" */
$pdf->SetTextColor(255, 255, 255, false);
示例7: F_getBoolean
if ($formstatus) {
if ($menu_mode != 'clear') {
if (!isset($obt_id) or empty($obt_id)) {
$obt_id = 0;
$obt_name = '';
$obt_color = '';
$obt_virtual = false;
} else {
$sql = 'SELECT * FROM ' . K_TABLE_OBJECT_TYPES . ' WHERE obt_id=' . $obt_id . ' LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$obt_id = $m['obt_id'];
$obt_name = $m['obt_name'];
$obt_description = $m['obt_description'];
$obt_color = $m['obt_color'];
$obt_virtual = F_getBoolean($m['obt_virtual']);
} else {
$obt_name = '';
$obt_description = '';
$obt_color = '';
$obt_virtual = false;
}
} else {
F_display_db_error();
}
}
}
}
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_editor">' . K_NEWLINE;
示例8: round
if (isset($teststat['testinfo']['user_score']) and $teststat['testinfo']['user_score'] >= $teststat['testinfo']['test_score_threshold']) {
$passmsg = ' - ' . $l['w_passed'];
} else {
$passmsg = ' - ' . $l['w_not_passed'];
}
}
if ($teststat['testinfo']['test_max_score'] > 0) {
$score_all = $teststat['testinfo']['user_score'] . ' / ' . $teststat['testinfo']['test_max_score'] . ' (' . round(100 * $teststat['testinfo']['user_score'] / $teststat['testinfo']['test_max_score']) . '%)' . $passmsg;
} else {
$score_all = $teststat['testinfo']['user_score'] . $passmsg;
}
echo getFormDescriptionLine($l['w_score'] . ':', $l['h_score_total'], $score_all);
$score_right_all = $teststat['qstats']['right'] . ' / ' . $teststat['qstats']['recurrence'] . ' (' . $teststat['qstats']['right_perc'] . '%)';
echo getFormDescriptionLine($l['w_answers_right'] . ':', $l['h_answers_right'], $score_right_all);
echo getFormDescriptionLine($l['w_comment'] . ':', $l['h_testcomment'], F_decode_tcecode($teststat['testinfo']['user_comment']));
if (F_getBoolean($teststat['testinfo']['test_report_to_users'])) {
echo '<div class="rowl">' . K_NEWLINE;
echo F_printUserTestStat($testuser_id);
echo '</div>' . K_NEWLINE;
// print statistics for modules and subjects
echo '<div class="rowl">' . K_NEWLINE;
echo '<hr />' . K_NEWLINE;
echo '<h2>' . $l['w_stats'] . '</h2>';
echo F_printTestStat($test_id, 0, $user_id, 0, 0, $testuser_id, $teststat, 1, true);
echo '<hr />' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
if (K_ENABLE_PUBLIC_PDF) {
echo '<div class="row">' . K_NEWLINE;
// PDF button
echo '<a href="tce_pdf_results.php?mode=3&test_id=' . $test_id . '&user_id=' . $user_id . '&testuser_id=' . $testuser_id . '" class="xmlbutton" title="' . $l['h_pdf'] . '">' . $l['w_pdf'] . '</a> ';
echo '</div>' . K_NEWLINE;
示例9: F_importOMRTestData
//.........这里部分代码省略.........
// for each question on array
for ($a = 1; $a <= $num_answers; ++$a) {
$answer_id = intval($omr_testdata[$q][1][$a]);
if (isset($omr_answers[$q][$a])) {
$answer_selected = $omr_answers[$q][$a];
//-1, 0, 1
} else {
$answer_selected = -1;
}
// add answer
$sqli = 'INSERT INTO ' . K_TABLE_LOG_ANSWER . ' (
logansw_testlog_id,
logansw_answer_id,
logansw_selected,
logansw_order
) VALUES (
' . $testlog_id . ',
' . $answer_id . ',
' . $answer_selected . ',
' . $a . '
)';
if (!($ri = F_db_query($sqli, $db))) {
F_display_db_error(false);
return false;
}
// calculate question score
if ($mq['question_type'] < 3) {
// MCSA or MCMA
// check if the answer is right
$answer_isright = false;
$sqla = 'SELECT answer_isright FROM ' . K_TABLE_ANSWERS . ' WHERE answer_id=' . $answer_id . ' LIMIT 1';
if ($ra = F_db_query($sqla, $db)) {
if ($ma = F_db_fetch_array($ra)) {
$answer_isright = F_getBoolean($ma['answer_isright']);
switch ($mq['question_type']) {
case 1:
// MCSA - Multiple Choice Single Answer
if ($answer_selected == 1) {
$unanswered = false;
if ($answer_isright) {
$qscore = $question_right_score;
} else {
$qscore = $question_wrong_score;
}
}
break;
case 2:
// MCMA - Multiple Choice Multiple Answer
if ($answer_selected == -1) {
$qscore += $question_unanswered_score;
} elseif ($answer_selected == 0) {
$unanswered = false;
if ($answer_isright) {
$qscore += $question_wrong_score;
} else {
$qscore += $question_right_score;
}
} elseif ($answer_selected == 1) {
$unanswered = false;
if ($answer_isright) {
$qscore += $question_right_score;
} else {
$qscore += $question_wrong_score;
}
}
break;
示例10: F_printUserTestStat
/**
* Returns user test stats as HTML table
* @param $testuser_id (int) test-user ID - if greater than zero, filter stats for the specified test-user.
* return $data string containing HTML table.
*/
function F_printUserTestStat($testuser_id)
{
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_functions_tcecode.php';
global $db, $l;
$testuser_id = intval($testuser_id);
$ret = '';
// display user questions
$sql = 'SELECT *
FROM ' . K_TABLE_QUESTIONS . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_SUBJECTS . ', ' . K_TABLE_MODULES . '
WHERE question_id=testlog_question_id
AND testlog_testuser_id=' . $testuser_id . '
AND question_subject_id=subject_id
AND subject_module_id=module_id
ORDER BY testlog_id';
if ($r = F_db_query($sql, $db)) {
$ret .= '<ol class="question">' . K_NEWLINE;
while ($m = F_db_fetch_array($r)) {
$ret .= '<li>' . K_NEWLINE;
// display question stats
$ret .= '<strong>[' . $m['testlog_score'] . ']' . K_NEWLINE;
$ret .= ' (';
$ret .= 'IP:' . getIpAsString($m['testlog_user_ip']) . K_NEWLINE;
if (isset($m['testlog_display_time']) and strlen($m['testlog_display_time']) > 0) {
$ret .= ' | ' . substr($m['testlog_display_time'], 11, 8) . K_NEWLINE;
} else {
$ret .= ' | --:--:--' . K_NEWLINE;
}
if (isset($m['testlog_change_time']) and strlen($m['testlog_change_time']) > 0) {
$ret .= ' | ' . substr($m['testlog_change_time'], 11, 8) . K_NEWLINE;
} else {
$ret .= ' | --:--:--' . K_NEWLINE;
}
if (isset($m['testlog_display_time']) and isset($m['testlog_change_time'])) {
$ret .= ' | ' . date('i:s', strtotime($m['testlog_change_time']) - strtotime($m['testlog_display_time'])) . '';
} else {
$ret .= ' | --:--' . K_NEWLINE;
}
if (isset($m['testlog_reaction_time']) and $m['testlog_reaction_time'] > 0) {
$ret .= ' | ' . $m['testlog_reaction_time'] / 1000 . '';
} else {
$ret .= ' | ------' . K_NEWLINE;
}
$ret .= ')</strong>' . K_NEWLINE;
$ret .= '<br />' . K_NEWLINE;
// display question description
$ret .= F_decode_tcecode($m['question_description']) . K_NEWLINE;
if (K_ENABLE_QUESTION_EXPLANATION and !empty($m['question_explanation'])) {
$ret .= '<br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($m['question_explanation']) . '' . K_NEWLINE;
}
if ($m['question_type'] == 3) {
// TEXT
$ret .= '<ul class="answer"><li>' . K_NEWLINE;
$ret .= F_decode_tcecode($m['testlog_answer_text']);
$ret .= ' </li></ul>' . K_NEWLINE;
} else {
$ret .= '<ol class="answer">' . K_NEWLINE;
// display each answer option
$sqla = 'SELECT *
FROM ' . K_TABLE_LOG_ANSWER . ', ' . K_TABLE_ANSWERS . '
WHERE logansw_answer_id=answer_id
AND logansw_testlog_id=\'' . $m['testlog_id'] . '\'
ORDER BY logansw_order';
if ($ra = F_db_query($sqla, $db)) {
while ($ma = F_db_fetch_array($ra)) {
$ret .= '<li>';
if ($m['question_type'] == 4) {
// ORDER
if ($ma['logansw_position'] > 0) {
if ($ma['logansw_position'] == $ma['answer_position']) {
$ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox">' . $ma['logansw_position'] . '</acronym>';
} else {
$ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox">' . $ma['logansw_position'] . '</acronym>';
}
} else {
$ret .= '<acronym title="' . $l['m_unanswered'] . '" class="offbox"> </acronym>';
}
} elseif ($ma['logansw_selected'] > 0) {
if (F_getBoolean($ma['answer_isright'])) {
$ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox">x</acronym>';
} else {
$ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox">x</acronym>';
}
} elseif ($m['question_type'] == 1) {
// MCSA
$ret .= '<acronym title="-" class="offbox"> </acronym>';
} else {
if ($ma['logansw_selected'] == 0) {
if (F_getBoolean($ma['answer_isright'])) {
$ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox"> </acronym>';
} else {
$ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox"> </acronym>';
}
} else {
$ret .= '<acronym title="' . $l['m_unanswered'] . '" class="offbox"> </acronym>';
//.........这里部分代码省略.........
示例11: intval
if (!isset($ssl_id) or empty($ssl_id)) {
$ssl_id = 0;
$ssl_name = '';
$ssl_hash = '';
$ssl_end_date = '';
$ssl_enabled = true;
$ssl_user_id = intval($_SESSION['session_user_id']);
} else {
$sql = 'SELECT * FROM ' . K_TABLE_SSLCERTS . ' WHERE ssl_id=' . $ssl_id . ' LIMIT 1';
if ($r = F_db_query($sql, $db)) {
if ($m = F_db_fetch_array($r)) {
$ssl_id = $m['ssl_id'];
$ssl_name = $m['ssl_name'];
$ssl_hash = $m['ssl_hash'];
$ssl_end_date = $m['ssl_end_date'];
$ssl_enabled = F_getBoolean($m['ssl_enabled']);
$ssl_user_id = intval($m['ssl_user_id']);
} else {
$ssl_name = '';
$ssl_hash = '';
$ssl_end_date = '';
$ssl_enabled = true;
$ssl_user_id = intval($_SESSION['session_user_id']);
}
} else {
F_display_db_error();
}
}
}
}
echo '<div class="container">' . K_NEWLINE;
示例12: printUserTestDetails
//.........这里部分代码省略.........
if (isset($m['testlog_reaction_time']) and strlen($m['testlog_reaction_time']) > 0) {
$reaction_time = $m['testlog_reaction_time'] / 1000;
} else {
$reaction_time = '';
}
$this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $display_time, 1, 0, 'C', 0);
$this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $change_time, 1, 0, 'C', 0);
$this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $diff_time, 1, 0, 'C', 0);
$this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $reaction_time, 1, 1, 'C', 0);
$this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['question_description']), 1, 1);
if (K_ENABLE_QUESTION_EXPLANATION and !empty($m['question_explanation'])) {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '', 0, 0, 'C', 0);
$this->SetFont('', 'BIU');
$this->Cell(0, $this->tce_data_cell_height, $l['w_explanation'], 'LTR', 1, '', 0, '', 0);
$this->SetFont('', '');
$this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['question_explanation']), 'LRB', 1, '', '');
}
if ($m['question_type'] == 3) {
// free-text question - print user text answer
$this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + 2 * $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['testlog_answer_text']), 1, 1);
} else {
// display each answer option
$sqla = 'SELECT * FROM ' . K_TABLE_LOG_ANSWER . ', ' . K_TABLE_ANSWERS . ' WHERE logansw_answer_id=answer_id AND logansw_testlog_id=' . $m['testlog_id'] . ' ORDER BY logansw_order';
if ($ra = F_db_query($sqla, $db)) {
$idx = 0;
// count items
while ($ma = F_db_fetch_array($ra)) {
$posfill = 0;
$idx++;
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '', 0, 0, 'C', 0);
if ($m['question_type'] == 4) {
if ($ma['logansw_position'] > 0) {
if ($ma['logansw_position'] == $ma['answer_position']) {
$posfill = 1;
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $ma['logansw_position'], 1, 0, 'C', 1);
} else {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $ma['logansw_position'], 1, 0, 'C', 0);
}
} else {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, ' ', 1, 0, 'C', 0);
}
} elseif ($ma['logansw_selected'] > 0) {
// selected
if (F_getBoolean($ma['answer_isright'])) {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '+', 1, 0, 'C', 1);
} else {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '-', 1, 0, 'C', 1);
}
} elseif ($m['question_type'] == 1) {
// MCSA
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, ' ', 1, 0, 'C', 0);
} else {
if ($ma['logansw_selected'] == 0) {
// unselected
if (F_getBoolean($ma['answer_isright'])) {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '-', 1, 0, 'C', 0);
} else {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '+', 1, 0, 'C', 0);
}
} else {
// no answer
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, ' ', 1, 0, 'C', 0);
}
}
if ($m['question_type'] == 4) {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $ma['answer_position'], 1, 0, 'C', $posfill);
} elseif (F_getBoolean($ma['answer_isright'])) {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $idx, 1, 0, 'C', 1);
} else {
$this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $idx, 1, 0, 'C', 0);
}
$this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + $tce_data_cell_width, $this->GetY(), F_decode_tcecode($ma['answer_description']), 'LRTB', 1);
if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) {
$this->Cell(3 * $tce_data_cell_width_third, $this->tce_data_cell_height, '', 0, 0, 'C', 0);
$this->SetFont('', 'BIU');
$this->Cell(0, $this->tce_data_cell_height, $l['w_explanation'], 'LTR', 1, '', 0, '', 0);
$this->SetFont('', '');
$this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + 3 * $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($ma['answer_explanation']), 'LRB', 1, '', '');
}
}
} else {
F_display_db_error();
}
}
// end multiple answers
if (strlen($m['testlog_comment']) > 0) {
// teacher / supervisor comment
$this->SetTextColor(255, 0, 0);
$this->writeHTMLCell(0, $this->tce_data_cell_height, PDF_MARGIN_LEFT + 2 * $tce_data_cell_width_third, $this->GetY(), F_decode_tcecode($m['testlog_comment']), 'LRTB', 1);
$this->SetTextColor(0, 0, 0);
}
$this->Ln($this->tce_data_cell_height);
$itemcount++;
}
} else {
F_display_db_error();
}
$stats = F_getTestStat($data['test']['test_id'], 0, $data['user_id'], 0, 0, $data['id']);
$this->printQuestionStats($stats['qstats'], 1);
}
示例13: F_xml_export_questions
/**
* 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;
//.........这里部分代码省略.........
示例14: F_show_select_questions
/**
* Display a list of selected questions.
* @author Nicola Asuni
* @since 2005-07-06
* @param $wherequery (string) question selection query
* @param $subject_module_id (string) module ID
* @param $subject_id (string) topic ID
* @param $order_field (string) order by column name
* @param $orderdir (int) oreder direction
* @param $firstrow (int) number of first row to display
* @param $rowsperpage (int) number of rows per page
* @param $hide_answers (boolean) if true hide answers
* @return false in case of empty database, true otherwise
*/
function F_show_select_questions($wherequery, $subject_module_id, $subject_id, $order_field, $orderdir, $firstrow, $rowsperpage, $hide_answers = false)
{
global $l, $db;
require_once '../config/tce_config.php';
require_once '../../shared/code/tce_functions_page.php';
$subject_module_id = intval($subject_module_id);
$subject_id = intval($subject_id);
$orderdir = intval($orderdir);
$firstrow = intval($firstrow);
$rowsperpage = intval($rowsperpage);
if (empty($order_field) or !in_array($order_field, array('question_id', 'question_subject_id', 'question_description', 'question_explanation', 'question_type', 'question_difficulty', 'question_enabled', 'question_position', 'question_timer', 'question_fullscreen', 'question_inline_answers', 'question_auto_next', 'question_enabled DESC, question_position, CAST(question_description as varchar2(100))', 'question_enabled DESC, question_position, question_description'))) {
$order_field = 'question_description';
}
if ($orderdir == 0) {
$nextorderdir = 1;
$full_order_field = $order_field;
} else {
$nextorderdir = 0;
$full_order_field = $order_field . ' DESC';
}
if (!F_count_rows(K_TABLE_QUESTIONS)) {
//if the table is void (no items) display message
F_print_error('MESSAGE', $l['m_databasempty']);
return FALSE;
}
if (empty($wherequery)) {
$wherequery = 'WHERE question_subject_id=' . $subject_id . '';
} else {
$wherequery = F_escape_sql($db, $wherequery);
$wherequery .= ' AND question_subject_id=' . $subject_id . '';
}
$sql = 'SELECT *
FROM ' . K_TABLE_QUESTIONS . '
' . $wherequery . '
ORDER BY ' . $full_order_field;
if (K_DATABASE_TYPE == 'ORACLE') {
$sql = 'SELECT * FROM (' . $sql . ') WHERE rownum BETWEEN ' . $firstrow . ' AND ' . ($firstrow + $rowsperpage) . '';
} else {
$sql .= ' LIMIT ' . $rowsperpage . ' OFFSET ' . $firstrow . '';
}
if ($r = F_db_query($sql, $db)) {
$questlist = '';
$itemcount = $firstrow;
while ($m = F_db_fetch_array($r)) {
$itemcount++;
$questlist .= '<li>' . K_NEWLINE;
$questlist .= '<strong>' . $itemcount . '.</strong> ';
$questlist .= '<input type="checkbox" name="questionid' . $itemcount . '" id="questionid' . $itemcount . '" value="' . $m['question_id'] . '" title="' . $l['w_select'] . '"';
if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1) {
$questlist .= ' checked="checked"';
}
$questlist .= ' />';
// display question description
if (F_getBoolean($m['question_enabled'])) {
$questlist .= '<acronym class="onbox" title="' . $l['w_enabled'] . '">+</acronym>';
} else {
$questlist .= '<acronym class="offbox" title="' . $l['w_disabled'] . '">-</acronym>';
}
switch ($m['question_type']) {
case 1:
$questlist .= ' <acronym class="offbox" title="' . $l['w_single_answer'] . '">S</acronym>';
break;
case 2:
$questlist .= ' <acronym class="offbox" title="' . $l['w_multiple_answers'] . '">M</acronym>';
break;
case 3:
$questlist .= ' <acronym class="offbox" title="' . $l['w_free_answer'] . '">T</acronym>';
break;
case 4:
$questlist .= ' <acronym class="offbox" title="' . $l['w_ordering_answer'] . '">O</acronym>';
break;
}
$questlist .= ' <acronym class="offbox" title="' . $l['h_question_difficulty'] . '">' . $m['question_difficulty'] . '</acronym>';
if ($m['question_position'] > 0) {
$questlist .= ' <acronym class="onbox" title="' . $l['h_position'] . '">' . intval($m['question_position']) . '</acronym>';
} else {
$questlist .= ' <acronym class="offbox" title="' . $l['h_position'] . '"> </acronym>';
}
if (F_getBoolean($m['question_fullscreen'])) {
$questlist .= ' <acronym class="onbox" title="' . $l['w_fullscreen'] . ': ' . $l['w_enabled'] . '">F</acronym>';
} else {
$questlist .= ' <acronym class="offbox" title="' . $l['w_fullscreen'] . ': ' . $l['w_disabled'] . '"> </acronym>';
}
if (F_getBoolean($m['question_inline_answers'])) {
$questlist .= ' <acronym class="onbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_enabled'] . '">I</acronym>';
} else {
//.........这里部分代码省略.........
示例15: intval
echo '>+</option>' . K_NEWLINE;
$sql = 'SELECT * FROM ' . K_TABLE_QUESTIONS . ' WHERE question_subject_id=' . intval($question_subject_id) . ' ORDER BY question_enabled DESC, question_position,';
if (K_DATABASE_TYPE == 'ORACLE') {
$sql .= 'CAST(question_description as varchar2(100))';
} else {
$sql .= 'question_description';
}
if ($r = F_db_query($sql, $db)) {
$countitem = 1;
while ($m = F_db_fetch_array($r)) {
echo '<option value="' . $m['question_id'] . '"';
if ($m['question_id'] == $question_id) {
echo ' selected="selected"';
}
echo '>' . $countitem . '. ';
if (!F_getBoolean($m['question_enabled'])) {
echo '-';
} else {
echo $qtype[$m['question_type'] - 1];
}
echo ' ' . htmlspecialchars(F_substr_utf8(F_remove_tcecode($m['question_description']), 0, K_SELECT_SUBSTRING), ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
$countitem++;
}
if ($countitem == 1) {
echo '<option value="0"> </option>' . K_NEWLINE;
}
} else {
echo '</select></span></div>' . K_NEWLINE;
F_display_db_error();
}
echo '</select>' . K_NEWLINE;