function display_category($cat_id, $cat_label) { $is_selected = $cat_id == $_GET['category_id']; // DISPLAY CATEGORY NUMBER AND LABEL echo '<tr><td valign="top" class="help_category">' . $cat_id . '.</td><td><a href="' . ($is_selected ? '' : '?category_id=' . $cat_id . '#go_category') . '" class="help_category">' . htmlspecialchars($cat_label) . '</a>'; if (is_admin()) { echo ' [<a href="add_category_form.php?category_id=' . $cat_id . '" class="menu">Edytuj</a>]'; } if ($is_selected) { // DISPLAY CATEGORY QUESTIONS (still same <td> as category label!) $questions = help_get_category_questions($cat_id); echo '<table id="go_category" cellpadding="2" cellspacing="0">' . "\n"; //open questions table if ($questions === false) { echo '<tr><td>B³±d bazy danych, spróbuj pó¼niej.</td></tr>'; } else { if (empty($questions)) { echo '<tr><td>Brak pytañ.</td></tr>'; } else { // DISPLAY ALL QUESTIONS OF A CATEGORY (seperate table) foreach ($questions as $qsn_id => $qsn_label) { display_question($cat_id, $qsn_id, $qsn_label); } } } echo "</table>\n"; } echo "</td></tr>\n"; }
function display_question_section() { $json = $GLOBALS['json']; $currentQuestion = $GLOBALS['current-question']; $questionCount = $GLOBALS['question-count']; $questionIndex = $currentQuestion - 1; $previousQuestion = ($questionIndex - 1 + $questionCount) % $questionCount + 1; $nextQuestion = ($questionIndex + 1) % $questionCount + 1; echo <<<_HD \t \t<section class="question-area"> \t\t<span id="current-question">{$currentQuestion}</span><span> / </span><span id="question-count">{$questionCount}</span> \t\t\t \t\t<form id="question-form" method="post" action="#"> \t\t\t<!-- the question content --> _HD; display_question($json, $currentQuestion); display_options($json, $currentQuestion); echo <<<_HD \t \t\t\t<p id="navigation-buttons"> \t\t\t\t<button id="previous" class="navigation" name="display-question" value="{$previousQuestion}"><<</button> \t\t\t\t<button id="next" class="navigation" name="display-question" value="{$nextQuestion}">>></button> \t\t\t\t<input id="current-question" type="hidden" name="current-question" value={$currentQuestion}> \t\t\t\t<input id="question-count" type="hidden" name="question-count" value={$questionCount}> \t \t\t</p> \t\t</form> \t</section> _HD; }
function display_q($configObject, $target_id, $db) { $question_data = $db->prepare("SELECT q_type, q_id, score_method, display_method, settings, marks_correct, marks_incorrect, marks_partial, theme, scenario, leadin, correct, REPLACE(option_text,'\t','') AS option_text, q_media, q_media_width, q_media_height, o_media, o_media_width, o_media_height, notes FROM questions LEFT JOIN options ON questions.q_id = options.o_id WHERE q_id = ? ORDER BY id_num"); $question_data->bind_param('i', $target_id); $question_data->execute(); $question_data->store_result(); $question_data->bind_result($q_type, $q_id, $score_method, $display_method, $settings, $marks_correct, $marks_incorrect, $marks_partial, $theme, $scenario, $leadin, $correct, $option_text, $q_media, $q_media_width, $q_media_height, $o_media, $o_media_width, $o_media_height, $notes); $num_rows = $question_data->num_rows; echo "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\" width=\"100%\" style=\"table-layout:fixed\">\n"; echo "<col width=\"40\"><col>\n"; $old_q_id = 0; while ($question_data->fetch()) { if ($old_q_id != $q_id) { $question['theme'] = trim($theme); $question['scenario'] = trim($scenario); $question['leadin'] = trim($leadin); $question['notes'] = trim($notes); $question['q_type'] = $q_type; $question['q_id'] = $q_id; $question['score_method'] = $score_method; $question['display_method'] = $display_method; $question['settings'] = $settings; $question['q_media'] = $q_media; $question['q_media_width'] = $q_media_width; $question['q_media_height'] = $q_media_height; $question['dismiss'] = ''; $question['assigned_number'] = $_GET['qNo']; } $question['options'][] = array('correct' => $correct, 'option_text' => $option_text, 'o_media' => $o_media, 'o_media_width' => $o_media_width, 'o_media_height' => $o_media_height, 'marks_correct' => $marks_correct, 'marks_incorrect' => $marks_incorrect, 'marks_partial' => $marks_partial); } $question_data->close(); $question_no = 0; $paper_type = 0; $unanswered = false; $question_offset = $_GET['qNo']; $screen_pre_submitted = 0; $user_answers = array(); if ($question['q_type'] == 'enhancedcalc') { require_once '../plugins/questions/enhancedcalc/enhancedcalc.class.php'; if (!isset($configObj)) { $configObj = Config::get_instance(); } $question['object'] = new EnhancedCalc($configObj); $question['object']->load($question); } display_question($configObject, $question, $paper_type, 0, 1, '', $question_no, $user_answers, $unanswered); $question_nos[] = $old_q_id; echo "</table>\n"; }
$questions_array[$q_no]['display_method'] = $display_method; $questions_array[$q_no]['q_media'] = $q_media; $questions_array[$q_no]['q_media_width'] = $q_media_width; $questions_array[$q_no]['q_media_height'] = $q_media_height; $questions_array[$q_no]['q_option_order'] = $q_option_order; } $questions_array[$q_no]['options'][$id_num] = $option_text; $old_q_id = $q_id; } $stmt->close(); // Display the questions foreach ($questions_array as &$question) { if ($question['theme'] == '') { echo "<tr><td colspan=\"2\"> </td></tr>\n"; } display_question($question, $question_no, $reviewer_data, $string, $mysqli); } ?> </table> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] . '?paperID=' . $paperID; ?> "> <div style="text-align:center"><input type="submit" name="submit" value="<?php echo $string['savetobank']; ?> " class="ok" style="width:250px" /></div> </form> </div> </body>
} if ($question['q_type'] == 'random') { randomQOverwrite($questions_array, $question, $paper_type, $user_answers, $current_screen, $tmp_q_no); } elseif ($question['q_type'] == 'keyword_based') { keywordQOverwrite($questions_array, $question, $paper_type, $user_answers, $current_screen, $tmp_q_no); } else { $questions_array[] = $question; } } unset($tmp_questions_array); //display the questions echo "<table cellpadding=\"0\" cellspacing=\"4\" border=\"0\" width=\"100%\" style=\"table-layout:fixed\" class=\"qtable\">\n"; echo "<col width=\"40\"><col>\n"; foreach ($questions_array as &$question) { if ($q_displayed == 0 and $current_screen == 1 and $paper_prologue != '') { echo '<tr><td colspan="2" style="padding:20px; text-align:justify">' . $paper_prologue . '</td></tr>'; } if ($q_displayed == 0 and $question['theme'] == '') { echo "<tr><td colspan=\"2\"> </td></tr>\n"; } display_question($question, $paper_type, $current_screen, $previous_q_type, $question_no, $question_offset, $user_answers); $previous_q_type = $question['q_type']; $q_displayed++; } echo "</table>\n"; $mysqli->close(); ?> </body> </html>
<?php if ($question['q_type'] == 'hotspot' or $question['q_type'] == 'labelling' or $question['q_type'] == 'area') { if ($configObject->get('cfg_interactive_qs') == 'html5') { echo "<script type=\"text/javascript\">\nvar lang_string = " . json_encode($jstring) . "\n</script>\n"; echo "<script type=\"text/javascript\" src=\"../js/html5.images.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../js/qsharedf.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../js/qlabelling.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../js/qhotspot.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../js/qarea.js\"></script>\n"; } else { echo "<script type=\"text/javascript\" src=\"../js/ie_fix.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../js/flash_include.js\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../js/jquery.flash_q.js\"></script>\n"; } } echo $configObject->get('cfg_js_root'); ?> </head> <body> <div id="maincontent"> <table cellpadding="4" cellspacing="0" border="0" width="100%" style="table-layout:fixed"> <col width="40"><col> <?php display_question($configObject, $question, $paper_type, 0, 1, '', $question_no, $user_answers, $unanswered); $question_nos[] = $old_q_id; echo "<table>\n"; ?> </div> </body> </html>
} echo "<table cellpadding=\"0\" cellspacing=\"4\" border=\"0\" width=\"100%\" style=\"table-layout:fixed\">\n"; echo "<col width=\"40\"><col>\n"; // Display the questions foreach ($questions_array as &$question) { if ($question['screen'] == $current_screen) { if ($screen_pre_submitted == 1 and $q_displayed == 0) { echo "<tr style=\"display:none\" id=\"unansweredkey\"><td colspan=\"2\"><span class=\"unans\"> </span> " . $string['unansweredquestion'] . "</td></tr>\n"; } if ($q_displayed == 0 and $current_screen == 1 and $propertyObj->get_paper_prologue() != '') { echo '<tr><td colspan="2" style="padding:20px; text-align:justify">' . $propertyObj->get_paper_prologue() . '</td></tr>'; } if ($q_displayed == 0 and $question['theme'] == '') { echo "<tr><td colspan=\"2\"> </td></tr>\n"; } display_question($configObject, $question, $propertyObj->get_paper_type(), $calculator, $current_screen, $previous_q_type, $question_no, $user_answers, $unanswered); $previous_q_type = $question['q_type']; $q_displayed++; } } echo "</table></td></tr>\n<tr><td>\n<br />\n"; $current_screen++; echo "<input type=\"hidden\" name=\"current_screen\" value=\"{$current_screen}\" />\n"; echo "<input type=\"hidden\" name=\"page_start\" value=\"" . date("YmdHis", time()) . "\" />\n"; echo "<input type=\"hidden\" name=\"old_screen\" value=\"" . ($current_screen - 1) . "\" />\n"; echo "<input type=\"hidden\" name=\"previous_duration\" value=\"{$previous_duration}\" />\n"; echo "<input type=\"hidden\" id=\"button_pressed\" name=\"button_pressed\" value=\"next\" />\n"; echo "<input type=\"hidden\" id=\"randomPageID\" name=\"randomPageID\" value=\"\" />\n"; if ($is_question_preview_mode) { echo "<input type=\"hidden\" id=\"mode\" name=\"mode\" value=\"preview\" />\n"; } else {
if (!isset($configObj)) { $configObj = Config::get_instance(); } $question['object'] = new EnhancedCalc($configObj); $question['object']->load($question); } if ($screen_pre_submitted == 1 and $q_displayed == 0) { echo "<tr><td colspan=\"2\"><span style=\"background-color:#FFC0C0\"> </span> = unanswered question</td></tr>\n"; } if ($q_displayed == 0 and $current_screen == 1 and $paper_prologue != '') { echo '<tr><td colspan="2" style="padding:20px; text-align:justify">' . $paper_prologue . '</td></tr>'; } if ($q_displayed == 0 and $question['theme'] == '') { echo "<tr><td colspan=\"2\"> </td></tr>\n"; } display_question($configObject, $question, $propertyObj->get_paper_type(), $propertyObj->get_calculator(), $current_screen, $previous_q_type, $question_no, $question_offset, $start_of_day_ts); $previous_q_type = $question['q_type']; $q_displayed++; } echo "</table></td></tr>\n<tr><td valign=\"bottom\">\n<br />\n"; $current_screen++; echo "<input type=\"hidden\" name=\"current_screen\" value=\"{$current_screen}\" />\n"; echo "<input type=\"hidden\" name=\"page_start\" value=\"" . date("YmdHis", time()) . "\" />\n"; echo "<input type=\"hidden\" name=\"old_screen\" value=\"" . ($current_screen - 1) . "\" />\n"; echo "<input type=\"hidden\" name=\"previous_duration\" value=\"{$previous_duration}\" />\n"; echo "<input type=\"hidden\" id=\"button_pressed\" name=\"button_pressed\" value=\"\" />\n"; echo $bottom_html; echo '<input type="text" style="background-color:transparent; text-align:center; color:white; border:0" id="theTime" size="8" /></td><td align="right">'; if ($propertyObj->get_bidirectional() == 1 and $no_screens > 1) { if ($current_screen > 2) { echo '<input id="previous" type="submit" name="prev" value="< ' . $string['screen'] . ' ' . ($current_screen - 2) . '" />';
$questions_array[$q_no]['q_media'] = $q_media; $questions_array[$q_no]['q_media_width'] = $q_media_width; $questions_array[$q_no]['q_media_height'] = $q_media_height; $questions_array[$q_no]['q_option_order'] = $q_option_order; } $questions_array[$q_no]['options'][] = $option_text; $old_q_id = $q_id; } $stmt->close(); // Display the questions if (count($questions_array) > 0) { foreach ($questions_array as &$question) { if ($question['theme'] == '') { echo "<tr><td colspan=\"2\"> </td></tr>\n"; } display_question($question, $question_no, $saved_data, $string); } } else { echo "<tr><td> </td><td>{$string['nosctquestions']}</td></tr>\n"; } ?> </table> <?php if (count($questions_array) > 0) { ?> <div style="text-align:center"><input type="submit" name="submit" value="<?php echo $string['save']; ?> " class="ok" /></div> <?php
display_question($questionID, $details, $member_userID, $row_no, $columns, $marking, $saved_results); } echo "<tr><td colspan=\"" . (count($questions) + 2) . "\"> </td></tr>\n"; } } $result->close(); } else { $row_no = 0; $member_userID = 0; echo "<tr><td></td>"; for ($i = 0; $i < $columns; $i++) { echo "<td class=\"col\">" . $parts[$i] . "</td>"; } echo "</tr>\n"; foreach ($questions as $questionID => $details) { display_question($questionID, $details, $member_userID, $row_no, $columns, $marking, $saved_results); } echo "<tr><td colspan=\"" . (count($questions) + 2) . "\"> </td></tr>\n"; } echo "</table>\n"; echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" style=\"width:100%\"><tr><td style=\"background-color:#5590CF; text-align:center\">"; if ($userObject->has_role('Student')) { echo "<input type=\"submit\" name=\"submit\" value=\"" . $string['save'] . "\" class=\"ok\" />"; } else { echo "<input type=\"button\" name=\"close\" value=\"" . $string['close'] . "\" style=\"width:140px\" onclick=\"window.close();\" />"; } echo "</td></tr>\n"; echo "</table>\n</form>\n"; ?> </html> </body>