Jump to content

quiz script integrated with an existing template


Hall of Famer

Recommended Posts

Well I generated a quiz script for my site, which uses a template with certain format. I cant get it to work though, since the quiz wouldnt fit in the desired position after adding the template codes. Do anyone of you know how to fix it? I have added a screenshot, a link to the quiz url and the entire php codes in this thread, please help...

 

Screenshot:

2ij0ldz.jpg

 

Url:

http://www.pokemansion.net/quiz2.php

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Well Pikachu2000 said I might need to post the entire php codes since people usually dont want to be bothered with downloading files, so here I am. Please help:

 

<?

// #########################################
// In this page you will find the code required to create multiple choice exams
// Copy this code and save it to a file name "whatever.php"
// The file name must finish with ".php"
// Save the file to a PHP unable server.
// Please consider adding a link to this service:
//      http://www.phptutorial.info/scripts/multiple_choice/
// #########################################


include("inc/functions.php");
include("inc/config.php");
include("inc/bbcode.php");

$themeurl = grabanysetting("themeurl");

// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************

$links = getlinks();

// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads = getads("any");

// **********************************************************************
// Grab any dynamic article content from the content table
// **********************************************************************


// Convert the BBCODE to HTML
$article_content = bbconvert($article_content);

// Convert line breaks to <br>
$article_content = nl2br($article_content);

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);

$template = replace(':ARTICLETITLE:',$article_title,$template);
$template = replace(':ARTICLECONTENT:',$article_content,$template);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

//Define our links
$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template = replace(':ADS:',$ads,$template);

//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);


echo $template;




$title = "Mysidia Quiz 1";
$address = "index.html";

$a = array(
1 => array(
   0 => "Who is the first member on Mysidia:",
   1 => "Hall of Famer",
   2 => "Dark Abyss",
   3 => "Akilina",
   4 => "Abrakadabra",
   5 => "Angela",
   6 => 3
),
2 => array(
   0 => "Which member has the highest number for the stats \'posts per day\' at the time I made this thread:",
   1 => "Hall of Famer",
   2 => "Dark Abyss",
   3 => "Pokemon_is_Awesome",
   4 => "Furankku",
   5 => "ArcanineOod",
   6 => 4
),
3 => array(
   0 => "Which active thread on Mysidia receives the greatest number of views:",
   1 => "Jordan ate Ozzy\'s hat. [DCC]",
   2 => "The \'Post a pic of yourself\' thread",
   3 => "The never ending, counting game!",
   4 => "The banned game",
   5 => "The daily chit-chat ",
   6 => 2
),
4 => array(
   0 => "Who is the top referrer on Mysidia:",
   1 => "Hall of Famer",
   2 => "Dark Abyss",
   3 => "Akilina",
   4 => "Angela",
   5 => "Tombi",
   6 => 2
),
5 => array(
   0 => "What is the difference between Head Admins and Staff Admins:",
   1 => "Head Admins have more forum permissions",
   2 => "Head Admins have more admincp permissions",
   3 => "Head Admins joined the forum earlier than Staff Admins",
   4 => "Head Admins are more active members than Staff Admins",
   5 => "Head Admins are forum founders, Staff Admins are forum admins",
   6 => 5
),
6 => array(
   0 => "Which user below was never an admin/mod on Mysidia and the three smaller old forums before:",
   1 => "Lynncreed",
   2 => "Hamako-chan",
   3 => "Frost",
   4 => "MissieMonster",
   5 => "Jordan",
   6 => 1
),
7 => array(
   0 => "Who was the most active members(based on postcount) in December 2009:",
   1 => "Pokemon_is_Awesome",
   2 => "Bub",
   3 => "Nesan",
   4 => "Dark Abyss",
   5 => "Zappyspiker",
   6 => 3
),
8 => array(
   0 => "How many forum staff members are female:",
   1 => "5",
   2 => "6",
   3 => "7",
   4 => "8",
   5 => "9",
   6 => 5
),
9 => array(
   0 => "Which user changes his/her usernames most frequently:",
   1 => "Abracadabra",
   2 => "Akilina",
   3 => "Dark Abyss",
   4 => "Saltare",
   5 => "The Hills",
   6 => 1
),
10 => array(
   0 => "Which user below receives the greatest number of VM from Hall of Famer:",
   1 => "Dark Abyss",
   2 => "Akilina",
   3 => "Angela",
   4 => "Arcanineood",
   5 => "Sophie",
   6 => 3
),
);

