Jump to content

Help pls. Getting the score


melo

Recommended Posts

I don't know what exactly the codes to be used in order to get the score of my quiz.  

Could someone help me on how will I be able to get its score and put it in a table.

I am new to php/programming so I dont know much about it and still getting confuse.

I already post this topic but I still can't get the answer. thanks

 

<?php
if (isset($_GET['id']))
{
	$quiz_id = $_GET['id'];
	$takeq = 'SELECT * FROM tblquiz WHERE QuizId="'.$quiz_id.'"';
	$takeg = mysql_query($takeq);
	$take = mysql_fetch_assoc($takeg);
	 
	?>
    
	<form method="post" action="index.php?id=<?php $quiz_id ?>#form">
	<table cellpadding="3" cellspacing="2" width="50%" bordercolor="#999999" style="margin-top:20px;" align="center">
    <tr>
		<th style="font-size:25px; background:#999;" colspan="8">Quiz (<?php echo $take['QuizTitle']; ?>)</th>
	</tr>
	<tr>
		<td width="100px" align="left" style="border:none;">Name : <?php echo $_SESSION['logged']['FirstName'].' '.$_SESSION['logged']['LastName'];  ?></td>
	</tr>
    <tr>
		<td width="100px" align="left" style="border:none;">Program/Section : <?php echo $_SESSION['logged']['SectionCode'];  ?></td>
	</tr>
    <tr>
		<td width="100px" align="left" style="border:none;">Quiz Item : <?php echo $take['Items']?> <hr /></td>
	</tr>
 
 
 <?php 
								  
	$quesq = "SELECT * FROM tblquestion_main WHERE QuizId = '".$quiz_id."'";
	$quesg = mysql_query($quesq);
	if($ques = mysql_fetch_array($quesg))
	{		
	while($ques = mysql_fetch_array($quesg)){
			$strQuery = "SELECT * FROM tblquestion_mc WHERE QuestionId = '{$ques['QuestionId']}'";
			$hQuery = mysql_query($strQuery);
			$arMChoices = mysql_fetch_array($hQuery);
			
		switch($ques['QuestionType'])
		{
		case 1:
			?> 
        <table border="1" cellpadding="2" cellspacing="2" width="500px" bordercolor="#999999" style="margin-top:20px;" align="center">
        <tr>
		<td width="100px" align="left" style="border:none;"> <b> Multiple Choice <br /> <pre> Direction:  </b> Choose the letter of the correct answer. </td>
		</tr>	 
    
        <tr>	
		<td width="100px" align="left" style="border:none;"> Question : <?php echo $ques['Question']; ?></td>
		</tr>
    	<tr>
		<td width="100px" align="left" style="border:none;"> A.  <?php echo $arMChoices['choice_a']; ?></td>
		</tr>    
   		<tr>
   		<td width="100px" align="left" style="border:none;"> B.  <?php echo $arMChoices['choice_b']; ?></td>
		</tr>
    	<tr>
    	<td width="100px" align="left" style="border:none;"> C.  <?php echo $arMChoices['choice_c']; ?></td>
		</tr>
    	<tr>
    	<td width="100px" align="left" style="border:none;"> D.  <?php echo $arMChoices['choice_d']; ?></td>
		</tr>
                <tr>
            	<td align="left" style="border:none;"> Answer:
             
			<select name="answer">
            <option>--Select Choices--</option>
				<option name ="answer <?php echo $ques['QuestionId']?>" value="A">A</option>
				<option name ="answer <?php echo $ques['QuestionId']?>" value="B">B</option>
                <option name ="answer <?php echo $ques['QuestionId']?>" value="C">C</option>
                <option name ="answer <?php echo $ques['QuestionId']?>" value="D">D</option>
			</select>
            </td>
        </tr>
          <?php
		  break;
		  case 2:
			?>        
            <tr>
			<td width="200px" align="left" style="border:none;"> <b> Identification  <br /> <pre> Direction:  </b> Write the correct answer. </td>
			</tr>
            <tr><td width="100px" align="left" style="border:none;">Question : <?php echo $ques['Question']; ?> </td></tr>
	 		<tr><td width="100px" align="left" style="border:none;">Answer :
			 <input type="text" name="answer <?php echo $ques['QuestionId']?>" style="width:210px; margin:0px;"/></td>
    		 </tr>
			 </td></tr>
             </form>
             
          <?php
		  break;
		  case 3:
			?>
           	<tr>
			<td width="100px" align="left" style="border:none;"> <b> True or False <br /> Direction:  </b> Write TRUE if the statement is correct otherwise write FALSE. </td>
			</tr>                 
            <tr><td width="100px" align="left" style="border:none;">Question : <?php echo $ques['Question']; ?> </td></tr>
	 		<tr><td align="left" style="border:none;">Answer :
			<select name="answer">
            	<option>--Select Choices--</option>
				<option name ="answer <?php echo $ques['QuestionId']?>" value="True" >True</option>
				<option name ="answer <?php echo $ques['QuestionId']?>" value="False">False</option></select></td>
    		</tr>
            </form>
		  <?php
			}
	}
}
?>  
        <tr>
        <td align="center" style="border:none;" colspan="2"><a href="index.php"><input type="submit" name="quizcheckSubmit" value="submit" onclick="return confirm('Are you sure you want to end the quiz?')" style="width:150px; height:30px;"/></a></td>
        </tr>
        </table>
        <?php		
}
		?>

 

 

 

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.