/**
 * 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;
}
Example #2
0
        // 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';
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']) . '&nbsp;</option>' . K_NEWLINE;
        $countitem++;
    }
    if ($countitem == 1) {
        echo '<option value="0">&nbsp;</option>' . K_NEWLINE;
    }
} else {
    echo '</select></span></div>' . K_NEWLINE;
    F_display_db_error();
}
echo '</select>' . K_NEWLINE;
Example #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;
}
Example #5
0
/**
 * 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;
}
Example #6
0
                // 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);
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;
Example #8
0
    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&amp;test_id=' . $test_id . '&amp;user_id=' . $user_id . '&amp;testuser_id=' . $testuser_id . '" class="xmlbutton" title="' . $l['h_pdf'] . '">' . $l['w_pdf'] . '</a> ';
        echo '</div>' . K_NEWLINE;
/**
 * Import user's test data from OMR.
 * @param $user_id (int) user ID.
 * @param $date (string) date-time field.
 * @param $omr_testdata (array) Array containing test data.
 * @param $omr_answers (array) Array containing test answers (from OMR).
 * @return boolean TRUE in case of success, FALSE otherwise.
 */
function F_importOMRTestData($user_id, $date, $omr_testdata, $omr_answers)
{
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_test.php';
    global $db, $l;
    // check arrays
    if (count($omr_testdata) > count($omr_answers) + 1) {
        // arrays must contain the same amount of questions
        return false;
    }
    $test_id = intval($omr_testdata[0]);
    $user_id = intval($user_id);
    $time = strtotime($date);
    $date = date(K_TIMESTAMP_FORMAT, $time);
    $dateanswers = date(K_TIMESTAMP_FORMAT, $time + 1);
    // check user's group
    if (F_count_rows(K_TABLE_USERGROUP . ', ' . K_TABLE_TEST_GROUPS . ' WHERE usrgrp_group_id=tstgrp_group_id AND tstgrp_test_id=' . $test_id . ' AND usrgrp_user_id=' . $user_id . ' LIMIT 1') == 0) {
        return false;
    }
    // get test data
    $testdata = F_getTestData($test_id);
    // 1. delete previous test data
    $sqld = 'DELETE FROM ' . K_TABLE_TEST_USER . ' WHERE testuser_test_id=' . $test_id . ' AND testuser_user_id=' . $user_id . '';
    if (!($rd = F_db_query($sqld, $db))) {
        F_display_db_error();
    }
    // 2. create new user's test entry
    // ------------------------------
    $sql = 'INSERT INTO ' . K_TABLE_TEST_USER . ' (
		testuser_test_id,
		testuser_user_id,
		testuser_status,
		testuser_creation_time,
		testuser_comment
		) VALUES (
		' . $test_id . ',
		' . $user_id . ',
		4,
		\'' . $date . '\',
		\'OMR\'
		)';
    if (!($r = F_db_query($sql, $db))) {
        F_display_db_error(false);
        return false;
    } else {
        // get inserted ID
        $testuser_id = F_db_insert_id($db, K_TABLE_TEST_USER, 'testuser_id');
    }
    // 3. create test log entries
    $num_questions = count($omr_testdata) - 1;
    // for each question on array
    for ($q = 1; $q <= $num_questions; ++$q) {
        $question_id = intval($omr_testdata[$q][0]);
        $num_answers = count($omr_testdata[$q][1]);
        // get question data
        $sqlq = 'SELECT question_type, question_difficulty FROM ' . K_TABLE_QUESTIONS . ' WHERE question_id=' . $question_id . ' LIMIT 1';
        if ($rq = F_db_query($sqlq, $db)) {
            if ($mq = F_db_fetch_array($rq)) {
                // question scores
                $question_right_score = $testdata['test_score_right'] * $mq['question_difficulty'];
                $question_wrong_score = $testdata['test_score_wrong'] * $mq['question_difficulty'];
                $question_unanswered_score = $testdata['test_score_unanswered'] * $mq['question_difficulty'];
                // add question
                $sqll = 'INSERT INTO ' . K_TABLE_TESTS_LOGS . ' (
					testlog_testuser_id,
					testlog_question_id,
					testlog_score,
					testlog_creation_time,
					testlog_display_time,
					testlog_reaction_time,
					testlog_order,
					testlog_num_answers
					) VALUES (
					' . $testuser_id . ',
					' . $question_id . ',
					' . $question_unanswered_score . ',
					\'' . $date . '\',
					\'' . $date . '\',
					1,
					' . $q . ',
					' . $num_answers . '
					)';
                if (!($rl = F_db_query($sqll, $db))) {
                    F_display_db_error(false);
                    return false;
                }
                $testlog_id = F_db_insert_id($db, K_TABLE_TESTS_LOGS, 'testlog_id');
                // set initial question score
                if ($mq['question_type'] == 1) {
                    // MCSA
                    $qscore = $question_unanswered_score;
                } else {
                    // MCMA
                    $qscore = 0;
                }
                $unanswered = true;
                // 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;
                                }
                            }
                        } else {
                            F_display_db_error(false);
                            return false;
                        }
                    }
                }
                // end for each answer
                if ($mq['question_type'] == 2) {
                    // MCMA
                    // normalize score
                    if (F_getBoolean($testdata['test_mcma_partial_score'])) {
                        // use partial scoring for MCMA and ORDER questions
                        $qscore = round($qscore / $num_answers, 3);
                    } else {
                        // all-or-nothing points
                        if ($qscore >= $question_right_score * $num_answers) {
                            // right
                            $qscore = $question_right_score;
                        } elseif ($qscore == $question_unanswered_score * $num_answers) {
                            // unanswered
                            $qscore = $question_unanswered_score;
                        } else {
                            // wrong
                            $qscore = $question_wrong_score;
                        }
                    }
                }
                if ($unanswered) {
                    $change_time = '';
                } else {
                    $change_time = $dateanswers;
                }
                // update question score
                $sqll = 'UPDATE ' . K_TABLE_TESTS_LOGS . ' SET
					testlog_score=' . $qscore . ',
					testlog_change_time=' . F_empty_to_null($change_time) . ',
					testlog_reaction_time=1000
					WHERE testlog_id=' . $testlog_id . '';
                if (!($rl = F_db_query($sqll, $db))) {
                    F_display_db_error();
                    return false;
                }
            }
        } else {
            F_display_db_error(false);
            return false;
        }
    }
    // end for each question
    return true;
}
/**
* 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 .= '&nbsp;</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">&nbsp;</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">&nbsp;</acronym>';
                        } else {
                            if ($ma['logansw_selected'] == 0) {
                                if (F_getBoolean($ma['answer_isright'])) {
                                    $ret .= '<acronym title="' . $l['h_answer_wrong'] . '" class="nobox">&nbsp;</acronym>';
                                } else {
                                    $ret .= '<acronym title="' . $l['h_answer_right'] . '" class="okbox">&nbsp;</acronym>';
                                }
                            } else {
                                $ret .= '<acronym title="' . $l['m_unanswered'] . '" class="offbox">&nbsp;</acronym>';
                            }
                        }
                        $ret .= '&nbsp;';
                        if ($m['question_type'] == 4) {
                            $ret .= '<acronym title="' . $l['w_position'] . '" class="onbox">' . $ma['answer_position'] . '</acronym>';
                        } elseif (F_getBoolean($ma['answer_isright'])) {
                            $ret .= '<acronym title="' . $l['w_answers_right'] . '" class="onbox">&reg;</acronym>';
                        } else {
                            $ret .= '<acronym title="' . $l['w_answers_wrong'] . '" class="offbox">&nbsp;</acronym>';
                        }
                        $ret .= ' ';
                        $ret .= F_decode_tcecode($ma['answer_description']);
                        if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) {
                            $ret .= '<br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($ma['answer_explanation']) . '' . K_NEWLINE;
                        }
                        $ret .= '</li>' . K_NEWLINE;
                    }
                } else {
                    F_display_db_error();
                }
                $ret .= '</ol>' . K_NEWLINE;
            }
            // end multiple answers
            // display teacher/supervisor comment to the question
            if (isset($m['testlog_comment']) and !empty($m['testlog_comment'])) {
                $ret .= '<ul class="answer"><li class="comment">' . K_NEWLINE;
                $ret .= F_decode_tcecode($m['testlog_comment']);
                $ret .= '&nbsp;</li></ul>' . K_NEWLINE;
            }
            $ret .= '<br /><br />' . K_NEWLINE;
            $ret .= '</li>' . K_NEWLINE;
        }
        $ret .= '</ol>' . K_NEWLINE;
    } else {
        F_display_db_error();
    }
    return $ret;
}
Example #11
0
        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;
Example #12
0
    /**
     * print test details for the selected user
     * @param $data (array) Testuser data array.
     * @param $onlytext (boolean) If true print only text questions.
     */
    public function printUserTestDetails($data, $onlytext = false)
    {
        require_once '../config/tce_config.php';
        require_once '../../shared/code/tce_functions_test_stats.php';
        require_once '../../shared/code/tce_functions_tcecode.php';
        global $db, $l;
        $testuser_id = intval($data['id']);
        $qtype = array('S', 'M', 'T', 'O');
        // question types
        $num_column = 7;
        $tce_data_cell_width = round($this->tce_page_width / $num_column, 2);
        $tce_data_cell_width_third = round($tce_data_cell_width / 3, 2);
        $tce_data_cell_width_half = round($tce_data_cell_width / 2, 2);
        $numberfont = 'courier';
        // 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';
        if ($onlytext) {
            // display only TEXT questions
            $sql .= ' AND question_type=3';
        }
        $sql .= ' ORDER BY testlog_id';
        if ($r = F_db_query($sql, $db)) {
            $this->SetFont(PDF_FONT_NAME_DATA, 'B', PDF_FONT_SIZE_DATA);
            $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, '#', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_score'], 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_ip'], 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $l['w_start'] . ' [' . $l['w_time_hhmmss'] . ']', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width + $tce_data_cell_width_third, $this->tce_data_cell_height, $l['w_end'] . ' [' . $l['w_time_hhmmss'] . ']', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_time'] . ' [' . $l['w_time_mmss'] . ']', 1, 0, 'C', 1);
            $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $l['w_reaction'] . ' [sec]', 1, 1, 'C', 1);
            $this->Ln($this->tce_data_cell_height);
            // print table rows
            $this->SetFont(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA);
            $itemcount = 1;
            while ($m = F_db_fetch_array($r)) {
                $this->Cell($tce_data_cell_width_third, $this->tce_data_cell_height, $itemcount . ' ' . $qtype[$m['question_type'] - 1], 1, 0, 'R', 0);
                $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, $m['testlog_score'], 1, 0, 'C', 0);
                $this->Cell($tce_data_cell_width, $this->tce_data_cell_height, getIpAsString($m['testlog_user_ip']), 1, 0, 'C', 0);
                if (isset($m['testlog_display_time']) and strlen($m['testlog_display_time']) > 0) {
                    $display_time = substr($m['testlog_display_time'], 11, 8);
                } else {
                    $display_time = '--:--:--';
                }
                if (isset($m['testlog_change_time']) and strlen($m['testlog_change_time']) > 0) {
                    $change_time = substr($m['testlog_change_time'], 11, 8);
                } else {
                    $change_time = '--:--:--';
                }
                if (isset($m['testlog_display_time']) and isset($m['testlog_change_time'])) {
                    $diff_time = date('i:s', strtotime($m['testlog_change_time']) - strtotime($m['testlog_display_time']));
                } else {
                    $diff_time = '--:--';
                }
                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);
    }
