PHP Code:
define('IN_PHPBB', true);
define('SHOW_ONLINE', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'config.'.$phpEx);
include($phpbb_root_path . '/includes/constants.'.$phpEx);
include($phpbb_root_path . 'common.'.$phpEx);
$numer = $board_config['questions_quiz'] + 1;
$contents="";
for ($xx=0; $xx < $numer; $xx++)
$user_answer = $user_answer . "" . $_POST[$xx];
if(!$user_answer)
{
message_die(GENERAL_ERROR, 'Please fill in all answers!');
}
$matchw = $user_answer;
// Match user answer with real answer
$smatch = "SELECT *
FROM phpbbtestboard_quiz_text
WHERE game_id = 1";
$yups = mysql_query($smatch);
$ans = '';
while($row = mysql_fetch_array($yups))
{
$ans .= $row['answer'];
$t3 = $ans;
$t1 = $matchw;
$check_for_match1 = strcmp($t1, $t3); // returns 0, and therefore matches
//$check_for_match2 = strcmp($var1, $var3); // doesn't return 1, and therefore doesn't match
if ($check_for_match1 == 0)
{
//
message_die(GENERAL_MESSAGE, 'Congratulations, you have scored 100%!');
}
if ($check_for_match1 == -1)
{
message_die(GENERAL_MESSAGE, 'You have incorrect answers! Better luck next time!');
}
}
That's quizzer.php the file I want to echo the $page in.
PHP Code:
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
$page_title = $lang['Quiz_page'];
//include($phpbb_root_path . 'includes/page_header.'.$phpEx);
//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_PROFILE);
init_userprefs($userdata);
//
// End session management
//
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
if(isset($HTTP_GET_VARS['viewquiz']))
{
$page = intval($HTTP_GET_VARS['viewquiz']);
}
// What's THIS one called?
// You'd like to know wouldn't ya
if(isset($page))
{
$title = "SELECT quiz_name
FROM " . QUIZ_TABLE . "
WHERE quiz_id = $page";
if ( !$result = $db->sql_query($title) )
{
message_die(GENERAL_ERROR, 'Cannot find quiz name', '', __LINE__, __FILE__, $title);
}
while ($row = mysql_fetch_assoc($result))
{
$quiz_title = $row['quiz_name'];
$quiz_title_disp = "<a href='./viewquestions.$phpEx?viewquiz=$page'>$quiz_title</a><br>";
}
$sql = "SELECT * FROM phpbbtestboard_quiz_text
WHERE game_id = $page
LIMIT " . $board_config['questions_quiz'] . "";
$result = $db->sql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$q = $row['question'];
$f1 = $row['fake1'];
$f2 = $row['fake2'];
$f3 = $row['fake3'];
$a = $row['answer'];
$inp = $row['quiz_id'];
{
$template->assign_block_vars('quizrow', array(
'ACTQ' => $q,
'ACTA' => $a,
'FO' =>$f1,
'FT' => $f2,
'FTH' => $f3,
'INPUT' => $inp)
);
}
}
}
else
{
print "No quiz has been specified";
}
$template->assign_vars(array(
'QUESTION' => $lang['Question'],
'ANSWER' => $lang['Answer'],
'QUIZ_HEADER' => $quiz_title_disp)
);
// So sad, St Kilda lost :'(
// Hope my coding stays quality :P
$template->set_filenames(array('body' => 'viewquiz_body.tpl'));
//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
testviewq.php
The page where $page lies.
PHP Code:
define('IN_PHPBB', true);
define('SHOW_ONLINE', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);
include($phpbb_root_path . '/includes/constants.'.$phpEx);
$userdata = session_pagestart($user_ip, PAGE_PROFILE);
init_userprefs($userdata);
$template->set_filenames(array('body' => 'quiz_body.tpl'));
$page_title = $lang['Quiz_page'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
// Time to get the authors :D
$aut = "SELECT q.*, u.*
FROM " . QUIZ_TABLE . " AS q, " . USERS_TABLE . " AS u
WHERE q.quiz_author = u.user_id";
if ( !$result = $db->sql_query($aut) )
{
message_die(GENERAL_ERROR, 'No author data found', '', __LINE__, __FILE__, $aut);
}
while ($row = mysql_fetch_assoc($result))
{
$quiz_aut = $row['username'];
$quiz_userid = $row['user_id'];
$quizauto = "<a href='./profile.php?mode=viewprofile&u=$quiz_userid'>$quiz_aut</a>";
$qn = "SELECT quiz_id
FROM " . QUIZ_TABLE . "
ORDER BY quiz_id DESC
LIMIT 1";
// ok, we're getting the total quiz # now...
// i'm so excited, i cant believe the index is nearly done.. =P
if ( !$result = $db->sql_query($qn) )
{
message_die(GENERAL_ERROR, 'No quizzes found!', '', __LINE__, __FILE__, $sql);
}
while( $row = $db->sql_fetchrow($result))
{
$quiz_number_id = $row['quiz_id'];
}
$sql = "select * from " . QUIZ_TABLE . " WHERE quiz_enabled = '1'";
$query = $db->sql_query($sql)
or die("error");
while ($row = mysql_fetch_assoc($query)){
$quiz_id = $row['quiz_id'];
$quiz_name = $row['quiz_name'];
$quizo = "<a href='./testviewq.php?viewquiz=$quiz_id'>$quiz_name</a>";
$template->assign_vars(array(
'QUIZZIE' => $lang['Quizzie'],
'QUIZZIO' => $lang['Quizzio'],
'QUIZ_NUMBER' => sprintf($lang['Quiz_number'], $quiz_number_id))
);
$template->assign_block_vars('quizrow', array(
'QUIZ_TITLE' => $quizo,
'QUIZ_CREATOR' => $quizauto)
);
}
}
//
// Generate the page
//
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
quiz.php, where all the fun starts. lol
Bookmarks