$max=10;

$question=$_POST["question"] ;

if ($_POST["Randon"]==0){
        srand((double)microtime()*1000000);
        $randval = rand(1,$max);
        $randval2 = $randval;
        }else{
        $randval=$_POST["Randon"];
        $randval2=$_POST["Randon"] + $question;
                if ($randval2>$max){
                $randval2=$randval2-$max;
                }
        }
        
$ok=$_POST["ok"] ;

if ($question==0){
        $question=0;
        $ok=0;
        $percentaje=0;
        }else{
        $percentaje= Round(100*$ok / $question);
        }
?>

<HTML><HEAD><TITLE>Multiple Choice Questions:  <? print $title; ?></TITLE>

<SCRIPT LANGUAGE='JavaScript'>
<!-- 
function Goahead (number){
        if (document.percentaje.response.value==0){
                if (number==<?php print $a[$randval2][6] ; ?>){
                        document.percentaje.response.value=1
                        document.percentaje.question.value++
                        document.percentaje.ok.value++
                }else{
                        document.percentaje.response.value=1
                        document.percentaje.question.value++
                }
        }
        if (number==<?php print $a[$randval2][6] ; ?>){
                document.question.response.value="Correct"
        }else{
                document.question.response.value="Incorrect"
        }
}
// -->
</SCRIPT>

</HEAD>
<BODY BGCOLOR=FFFFFF>

<CENTER>
<H1><? print "$title"; ?></H1>
<TABLE BORDER=0 CELLSPACING=5 WIDTH=500>

<?php if ($question<$max){ ?>

<TR><TD ALIGN=RIGHT>
<FORM METHOD=POST NAME="percentaje" ACTION="<?php print $URL; ?>">

<BR>Percentaje of correct responses: <?php print $percentaje; ?> %
<BR><input type=submit value="Next >>">
<input type=hidden name=response value=0>
<input type=hidden name=question value=<?php print $question; ?>>
<input type=hidden name=ok value=<?php print $ok; ?>>
<input type=hidden name=Randon value=<?php print $randval; ?>>
<br><?php print $question+1; ?> / <?php print $max; ?>
</FORM>
<HR>
</TD></TR>

<TR><TD>
<FORM METHOD=POST NAME="question" ACTION="">
<?php print "<b>".$a[$randval2][0]."</b>"; ?>

<BR>     <INPUT TYPE=radio NAME="option" VALUE="1"  onClick=" Goahead (1);"><?php print $a[$randval2][1] ; ?>
<BR>     <INPUT TYPE=radio NAME="option" VALUE="2"  onClick=" Goahead (2);"><?php print $a[$randval2][2] ; ?>
<? if ($a[$randval2][3]!=""){ ?>
<BR>     <INPUT TYPE=radio NAME="option" VALUE="3"  onClick=" Goahead (3);"><?php print $a[$randval2][3] ; } ?>
<? if ($a[$randval2][4]!=""){ ?>
<BR>     <INPUT TYPE=radio NAME="option" VALUE="4"  onClick=" Goahead (4);"><?php print $a[$randval2][4] ; } ?>
<? if ($a[$randval2][5]!=""){ ?>
<BR>     <INPUT TYPE=radio NAME="option" VALUE="5"  onClick=" Goahead (5);"><?php print $a[$randval2][5] ; } ?>
<BR>     <input type=text name=response size=8>


</FORM>

<?
}else{
?>
<TR><TD ALIGN=Center>
The Quiz has finished
<BR>Percentaje of correct responses: <?php print $percentaje ; ?> %
<p><A HREF="<? print $address; ?>">Home Page</a>

<? } ?>

</TD></TR>
</TABLE>

</CENTER>
</BODY>
</HTML>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.