2001-09-17 # # Copyright 2001 (c) CGIHK.com. All rights reserved. # ####################################################################### # # # CGIHK.com: # # http://www.cgihk.com/ # # Support: # # http://www.cgihk.com/forum/ # # ThomasTsoi.com # # http://www.ThomasTsoi.com/ # # Winapi.com # # http://www.winapi.com/ # # Astronomy.org.hk # # http://www.astronomy.org.hk/ # # # # ################################################################### # # # # This is a commercial product and CANNOT be distributed # # without the author's authorization. # # # ####################################################################### require("config.php"); if (! mysql_connect($host, $username, $password)) { print "MySQL Error: " . mysql_error(); exit; } mysql_select_db($database); $result = mysql_query( "SELECT anticheat, require_info, show_record, show_answer, show_copyright, " . "use_table, randomize_ans, allow_empty_ans, " . "admin_password, admin_email, email_admin, email_taker, header, footer, ". "url_site, url_tick, url_cross, font_face, font_color, table_border_color, ". "table_color_1, table_color_2, level_name_1, level_name_2, level_name_3, ". "no_options, no_recent, no_top FROM quirex_config"); if ($result) { list($anticheat, $require_info, $show_record, $show_answer, $show_copyright, $use_table, $randomize_ans, $allow_empty_ans, $admin_password, $admin_email, $email_admin, $email_taker, $header, $footer, $url_site, $url_tick, $url_cross, $font_face, $font_color, $table_border_color, $table_color_1, $table_color_2, $level_name_1, $level_name_2, $level_name_3, $no_options, $no_recent, $no_top) = mysql_fetch_row($result); } else { print "MySQL Error: " . mysql_error(); exit; } $script = $PHP_SELF; if (file_exists("language.php")) { include("language.php"); } else { $language[quiz] = "Quiz"; $language[total_takers] = "Total Takers"; $language[record_holder] = "Record Holders"; $language[na] = "N/A"; $language[num_of_questions] = "Number of Questions"; $language[name] = "Name"; $language[email] = "E-mail"; $language[both_required] = "both reqired"; $language[hide_email] = "Check here if you want to hide your email address"; $language[take_quiz] = "Take the quiz now!"; $language[tf_true] = "True"; $language[tf_false] = "False"; $language[answer] = "Answer"; $language[submit] = "Done!"; $language[continue_quiz] = "Continue the Quiz..."; $language[info_required_msg] = "Both your name and email are required to take the quiz."; $language[anticheat_msg] = "You are not allowed to re-take the same quiz within 1 hour."; $language[empty_ans_msg] = "You have unanswered questions."; $language[your_answer] = "Your Answer"; $language[correct_answer] = "Correct Answer"; $language[explanation] = "Explanation"; $language[result] = "Results were [no_correct] correct out of [no_total] questions, [percentage] correct."; $language[take_again] = "Take the Quiz Again!"; $language[back] = "Back to Home"; $language[no_total] = "Ques Attemped"; $language[no_correct] = "Ques Correct"; $language[score] = "Score"; $language[time_taken] = "Time Taken"; $language[time_of_trial] = "Time"; } srand ((float) microtime() * 1000000); header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); print $header; if ($action == 'quiz' && $quiz != '') { if (isset($first_ques)) { continue_quiz(); } else { start_quiz(); } } elseif ($action == 'done' && $quiz != '') { check_answer(); } elseif ($quiz) { if (eregi("^recent", $show)) $show = "recent"; if (eregi("^top", $show)) $show = "top"; if (($show == 'recent' || $show == 'top') && $show_record) { show_record($show); } else { start_quiz(0); } } else { show_quiz(); } print $footer; function show_quiz($msg = '') { global $script, $anticheat, $require_info, $show_record, $show_answer, $show_copyright, $use_table, $randomize_ans, $allow_empty_ans, $admin_password, $admin_email, $email_admin, $email_taker, $header, $footer, $url_site, $url_tick, $url_cross, $font_face, $font_color, $table_border_color, $table_color_1, $table_color_2, $level_name_1, $level_name_2, $level_name_3, $no_options, $no_recent, $no_top; global $action, $quiz, $number, $name, $email, $hide; global $language; print "
\n"; print "
\n"; print "\n"; if ($show_record) {$colspan=4;} else {$colspan=2;} print ""; print ""; print ""; if ($show_record) { print ""; print ""; } print "\n"; $result = mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '0' ORDER BY quiz_name"); if (mysql_num_rows($result) > 0) { for ($i=0;$i 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder = "$language[na]";} print ""; print ""; print ""; if ($show_record) { print ""; print ""; } print "\n"; } } $result = mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '1' ORDER BY quiz_name"); if (mysql_num_rows($result) > 0) { print "\n"; for ($i=0;$i 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder = "$language[na]";} print ""; print ""; print ""; if ($show_record) { print ""; print ""; } print "\n"; } } $result = mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '2' ORDER BY quiz_name"); if (mysql_num_rows($result) > 0) { print "\n"; for ($i=0;$i 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder = "$language[na]";} print ""; print ""; print ""; if ($show_record) { print ""; print ""; } print "\n"; } } $result = mysql_query("SELECT quiz_id, quiz_name, quiz_desc FROM quirex_list WHERE quiz_level = '3' ORDER BY quiz_name"); if (mysql_num_rows($result) > 0) { print "\n"; for ($i=0;$i 0) {list($record_holder) = mysql_fetch_row(mysql_query("SELECT taker_name FROM quirex_record WHERE quiz_id = '$quiz_id' ORDER BY (no_correct/no_total) DESC, no_total DESC, (time_finish - time_begin) ASC, time_finish DESC LIMIT 1"));} else {$record_holder = "$language[na]";} print ""; print ""; print ""; if ($show_record) { print ""; print ""; } print "\n"; } } print "\n"; if ($msg) print "\n"; if ($require_info) print "\n"; print "\n"; if ($show_copyright) print "\n"; print "
.$language[quiz]$language[total_takers]$language[record_holder]
$quiz_name
$quiz_desc
$ttl_taker$record_holder
$level_name_1
$quiz_name
$quiz_desc
$ttl_taker$record_holder
$level_name_2
$quiz_name
$quiz_desc
$ttl_taker$record_holder
$level_name_3
$quiz_name
$quiz_desc
$ttl_taker$record_holder
$language[num_of_questions]:
$msg
$language[name]: $language[email]: ($language[both_required])
$language[hide_email]:
Powered by Quirex PHP
\n"; print "
\n"; print "\n"; print "
\n"; } function start_quiz($check_info = 1) { global $script, $anticheat, $require_info, $show_record, $show_answer, $show_copyright, $use_table, $randomize_ans, $allow_empty_ans, $admin_password, $admin_email, $email_admin, $email_taker, $header, $footer, $url_site, $url_tick, $url_cross, $font_face, $font_color, $table_border_color, $table_color_1, $table_color_2, $level_name_1, $level_name_2, $level_name_3, $no_options, $no_recent, $no_top; global $action, $quiz, $number, $name, $email, $hide; global $language; if ($check_info && $require_info && ($name == '' || ! ereg(".+@.+\..+", $email))) { show_quiz($language[both_required_long]); } else { list($all_ques) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM quirex_ques WHERE quiz_id = '$quiz'")); if ($all_ques == 0) { print "No questions"; print $footer; exit; } if(is_numeric($number)) { $ques_show = min($number, $all_ques); } elseif (strtolower($number) == 'all') { $ques_show = $all_ques; } else { $ques_show = min(10, $all_ques); } print "\n"; print "
\n"; list($quiz_name) = mysql_fetch_row(mysql_query("SELECT quiz_name FROM quirex_list WHERE quiz_id = '$quiz'")); if ($use_table) { print "
\n"; print "\n"; print "\n"; } else { print "$quiz_name