Example #13
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;
}
Example #14
0
/**
 * 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'] . '">&nbsp;</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'] . '">&nbsp;</acronym>';
            }
            if (F_getBoolean($m['question_inline_answers'])) {
                $questlist .= ' <acronym class="onbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_enabled'] . '">I</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_disabled'] . '">&nbsp;</acronym>';
            }
            if (F_getBoolean($m['question_auto_next'])) {
                $questlist .= ' <acronym class="onbox" title="' . $l['w_auto_next'] . ': ' . $l['w_enabled'] . '">A</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['w_auto_next'] . ': ' . $l['w_disabled'] . '">&nbsp;</acronym>';
            }
            if ($m['question_timer'] > 0) {
                $questlist .= ' <acronym class="onbox" title="' . $l['h_question_timer'] . '">' . intval($m['question_timer']) . '</acronym>';
            } else {
                $questlist .= ' <acronym class="offbox" title="' . $l['h_question_timer'] . '">&nbsp;</acronym>';
            }
            $questlist .= ' <a href="tce_edit_question.php?subject_module_id=' . $subject_module_id . '&amp;question_subject_id=' . $subject_id . '&amp;question_id=' . $m['question_id'] . '" title="' . $l['t_questions_editor'] . ' [ID = ' . $m['question_id'] . ']" class="xmlbutton">' . $l['w_edit'] . '</a>';
            $questlist .= '<br /><br />' . K_NEWLINE;
            $questlist .= '<div class="paddingleft">' . F_decode_tcecode($m['question_description']) . '</div>' . K_NEWLINE;
            if (K_ENABLE_QUESTION_EXPLANATION and !empty($m['question_explanation'])) {
                $questlist .= '<div class="paddingleft"><br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($m['question_explanation']) . '</div>' . K_NEWLINE;
            }
            if (!$hide_answers) {
                // display alternative answers
                $sqla = 'SELECT *
					FROM ' . K_TABLE_ANSWERS . '
					WHERE answer_question_id=\'' . $m['question_id'] . '\'
					ORDER BY answer_enabled DESC,answer_position,answer_isright DESC';
                if ($ra = F_db_query($sqla, $db)) {
                    $answlist = '';
                    while ($ma = F_db_fetch_array($ra)) {
                        $answlist .= '<li>';
                        if (F_getBoolean($ma['answer_enabled'])) {
                            $answlist .= '<acronym class="onbox" title="' . $l['w_enabled'] . '">+</acronym>';
                        } else {
                            $answlist .= '<acronym class="offbox" title="' . $l['w_disabled'] . '">-</acronym>';
                        }
                        if ($m['question_type'] != 4) {
                            if (F_getBoolean($ma['answer_isright'])) {
                                $answlist .= ' <acronym class="okbox" title="' . $l['h_answer_right'] . '">T</acronym>';
                            } else {
                                $answlist .= ' <acronym class="nobox" title="' . $l['h_answer_wrong'] . '">F</acronym>';
                            }
                        }
                        if ($ma['answer_position'] > 0) {
                            $answlist .= ' <acronym class="onbox" title="' . $l['h_position'] . '">' . intval($ma['answer_position']) . '</acronym>';
                        } else {
                            $answlist .= ' <acronym class="offbox" title="' . $l['h_position'] . '">&nbsp;</acronym>';
                        }
                        if ($ma['answer_keyboard_key'] > 0) {
                            $answlist .= ' <acronym class="onbox" title="' . $l['h_answer_keyboard_key'] . '">' . F_text_to_xml(chr($ma['answer_keyboard_key'])) . '</acronym>';
                        } else {
                            $answlist .= ' <acronym class="offbox" title="' . $l['h_answer_keyboard_key'] . '">&nbsp;</acronym>';
                        }
                        $answlist .= ' <a href="tce_edit_answer.php?subject_module_id=' . $subject_module_id . '&amp;question_subject_id=' . $subject_id . '&amp;answer_question_id=' . $m['question_id'] . '&amp;answer_id=' . $ma['answer_id'] . '" title="' . $l['t_answers_editor'] . ' [ID = ' . $ma['answer_id'] . ']" class="xmlbutton">' . $l['w_edit'] . '</a>';
                        //$answlist .= " ";
                        //$answlist .= "".F_decode_tcecode($ma['answer_description'])."";
                        $answlist .= '<br /><br />' . K_NEWLINE;
                        $answlist .= '<div class="paddingleft">' . F_decode_tcecode($ma['answer_description']) . '</div>' . K_NEWLINE;
                        if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) {
                            $answlist .= '<div class="paddingleft"><br /><span class="explanation">' . $l['w_explanation'] . ':</span><br />' . F_decode_tcecode($ma['answer_explanation']) . '</div>' . K_NEWLINE;
                        }
                        $answlist .= '</li>' . K_NEWLINE;
                    }
                    if (strlen($answlist) > 0) {
                        $questlist .= "<ol class=\"answer\">\n" . $answlist . "</ol><br /><br />\n";
                    }
                } else {
                    F_display_db_error();
                }
            }
            // end if hide_answers
            $questlist .= '</li>' . K_NEWLINE;
        }
        if (strlen($questlist) > 0) {
            // display the list
            echo '<ul class="question">' . K_NEWLINE;
            echo $questlist;
            echo '</ul>' . K_NEWLINE;
            echo '<div class="row"><hr /></div>' . K_NEWLINE;
            // check/uncheck all options
            echo '<span dir="' . $l['a_meta_dir'] . '">';
            echo '<input type="radio" name="checkall" id="checkall1" value="1" onclick="document.getElementById(\'form_selectquestions\').submit()" />';
            echo '<label for="checkall1">' . $l['w_check_all'] . '</label> ';
            echo '<input type="radio" name="checkall" id="checkall0" value="0" onclick="document.getElementById(\'form_selectquestions\').submit()" />';
            echo '<label for="checkall0">' . $l['w_uncheck_all'] . '</label>';
            echo '</span>' . K_NEWLINE;
            echo '&nbsp;';
            if ($l['a_meta_dir'] == 'rtl') {
                $arr = '&larr;';
            } else {
                $arr = '&rarr;';
            }
            // action options
            echo '<select name="menu_action" id="menu_action" size="0">' . K_NEWLINE;
            echo '<option value="0" style="color:gray">' . $l['m_with_selected'] . '</option>' . K_NEWLINE;
            echo '<option value="enable">' . $l['w_enable'] . '</option>' . K_NEWLINE;
            echo '<option value="disable">' . $l['w_disable'] . '</option>' . K_NEWLINE;
            echo '<option value="delete">' . $l['w_delete'] . '</option>' . K_NEWLINE;
            echo '<option value="copy">' . $l['w_copy'] . ' ' . $arr . '</option>' . K_NEWLINE;
            echo '<option value="move">' . $l['w_move'] . ' ' . $arr . '</option>' . K_NEWLINE;
            echo '</select>' . K_NEWLINE;
            // select new topic (for copy or move action)
            echo '<select name="new_subject_id" id="new_subject_id" size="0" title="' . $l['h_subject'] . '">' . K_NEWLINE;
            $sql = F_select_module_subjects_sql('module_enabled=\'1\' AND subject_enabled=\'1\'');
            if ($r = F_db_query($sql, $db)) {
                echo '<option value="0" style="color:gray">' . $l['w_subject'] . '</option>' . K_NEWLINE;
                $prev_module_id = 0;
                while ($m = F_db_fetch_array($r)) {
                    if ($m['module_id'] != $prev_module_id) {
                        $prev_module_id = $m['module_id'];
                        echo '<option value="0" style="color:gray;font-weight:bold;" disabled="disabled">* ' . htmlspecialchars($m['module_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
                    }
                    echo '<option value="' . $m['subject_id'] . '">&nbsp;&nbsp;&nbsp;&nbsp;' . htmlspecialchars($m['subject_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
                }
            } else {
                echo '</select>' . K_NEWLINE;
                F_display_db_error();
            }
            echo '</select>' . K_NEWLINE;
            // submit button
            F_submit_button("update", $l['w_update'], $l['h_update']);
        }
        // ---------------------------------------------------------------
        // -- page jumper (menu for successive pages)
        if ($rowsperpage > 0) {
            $sql = 'SELECT count(*) AS total FROM ' . K_TABLE_QUESTIONS . ' ' . $wherequery . '';
            if (!empty($order_field)) {
                $param_array = '&amp;order_field=' . urlencode($order_field) . '';
            }
            if (!empty($orderdir)) {
                $param_array .= '&amp;orderdir=' . $orderdir . '';
            }
            if (!empty($hide_answers)) {
                $param_array .= '&amp;hide_answers=' . intval($hide_answers) . '';
            }
            $param_array .= '&amp;subject_module_id=' . $subject_module_id . '';
            $param_array .= '&amp;subject_id=' . $subject_id . '';
            $param_array .= '&amp;submitted=1';
            F_show_page_navigator($_SERVER['SCRIPT_NAME'], $sql, $firstrow, $rowsperpage, $param_array);
        }
    } else {
        F_display_db_error();
    }
    return TRUE;
}
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">&nbsp;</option>' . K_NEWLINE;
    }
} else {
    echo '</select></span></div>' . K_NEWLINE;
    F_display_db_error();
}
echo '</select>' . K_NEWLINE;
Example #16
0
if (isset($_REQUEST['date'])) {
    $date = $_REQUEST['date'];
    $date_time = strtotime($date);
    $date = date(K_TIMESTAMP_FORMAT, $date_time);
} else {
    $date = date(K_TIMESTAMP_FORMAT);
}
if (isset($_REQUEST['omrdir']) and strpos($_REQUEST['omrdir'], K_PATH_CACHE . 'OMR') == 0) {
    $omrdir = $_REQUEST['omrdir'];
} else {
    $omrdir = K_PATH_CACHE . 'OMR/';
}
if (!isset($_REQUEST['overwrite']) or empty($_REQUEST['overwrite'])) {
    $overwrite = false;
} else {
    $overwrite = F_getBoolean($_REQUEST['overwrite']);
}
// process OMR files on the specified directory
if (isset($menu_mode) and $menu_mode == 'upload' and file_exists($omrdir)) {
    $logfilename = 'log_import_omr_' . time() . '.txt';
    $logfile = K_PATH_CACHE . 'OMR/' . $logfilename;
    $dirhdl = @opendir($omrdir);
    if ($dirhdl !== false) {
        while ($file = readdir($dirhdl)) {
            if ($file != '.' and $file != '..') {
                $filename = $omrdir . $file;
                $matches = array();
                if (!is_dir($filename) and preg_match('/OMR_([^_]+)_QR.([a-zA-Z]+)/', $file, $matches)) {
                    // read OMR DATA page
                    $omr_testdata = F_decodeOMRTestDataQRCode($filename);
                    if ($omr_testdata === false) {
                    // display each answer option
                    $sqla = 'SELECT *
						FROM ' . K_TABLE_LOG_ANSWER . ', ' . K_TABLE_ANSWERS . '
						WHERE logansw_answer_id=answer_id
							AND logansw_testlog_id=\'' . $mq['testlog_id'] . '\'
						ORDER BY logansw_order';
                    if ($ra = F_db_query($sqla, $db)) {
                        $idx = 1;
                        // count answer items
                        while ($ma = F_db_fetch_array($ra)) {
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<answer num="' . $idx . '" id="' . $ma['answer_id'] . '">' . K_NEWLINE;
                            if ($mq['question_type'] == 4) {
                                $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<position>' . $ma['answer_position'] . '</position>' . K_NEWLINE;
                                $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<answposition>' . $ma['logansw_position'] . '</answposition>' . K_NEWLINE;
                            } else {
                                $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<isright>' . $boolean[intval(F_getBoolean($ma['answer_isright']))] . '</isright>' . K_NEWLINE;
                                $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<selected>' . intval($ma['logansw_selected']) . '</selected>' . K_NEWLINE;
                            }
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<key>' . F_text_to_xml(chr($ma['answer_keyboard_key'])) . '</key>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<description>' . F_text_to_xml($ma['answer_description']) . '</description>' . K_NEWLINE;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<explanation>' . F_text_to_xml($ma['answer_explanation']) . '</explanation>' . K_NEWLINE;
                            $idx++;
                            $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '</answer>' . K_NEWLINE;
                        }
                    } else {
                        F_display_db_error();
                    }
                }
                // end multiple answers
                $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '</answers>' . K_NEWLINE;
                // export teacher/supervisor comment to the question
/**
 * Get an HTML representation of objects on the selected rack.
 * @param $dcn_id (int) ID of selected datacenter.
 * @param $sts_id (int) ID of selected suite.
 * @param $rck_id (int) ID of selected rack.
 * @param $rack_data (array) Array of rack data objects.
 * @return string.
 */
