javascript – Displaying a status of completed after its usage for online examination. Display start and display completed after completion of exam-ThrowExceptions

Exception or error:

On purpose of preparing online exam I should display whether the exam is taken or not to user.
So, how to display my dummy button named completed after completing the exam.
but after taking the second test it is also showing the start button to completed exam instead of showing completed.

This is the code:

<?php
session_start();
extract($_POST);
extract($_GET);
extract($_SESSION);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Online Quiz - Quiz List</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="quiz.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<style type="text/css">
    #start{
        float: right;
        margin: 0 auto;
        padding:5px 10px;
        border: 2px solid black;
        background-color: white;
        font-size: 16px;
        cursor: pointer;
        border-color: #4CAF50;
        color: green;
        position:relative;
        display: inline-block;
    }
    #completed{
        float: right;
        margin: 0 auto;
        padding:5px 10px;
        border: 2px solid black;
        background-color: #4CAF50;
        font-size: 16px;
        cursor: pointer;
        border-color: #4CAF50;
        color: white;
        position:relative;
        display: inline-block;
    }
</style>
</head>
<body>
<?php
include("header.php");
include("database.php");
echo "<h1 class='text-center bg-danger'>Select Subject to Give Quiz</h1>";
$rs=mysqli_query($con,"select * from mst_subject where sub_name='Quant'");
echo "<table class='table table-striped'>";
// Quant button
while($row=mysqli_fetch_row($rs))
{
    echo "<tr>
                <td align=left >
                <font size=4 style='padding-left:340px; margin:0 auto;'>$row[1]</font>";
                ?><?php
                if(($used_type==$row[1])||($used_type==$row[1]&&$time=='timeup'))
                {
                     echo "<input type='button' id='completed' value='Completed'/>";
                 }
                else {
                        echo "<a href=quiz.php?subid=$row[0]&type=$row[1]><input type='button' id='start' value='Start'/></a>";
                }
}

//Verbal Button
$rs=mysqli_query($con,"select * from mst_subject where sub_name='Verbal'");
while($row=mysqli_fetch_row($rs))
{
    echo "<tr>
                <td align=left >
                <font size=4 style='padding-left:340px; margin:0 auto;'>$row[1]</font>";
                ?><?php
                if(($used_type==$row[1])||($used_type==$row[1]&&$time=='timeup'))
                {
                     echo "<input type='button' id='completed' value='Completed'/>";
                 }
                else {
                        echo "<a href=quiz.php?subid=$row[0]&type=$row[1]><input type='button' id='start' value='Start'/></a>";
                }
}

//Reasoning Button
$rs=mysqli_query($con,"select * from mst_subject where sub_name='Reasoning'");
while($row=mysqli_fetch_row($rs))
{
    echo "<tr>
                <td align=left >
                <font size=4 style='padding-left:340px; margin:0 auto;'>$row[1]</font>";
                ?><?php
                if(($used_type==$row[1])||($used_type==$row[1]&&$time=='timeup'))
                {
                     echo "<input type='button' id='completed' value='Completed'/>";
                 }
                else {
                        echo "<a href=quiz.php?subid=$row[0]&type=$row[1]><input type='button' id='start' value='Start'/></a>";
                }
 }

//Programming Button
$rs=mysqli_query($con,"select * from mst_subject where sub_name='Programming'");
while($row=mysqli_fetch_row($rs))
{
    echo "<tr>
                <td align=left >
                <font size=4 style='padding-left:340px; margin:0 auto;'>$row[1]</font>";
                ?><?php
                if(($used_type==$row[1])||($used_type==$row[1]&&$time=='timeup'))
                {
                     echo "<input type='button' id='completed' value='Completed'/>";
                 }
                else {
                        echo "<a href=quiz.php?subid=$row[0]&type=$row[1]><input type='button' id='start' value='Start'/></a>";
                }
}
echo "</table>"
?>
</body>
</html>

here used_type variable is returned to this file after completion of exam(it contains data Quant, Verbal, Reasoning ,Programming) and time variable from the timer when its time is over it passes a string as a indication that the time is over and displays the completed button.

This picture is my view of selecting the exam where I have the trouble:

enter image description here

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *