$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 { $pdf->Cell($data_cell_width_third / 2, $data_cell_height, '', 1, 0, 'C', $answer_disabled); } $pdf->Ln(); $pdf->writeHTMLCell(0, $data_cell_height, PDF_MARGIN_LEFT + 2 * $data_cell_width_third, $pdf->GetY(), F_decode_tcecode($ma['answer_description']), 1, 1, '', '', ''); if (K_ENABLE_ANSWER_EXPLANATION and !empty($ma['answer_explanation'])) { $pdf->Cell(2 * $data_cell_width_third, $data_cell_height, '', 0, 0, 'C', 0); $pdf->SetFont('', 'BIU'); $pdf->Cell(0, $data_cell_height, $l['w_explanation'], 'LTR', 1, '', 0, '', 0); $pdf->SetFont('', ''); $pdf->writeHTMLCell(0, $data_cell_height, PDF_MARGIN_LEFT + 2 * $data_cell_width_third, $pdf->GetY(), F_decode_tcecode($ma['answer_explanation']), 'LRB', 1, '', ''); } } } else { F_display_db_error();
} $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 if (isset($mq['testlog_comment']) and !empty($mq['testlog_comment'])) { $xml .= K_TAB . K_TAB . K_TAB . K_TAB . K_TAB . '<qcomment>' . F_text_to_xml($mq['testlog_comment']) . '</qcomment>' . K_NEWLINE; } $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '</question>' . K_NEWLINE; $itemcount++; } // end questions $xml .= K_TAB . K_TAB . K_TAB . '</details>' . K_NEWLINE; } else { F_display_db_error(); } $xml .= K_TAB . K_TAB . '</user>' . K_NEWLINE; } } else { F_display_db_error(); } // calculate statistics
/** * Get data array in XML format. * @param $data (array) Array of data (key => value). * @param $level (int) Indentation level. * @return string XML data */ function getDataXML($data, $level = 1) { $xml = ''; $tb = str_repeat("\t", $level); foreach ($data as $key => $value) { $xml .= $tb . '<' . $key . '>'; if (is_array($value)) { $xml .= "\n" . getDataXML($value, $level + 1); } else { $xml .= F_text_to_xml($value); } $xml .= '</' . $key . '>' . "\n"; } return $xml; }
/** * Export user results in XML format. * @param $user_id (int) user ID - if greater than zero, filter stats for the specified user. * @param $startdate (string) start date ID - if greater than zero, filter stats for the specified starting date * @param $enddate (string) end date ID - if greater than zero, filter stats for the specified ending date * @param $order_field (string) Ordering fields for SQL query. * @author Nicola Asuni * @return XML data */ function F_xml_export_user_results($user_id, $startdate, $enddate, $order_field) { global $l, $db; require_once '../config/tce_config.php'; // define symbols for answers list $qtype = array('S', 'M', 'T', 'O'); // question types $type = array('single', 'multiple', 'text', 'ordering'); $boolean = array('false', 'true'); $xml = ''; // XML data to be returned $xml .= '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . K_NEWLINE; $xml .= '<tcexamuserresults 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 . K_TAB . '<user_id>' . $user_id . '</user_id>' . K_NEWLINE; $sql = 'SELECT user_name, user_lastname, user_firstname FROM ' . K_TABLE_USERS . ' WHERE user_id=' . $user_id . ''; if ($r = F_db_query($sql, $db)) { if ($m = F_db_fetch_array($r)) { $xml .= K_TAB . K_TAB . '<user_name>' . $m['user_name'] . '</user_name>' . K_NEWLINE; $xml .= K_TAB . K_TAB . '<user_lastname>' . $m['user_lastname'] . '</user_lastname>' . K_NEWLINE; $xml .= K_TAB . K_TAB . '<user_firstname>' . $m['user_firstname'] . '</user_firstname>' . K_NEWLINE; } } else { F_display_db_error(); } $xml .= K_TAB . K_TAB . '<date_from>' . $startdate . '</date_from>' . K_NEWLINE; $xml .= K_TAB . K_TAB . '<date_to>' . $enddate . '</date_to>' . K_NEWLINE; $xml .= K_TAB . '</header>' . K_NEWLINE; $xml .= K_TAB . '<body>' . K_NEWLINE; $statsdata = array(); $statsdata['score'] = array(); $statsdata['right'] = array(); $statsdata['wrong'] = array(); $statsdata['unanswered'] = array(); $statsdata['undisplayed'] = array(); $statsdata['unrated'] = array(); $sql = 'SELECT testuser_id, test_id, test_name, testuser_creation_time, testuser_status, SUM(testlog_score) AS total_score, MAX(testlog_change_time) AS testuser_end_time FROM ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS . ' WHERE testuser_status>0 AND testuser_creation_time>=\'' . F_escape_sql($db, $startdate) . '\' AND testuser_creation_time<=\'' . F_escape_sql($db, $enddate) . '\' AND testuser_user_id=' . $user_id . ' AND testlog_testuser_id=testuser_id AND testuser_test_id=test_id'; if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) { $sql .= ' AND test_user_id IN (' . F_getAuthorizedUsers($_SESSION['session_user_id']) . ')'; } $sql .= ' GROUP BY testuser_id, test_id, test_name, testuser_creation_time, testuser_status ORDER BY ' . F_escape_sql($db, $order_field) . ''; if ($r = F_db_query($sql, $db)) { $passed = 0; while ($m = F_db_fetch_array($r)) { $testuser_id = $m['testuser_id']; $usrtestdata = F_getUserTestStat($m['test_id'], $user_id); $halfscore = $usrtestdata['max_score'] / 2; $xml .= K_TAB . K_TAB . '<test id=\'' . $m['test_id'] . '\'>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<start_time>' . $m['testuser_creation_time'] . '</start_time>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<end_time>' . $m['testuser_end_time'] . '</end_time>' . K_NEWLINE; $time_diff = strtotime($m['testuser_end_time']) - strtotime($m['testuser_creation_time']); //sec $time_diff = gmdate('H:i:s', $time_diff); $xml .= K_TAB . K_TAB . K_TAB . '<time>' . $time_diff . '</time>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<name>' . F_text_to_xml($m['test_name']) . '</name>' . K_NEWLINE; if ($usrtestdata['score_threshold'] > 0) { if ($usrtestdata['score'] >= $usrtestdata['score_threshold']) { $xml .= K_TAB . K_TAB . K_TAB . '<passed>true</passed>' . K_NEWLINE; $passed++; } else { $xml .= K_TAB . K_TAB . K_TAB . '<passed>false</passed>' . K_NEWLINE; } } elseif ($usrtestdata['score'] > $halfscore) { $passed++; } $xml .= K_TAB . K_TAB . K_TAB . '<score>' . round($m['total_score'], 3) . '</score>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<score_percent>' . round(100 * $usrtestdata['score'] / $usrtestdata['max_score']) . '</score_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<right>' . $usrtestdata['right'] . '</right>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<right_percent>' . round(100 * $usrtestdata['right'] / $usrtestdata['all']) . '</right_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<wrong>' . $usrtestdata['wrong'] . '</wrong>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<wrong_percent>' . round(100 * $usrtestdata['wrong'] / $usrtestdata['all']) . '</wrong_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unanswered>' . $usrtestdata['unanswered'] . '</unanswered>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unanswered_percent>' . round(100 * $usrtestdata['unanswered'] / $usrtestdata['all']) . '</unanswered_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<undisplayed>' . $usrtestdata['undisplayed'] . '</undisplayed>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<undisplayed_percent>' . round(100 * $usrtestdata['undisplayed'] / $usrtestdata['all']) . '</undisplayed_percent>' . K_NEWLINE; if ($m['testuser_status'] == 4) { $status = $l['w_locked']; } else { $status = $l['w_unlocked']; } $xml .= K_TAB . K_TAB . K_TAB . '<status>' . $status . '</status>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<comment>' . F_text_to_xml($usrtestdata['comment']) . '</comment>' . K_NEWLINE; $xml .= K_TAB . K_TAB . '</test>' . K_NEWLINE; // collects data for descriptive statistics $statsdata['score'][] = $m['total_score'] / $usrtestdata['max_score']; $statsdata['right'][] = $usrtestdata['right'] / $usrtestdata['all']; $statsdata['wrong'][] = $usrtestdata['wrong'] / $usrtestdata['all']; $statsdata['unanswered'][] = $usrtestdata['unanswered'] / $usrtestdata['all']; $statsdata['undisplayed'][] = $usrtestdata['undisplayed'] / $usrtestdata['all']; $statsdata['unrated'][] = $usrtestdata['unrated'] / $usrtestdata['all']; } } else { F_display_db_error(); } // calculate statistics $stats = F_getArrayStatistics($statsdata); $excludestat = array('sum', 'variance'); $calcpercent = array('mean', 'median', 'mode', 'minimum', 'maximum', 'range', 'standard_deviation'); $xml .= K_TAB . K_TAB . '<teststatistics>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<passed>' . $passed . '</passed>' . K_NEWLINE; $passed_perc = 0; if ($itemcount > 0) { $passed_perc = $passed / $stats['number']['score']; } $xml .= K_TAB . K_TAB . K_TAB . '<passed_percent>' . round(100 * $passed_perc) . '</passed_percent>' . K_NEWLINE; foreach ($stats as $row => $columns) { if (!in_array($row, $excludestat)) { $xml .= K_TAB . K_TAB . K_TAB . '<' . $row . '>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<score>' . round($columns['score'], 3) . '</score>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<right>' . round($columns['right'], 3) . '</right>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<wrong>' . round($columns['wrong'], 3) . '</wrong>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<unanswered>' . round($columns['unanswered'], 3) . '</unanswered>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<undisplayed>' . round($columns['undisplayed'], 3) . '</undisplayed>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<unrated>' . round($columns['unrated'], 3) . '</unrated>' . K_NEWLINE; if (in_array($row, $calcpercent)) { $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<score_percent>' . round(100 * ($columns['score'] / $usrtestdata['max_score'])) . '</score_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<right_percent>' . round(100 * ($columns['right'] / $usrtestdata['all'])) . '</right_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<wrong_percent>' . round(100 * ($columns['wrong'] / $usrtestdata['all'])) . '</wrong_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<unanswered_percent>' . round(100 * ($columns['unanswered'] / $usrtestdata['all'])) . '</unanswered_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<undisplayed_percent>' . round(100 * ($columns['undisplayed'] / $usrtestdata['all'])) . '</undisplayed_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<unrated_percent>' . round(100 * ($columns['unrated'] / $usrtestdata['all'])) . '</unrated_percent>' . K_NEWLINE; } $xml .= K_TAB . K_TAB . K_TAB . '</' . $row . '>' . K_NEWLINE; } } $xml .= K_TAB . K_TAB . '</teststatistics>' . K_NEWLINE; $xml .= K_TAB . '</body>' . K_NEWLINE; $xml .= '</tcexamuserresults>' . K_NEWLINE; return $xml; }
/** * Export all users to XML grouped by users' groups. * @author Nicola Asuni * @since 2006-03-17 * @return XML data */ function F_xml_export_users() { global $l, $db; require_once '../config/tce_config.php'; $boolean = array('false', 'true'); $xml = ''; // XML data to be returned $xml .= '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . K_NEWLINE; $xml .= '<tcexamusers 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; // select users $sqla = 'SELECT * FROM ' . K_TABLE_USERS . ' WHERE (user_id>1)'; if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) { // filter for level $sqla .= ' AND ((user_level<' . $_SESSION['session_user_level'] . ') OR (user_id=' . $_SESSION['session_user_id'] . '))'; // filter for groups $sqla .= ' AND user_id IN (SELECT tb.usrgrp_user_id FROM ' . K_TABLE_USERGROUP . ' AS ta, ' . K_TABLE_USERGROUP . ' AS tb WHERE ta.usrgrp_group_id=tb.usrgrp_group_id AND ta.usrgrp_user_id=' . intval($_SESSION['session_user_id']) . ' AND tb.usrgrp_user_id=user_id)'; } $sqla .= ' ORDER BY user_lastname,user_firstname,user_name'; if ($ra = F_db_query($sqla, $db)) { while ($ma = F_db_fetch_array($ra)) { $xml .= K_TAB . K_TAB . K_TAB . '<user id="' . $ma['user_id'] . '">' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<name>'; $xml .= F_text_to_xml($ma['user_name']); $xml .= '</name>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<password>'; // password cannot be exported because is encrypted //$xml .= $ma['user_password']; $xml .= '</password>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<email>'; $xml .= $ma['user_email']; $xml .= '</email>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<regdate>'; $xml .= $ma['user_regdate']; $xml .= '</regdate>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<ip>'; $xml .= $ma['user_ip']; $xml .= '</ip>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<firstname>'; $xml .= F_text_to_xml($ma['user_firstname']); $xml .= '</firstname>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<lastname>'; $xml .= F_text_to_xml($ma['user_lastname']); $xml .= '</lastname>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<birthdate>'; $xml .= substr($ma['user_birthdate'], 0, 10); $xml .= '</birthdate>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<birthplace>'; $xml .= F_text_to_xml($ma['user_birthplace']); $xml .= '</birthplace>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<regnumber>'; $xml .= F_text_to_xml($ma['user_regnumber']); $xml .= '</regnumber>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<ssn>'; $xml .= F_text_to_xml($ma['user_ssn']); $xml .= '</ssn>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<level>'; $xml .= $ma['user_level']; $xml .= '</level>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<verifycode>'; $xml .= $ma['user_verifycode']; $xml .= '</verifycode>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<otpkey>'; $xml .= $ma['user_otpkey']; $xml .= '</otpkey>' . K_NEWLINE; // add user's groups $sqlg = 'SELECT * FROM ' . K_TABLE_GROUPS . ', ' . K_TABLE_USERGROUP . ' WHERE usrgrp_group_id=group_id AND usrgrp_user_id=' . $ma['user_id'] . ' ORDER BY group_name'; if ($rg = F_db_query($sqlg, $db)) { while ($mg = F_db_fetch_array($rg)) { $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<group id="' . $mg['group_id'] . '">'; $xml .= $mg['group_name']; $xml .= '</group>' . K_NEWLINE; } } else { F_display_db_error(); } $xml .= K_TAB . K_TAB . K_TAB . '</user>' . K_NEWLINE; } } else { F_display_db_error(); } $xml .= K_TAB . '</body>' . K_NEWLINE; $xml .= '</tcexamusers>' . K_NEWLINE; return $xml; }
/** * Get data array in XML format. * @param $data (array) Array of data (key => value). * @param $level (int) Indentation level. * @return string XML data */ function getDataXML($data, $level = 1) { $xml = ''; $tb = str_repeat("\t", $level); foreach ($data as $key => $value) { $key = strtolower($key); $key = preg_replace('/[^a-z0-9]+/', '_', $key); if (is_numeric($key[0]) or $key[0] == '_') { $key = 'item' . $key; } $xml .= $tb . '<' . $key . '>'; if (is_array($value)) { $xml .= "\n" . getDataXML($value, $level + 1); } else { $xml .= F_text_to_xml($value); } $xml .= '</' . $key . '>' . "\n"; } return $xml; }
/** * Export all question statistics of the selected test to XML. * @author Nicola Asuni * @since 2010-05-10 * @param $test_id (int) test ID * @return XML data */ function F_xml_export_question_stats($test_id) { global $l, $db; require_once '../config/tce_config.php'; require_once '../../shared/code/tce_authorization.php'; require_once '../code/tce_functions_auth_sql.php'; $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 .= '<tcexamquestionstats 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; // get test data $testdata = F_getTestData($test_id); // get total number of questions for the selected test $num_questions = F_count_rows(K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER, 'WHERE testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ''); // output questions stats $sqlr = 'SELECT question_id, COUNT(question_id) AS recurrence, AVG(testlog_score) AS average_score, AVG(testlog_change_time - testlog_display_time) AS average_time, min(question_difficulty) AS question_difficulty FROM ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_TEST_USER . ', ' . K_TABLE_QUESTIONS . ' WHERE testlog_testuser_id=testuser_id AND testlog_question_id=question_id AND testuser_test_id=' . $test_id . ' GROUP BY question_id ORDER BY recurrence DESC,average_score DESC'; if ($rr = F_db_query($sqlr, $db)) { while ($mr = F_db_fetch_array($rr)) { $xml .= K_TAB . K_TAB . '<question>' . K_NEWLINE; // get the question max score $question_max_score = $testdata['test_score_right'] * $mr['question_difficulty']; $qsttestdata = F_getQuestionTestStat($test_id, $mr['question_id']); $xml .= K_TAB . K_TAB . K_TAB . '<id>' . $mr['question_id'] . '</id>' . K_NEWLINE; $question_description = ''; $sqlrq = 'SELECT question_description FROM ' . K_TABLE_QUESTIONS . ' WHERE question_id=' . $mr['question_id'] . ''; if ($rrq = F_db_query($sqlrq, $db)) { if ($mrq = F_db_fetch_array($rrq)) { $question_description = $mrq['question_description']; } } else { F_display_db_error(); } $xml .= K_TAB . K_TAB . K_TAB . '<description>' . F_text_to_xml($question_description) . '</description>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<recurrence>' . $mr['recurrence'] . '</recurrence>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<recurrence_percent>' . F_formatXMLPercentage($mr['recurrence'] / $num_questions) . '</recurrence_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<points>' . number_format($mr['average_score'], 3, '.', '') . '</points>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<points_percent>' . F_formatXMLPercentage($mr['average_score'] / $question_max_score) . '</points_percent>' . K_NEWLINE; if (stripos($mr['average_time'], ':') !== FALSE) { // PostgreSQL returns formatted time, while MySQL returns the number of seconds $mr['average_time'] = strtotime($mr['average_time']); } $xml .= K_TAB . K_TAB . K_TAB . '<time>' . date('i:s', $mr['average_time']) . '</time>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<correct>' . $qsttestdata['right'] . '</correct>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<correct_percent>' . F_formatXMLPercentage($qsttestdata['right'] / $qsttestdata['num']) . '</correct_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<wrong>' . $qsttestdata['wrong'] . '</wrong>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<wrong_percent>' . F_formatXMLPercentage($qsttestdata['wrong'] / $qsttestdata['num']) . '</wrong_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unanswered>' . $qsttestdata['unanswered'] . '</unanswered>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unanswered_percent>' . F_formatXMLPercentage($qsttestdata['unanswered'] / $qsttestdata['num']) . '</unanswered_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<undisplayed>' . $qsttestdata['undisplayed'] . '</undisplayed>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<undisplayed_percent>' . F_formatXMLPercentage($qsttestdata['undisplayed'] / $qsttestdata['num']) . '</undisplayed_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unrated>' . $qsttestdata['unrated'] . '</unrated>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unrated_percent>' . F_formatXMLPercentage($qsttestdata['unrated'] / $qsttestdata['num']) . '</unrated_percent>' . K_NEWLINE; // answers statistics $sqla = 'SELECT * FROM ' . K_TABLE_ANSWERS . ' WHERE answer_question_id=' . $mr['question_id'] . ' ORDER BY answer_id'; if ($ra = F_db_query($sqla, $db)) { while ($ma = F_db_fetch_array($ra)) { $xml .= K_TAB . K_TAB . K_TAB . '<answer>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<id>' . $ma['answer_id'] . '</id>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<description>' . F_text_to_xml($ma['answer_description']) . '</description>' . K_NEWLINE; $num_all_answers = F_count_rows(K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_ANSWERS . ', ' . K_TABLE_LOG_ANSWER . ' WHERE logansw_answer_id=answer_id AND logansw_testlog_id=testlog_id AND testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testlog_question_id=' . $mr['question_id'] . ''); $num_answers = F_count_rows(K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_ANSWERS . ', ' . K_TABLE_LOG_ANSWER . ' WHERE answer_id=' . $ma['answer_id'] . ' AND logansw_answer_id=answer_id AND logansw_testlog_id=testlog_id AND testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testlog_question_id=' . $mr['question_id'] . ''); $right_answers = F_count_rows(K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_ANSWERS . ', ' . K_TABLE_LOG_ANSWER . ' WHERE answer_id=' . $ma['answer_id'] . ' AND logansw_answer_id=answer_id AND logansw_testlog_id=testlog_id AND testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testlog_question_id=' . $mr['question_id'] . ' AND ((answer_isright=\'0\' AND logansw_selected=0) OR (answer_isright=\'1\' AND logansw_selected=1) OR (answer_position IS NOT NULL AND logansw_position IS NOT NULL AND answer_position=logansw_position))'); $wrong_answers = F_count_rows(K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_ANSWERS . ', ' . K_TABLE_LOG_ANSWER . ' WHERE answer_id=' . $ma['answer_id'] . ' AND logansw_answer_id=answer_id AND logansw_testlog_id=testlog_id AND testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testlog_question_id=' . $mr['question_id'] . ' AND ((answer_isright=\'0\' AND logansw_selected=1) OR (answer_isright=\'1\' AND logansw_selected=0) OR (answer_position IS NOT NULL AND answer_position!=logansw_position))'); $unanswered = F_count_rows(K_TABLE_TEST_USER . ', ' . K_TABLE_TESTS_LOGS . ', ' . K_TABLE_ANSWERS . ', ' . K_TABLE_LOG_ANSWER . ' WHERE answer_id=' . $ma['answer_id'] . ' AND logansw_answer_id=answer_id AND logansw_testlog_id=testlog_id AND testlog_testuser_id=testuser_id AND testuser_test_id=' . $test_id . ' AND testlog_question_id=' . $mr['question_id'] . ' AND logansw_selected=-1'); $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<recurrence>' . $num_answers . '</recurrence>' . K_NEWLINE; $perc = 0; if ($num_all_answers > 0) { $perc = $num_answers / $num_all_answers; } $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<recurrence_percent>' . F_formatXMLPercentage($perc) . '</recurrence_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<correct>' . $right_answers . '</correct>' . K_NEWLINE; $perc = 0; if ($num_answers > 0) { $perc = $right_answers / $num_answers; } $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<correct_percent>' . F_formatXMLPercentage($perc) . '</correct_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<wrong>' . $wrong_answers . '</wrong>' . K_NEWLINE; $perc = 0; if ($num_answers > 0) { $perc = round($wrong_answers / $num_answers); } $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<wrong_percent>' . F_formatXMLPercentage($perc) . '</wrong_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<unanswered>' . $unanswered . '</unanswered>' . K_NEWLINE; $perc = 0; if ($num_answers > 0) { $perc = round($unanswered / $num_answers); } $xml .= K_TAB . K_TAB . K_TAB . K_TAB . '<unanswered_percent>' . F_formatXMLPercentage($perc) . '</unanswered_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '</answer>' . K_NEWLINE; } } else { F_display_db_error(); } $xml .= K_TAB . K_TAB . '</question>' . K_NEWLINE; } } else { F_display_db_error(); } $xml .= K_TAB . '</body>' . K_NEWLINE; $xml .= '</tcexamquestionstats>' . K_NEWLINE; return $xml; }
$xml .= K_TAB . K_TAB . K_TAB . '<score_percent>' . round(100 * $usrtestdata['score'] / $usrtestdata['max_score']) . '</score_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<right>' . $usrtestdata['right'] . '</right>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<right_percent>' . round(100 * $usrtestdata['right'] / $usrtestdata['all']) . '</right_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<wrong>' . $usrtestdata['wrong'] . '</wrong>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<wrong_percent>' . round(100 * $usrtestdata['wrong'] / $usrtestdata['all']) . '</wrong_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unanswered>' . $usrtestdata['unanswered'] . '</unanswered>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<unanswered_percent>' . round(100 * $usrtestdata['unanswered'] / $usrtestdata['all']) . '</unanswered_percent>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<undisplayed>' . $usrtestdata['undisplayed'] . '</undisplayed>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<undisplayed_percent>' . round(100 * $usrtestdata['undisplayed'] / $usrtestdata['all']) . '</undisplayed_percent>' . K_NEWLINE; if ($m['testuser_status'] == 4) { $status = $l['w_locked']; } else { $status = $l['w_unlocked']; } $xml .= K_TAB . K_TAB . K_TAB . '<status>' . $status . '</status>' . K_NEWLINE; $xml .= K_TAB . K_TAB . K_TAB . '<comment>' . F_text_to_xml($usrtestdata['comment']) . '</comment>' . K_NEWLINE; $xml .= K_TAB . K_TAB . '</test>' . K_NEWLINE; // collects data for descriptive statistics $statsdata['score'][] = $m['total_score'] / $usrtestdata['max_score']; $statsdata['right'][] = $usrtestdata['right'] / $usrtestdata['all']; $statsdata['wrong'][] = $usrtestdata['wrong'] / $usrtestdata['all']; $statsdata['unanswered'][] = $usrtestdata['unanswered'] / $usrtestdata['all']; $statsdata['undisplayed'][] = $usrtestdata['undisplayed'] / $usrtestdata['all']; $statsdata['unrated'][] = $usrtestdata['unrated'] / $usrtestdata['all']; } } else { F_display_db_error(); } // calculate statistics $stats = F_getArrayStatistics($statsdata); $excludestat = array('sum', 'variance');
/** * 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; }
/** * Display a list of selected questions. * @author Nicola Asuni * @since 2005-07-06 * @param $wherequery (string) question selection query * @param $subject_module_id (string) module ID * @param $subject_id (string) topic ID * @param $order_field (string) order by column name * @param $orderdir (int) oreder direction * @param $firstrow (int) number of first row to display * @param $rowsperpage (int) number of rows per page * @param $hide_answers (boolean) if true hide answers * @return false in case of empty database, true otherwise */ function F_show_select_questions($wherequery, $subject_module_id, $subject_id, $order_field, $orderdir, $firstrow, $rowsperpage, $hide_answers = false) { global $l, $db; require_once '../config/tce_config.php'; require_once '../../shared/code/tce_functions_page.php'; $subject_module_id = intval($subject_module_id); $subject_id = intval($subject_id); $orderdir = intval($orderdir); $firstrow = intval($firstrow); $rowsperpage = intval($rowsperpage); if (empty($order_field) or !in_array($order_field, array('question_id', 'question_subject_id', 'question_description', 'question_explanation', 'question_type', 'question_difficulty', 'question_enabled', 'question_position', 'question_timer', 'question_fullscreen', 'question_inline_answers', 'question_auto_next', 'question_enabled DESC, question_position, CAST(question_description as varchar2(100))', 'question_enabled DESC, question_position, question_description'))) { $order_field = 'question_description'; } if ($orderdir == 0) { $nextorderdir = 1; $full_order_field = $order_field; } else { $nextorderdir = 0; $full_order_field = $order_field . ' DESC'; } if (!F_count_rows(K_TABLE_QUESTIONS)) { //if the table is void (no items) display message F_print_error('MESSAGE', $l['m_databasempty']); return FALSE; } if (empty($wherequery)) { $wherequery = 'WHERE question_subject_id=' . $subject_id . ''; } else { $wherequery = F_escape_sql($db, $wherequery); $wherequery .= ' AND question_subject_id=' . $subject_id . ''; } $sql = 'SELECT * FROM ' . K_TABLE_QUESTIONS . ' ' . $wherequery . ' ORDER BY ' . $full_order_field; if (K_DATABASE_TYPE == 'ORACLE') { $sql = 'SELECT * FROM (' . $sql . ') WHERE rownum BETWEEN ' . $firstrow . ' AND ' . ($firstrow + $rowsperpage) . ''; } else { $sql .= ' LIMIT ' . $rowsperpage . ' OFFSET ' . $firstrow . ''; } if ($r = F_db_query($sql, $db)) { $questlist = ''; $itemcount = $firstrow; while ($m = F_db_fetch_array($r)) { $itemcount++; $questlist .= '<li>' . K_NEWLINE; $questlist .= '<strong>' . $itemcount . '.</strong> '; $questlist .= '<input type="checkbox" name="questionid' . $itemcount . '" id="questionid' . $itemcount . '" value="' . $m['question_id'] . '" title="' . $l['w_select'] . '"'; if (isset($_REQUEST['checkall']) and $_REQUEST['checkall'] == 1) { $questlist .= ' checked="checked"'; } $questlist .= ' />'; // display question description if (F_getBoolean($m['question_enabled'])) { $questlist .= '<acronym class="onbox" title="' . $l['w_enabled'] . '">+</acronym>'; } else { $questlist .= '<acronym class="offbox" title="' . $l['w_disabled'] . '">-</acronym>'; } switch ($m['question_type']) { case 1: $questlist .= ' <acronym class="offbox" title="' . $l['w_single_answer'] . '">S</acronym>'; break; case 2: $questlist .= ' <acronym class="offbox" title="' . $l['w_multiple_answers'] . '">M</acronym>'; break; case 3: $questlist .= ' <acronym class="offbox" title="' . $l['w_free_answer'] . '">T</acronym>'; break; case 4: $questlist .= ' <acronym class="offbox" title="' . $l['w_ordering_answer'] . '">O</acronym>'; break; } $questlist .= ' <acronym class="offbox" title="' . $l['h_question_difficulty'] . '">' . $m['question_difficulty'] . '</acronym>'; if ($m['question_position'] > 0) { $questlist .= ' <acronym class="onbox" title="' . $l['h_position'] . '">' . intval($m['question_position']) . '</acronym>'; } else { $questlist .= ' <acronym class="offbox" title="' . $l['h_position'] . '"> </acronym>'; } if (F_getBoolean($m['question_fullscreen'])) { $questlist .= ' <acronym class="onbox" title="' . $l['w_fullscreen'] . ': ' . $l['w_enabled'] . '">F</acronym>'; } else { $questlist .= ' <acronym class="offbox" title="' . $l['w_fullscreen'] . ': ' . $l['w_disabled'] . '"> </acronym>'; } if (F_getBoolean($m['question_inline_answers'])) { $questlist .= ' <acronym class="onbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_enabled'] . '">I</acronym>'; } else { $questlist .= ' <acronym class="offbox" title="' . $l['w_inline_answers'] . ': ' . $l['w_disabled'] . '"> </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'] . '"> </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'] . '"> </acronym>'; } $questlist .= ' <a href="tce_edit_question.php?subject_module_id=' . $subject_module_id . '&question_subject_id=' . $subject_id . '&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'] . '"> </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'] . '"> </acronym>'; } $answlist .= ' <a href="tce_edit_answer.php?subject_module_id=' . $subject_module_id . '&question_subject_id=' . $subject_id . '&answer_question_id=' . $m['question_id'] . '&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 ' '; if ($l['a_meta_dir'] == 'rtl') { $arr = '←'; } else { $arr = '→'; } // 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'] . '"> ' . 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 = '&order_field=' . urlencode($order_field) . ''; } if (!empty($orderdir)) { $param_array .= '&orderdir=' . $orderdir . ''; } if (!empty($hide_answers)) { $param_array .= '&hide_answers=' . intval($hide_answers) . ''; } $param_array .= '&subject_module_id=' . $subject_module_id . ''; $param_array .= '&subject_id=' . $subject_id . ''; $param_array .= '&submitted=1'; F_show_page_navigator($_SERVER['SCRIPT_NAME'], $sql, $firstrow, $rowsperpage, $param_array); } } else { F_display_db_error(); } return TRUE; }