function getRackStack($dcn_id, $sts_id, $rck_id, &$rack_data)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once 'tce_functions_group_permissions.php';
    $user_id = intval($_SESSION['session_user_id']);
    $dcn_id = intval($dcn_id);
    $sts_id = intval($sts_id);
    $rck_id = intval($rck_id);
    // get ID for 'guest' object type
    $guest_obt_id = F_getObjectTypeID('guest');
    $rck_permission = F_getUserPermission($user_id, K_TABLE_RACK_GROUPS, $rck_id);
    // get objects on rack
    $rackstack = array();
    $sql = 'SELECT * FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_LOCATIONS . ' WHERE obj_id=loc_obj_id AND loc_rack_id=' . $rck_id . ' ORDER BY loc_row_top DESC, loc_front DESC, loc_center DESC, loc_rear DESC';
    if ($r = F_db_query($sql, $db)) {
        while ($m = F_db_fetch_assoc($r)) {
            $obj_permission = F_getUserPermission($user_id, K_TABLE_OBJECT_GROUPS, $m['obj_id']);
            if ($obj_permission > 0) {
                // get object position on the row
                $rpos = bindec(intval($m['loc_front']) . intval($m['loc_center']) . intval($m['loc_rear']));
                switch ($m['loc_side']) {
                    case 'left':
                    case 'right':
                        $rkey = $m['loc_side'] . '_' . $m['loc_row_top'];
                        if (F_getBoolean($m['loc_front'])) {
                            $rkey .= '_front';
                        } elseif (F_getBoolean($m['loc_rear'])) {
                            $rkey .= '_rear';
                        }
                        break;
                    case 'top':
                    case 'bottom':
                        $rkey = $m['loc_side'] . '_' . $m['loc_row_top'] . '_' . $rpos;
                        break;
                    case '-':
                    default:
                        $rkey = $m['loc_row_top'] . '_' . $rpos;
                        break;
                }
                $rackstack[$rkey] = $m;
                // get guest list
                $rackstack[$rkey]['guests'] = F_getGuestList($m['obj_id'], $guest_obt_id);
                // get capacity for each object on rack
                $capacity = array();
                F_get_object_data_array($m['obj_id'], $ilo, $capacity);
                if (isset($capacity) and !empty($capacity)) {
                    $rackstack[$rkey]['capacity'] = $capacity;
                }
            }
        }
    } else {
        F_display_db_error();
    }
    $rackobjs = '<table class="rack">' . K_NEWLINE;
    $rackobjs .= '<tr style="font-size:80%;"><th>#</th>';
    $rackobjs .= '<th title="' . $l['w_front'] . ' - ' . $l['w_left'] . '">FL</th><th title="' . $l['w_front'] . ' - ' . $l['w_right'] . '">FR</th>';
    $rackobjs .= '<th style="min-width:50px;">' . $l['w_front'] . '</th>';
    $rackobjs .= '<th style="min-width:50px;">' . $l['w_center'] . '</th>';
    $rackobjs .= '<th style="min-width:50px;">' . $l['w_rear'] . '</th>';
    $rackobjs .= '<th title="' . $l['w_rear'] . ' - ' . $l['w_left'] . '">RL</th><th title="' . $l['w_rear'] . ' - ' . $l['w_right'] . '">RR</th></tr>';
    $nextrow_front = $rack_data['rck_height'] + 1;
    $nextrow_center = $nextrow_front;
    $nextrow_rear = $nextrow_front;
    $nextrow_frontleft = $nextrow_front;
    $nextrow_frontright = $nextrow_front;
    $nextrow_rearleft = $nextrow_front;
    $nextrow_rearright = $nextrow_front;
    // initialize array to store the number of free slots
    $freeslots = array('3L' => 0, '2L' => 0, '1L' => 0);
    for ($pos = $rack_data['rck_height'] + 1; $pos >= 0; --$pos) {
        if ($pos > $rack_data['rck_height']) {
            // top
            $slidenum = $l['w_top'];
            $oidx = 'top_' . $pos;
        } elseif ($pos == 0) {
            // bottom
            $slidenum = $l['w_bottom'];
            $oidx = 'bottom_' . $pos;
        } else {
            $slidenum = $pos;
            $oidx = $pos;
        }
        $rackobjs .= '<tr>' . K_NEWLINE;
        $rackobjs .= '<td>' . $slidenum . '</td>';
        // object capacity
        $objcap = '';
        // LEFT-FRONT RACK SIDE
        if (isset($rackstack['left_' . $pos . '_front'])) {
            $oidx = 'left_' . $pos . '_front';
            if (isset($rackstack[$oidx]['capacity'])) {
                $objcap = F_getObjectCapacityString($rackstack[$oidx]['capacity']);
            }
            $lrowspan = 1 + $pos - $rackstack[$oidx]['loc_row_bottom'];
            $rackobjs .= '<td style="max-width:20px;" rowspan="' . $lrowspan . '" class="rackobject" id="robj_' . $rackstack[$oidx]['obj_id'] . '"><a class="vtext" href="tce_view_object.php?dcn_id=' . $dcn_id . '&amp;sts_id=' . $sts_id . '&amp;rck_id=' . $rck_id . '&amp;obj_id=' . $rackstack[$oidx]['obj_id'] . '#object" title="' . $l['w_show_details'] . '">' . $rackstack[$oidx]['obj_name'] . ' - ' . $rackstack[$oidx]['obj_label'] . ' - ' . $rackstack[$oidx]['obj_tag'] . $objcap . '</a></td>';
            $nextrow_frontleft = $rackstack[$oidx]['loc_row_bottom'] - 1;
        } elseif ($pos <= $nextrow_frontleft) {
            if ($rck_permission > 1) {
                $rackobjs .= '<td><a href="tce_edit_objects.php?loc_rack_id=' . $rck_id . '&amp;loc_side=left&amp;loc_row_top=' . $pos . '&amp;loc_row_bottom=' . $pos . '" title="' . $l['t_object_editor'] . '">' . $l['w_new'] . '</a></td>' . K_NEWLINE;
            } else {
                $rackobjs .= '<td>&nbsp;</td>' . K_NEWLINE;
            }
        }
        // RIGHT-FRONT RACK SIDE
        if (isset($rackstack['right_' . $pos . '_front'])) {
            $oidx = 'right_' . $pos . '_front';
            if (isset($rackstack[$oidx]['capacity'])) {
                $objcap = F_getObjectCapacityString($rackstack[$oidx]['capacity']);
            }
            $lrowspan = 1 + $pos - $rackstack[$oidx]['loc_row_bottom'];
            $rackobjs .= '<td style="max-width:20px;" rowspan="' . $lrowspan . '" class="rackobject" id="robj_' . $rackstack[$oidx]['obj_id'] . '"><a class="vtext" href="tce_view_object.php?dcn_id=' . $dcn_id . '&amp;sts_id=' . $sts_id . '&amp;rck_id=' . $rck_id . '&amp;obj_id=' . $rackstack[$oidx]['obj_id'] . '#object" title="' . $l['w_show_details'] . '">' . $rackstack[$oidx]['obj_name'] . ' - ' . $rackstack[$oidx]['obj_label'] . ' - ' . $rackstack[$oidx]['obj_tag'] . $objcap . '</a></td>';
            $nextrow_frontright = $rackstack[$oidx]['loc_row_bottom'] - 1;
        } elseif ($pos <= $nextrow_frontright) {
            if ($rck_permission > 1) {
                $rackobjs .= '<td><a href="tce_edit_objects.php?loc_rack_id=' . $rck_id . '&amp;loc_side=right&amp;loc_row_top=' . $pos . '&amp;loc_row_bottom=' . $pos . '" title="' . $l['t_object_editor'] . '">' . $l['w_new'] . '</a></td>' . K_NEWLINE;
            } else {
                $rackobjs .= '<td>&nbsp;</td>' . K_NEWLINE;
            }
        }
        // possible positions for single object on a rack row are:
        // 000 invalid
        // 001 1
        // 010 2
        // 011 3
        // 100 4
        // 101 invalid
        // 110 6
        // 111 7
        $rowpos = array(7, 6, 4, 3, 2, 1);
        $tmpfront = false;
        $tmpcenter = false;
        $tmprear = false;
        // for each possible position combinations
        foreach ($rowpos as $rp) {
            $oidxr = $oidx . '_' . $rp;
            if (isset($rackstack[$oidxr])) {
                if (isset($rackstack[$oidxr]['capacity'])) {
                    $objcap = F_getObjectCapacityString($rackstack[$oidxr]['capacity']);
                }
                // print object
                $rowspan = 1 + $pos - $rackstack[$oidxr]['loc_row_bottom'];
                // calculate object width (1, 2 or 3)
                $obj_cols = intval($rackstack[$oidxr]['loc_front']) + intval($rackstack[$oidxr]['loc_center']) + intval($rackstack[$oidxr]['loc_rear']);
                // print object
                $obj_cell = '<td rowspan="' . $rowspan . '" colspan="' . $obj_cols . '" class="rackobject" id="robj_' . $rackstack[$oidxr]['obj_id'] . '"><a href="tce_view_object.php?dcn_id=' . $dcn_id . '&amp;sts_id=' . $sts_id . '&amp;rck_id=' . $rck_id . '&amp;obj_id=' . $rackstack[$oidxr]['obj_id'] . '#object" title="' . $l['w_show_details'] . '">' . $rackstack[$oidxr]['obj_name'] . ' - ' . $rackstack[$oidxr]['obj_label'] . ' - ' . $rackstack[$oidxr]['obj_tag'] . $objcap . '</a></td>';
                $nextrow = $rackstack[$oidxr]['loc_row_bottom'] - 1;
                if ($rackstack[$oidxr]['loc_front']) {
                    $tmpfront = true;
                    $nextrow_front = $nextrow;
                }
                if ($rackstack[$oidxr]['loc_center']) {
                    $tmpcenter = true;
                    $nextrow_center = $nextrow;
                }
                if ($rackstack[$oidxr]['loc_rear']) {
                    $tmprear = true;
                    $nextrow_rear = $nextrow;
                }
                $empty_cols = 0;
                if ($rp < 4) {
                    if (!$tmpfront) {
                        if ($pos <= $nextrow_front) {
                            ++$empty_cols;
                        }
                    }
                    if ($rp < 2) {
                        if (!$tmpcenter) {
                            if ($pos <= $nextrow_center) {
                                ++$empty_cols;
                            }
                        }
                    }
                }
                // check for empty slots before this
                if ($empty_cols > 0) {
                    if ($rp != 1 or $empty_cols != 1) {
                        if ($rck_permission > 1) {
                            $rackobjs .= '<td colspan="' . $empty_cols . '"><a href="tce_edit_objects.php?loc_rack_id=' . $rck_id . '&amp;loc_row_top=' . $pos . '&amp;loc_row_bottom=' . $pos . '" title="' . $l['t_object_editor'] . '">' . $l['w_new'] . '</a></td>' . K_NEWLINE;
                        } else {
                            $rackobjs .= '<td colspan="' . $empty_cols . '">&nbsp;</td>' . K_NEWLINE;
                        }
                        // count free slots
                        if ($pos > 0 and $pos <= $rack_data['rck_height']) {
                            $freeslots[$empty_cols . 'L'] += 1;
                        }
                    } else {
                        // you cannot add an object in the middle
                        $rackobjs .= '<td colspan="' . $empty_cols . '" style="background-color:#aaaaaa;">&nbsp;</td>' . K_NEWLINE;
                    }
                }
                // print object
                $rackobjs .= $obj_cell;
            }
        }
        // end for each position
        // print last empty rows
        $empty_cols = 0;
        if (!$tmprear) {
            if ($pos <= $nextrow_rear) {
                ++$empty_cols;
            }
            if (!$tmpcenter) {
                if ($pos <= $nextrow_center) {
                    ++$empty_cols;
                }
                if (!$tmpfront) {
                    if ($pos <= $nextrow_front) {
                        ++$empty_cols;
                    }
                }
            }
        }
        if ($empty_cols > 0) {
            if ($rck_permission > 1) {
                $rackobjs .= '<td colspan="' . $empty_cols . '"><a href="tce_edit_objects.php?loc_rack_id=' . $rck_id . '&amp;loc_row_top=' . $pos . '&amp;loc_row_bottom=' . $pos . '" title="' . $l['t_object_editor'] . '">' . $l['w_new'] . '</a></td>' . K_NEWLINE;
            } else {
                $rackobjs .= '<td colspan="' . $empty_cols . '">&nbsp;</td>' . K_NEWLINE;
            }
            // count free slots
            if ($pos > 0 and $pos <= $rack_data['rck_height']) {
                $freeslots[$empty_cols . 'L'] += 1;
            }
        }
        // LEFT-REAR RACK SIDE
        if (isset($rackstack['left_' . $pos . '_rear'])) {
            $oidx = 'left_' . $pos . '_rear';
            if (isset($rackstack[$oidx]['capacity'])) {
                $objcap = F_getObjectCapacityString($rackstack[$oidx]['capacity']);
            }
            $lrowspan = 1 + $pos - $rackstack[$oidx]['loc_row_bottom'];
            $rackobjs .= '<td style="max-width:20px;" rowspan="' . $lrowspan . '" class="rackobject" id="robj_' . $rackstack[$oidx]['obj_id'] . '"><a class="vtext" href="tce_view_object.php?dcn_id=' . $dcn_id . '&amp;sts_id=' . $sts_id . '&amp;rck_id=' . $rck_id . '&amp;obj_id=' . $rackstack[$oidx]['obj_id'] . '#object" title="' . $l['w_show_details'] . '">' . $rackstack[$oidx]['obj_name'] . ' - ' . $rackstack[$oidx]['obj_label'] . ' - ' . $rackstack[$oidx]['obj_tag'] . $objcap . '</a></td>';
            $nextrow_rearleft = $rackstack[$oidx]['loc_row_bottom'] - 1;
        } elseif ($pos <= $nextrow_rearleft) {
            if ($rck_permission > 1) {
                $rackobjs .= '<td><a href="tce_edit_objects.php?loc_rack_id=' . $rck_id . '&amp;loc_side=left&amp;loc_row_top=' . $pos . '&amp;loc_row_bottom=' . $pos . '" title="' . $l['t_object_editor'] . '">' . $l['w_new'] . '</a></td>' . K_NEWLINE;
            } else {
                $rackobjs .= '<td>&nbsp;</td>' . K_NEWLINE;
            }
        }
        // RIGHT-REAR RACK SIDE
        if (isset($rackstack['right_' . $pos . '_rear'])) {
            $oidx = 'right_' . $pos . '_rear';
            if (isset($rackstack[$oidx]['capacity'])) {
                $objcap = F_getObjectCapacityString($rackstack[$oidx]['capacity']);
            }
            $lrowspan = 1 + $pos - $rackstack[$oidx]['loc_row_bottom'];
            $rackobjs .= '<td style="max-width:20px;" rowspan="' . $lrowspan . '" class="rackobject" id="robj_' . $rackstack[$oidx]['obj_id'] . '"><a class="vtext" href="tce_view_object.php?dcn_id=' . $dcn_id . '&amp;sts_id=' . $sts_id . '&amp;rck_id=' . $rck_id . '&amp;obj_id=' . $rackstack[$oidx]['obj_id'] . '#object" title="' . $l['w_show_details'] . '">' . $rackstack[$oidx]['obj_name'] . ' - ' . $rackstack[$oidx]['obj_label'] . ' - ' . $rackstack[$oidx]['obj_tag'] . $objcap . '</a></td>';
            $nextrow_rearright = $rackstack[$oidx]['loc_row_bottom'] - 1;
        } elseif ($pos <= $nextrow_rearright) {
            if ($rck_permission > 1) {
                $rackobjs .= '<td><a href="tce_edit_objects.php?loc_rack_id=' . $rck_id . '&amp;loc_side=right&amp;loc_row_top=' . $pos . '&amp;loc_row_bottom=' . $pos . '" title="' . $l['t_object_editor'] . '">' . $l['w_new'] . '</a></td>' . K_NEWLINE;
            } else {
                $rackobjs .= '<td>&nbsp;</td>' . K_NEWLINE;
            }
        }
        $rackobjs .= '</tr>' . K_NEWLINE;
    }
    // store rack stack
    $rack_data['rackstack'] = $rackstack;
    // store free slots info
    $rack_data['free_slots'] = $freeslots;
    $rackobjs .= '<tr><td colspan="8" style="background-color:#ffffcc;color:#000000;text-align:right;">' . $l['t_free_1u_slots'] . ': 3L=' . $rack_data['free_slots']['3L'] . ', 2L=' . $rack_data['free_slots']['2L'] . ', 1L=' . $rack_data['free_slots']['1L'] . '</td></tr>' . K_NEWLINE;
    $rackobjs .= '</table>' . K_NEWLINE;
    return $rackobjs;
}
Example #19
0
echo '<select name="subject_id" id="subject_id" size="0" onchange="document.getElementById(\'form_subjecteditor\').submit()" title="' . $l['h_subject'] . '">' . K_NEWLINE;
echo '<option value="0" style="background-color:#009900;color:white;"';
if ($subject_id == 0) {
    echo ' selected="selected"';
}
echo '>+</option>' . K_NEWLINE;
$sql = F_select_subjects_sql('subject_module_id=' . $subject_module_id);
if ($r = F_db_query($sql, $db)) {
    $countitem = 1;
    while ($m = F_db_fetch_array($r)) {
        echo '<option value="' . $m['subject_id'] . '"';
        if ($m['subject_id'] == $subject_id) {
            echo ' selected="selected"';
        }
        echo '>' . $countitem . '. ';
        if (F_getBoolean($m['subject_enabled'])) {
            echo '+';
        } else {
            echo '-';
        }
        echo ' ' . htmlspecialchars($m['subject_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '&nbsp;</option>' . K_NEWLINE;
        $countitem++;
    }
    if ($countitem == 1) {
        echo '<option value="0">&nbsp;</option>' . K_NEWLINE;
    }
} else {
    echo '</select></span></div>' . K_NEWLINE;
    F_display_db_error();
}
echo '</select>' . K_NEWLINE;
Example #20
0
     $test_score_unanswered = $m['test_score_unanswered'];
     $test_max_score = $m['test_max_score'];
     $test_score_threshold = $m['test_score_threshold'];
     $test_random_questions_select = F_getBoolean($m['test_random_questions_select']);
     $test_random_questions_order = F_getBoolean($m['test_random_questions_order']);
     $test_questions_order_mode = intval($m['test_questions_order_mode']);
     $test_random_answers_select = F_getBoolean($m['test_random_answers_select']);
     $test_random_answers_order = F_getBoolean($m['test_random_answers_order']);
     $test_answers_order_mode = intval($m['test_answers_order_mode']);
     $test_comment_enabled = F_getBoolean($m['test_comment_enabled']);
     $test_menu_enabled = F_getBoolean($m['test_menu_enabled']);
     $test_noanswer_enabled = F_getBoolean($m['test_noanswer_enabled']);
     $test_mcma_radio = F_getBoolean($m['test_mcma_radio']);
     $test_repeatable = F_getBoolean($m['test_repeatable']);
     $test_mcma_partial_score = F_getBoolean($m['test_mcma_partial_score']);
     $test_logout_on_timeout = F_getBoolean($m['test_logout_on_timeout']);
     $test_password = $m['test_password'];
 } else {
     $test_name = '';
     $test_description = '';
     $test_begin_time = date(K_TIMESTAMP_FORMAT);
     $test_end_time = date(K_TIMESTAMP_FORMAT, time() + K_SECONDS_IN_DAY);
     $test_duration_time = 60;
     $test_ip_range = '*.*.*.*';
     $test_results_to_users = false;
     $test_report_to_users = false;
     $test_score_right = 1;
     $test_score_wrong = 0;
     $test_score_unanswered = 0;
     $test_max_score = 0;
     $test_score_threshold = 0;
                            $pdf->SetFont('', '');
                            $pdf->writeHTMLCell(0, $data_cell_height, PDF_MARGIN_LEFT + $data_cell_width_third, $pdf->GetY(), F_decode_tcecode($mq['question_explanation']), 'LRB', 1, '', '');
                        }
                        if ($show_answers) {
                            // display alternative answers
                            $sqla = 'SELECT *
								FROM ' . K_TABLE_ANSWERS . '
								WHERE answer_question_id=\'' . $mq['question_id'] . '\'
								ORDER BY answer_position,answer_isright DESC';
                            if ($ra = F_db_query($sqla, $db)) {
                                $idx = 0;
                                // count items
                                while ($ma = F_db_fetch_array($ra)) {
                                    $idx++;
                                    $answer_disabled = intval(!F_getBoolean($ma['answer_enabled']));
                                    $answer_isright = intval(F_getBoolean($ma['answer_isright']));
                                    $pdf->Cell($data_cell_width_third, $data_cell_height, '', 0, 0, 'C', 0);
                                    $pdf->Cell($data_cell_width_third, $data_cell_height, $idx, 1, 0, 'C', $answer_disabled);
                                    if ($mq['question_type'] != 4) {
                                        $pdf->Cell($data_cell_width_third / 2, $data_cell_height, $qright[$answer_isright], 1, 0, 'C', $answer_disabled);
                                    } else {
                                        $pdf->Cell($data_cell_width_third / 2, $data_cell_height, '', 1, 0, 'C', $answer_disabled);
                                    }
                                    if ($ma['answer_position'] > 0) {
                                        $pdf->Cell($data_cell_width_third, $data_cell_height, $ma['answer_position'], 1, 0, 'C', $answer_disabled);
                                    } else {
                                        $pdf->Cell($data_cell_width_third, $data_cell_height, '', 1, 0, 'C', $answer_disabled);
                                    }
                                    if ($ma['answer_keyboard_key'] > 0) {
                                        $pdf->Cell($data_cell_width_third / 2, $data_cell_height, F_text_to_xml(chr($ma['answer_keyboard_key'])), 1, 0, 'C', $answer_disabled);
                                    } else {
Example #22
0
echo '<select name="obj_obt_id" id="obj_obt_id" size="0" onchange="document.getElementById(\'form_editor\').submit()">' . K_NEWLINE;
$sql = 'SELECT * FROM ' . K_TABLE_OBJECT_TYPES . ' WHERE 1 ORDER BY obt_name ASC';
if ($r = F_db_query($sql, $db)) {
    while ($m = F_db_fetch_array($r)) {
        echo '<option value="' . $m['obt_id'] . '"';
        if (strlen($m['obt_color']) == 6) {
            echo ' style="background-color:#' . $m['obt_color'] . ';color:#' . getContrastColor($m['obt_color']) . '"';
        }
        if ($m['obt_id'] == $obj_obt_id) {
            echo ' selected="selected"';
            if (F_getBoolean($m['obt_virtual'])) {
                $virtual = true;
            }
        }
        echo '>';
        if (F_getBoolean($m['obt_virtual'])) {
            echo '&otimes; ';
        }
        echo htmlspecialchars($m['obt_name'], ENT_NOQUOTES, $l['a_meta_charset']) . '</option>' . K_NEWLINE;
    }
} else {
    echo '</select></span></div>' . K_NEWLINE;
    F_display_db_error();
}
echo '</select>' . K_NEWLINE;
echo '</span>' . K_NEWLINE;
echo '</div>' . K_NEWLINE;
// child of
echo F_parent_object_selector($omp_parent_obj_ids, 'omp_parent_obj_ids', $virtual);
// manufacturer
echo '<div class="row">' . K_NEWLINE;