\n"; print "\n"; } $result = mysql_query("SELECT ques_id, ques_type, question, ques_img, choice FROM quirex_ques WHERE quiz_id = '$quiz' ORDER BY RAND() LIMIT $ques_show"); for ($i=0;$i\n"; } else { print "".($i+1).". $question
"; if ($ques_img) print "
"; if ($ques_type == 'mc') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } print " $choice_shown
"; } } elseif ($ques_type == 'ma') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } print " $choice_shown
"; } } elseif ($ques_type == 'sa') { print "$language[answer]:
"; } elseif ($ques_type == 'nu') { print "$language[answer]:
"; } elseif ($ques_type == 'tf') { print "$language[tf_true] $language[tf_false]
"; } print "
\n"; } } if ($use_table) { if (!$check_info && $require_info) print "
\n"; print "\n"; if ($show_copyright) print "\n"; print "
$quiz_name
"; print "".($i+1).". $question
"; if ($ques_img) print "
"; if ($ques_type == 'mc') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } print " $choice_shown
"; } } elseif ($ques_type == 'ma') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } print " $choice_shown
"; } } elseif ($ques_type == 'sa') { print "$language[answer]:
"; } elseif ($ques_type == 'nu') { print "$language[answer]:
"; } elseif ($ques_type == 'tf') { print "$language[tf_true] $language[tf_false]
"; } print "
$language[name]: $language[email]: ($language[both_required])
$language[hide_email]:
Powered by Quirex PHP
\n"; print "
\n"; } else { if (!$check_info && $require_info) print "$language[name]: $language[email]: ($language[both_required])
$language[hide_email]:
\n"; print "

\n"; print ""; if ($show_copyright) print "

Powered by Quirex PHP

\n"; } if ($check_info && $require_info) { print "\n"; print "\n"; print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } } function continue_quiz() { global $script, $anticheat, $require_info, $show_record, $show_answer, $show_copyright, $use_table, $randomize_ans, $allow_empty_ans, $admin_password, $admin_email, $email_admin, $email_taker, $header, $footer, $url_site, $url_tick, $url_cross, $font_face, $font_color, $table_border_color, $table_color_1, $table_color_2, $level_name_1, $level_name_2, $level_name_3, $no_options, $no_recent, $no_top; global $action, $quiz, $number, $name, $email, $hide, $first_ques, $q0; global $language; list($all_ques) = mysql_fetch_row(mysql_query("SELECT COUNT(*) FROM quirex_ques WHERE quiz_id = '$quiz'")); if(is_numeric($number)) { $ques_show = min($number, $all_ques); } elseif (strtolower($number) == 'all') { $ques_show = $all_ques; } else { $ques_show = min(10, $all_ques); } print "\n"; print "
\n"; list($quiz_name) = mysql_fetch_row(mysql_query("SELECT quiz_name FROM quirex_list WHERE quiz_id = '$quiz'")); if ($use_table) { print "
\n"; print "\n"; print "\n"; } else { print "$quiz_name

\n"; print "\n"; } list($ques_id, $ques_type, $question, $ques_img, $choice) = mysql_fetch_row(mysql_query("SELECT ques_id, ques_type, question, ques_img, choice FROM quirex_ques WHERE quiz_id = '$quiz' AND ques_id = '$first_ques' LIMIT 1")); $ques_search = $ques_show - 1; $result = mysql_query("SELECT ques_id, ques_type, question, ques_img, choice FROM quirex_ques WHERE quiz_id = '$quiz' AND ques_id != '$first_ques' ORDER BY RAND() LIMIT $ques_search"); for ($i=0;$i0) { list($ques_id, $ques_type, $question, $ques_img, $choice) = mysql_fetch_row($result); } $ques_array[] = $ques_id; $row_color = ($i % 2) ? $table_color_1 : $table_color_2; if ($use_table) { print "\n"; } else { print "".($i+1).". $question
"; if ($ques_img) print "
"; if ($ques_type == 'mc') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } if ($i==0 && $choice_value == $q0) print " $choice_shown
"; else print " $choice_shown
"; } } elseif ($ques_type == 'ma') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } if ($i==0) { $matched = 0; for ($k=0;$k $choice_shown
"; else print " $choice_shown
"; } else print " $choice_shown
"; } } elseif ($ques_type == 'sa') { if ($i==0) print "$language[answer]:
"; else print "$language[answer]:
"; } elseif ($ques_type == 'nu') { if ($i==0) print "$language[answer]:
"; else print "$language[answer]:
"; } elseif ($ques_type == 'tf') { if ($i==0) { if ($q0 == 't') $selected_t = " checked"; if ($q0 == 'f') $selected_f = " checked"; print "$language[tf_true] $language[tf_false]
"; } else print "$language[tf_true] $language[tf_false]
"; } print "
\n"; } } if ($use_table) { if ($require_info) print "
\n"; print "\n"; if ($show_copyright) print "\n"; print "
$quiz_name
"; print "".($i+1).". $question
"; if ($ques_img) print "
"; if ($ques_type == 'mc') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } if ($i==0 && $choice_value == $q0) print " $choice_shown
"; else print " $choice_shown
"; } } elseif ($ques_type == 'ma') { $choices = split("\|\|", $choice); if ($randomize_ans) { for ($j=0;$j"; } else { $choice_shown = $choices[$j]; } if ($i==0) { $matched = 0; for ($k=0;$k $choice_shown
"; else print " $choice_shown
"; } else print " $choice_shown
"; } } elseif ($ques_type == 'sa') { if ($i==0) print "$language[answer]:
"; else print "$language[answer]:
"; } elseif ($ques_type == 'nu') { if ($i==0) print "$language[answer]:
"; else print "$language[answer]:
"; } elseif ($ques_type == 'tf') { if ($i==0) { if ($q0 == 't') $selected_t = " checked"; if ($q0 == 'f') $selected_f = " checked"; print "$language[tf_true] $language[tf_false]
"; } else print "$language[tf_true] $language[tf_false]
"; } print "
$language[name]: $language[email]: ($language[both_required])
$language[hide_email]:
Powered by Quirex PHP
\n"; print "
\n"; } else { if ($require_info) print "$language[name]: $language[email]: ($language[both_required])
$language[hide_email]:
\n"; print "

\n"; print ""; if ($show_copyright) print "

Powered by Quirex PHP

\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } function check_answer() { global $script, $anticheat, $require_info, $show_record, $show_answer, $show_copyright, $use_table, $randomize_ans, $allow_empty_ans, $admin_password, $admin_email, $email_admin, $email_taker, $header, $footer, $url_site, $url_tick, $url_cross, $font_face, $font_color, $table_border_color, $table_color_1, $table_color_2, $level_name_1, $level_name_2, $level_name_3, $no_options, $no_recent, $no_top; global $action, $array, $quiz, $number, $name, $email, $hide, $begin; global $language; for ($i=0;$i<$number;$i++) global ${"q$i"}; $taker_ip = getenv("REMOTE_ADDR"); if ($anticheat != 0) { $seconds = $anticheat * 3600; $result = mysql_query("SELECT * FROM quirex_record WHERE ip = '$taker_ip' AND quiz_id = '$quiz' AND (UNIX_TIMESTAMP() - time_finish) < $seconds"); } if (!$allow_empty_ans) { $empty_ans = 0; for ($i=0;$i<$number;$i++) if (!isset(${"q$i"})) $empty_ans = 1; } if ($anticheat != 0 && mysql_num_rows($result) != 0) { print "$language[anticheat_msg]"; } elseif (!$allow_empty_ans && $empty_ans) { print "$language[empty_ans_msg]"; } elseif ($require_info && ($name == '' || ! ereg(".+@.+\..+", $email))) { print "$language[info_required_msg]"; } else { print "\n"; $id = split(",", $array); $no_correct = 0; list($quiz_name) = mysql_fetch_row(mysql_query("SELECT quiz_name FROM quirex_list WHERE quiz_id = '$quiz'")); if ($use_table) { print "
\n"; print "\n"; print "\n"; } else { print "$quiz_name

\n"; } for ($i=0;$i<$number;$i++) { list($ques_id, $ques_type, $question, $choice, $answer, $ans_img, $explanation) = mysql_fetch_row(mysql_query("SELECT ques_id, ques_type, question, choice, answer, ans_img, explanation FROM quirex_ques WHERE ques_id = '$id[$i]'")); if ($ques_type == 'ma') { if (isset(${"q$i"})) { foreach (${"q$i"} as $index => $value) { ${"q$i"}[$index] = stripslashes(${"q$i"}[$index]); } } } else { ${"q$i"} = stripslashes(${"q$i"}); } $is_correct = 0; if ($ques_type == 'mc') { if (${"q$i"} == $answer) $is_correct = 1; } elseif ($ques_type == 'ma' && isset(${"q$i"})) { $multi_ans = split("\|\|", $answer); $flag = 1; for ($j=0;$j"; else print "WRONG>"; print "\n"; if (!$anticheat) { if ($use_table) print "\n"; } if ($use_table) { if ($show_copyright) print "\n"; print "
$quiz_name
"; if ($is_correct) print "RIGHT>"; print "".($i+1).". $question
"; if ($ques_type == 'mc' && isset(${"q$i"})) $your_ans = eregi_replace("\[img=([^]]+)\]", "", ${"q$i"}); elseif ($ques_type == 'ma' && isset(${"q$i"})) $your_ans = eregi_replace("\[img=([^]]+)\]", "", join(", ", ${"q$i"})); elseif ($ques_type == 'sa' && ${"q$i"} != '') $your_ans = trim(${"q$i"}); elseif ($ques_type == 'tf' && isset(${"q$i"})) { if (${"q$i"} == 't') $your_ans = $language[tf_true]; if (${"q$i"} == 'f') $your_ans = $language[tf_false]; } elseif ($ques_type == 'nu' && ${"q$i"} != '') { $your_ans = ${"q$i"}; } else { $your_ans = $language[na]; } print "$language[your_answer]: $your_ans
"; if ($show_answer) { if ($ques_type == 'sa') { $ans = join(", ", split("\|\|", $answer)); } elseif ($ques_type == 'ma') { $ans = join(", ", split("\|\|", $answer)); $ans = eregi_replace("\[img=([^]]+)\]", "", $ans); } elseif ($ques_type == 'tf') { if ($answer == 't') $ans = $language[tf_true]; if ($answer == 'f') $ans = $language[tf_false]; } elseif ($ques_type == 'mc') $ans = eregi_replace("\[img=([^]]+)\]", "", $answer); else $ans = $answer; print "$language[correct_answer]: $ans
"; if ($ans_img) print "
"; if ($explanation) print "$language[explanation]: $explanation
"; } print "\n"; } else { if ($is_correct) print "RIGHT "; else print "WRONG "; print "".($i+1).". $question
"; if ($ques_type == 'mc' && isset(${"q$i"})) $your_ans = eregi_replace("\[img=([^]]+)\]", "", ${"q$i"}); elseif ($ques_type == 'ma' && isset(${"q$i"})) $your_ans = eregi_replace("\[img=([^]]+)\]", "", join(", ", ${"q$i"})); elseif ($ques_type == 'sa' && ${"q$i"} != '') $your_ans = trim(${"q$i"}); elseif ($ques_type == 'tf' && isset(${"q$i"})) { if (${"q$i"} == 't') $your_ans = $language[tf_true]; if (${"q$i"} == 'f') $your_ans = $language[tf_false]; } elseif ($ques_type == 'nu' && ${"q$i"} != '') { $your_ans = ${"q$i"}; } else { $your_ans = $language[na]; } print "$language[your_answer]: $your_ans
"; if ($show_answer) { if ($ques_type == 'sa') { $ans = join(", ", split("\|\|", $answer)); } elseif ($ques_type == 'ma') { $ans = join(", ", split("\|\|", $answer)); $ans = eregi_replace("\[img=([^]]+)\]", "", $ans); } elseif ($ques_type == 'tf') { if ($answer == 't') $ans = $language[tf_true]; if ($answer == 'f') $ans = $language[tf_false]; } elseif ($ques_type == 'mc') $ans = eregi_replace("\[img=([^]]+)\]", "", $answer); else $ans = $answer; print "$language[correct_answer]: $ans
"; if ($ans_img) print "
"; if ($explanation) print "$language[explanation]: $explanation
"; } print "
\n"; } } $percentage = round($no_correct/$number*10000) / 100; $language[result] = eregi_replace("\[no_correct\]", "$no_correct", $language[result]); $language[result] = eregi_replace("\[no_total\]", "$number", $language[result]); $language[result] = eregi_replace("\[percentage\]", "$percentage", $language[result]); if ($use_table) print "
\n"; print "$language[result]\n"; if ($use_table) print "
\n"; print "

