0) { $quiz_name = stripslashes(mysql_result($quiz_result, 0, 'name')); } } return $quiz_name; } function getQuizTagDescription($qiz_id) { // geeft de tag_description terug van een quiz global $website_description; $tag_description = $website_description; if ($qiz_id!="") { $category_result = mysql_query("SELECT tag_description FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $tag_description = stripslashes(mysql_result($category_result, 0, 'tag_description')); } } return $tag_description; } function getQuizTagKeywords($qiz_id) { // geeft de tag_keywords terug van een quiz global $website_keywords; $tag_keywords = $website_keywords; if ($qiz_id!="") { $category_result = mysql_query("SELECT tag_keywords FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $tag_keywords = stripslashes(mysql_result($category_result, 0, 'tag_keywords')); } } return $tag_keywords; } function getQuizDescription($qiz_id) { // geeft de omschrijving terug van een quiz $quiz_description = "[[geen]]"; if ($qiz_id!="") { $quiz_result = mysql_query("SELECT description FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) { $quiz_description = stripslashes(mysql_result($quiz_result, 0, 'description')); } } return $quiz_description; } function getQuizUrl($qiz_id) { // geeft de url terug waarop de quiz te vinden is global $use_name_urls; if (!$use_name_urls) { $quiz_url = "quiz.php?qiz_id=".$qiz_id; } else { $sce_id = getSubCategoryFromQuiz($qiz_id); $quiz_url = getSubCategoryName($sce_id)." ".getQuizName($qiz_id); $quiz_url = str_replace(" ","_",$quiz_url); $quiz_url = str_replace("/","",$quiz_url); $quiz_url = str_replace("'","",$quiz_url); $quiz_url = str_replace("(","",$quiz_url); $quiz_url = str_replace(")","",$quiz_url); $quiz_url = str_replace("&","en",$quiz_url); $quiz_url = str_replace("!","",$quiz_url); $quiz_url = urlencode(trim(strToLower($quiz_url))); $quiz_url .= "_q-".$qiz_id.".html"; } return $quiz_url; } function getQuizPicture($qiz_id) { // geeft het plaatje terug van een quiz $quiz_picture = ""; if ($qiz_id!="") { $quiz_result = mysql_query("SELECT picture FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) { $quiz_picture = stripslashes(mysql_result($quiz_result, 0, 'picture')); } } return $quiz_picture; } function getPopularQuizzesList($main_categories_count,$quizzes_count) { // geeft voor een aantal willekeurige hoofdrubrieken de populairste quizzes terug $maincat_result = mysql_query("SELECT MCE_id FROM main_categories WHERE deleted=0 AND active=1 ORDER BY RAND() LIMIT $main_categories_count") or die (mysql_error()); $maincat_counter = 0; while ($catrow = mysql_fetch_array($maincat_result)) { $mce_id = $catrow[MCE_id]; $quiz_result = mysql_query("SELECT q.QIZ_id, count(uq.UQZ_id) as nr FROM quizzes q INNER JOIN sub_categories sc ON q.SCE_id=sc.SCE_id INNER JOIN user_quizzes uq ON q.QIZ_id=uq.QIZ_id WHERE q.deleted=0 AND q.active=1 AND sc.MCE_id=$mce_id GROUP BY q.QIZ_id ORDER BY nr DESC") or die (mysql_error()); $quiz_counter = 0; while ($row = mysql_fetch_array($quiz_result)) { $quiz_list[$maincat_counter][mce_id] = $mce_id; $quiz_list[$maincat_counter][quizzes][$quiz_counter] = $row[QIZ_id]; $quiz_counter++; } $maincat_counter++; } return $quiz_list; } function getSubCategoryQuizzesList($sce_id,$nr) { // geeft voor een subrubriek de quizzes terug if ($nr>0) { $quiz_result = mysql_query("SELECT QIZ_id FROM quizzes WHERE deleted=0 AND active=1 AND SCE_id=$sce_id ORDER BY sequence LIMIT $nr") or die (mysql_error()); } else { $quiz_result = mysql_query("SELECT QIZ_id FROM quizzes WHERE deleted=0 AND active=1 AND SCE_id=$sce_id ORDER BY sequence") or die (mysql_error()); } $quiz_counter = 0; while ($row = mysql_fetch_array($quiz_result)) { $quiz_list[$quiz_counter] = $row[QIZ_id]; $quiz_counter++; } return $quiz_list; } function getSubCategoryFromQuiz($qiz_id) { // geeft de subcategorie terug voor een quiz $sub_category_result = mysql_query("SELECT SCE_id FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); $sce_id = ""; if (mysql_num_rows($sub_category_result) > 0) $sce_id = mysql_result($sub_category_result, 0, 'SCE_id'); return $sce_id; } function getQuizPickRandomQuestions($qiz_id) { // geeft terug of er bij een quiz willekeurige vragen gekozen moeten worden $pick_random_questions = 0; $quiz_result = mysql_query("SELECT pick_random_questions FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $pick_random_questions = mysql_result($quiz_result, 0, 'pick_random_questions'); return $pick_random_questions; } function getQuizPickRandomQuestionsCount($qiz_id) { // geeft terug hoeveel willekeurige vragen er gekozen moeten worden bij een quiz $pick_random_questions_count = 10; $quiz_result = mysql_query("SELECT pick_random_questions_count FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $pick_random_questions_count = mysql_result($quiz_result, 0, 'pick_random_questions_count'); return $pick_random_questions_count; } function getQuizShuffleQuestions($qiz_id) { // geeft terug of de vragen in een quiz door elkaar gehusseld moeten worden $shuffle_questions = ""; $quiz_result = mysql_query("SELECT shuffle_questions FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $shuffle_questions = mysql_result($quiz_result, 0, 'shuffle_questions'); return $shuffle_questions; } function getQuizDifficultyRating($qiz_id) { // geeft de moeilijkheidsgraad van een quiz terug $difficulty_rating = 0; $quiz_result = mysql_query("SELECT difficulty_rating FROM quizzes WHERE QIZ_id=$qiz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $difficulty_rating = mysql_result($quiz_result, 0, 'difficulty_rating'); return $difficulty_rating; } function displayQuizDifficultyRating($qiz_id) { // toont de moeilijkheidgraad van een quiz $difficulty_rating = getQuizDifficultyRating($qiz_id); echo ""; echo ""; for ($diff_teller=0;$diff_teller<=9;$diff_teller++) { $lower_diff = $diff_teller * 10; $upper_diff = ($diff_teller+1) * 10; echo ""; } echo ""; echo ""; echo ""; echo "
"; echo ""; echo ""; if ($difficulty_rating>=$upper_diff) { echo ""; } else { if ($difficulty_rating<=$lower_diff) { echo ""; } else { echo ""; echo ""; } } echo ""; echo "
"; echo "
".(round($difficulty_rating/10,1))."
"; } function updateQuizDifficultyRating($qiz_id) { // past de moeilijkheidsgraad aan in de database // dit wordt berekend uit het gemiddelde van de laatste 3 maanden $three_months_ago = date("Y-m-j",mktime(0,0,0,date("m")-3,date("j"),date("Y"))); $diff_result = mysql_query("SELECT Avg(calculated_percentage_correct) as avg_diff FROM user_quizzes WHERE QIZ_id=$qiz_id AND completed=1 AND timestamp_started>'$three_months_ago'") or die (mysql_error()); if (mysql_num_rows($diff_result) > 0) { $avg_diff = mysql_result($diff_result, 0, 'avg_diff'); $difficulty_rating = round(100 - $avg_diff); mysql_query("UPDATE quizzes SET difficulty_rating=$difficulty_rating WHERE QIZ_id=$qiz_id") or die (mysql_error()); } } function getQuizNrOfQuestions($qiz_id) { // geeft het aantal vragen terug waaruit de quiz bestaat if (getQuizPickRandomQuestions($qiz_id)) { $nr_of_questions = getQuizPickRandomQuestionsCount($qiz_id); } else { $nr_of_questions = count(getQuestionsList($qiz_id)); } return $nr_of_questions; } // ################################## weergave quizpaginas #################################### function displayQuizStart() { // toont de startpagina van een quiz global $quiz_image_location; $qiz_id = addslashes($_GET['qiz_id']); $quiz_name = getQuizName($qiz_id); $quiz_description = getQuizDescription($qiz_id); $quiz_picture = getQuizPicture($qiz_id); $sce_id = getSubCategoryFromQuiz($qiz_id); $mce_id = getMainCategoryFromSubCategory($sce_id); $subcat_name = getSubCategoryName($sce_id); $maincat_name = getMainCategoryName($mce_id); $quiz_nr_of_questions = getQuizNrOfQuestions($qiz_id); $quiz_pick_random_questions = getQuizPickRandomQuestions($qiz_id); ?>
<? echo $quiz_name; ?>
Hoofdcategorie:
Subcategorie:
Moeilijkheidsgraad:
Klik hier om de quiz te starten
Hoogste scores vandaag
$this_day) AND u.name<>'' ORDER BY uq.calculated_percentage_correct DESC, uq.calculated_time_taken LIMIT 50") or die (mysql_error()); if (mysql_num_rows($score_result) < 5) $score_result = mysql_query("SELECT u.USR_id, u.name, uq.calculated_percentage_correct, uq.calculated_time_taken FROM user_quizzes uq INNER JOIN users u ON uq.USR_id=u.USR_id WHERE uq.QIZ_id=$qiz_id AND uq.completed=1 AND (Year(uq.timestamp_started)=$this_year AND Month(uq.timestamp_started)=$this_month AND Day(uq.timestamp_started)>($this_day-2)) AND u.name<>'' ORDER BY uq.calculated_percentage_correct DESC, uq.calculated_time_taken LIMIT 50") or die (mysql_error()); $score_counter = 1; while ($row = mysql_fetch_array($score_result)) { $score_user = $row[USR_id]; $name = $row[name]; $calculated_percentage_correct = $row[calculated_percentage_correct]; $calculated_time_taken = $row[calculated_time_taken]; $calculated_time_taken_minutes = floor($calculated_time_taken/60); $calculated_time_taken_seconds = $calculated_time_taken - ($calculated_time_taken_minutes*60); if ($calculated_time_taken_seconds<10) $calculated_time_taken_seconds = "0".$calculated_time_taken_seconds; ?>
. Dit is een score van jou! Klik hier voor al jouw topscores Klik hier voor alle topscores van <? echo $name; ?> % in :
Hoogste scores allertijden
'' ORDER BY uq.calculated_percentage_correct DESC, uq.calculated_time_taken LIMIT 50") or die (mysql_error()); $score_result = mysql_query("SELECT u.USR_id, u.name, hs.percentage as calculated_percentage_correct, hs.time_taken as calculated_time_taken FROM user_highscores hs INNER JOIN users u ON hs.USR_id=u.USR_id WHERE hs.QIZ_id=$qiz_id AND u.name<>'' ORDER BY rank LIMIT 50") or die (mysql_error()); $score_counter = 1; while ($row = mysql_fetch_array($score_result)) { $score_user = $row[USR_id]; $name = $row[name]; $calculated_percentage_correct = $row[calculated_percentage_correct]; $calculated_time_taken = $row[calculated_time_taken]; $calculated_time_taken_minutes = floor($calculated_time_taken/60); $calculated_time_taken_seconds = $calculated_time_taken - ($calculated_time_taken_minutes*60); if ($calculated_time_taken_seconds<10) $calculated_time_taken_seconds = "0".$calculated_time_taken_seconds; ?>
. Dit is een score van jou! Klik hier voor al jouw topscores Klik hier voor alle topscores van <? echo $name; ?> % in :
0) { $question_text = stripslashes(mysql_result($question_result, 0, 'question_text')); if ($cut_off_at>0) { if (strlen($question_text)>$cut_off_at) $question_text = substr($question_text,0,$cut_off_at)."..."; } } } return $question_text; } function getQuestionPicture($qtn_id) { // geeft het plaatje terug bij een vraag $question_picture = ""; $question_result = mysql_query("SELECT question_picture FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $question_picture = mysql_result($question_result, 0, 'question_picture'); return $question_picture; } function getQuestionCorrectOTNid($qtn_id) { // geeft het correct antwoord terug bij een vraag $correct_otn_id = ""; $question_result = mysql_query("SELECT correct_OTN_id FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $correct_otn_id = mysql_result($question_result, 0, 'correct_OTN_id'); return $correct_otn_id; } function getQuestionPickRandomOptions($qtn_id) { // geeft terug of er bij een vraag willekeurige opties gekozen moeten worden $pick_random_options = ""; $question_result = mysql_query("SELECT pick_random_options FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $pick_random_options = mysql_result($question_result, 0, 'pick_random_options'); return $pick_random_options; } function getQuestionPickRandomOptionsCount($qtn_id) { // geeft terug hoeveel willekeurige opties er gekozen moeten worden bij een vraag $pick_random_options_count = 4; $question_result = mysql_query("SELECT pick_random_options_count FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $pick_random_options_count = mysql_result($question_result, 0, 'pick_random_options_count'); return $pick_random_options_count; } function getQuestionShuffleOptions($qtn_id) { // geeft terug of bij een vraag de opties geshuffled moeten worden $shuffle_options = 1; $question_result = mysql_query("SELECT shuffle_options FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $shuffle_options = mysql_result($question_result, 0, 'shuffle_options'); if ($shuffle_options==1) { $shuffle_options = true; } else { $shuffle_options = false; } return $shuffle_options; } function getQuestionUseOptionLetters($qtn_id) { // geeft terug of bij een vraag de opties geshuffled moeten worden $use_option_letters = 1; $question_result = mysql_query("SELECT use_option_letters FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $use_option_letters = mysql_result($question_result, 0, 'use_option_letters'); if ($use_option_letters==1) { $use_option_letters = true; } else { $use_option_letters = false; } return $use_option_letters; } function getQuestionQuiz($qtn_id) { // geeft de quiz terug bij een vraag $qiz_id = ""; $question_result = mysql_query("SELECT QIZ_id FROM questions WHERE QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($question_result) > 0) $qiz_id = mysql_result($question_result, 0, 'QIZ_id'); return $qiz_id; } // ##################################### opties ################################ function getOptionsList($qtn_id,$exclude_otn_id) { // geeft een lijst terug met opties $option_result = mysql_query("SELECT OTN_id FROM options WHERE QTN_id=".$qtn_id." AND OTN_id <> $exclude_otn_id") or die (mysql_error()); $option_counter = 0; while ($row = mysql_fetch_array($option_result)) { $option_list[$option_counter] = $row[OTN_id]; $option_counter++; } return $option_list; } function getQuestionOptionsList($qtn_id) { // geeft een lijstje met opties terug voor bij een vraag global $debug; $shuffle_options = getQuestionShuffleOptions($qtn_id); if ($shuffle_options) { // opties shuffelen $correct_otn_id = getQuestionCorrectOTNid($qtn_id); if ($debug) echo "correct: $correct_otn_id
"; $options_list = getOptionsList($qtn_id,$correct_otn_id); if ($debug) { print_r($options_list); echo "

"; } shuffle($options_list); if ($debug) { print_r($options_list); echo "

"; } $pick_random_options = getQuestionPickRandomOptions($qtn_id); $pick_random_options_count = getQuestionPickRandomOptionsCount($qtn_id); if ($pick_random_options) { $new_options_list[0] = $correct_otn_id; for ($teller=1;$teller<$pick_random_options_count;$teller++) { $new_options_list[$teller] = $options_list[$teller-1]; } } else { $new_options_list[0] = $correct_otn_id; for ($teller=1;$teller<=count($options_list);$teller++) { $new_options_list[$teller] = $options_list[$teller-1]; } } if ($debug) { print_r($new_options_list); echo "

"; } shuffle($new_options_list); if ($debug) { print_r($new_options_list); echo "

"; } } else { // opties niet shuffelen $new_options_list = getOptionsList($qtn_id,0); if ($debug) { print_r($new_options_list); echo "

"; } } return $new_options_list; } function getOptionText($otn_id,$cut_off_at) { // geeft de tekst terug voor een optie // wanneer cut_off_at groter is dan 0, dan wordt de string op die positie afgebroken $option_text = "[[geen]]"; if ($otn_id!="") { $option_result = mysql_query("SELECT option_text FROM options WHERE OTN_id=$otn_id") or die (mysql_error()); if (mysql_num_rows($option_result) > 0) { $option_text = stripslashes(mysql_result($option_result, 0, 'option_text')); if ($cut_off_at>0) { if (strlen($option_text)>$cut_off_at) $option_text = substr($option_text,0,$cur_off_at)."..."; } } } return $option_text; } function getOptionPicture($otn_id) { // geeft het plaatje terug bij eenoptie $option_picture = ""; $option_result = mysql_query("SELECT option_picture FROM options WHERE OTN_id=$otn_id") or die (mysql_error()); if (mysql_num_rows($option_result) > 0) $option_picture = mysql_result($option_result, 0, 'option_picture'); return $option_picture; } ?>
"; } // toevoegen gebruikersquiz $timestamp_started = date("Y-m-j H:i:s",mktime(date("H"),date("i"),date("s"),date("m"),date("j"),date("Y"))); mysql_query("INSERT INTO user_quizzes (USR_id,QIZ_id,timestamp_started) VALUES ($usr_id,$qiz_id,'$timestamp_started')") or die (mysql_error()); $uqz_id = mysql_insert_id(); $_SESSION['uqz_id'] = $uqz_id; // eventueel vragen huzzelen if ($shuffle_questions || $quiz_pick_random_questions) { shuffle($all_questions_list); if ($debug) { print_r($all_questions_list); echo "

"; } } // door de vragen in de lijst heen lopen tot het aantal vragen bereikt is for ($teller=0;$teller < $quiz_nr_of_questions;$teller++) { if ($teller < count($all_questions_list)) { $qtn_id = $all_questions_list[$teller]; $sequence = $teller + 1; mysql_query("INSERT INTO user_quiz_answers (UQZ_id,QTN_id,sequence) VALUES ($uqz_id,$qtn_id,$sequence)") or die (mysql_error()); } } } function clearOlderUserQuizzesNotCompleted() { // verwijdert gebruikeresquizzes en vragen die al 2 dagen niet gecomplete zijn $this_month = date("n"); $this_day = date("j")-1; mysql_query("DELETE FROM user_quizzes WHERE completed=0 AND (Month(timestamp_started)<>$this_month OR (Month(timestamp_started)=$this_month AND Day(timestamp_started)<$this_day))") or die (mysql_error()); mysql_query("DELETE FROM user_quiz_answers WHERE UQZ_id NOT IN (SELECT UQZ_id FROM user_quizzes)") or die (mysql_error()); } function getNextUserQuizQuestion($uqz_id) { // geeft de eerstvolgende vraag van een gebruikersquiz terug die nog niet beantwoord is $qtn_id = ""; $quiz_result = mysql_query("SELECT QTN_id FROM user_quiz_answers WHERE UQZ_id=$uqz_id AND OTN_id=0 ORDER BY sequence LIMIT 1") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $qtn_id = mysql_result($quiz_result, 0, 'QTN_id'); return $qtn_id; } function getUserQuizQuiz($uqz_id) { // geeft de quiz terug van een gebruikersquiz $qiz_id = 0; $quiz_result = mysql_query("SELECT QIZ_id FROM user_quizzes WHERE UQZ_id=$uqz_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $qiz_id = mysql_result($quiz_result, 0, 'QIZ_id'); return $qiz_id; } function displayUserQuizQuestion() { // geeft een quizvraag weer voor een gebruikersquiz global $debug; global $question_image_location; $usr_id = addslashes($_SESSION['usr_id']); $uqz_id = addslashes($_SESSION['uqz_id']); $qiz_id = getUserQuizQuiz($uqz_id); $quiz_name = getQuizName($qiz_id); // eerst bepalen welke vraag er getoond moet worden $qtn_id = getNextUserQuizQuestion($uqz_id); if ($debug) echo "vraag qtn_id: $qtn_id
"; // ophalen aantal vragen $quiz_nr_of_questions = getQuizNrOfQuestions($qiz_id); // ophalen huidige vraag nr $question_sequence = getUserQuizAnswerSequence($uqz_id,$qtn_id); ?> "; echo "\"".$question_text."\""; echo ""; ?> 0) { ?>
Quiz: Vraag /
0) { $score[calculated_time_taken] = mysql_result($userquiz_result, 0, 'calculated_time_taken'); $score[calculated_nr_of_questions] = mysql_result($userquiz_result, 0, 'calculated_nr_of_questions'); $score[calculated_nr_of_answers_correct] = mysql_result($userquiz_result, 0, 'calculated_nr_of_answers_correct'); $score[calculated_percentage_correct] = mysql_result($userquiz_result, 0, 'calculated_percentage_correct'); } return $score; } // ################################## quiz antwoorden ###################################3 function getUserQuizAnswerSequence($uqz_id,$qtn_id) { // geeft het volgnummer van een quizvraag terug $sequence = 0; $quiz_result = mysql_query("SELECT sequence FROM user_quiz_answers WHERE UQZ_id=$uqz_id AND QTN_id=$qtn_id") or die (mysql_error()); if (mysql_num_rows($quiz_result) > 0) $sequence = mysql_result($quiz_result, 0, 'sequence'); return $sequence; } function finishUserQuiz() { // verwerken eindresultaten na afloop van quiz global $debug; $uqz_id = addslashes($_SESSION['uqz_id']); $timestamp_ended = mktime(date("H"),date("i"),date("s"),date("m"),date("j"),date("Y")); $userquiz_result = mysql_query("SELECT timestamp_started FROM user_quizzes WHERE UQZ_id=$uqz_id") or die (mysql_error()); if (mysql_num_rows($userquiz_result) > 0) { $timestamp_started = strtotime(mysql_result($userquiz_result, 0, 'timestamp_started')); if ($debug) echo "start: ".$timestamp_started."
"; if ($debug) echo "eind: ".$timestamp_ended."
"; $calculated_time_taken = $timestamp_ended - $timestamp_started; if ($debug) echo "tijd: ".$calculated_time_taken."
"; $userquizanswers_result = mysql_query("SELECT Sum(calculated_correct) as correct, Count(QTN_id) as total FROM user_quiz_answers WHERE UQZ_id=$uqz_id") or die (mysql_error()); if (mysql_num_rows($userquizanswers_result) > 0) { $calculated_nr_of_questions = mysql_result($userquizanswers_result, 0, 'total'); $calculated_nr_of_answers_correct = mysql_result($userquizanswers_result, 0, 'correct'); $calculated_percentage_correct = 0; if ($calculated_nr_of_questions>0) $calculated_percentage_correct = round(($calculated_nr_of_answers_correct / $calculated_nr_of_questions)*100); if ($debug) echo "calculated_nr_of_questions: ".$calculated_nr_of_questions."
"; if ($debug) echo "calculated_nr_of_answers_correct: ".$calculated_nr_of_answers_correct."
"; mysql_query("UPDATE user_quizzes SET timestamp_ended='$timestamp_ended', calculated_time_taken=$calculated_time_taken, completed=1, calculated_nr_of_questions=$calculated_nr_of_questions, calculated_nr_of_answers_correct=$calculated_nr_of_answers_correct, calculated_percentage_correct=$calculated_percentage_correct WHERE UQZ_id=$uqz_id") or die (mysql_error()); $usr_id = addslashes($_SESSION['usr_id']); $qiz_id = getUserQuizQuiz($uqz_id); updateUserHighScore($usr_id,$qiz_id); } } } function getUserAnswersList($uqz_id) { // geeft een lijstje terug met de antwoorden van een gebruiker op een quiz $answer_result = mysql_query("SELECT * FROM user_quiz_answers WHERE UQZ_id=".$uqz_id." ORDER BY sequence") or die (mysql_error()); $answer_counter = 0; while ($row = mysql_fetch_array($answer_result)) { $answer_list[$answer_counter][QTN_id] = $row[QTN_id]; $answer_list[$answer_counter][OTN_id] = $row[OTN_id]; $answer_counter++; } return $answer_list; } function displayUserQuizFinish() { // geeft de resultaatpagina weer na afloop van een quiz $usr_id = addslashes($_SESSION['usr_id']); $uqz_id = addslashes($_SESSION['uqz_id']); $qiz_id = getUserQuizQuiz($uqz_id); $quiz_name = getQuizName($qiz_id); $quiz_pick_random_questions = getQuizPickRandomQuestions($qiz_id); $userquiz_score = getUserQuizScore($uqz_id); $calculated_time_taken = $userquiz_score[calculated_time_taken]; $calculated_time_taken_minutes = floor($calculated_time_taken/60); $calculated_time_taken_seconds = $calculated_time_taken - ($calculated_time_taken_minutes*60); ?>
Jouw score: / (%)
Jouw tijd: minuten en seconden
Vul je naam in om aan de topscorelijst toegevoegd te worden.
Jouw naam:
Je score is toegevoegd aan de topscorelijst onder de naam ''.
Klik hier om naar de topscorelijst toe te gaan.
0) { $column_counter = 0; ?> "; } echo ""; $column_counter++; if ($column_counter==3) { echo ""; $column_counter=0; } } if ($column_counter>0) { for ($teller=$column_counter;$teller<3;$teller++) { echo ""; } } ?>
"; displayUserQuizAnswer($answer_counter+1,$answers_list[$answer_counter][QTN_id],$answers_list[$answer_counter][OTN_id]); echo "
Klik hier om de quiz opnieuw te starten
Jouw Top 10:
% in
1) { ?>
Jouw Gemiddelde:
% in
Vraag :
Vraag: <? echo $question_nr; ?>
","",$name); mysql_query("UPDATE users SET name='$name' WHERE USR_id=$usr_id") or die (mysql_error()); ?>
Je score is opgeslagen in de topscorelijst.


Klik hier om te proberen je score op deze quiz te verbeteren.

Klik hier om de topscorelijst te bekijken.
0) { $category_name = stripslashes(mysql_result($category_result, 0, 'name')); } } return $category_name; } function getMainCategoryTagDescription($mce_id) { // geeft de tag_description terug van een hoofdcategorie global $website_description; $tag_description = $website_description; if ($mce_id!="") { $category_result = mysql_query("SELECT tag_description FROM main_categories WHERE MCE_id=$mce_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $tag_description = stripslashes(mysql_result($category_result, 0, 'tag_description')); } } return $tag_description; } function getMainCategoryTagKeywords($mce_id) { // geeft de tag_keywords terug van een hoofdcategorie global $website_keywords; $tag_keywords = $website_keywords; if ($mce_id!="") { $category_result = mysql_query("SELECT tag_keywords FROM main_categories WHERE MCE_id=$mce_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $tag_keywords = stripslashes(mysql_result($category_result, 0, 'tag_keywords')); } } return $tag_keywords; } function getMainCategoryDescription($mce_id) { // geeft de omschrijving terug van een hoofdcategorie $category_description = ""; if ($mce_id!="") { $category_result = mysql_query("SELECT description FROM main_categories WHERE MCE_id=$mce_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $category_description = stripslashes(mysql_result($category_result, 0, 'description')); } } return $category_description; } function getMainCategoryUrl($mce_id) { // geeft de url terug waarop de hoofdcategorie te vinden is global $use_name_urls; if (!$use_name_urls) { $maincat_url = "hoofdcategorie.php?mce_id=".$mce_id; } else { $maincat_url = getMainCategoryName($mce_id); $maincat_url = str_replace(" ","_",$maincat_url); $maincat_url = str_replace("/","",$maincat_url); $maincat_url = str_replace("'","",$maincat_url); $maincat_url = str_replace("(","",$maincat_url); $maincat_url = str_replace(")","",$maincat_url); $maincat_url = str_replace("&","en",$maincat_url); $maincat_url = str_replace("!","",$maincat_url); $maincat_url = urlencode(trim(strToLower($maincat_url))); $maincat_url .= "_m-".$mce_id.".html"; } return $maincat_url; } ?> 0) { $category_name = stripslashes(mysql_result($category_result, 0, 'name')); } } return $category_name; } function getSubCategoryTagDescription($sce_id) { // geeft de tag_description terug van een subcategorie global $website_description; $tag_description = $website_description; if ($sce_id!="") { $category_result = mysql_query("SELECT tag_description FROM sub_categories WHERE SCE_id=$sce_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $tag_description = stripslashes(mysql_result($category_result, 0, 'tag_description')); } } return $tag_description; } function getSubCategoryTagKeywords($sce_id) { // geeft de tag_keywords terug van een subcategorie global $website_keywords; $tag_keywords = $website_keywords; if ($sce_id!="") { $category_result = mysql_query("SELECT tag_keywords FROM sub_categories WHERE SCE_id=$sce_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $tag_keywords = stripslashes(mysql_result($category_result, 0, 'tag_keywords')); } } return $tag_keywords; } function getSubCategoryUrl($sce_id) { // geeft de url terug waarop de subcategorie te vinden is global $use_name_urls; if (!$use_name_urls) { $subcat_url = "subcategorie.php?sce_id=".$sce_id; } else { $mce_id = getMainCategoryFromSubCategory($sce_id); $subcat_url = getMainCategoryName($mce_id)." ".getSubCategoryName($sce_id); $subcat_url = str_replace(" ","_",$subcat_url); $subcat_url = str_replace("/","",$subcat_url); $subcat_url = str_replace("'","",$subcat_url); $subcat_url = str_replace("(","",$subcat_url); $subcat_url = str_replace(")","",$subcat_url); $subcat_url = str_replace("&","en",$subcat_url); $subcat_url = str_replace("!","",$subcat_url); $subcat_url = urlencode(trim(strToLower($subcat_url))); $subcat_url .= "_s-".$sce_id.".html"; } return $subcat_url; } function getSubCategoryDescription($sce_id) { // geeft de omschrijving terug van een subcategorie $category_description = ""; if ($sce_id!="") { $category_result = mysql_query("SELECT description FROM sub_categories WHERE SCE_id=$sce_id") or die (mysql_error()); if (mysql_num_rows($category_result) > 0) { $category_description = stripslashes(mysql_result($category_result, 0, 'description')); } } return $category_description; } function getMainCategoryFromSubCategory($sce_id) { // geeft de hoofdcategorie terug voor een subcategorie $main_category_result = mysql_query("SELECT MCE_id FROM sub_categories WHERE SCE_id=$sce_id") or die (mysql_error()); $mce_id = ""; if (mysql_num_rows($main_category_result) > 0) $mce_id = mysql_result($main_category_result, 0, 'MCE_id'); return $mce_id; } ?> 0) { ?>
"; echo ""; echo ""; } ?>
"; echo ""; echo $website_name; echo ""; echo "
0) { // user gevonden $set_usr_id = mysql_result($user_result, 0, 'USR_id'); mysql_query("UPDATE users SET last_seen='$last_seen' WHERE USR_id=$set_usr_id") or die (mysql_error()); } else { // user niet gevonden, inserten in database en cookie plaatsen $date_created = date("Y-m-j",mktime(date("H"),date("i"),date("s"),date("m"),date("j"),date("Y"))); mysql_query("INSERT INTO users (ip_address,date_created,last_seen) VALUES ('$ip_address','$date_created','$last_seen')") or die (mysql_error()); $set_usr_id = mysql_insert_id(); setcookie("usr_id", $set_usr_id, time()+321408000); } $_SESSION['usr_id'] = $set_usr_id; } if ($debug) echo $_SESSION['usr_id']; function getUserName($usr_id) { // geeft de naam van een gebruiker terug $user_name = ""; $user_result = mysql_query("SELECT name FROM users WHERE USR_id=$usr_id") or die (mysql_error()); if (mysql_num_rows($user_result) > 0) $user_name = stripslashes(mysql_result($user_result, 0, 'name')); return $user_name; } function clearOlderUsersNotActive() { // ruimt oude niet active gebruikers op die nog geen quizzes hebben gemaakt $mark_date = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-3,date("Y"))); mysql_query("DELETE FROM users WHERE (name is Null OR name='') AND last_seen<'$mark_date' AND USR_id NOT IN (SELECT USR_id FROM user_quizzes WHERE completed=1)") or die (mysql_error()); // opruimen oude topscores van verwijderde gebruikers mysql_query("DELETE FROM user_highscores WHERE USR_id NOT IN (SELECT USR_id FROM users)") or die (mysql_error()); } // ################################### highscores ####################################### function updateUserHighScore($usr_id,$qiz_id) { // update de highscore op een quiz voor een gebruiker $highscore_result = mysql_query("SELECT calculated_time_taken, calculated_percentage_correct FROM user_quizzes WHERE USR_id=$usr_id AND QIZ_id=$qiz_id AND completed=1 ORDER BY calculated_percentage_correct DESC, calculated_time_taken LIMIT 1") or die (mysql_error()); if (mysql_num_rows($highscore_result) > 0) { $time_taken = stripslashes(mysql_result($highscore_result, 0, 'calculated_time_taken')); $percentage = stripslashes(mysql_result($highscore_result, 0, 'calculated_percentage_correct')); mysql_query("DELETE FROM user_highscores WHERE USR_id=$usr_id AND QIZ_id=$qiz_id") or die (mysql_error()); mysql_query("INSERT INTO user_highscores (USR_id,QIZ_id,percentage,time_taken) VALUES ($usr_id,$qiz_id,$percentage,$time_taken)") or die (mysql_error()); } // updaten ranks $rank = 1; $score_result = mysql_query("SELECT hs.UHS_id FROM user_highscores hs INNER JOIN users u ON hs.USR_id=u.USR_id WHERE hs.QIZ_id=$qiz_id AND u.name<>'' ORDER BY hs.percentage DESC, hs.time_taken, hs.UHS_id DESC") or die (mysql_error()); while ($row = mysql_fetch_array($score_result)) { $uhs_id = $row[UHS_id]; mysql_query("UPDATE user_highscores SET rank=$rank WHERE UHS_id=$uhs_id") or die (mysql_error()); $rank++; } } function getUserHighScoresList($usr_id) { // geeft een lijst terug met topscores van een gebruiker $scores_result = mysql_query("SELECT * FROM user_highscores WHERE USR_id=$usr_id ORDER BY rank") or die (mysql_error()); $scores_counter = 0; while ($row = mysql_fetch_array($scores_result)) { $scores_list[$scores_counter][QIZ_id] = $row[QIZ_id]; $scores_list[$scores_counter][percentage] = $row[percentage]; $scores_list[$scores_counter][time_taken] = $row[time_taken]; $scores_list[$scores_counter][rank] = $row[rank]; $scores_counter++; } return $scores_list; } function getUserQuizWithNoScoreList($usr_id) { // geeft een lijst terug met quizzes waarvoor een gebruiker nog geen topscore heeft $quiz_result = mysql_query("SELECT QIZ_id FROM quizzes WHERE active=1 AND deleted=0 AND QIZ_id NOT IN (SELECT QIZ_id FROM user_highscores WHERE USR_id=$usr_id)") or die (mysql_error()); $quiz_counter = 0; while ($row = mysql_fetch_array($quiz_result)) { $quizzes_list[$quiz_counter] = $row[QIZ_id]; $quiz_counter++; } return $quizzes_list; } ?> <? echo $website_title; ?> - <? echo $page_title; ?>
 
Klik hier

Delen op Facebook
Hoogste scores vandaag
'' ORDER BY uq.calculated_percentage_correct DESC, uq.calculated_time_taken LIMIT 5") or die (mysql_error()); if (mysql_num_rows($score_result) < 3) $score_result = mysql_query("SELECT u.USR_id, u.name, uq.calculated_percentage_correct, uq.calculated_time_taken FROM user_quizzes uq INNER JOIN users u ON uq.USR_id=u.USR_id WHERE uq.QIZ_id=$qiz_id AND uq.completed=1 AND (Year(uq.timestamp_started)=$this_year AND Month(uq.timestamp_started)=$this_month AND Day(uq.timestamp_started)>($this_day-2)) AND u.name<>'' ORDER BY uq.calculated_percentage_correct DESC, uq.calculated_time_taken LIMIT 5") or die (mysql_error()); $score_counter = 1; while ($row = mysql_fetch_array($score_result)) { $score_user = $row[USR_id]; $name = $row[name]; $calculated_percentage_correct = $row[calculated_percentage_correct]; $calculated_time_taken = $row[calculated_time_taken]; $calculated_time_taken_minutes = floor($calculated_time_taken/60); $calculated_time_taken_seconds = $calculated_time_taken - ($calculated_time_taken_minutes*60); if ($calculated_time_taken_seconds<10) $calculated_time_taken_seconds = "0".$calculated_time_taken_seconds; ?>
. Dit is een score van jou! Klik hier voor al jouw topscores Klik hier voor alle topscores van <? echo $name; ?> % in :
Hoogste scores allertijden
'' ORDER BY uq.calculated_percentage_correct DESC, uq.calculated_time_taken LIMIT 5") or die (mysql_error()); $score_result = mysql_query("SELECT u.USR_id, u.name, hs.percentage as percentage_correct, hs.time_taken as calculated_time_taken FROM user_highscores hs INNER JOIN users u ON hs.USR_id=u.USR_id WHERE hs.QIZ_id=$qiz_id AND u.name<>'' ORDER BY rank LIMIT 5") or die (mysql_error()); $score_counter = 1; while ($row = mysql_fetch_array($score_result)) { $score_user = $row[USR_id]; $name = $row[name]; $calculated_percentage_correct = $row[percentage_correct]; $calculated_time_taken = $row[calculated_time_taken]; $calculated_time_taken_minutes = floor($calculated_time_taken/60); $calculated_time_taken_seconds = $calculated_time_taken - ($calculated_time_taken_minutes*60); if ($calculated_time_taken_seconds<10) $calculated_time_taken_seconds = "0".$calculated_time_taken_seconds; ?>
. Dit is een score van jou! Klik hier voor al jouw topscores Klik hier voor alle topscores van <? echo $name; ?> % in :
Topscores