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) { $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) { // 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_main; ?>
 
0) { $qiz_id = $new_quizzes_list[0]; $quiz_picture = getQuizPicture($qiz_id); $quiz_url = getQuizUrl($qiz_id); ?>
"; echo ""; echo ""; } ?>
"; displayNewQuizOption($quiz_name,$quiz_url,$quiz_picture); echo "
Delen op Facebook
0) { ?>
0) { $qiz_id = $quizzes_list[0]; $quiz_picture = getQuizPicture($qiz_id); $quiz_url = getQuizUrl($qiz_id); ?>
"; echo ""; echo ""; } ?>
"; displayPopularOption($maincat_counter,$quiz_name,$quiz_url,$quiz_picture); echo "
>> meer
0) { if ($first_cat) { $first_cat = false; } else { ?>