\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "

\n"; if ($use_table) print "
Powered by Quirex PHP
\n"; print "
\n"; } print "

$language[back]

"; if ($hide == '1') $show_info = 0; if ($hide == '') $show_info = 1; mysql_query("INSERT INTO quirex_record SET quiz_id = '$quiz', taker_name = '$name', taker_email = '$email', show_record = '$show_info', no_total = '$number', no_correct = '$no_correct', time_begin = '$begin', time_finish = UNIX_TIMESTAMP(), ip = '$taker_ip'"); $seconds = $anticheat * 3600; mysql_query("UPDATE quirex_record SET ip = '' WHERE (UNIX_TIMESTAMP() - time_finish) > $seconds"); print "
\n"; if ($email_admin) { $mail_header = "From: \"Quirex PHP\" <$admin_email>\n"; $mail_subject= "Someone has taken your Quiz"; $mail_body = "$name has taken the quiz \"$quiz_name\" \n"; $mail_body .= "at ".strftime("%Y-%m-%d %H:%M:%S").".\n"; $mail_body .= "The following is a report of his/her answers.\n"; $mail_body .= "\n"; for ($i=0;$i<$number;$i++) { list($ques_type, $question, $answer) = mysql_fetch_row(mysql_query("SELECT ques_type, question, answer FROM quirex_ques WHERE ques_id = '$id[$i]'")); $mail_body .= ($i+1).". $question\n"; if ($ques_type == 'mc') { $mail_body .= "Taker's Answer: ".${"q$i"}."\n"; $mail_body .= "Correct Answer: $answer\n"; } elseif ($ques_type == 'ma') { $mail_body .= "Taker's Answer: ".join(", ", ${"q$i"})."\n"; $mail_body .= "Correct Answer: ".join(", ", split("\|\|", $answer))."\n"; } elseif ($ques_type == 'sa') { $mail_body .= "Taker's Answer: ".${"q$i"}."\n"; $mail_body .= "Correct Answer: ".join(", ", split("\|\|", $answer))."\n"; } elseif ($ques_type == 'nu') { $mail_body .= "Taker's Answer: ".${"q$i"}."\n"; $mail_body .= "Correct Answer: $answer\n"; } elseif ($ques_type == 'tf') { $tf[t] = "True"; $tf[f] = "False"; $mail_body .= "Taker's Answer: ".$tf[${"q$i"}]."\n"; $mail_body .= "Correct Answer: ".$tf[$answer]."\n"; } $mail_body .= "\n"; } mail($admin_email, $mail_subject, $mail_body, $mail_header); } if ($email_admin) { $mail_header = "From: $admin_email\n"; $mail_subject= "Quiz Report for $name"; $mail_body = "$name,\n"; $mail_body = "Thank you for taking the quiz \"$quiz_name\".\n"; $mail_body .= "The following is your quiz report.\n"; $mail_body .= "$language[result]\n"; $mail_body .= "\n"; for ($i=0;$i<$number;$i++) { list($ques_type, $question, $answer) = mysql_fetch_row(mysql_query("SELECT ques_type, question, answer FROM quirex_ques WHERE ques_id = '$id[$i]'")); $mail_body .= ($i+1).". $question\n"; if ($ques_type == 'mc') { $mail_body .= "Your Answer: ".${"q$i"}."\n"; if ($show_answer) $mail_body .= "Correct Answer: $answer\n"; } elseif ($ques_type == 'ma') { $mail_body .= "Your Answer: ".join(", ", ${"q$i"})."\n"; if ($show_answer) $mail_body .= "Correct Answer: ".join(", ", split("\|\|", $answer))."\n"; } elseif ($ques_type == 'sa') { $mail_body .= "Your Answer: ".${"q$i"}."\n"; if ($show_answer) $mail_body .= "Correct Answer: ".join(", ", split("\|\|", $answer))."\n"; } elseif ($ques_type == 'nu') { $mail_body .= "Your Answer: ".${"q$i"}."\n"; if ($show_answer) $mail_body .= "Correct Answer: $answer\n"; } elseif ($ques_type == 'tf') { $tf[t] = "True"; $tf[f] = "False"; $mail_body .= "Your Answer: ".$tf[${"q$i"}]."\n"; if ($show_answer) $mail_body .= "Correct Answer: ".$tf[$answer]."\n"; } $mail_body .= "\n"; } mail($email, $mail_subject, $mail_body, $mail_header); } } } function show_record($show) { global $script, $anticheat, $require_info, $show_record, $show_answer, $show_copyright, $use_table, $randomize_ans, $allow_empty_ans, $admin_password, $admin_email, $email_admin, $email_taker, $header, $footer, $url_site, $url_tick, $url_cross, $font_face, $font_color, $table_border_color, $table_color_1, $table_color_2, $level_name_1, $level_name_2, $level_name_3, $no_options, $no_recent, $no_top; global $quiz, $language; if ($show == "recent") { $result = mysql_query("SELECT taker_name, taker_email, show_record, no_total, no_correct, (time_finish-time_begin) AS time_taken, FROM_UNIXTIME(time_finish) FROM quirex_record WHERE quiz_id = '$quiz' ORDER BY time_finish DESC LIMIT $no_recent"); $str = "Recent $no_recent"; } elseif ($show == "top") { $result = mysql_query("SELECT taker_name, taker_email, show_record, no_total, no_correct, (time_finish-time_begin) AS time_taken, FROM_UNIXTIME(time_finish) FROM quirex_record WHERE quiz_id = '$quiz' ORDER BY (no_correct/no_total) DESC, no_total DESC, time_taken ASC, time_finish DESC LIMIT $no_top"); $str = "Top $no_top"; } list($quiz_name) = mysql_fetch_row(mysql_query("SELECT quiz_name FROM quirex_list WHERE quiz_id = '$quiz'")); print "
\n"; print "\n"; print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "\n"; for($i=0;$i\n"; if ($show_record) $taker_name = "$taker_name"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "\n"; } print "
$quiz_name: $str Quiz Takers
$language[name]$language[no_total]$language[no_correct]$language[score]$language[time_taken]$language[time_of_trial]
$taker_name$no_total$no_correct$percentage$time_taken$time
\n"; print "
\n"; } ?>