Exam system exam interface code

html code:

<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Online Test Page</title>
<style type="text/css">
    #maintable{
        font-family: "宋体";
        background-color: #D3D3D3;
        text-align: left;
        width: 95%;
        height: auto;
        vertical-align: middle;
    }
    .div-inline{
        display:inline;
        position: relative;
        top: 20%;
    }
</style>
<script type="text/javascript">
var maxtime = 3*60*60 //按秒计算,自己调整!时-h 分-'(min) 秒-"(s)
function CountDown(){
    if(maxtime>=0){
        hours = Math.floor(maxtime/60/60%24);
        minutes = Math.floor(maxtime/60%60);  
        seconds = Math.floor(maxtime%60);  
        msg = "Time remaining: "+hours+": "+minutes+":"+seconds;
        document.all["timer"].innerHTML = msg;
         if(maxtime == 5*60) alert('Attention, there are 5 minutes left!'); 
         --maxtime;
    }else {
        clearInterval(timer);  
        //alert("Time is up, it's over!");
        //window.location = "testLogin.jsp";//Relocation
        window.location.href = "<{$app}>/ceshi /Exam/result";//Jump, form data not submitted
        //var action = document.getElementById("form1").action;
        //document.forms[0].action = action;
        //document.forms[0].submit();
    }
}
timer = setInterval("CountDown()",1000);
</script>
</head>
<body style="background-color: #F5F5F5;font-family: '宋体';">
    <br><!--  style="border:1px solid #f00;"红色边框 style="border:1px solid #0ff;width: 800px;height: 28px;" -->
    <div style="width: 90%;height: 30px;border:1px solid #000;position: relative;left: 5%;" id="topdiv">
        <div class="div-inline" id="tester">测试工号:CS00351 <div class="div-inline" id="timer" style="color:red;">剩余时间:2:48:50</div></div>        
        <div class="div-inline" id="empty">
           
           
           
           
        </div>         </div>         </div>
        
    </div> 
    <div style="width: 90%;height: auto;border:1px solid #000;position: relative;left: 5%;" id="formdiv">
    <form id="form1" name="subform" action="<{$app}>/Exam/result" method="post">
        <input type="hidden" name="badgeNo" value="CS00351">
        <h2 align="center">在线测试</h2>
        <h3 align="right">(考试时间:180分钟    题型:多选题    满分:100分)</h3><hr>
        <h4>  多选题(错选、少选、多选不得分)</h4><hr>
        
            <h5>  1、testDS13</h5>
            <input type="checkbox" name="A219" value="A">  A testDScA13<br>
            <input type="checkbox" name="B219" value="B">  B testDScb13<br>
            <input type="checkbox" name="C219" value="C">  C testDScc13<br>
            <input type="checkbox" name="D219" value="D">  D testDScd13<hr>
        
            <h5>  2、testDS15</h5>
            <input type="checkbox" name="A221" value="A">  A testDScA15<br>
            <input type="checkbox" name="B221" value="B">  B testDScb15<br>
            <input type="checkbox" name="C221" value="C">  C testDScc15<br>
            <input type="checkbox" name="D221" value="D">  D testDScd15<hr>
        
            <h5>  3、testDS20</h5>
            <input type="checkbox" name="A226" value="A">  A testDScA20<br>
            <input type="checkbox" name="B226" value="B">  B testDScb20<br>
            <input type="checkbox" name="C226" value="C">  C testDScc20<br>
            <input type="checkbox" name="D226" value="D">  D testDScd20<hr>
        
            <h5>  4、testDS23</h5>
            <input type="checkbox" name="A229" value="A">  A testDScA23<br>
            <input type="checkbox" name="B229" value="B">  B testDScb23<br>
            <input type="checkbox" name="C229" value="C">  C testDScc23<br>
            <input type="checkbox" name="D229" value="D">  D testDScd23<hr>
        
            <h5>  5、testDS43</h5>
            <input type="checkbox" name="A249" value="A">  A testDScA43<br>
            <input type="checkbox" name="B249" value="B">  B testDScb43<br>
            <input type="checkbox" name="C249" value="C">  C testDScc43<br>
            <input type="checkbox" name="D249" value="D">  D testDScd43<hr>
        
            <h5>  6、testDS53</h5>
            <input type="checkbox" name="A259" value="A">  A testDScA53<br>
            <input type="checkbox" name="B259" value="B">  B testDScb53<br>
            <input type="checkbox" name="C259" value="C">  C testDScc53<br>
            <input type="checkbox" name="D259" value="D">  D testDScd53<hr>
        
            <h5>  7、testDS72</h5>
            <input type="checkbox" name="A278" value="A">  A testDScA72<br>
            <input type="checkbox" name="B278" value="B">  B testDScb72<br>
            <input type="checkbox" name="C278" value="C">  C testDScc72<br>
            <input type="checkbox" name="D278" value="D">  D testDScd72<hr>
        
            <h5>  8、testDS77</h5>
            <input type="checkbox" name="A283" value="A">  A testDScA77<br>
            <input type="checkbox" name="B283" value="B">  B testDScb77<br>
            <input type="checkbox" name="C283" value="C">  C testDScc77<br>
            <input type="checkbox" name="D283" value="D">  D testDScd77<hr>
        
            <h5>  9、testDS91</h5>
            <input type="checkbox" name="A297" value="A">  A testDScA91<br>
            <input type="checkbox" name="B297" value="B">  B testDScb91<br>
            <input type="checkbox" name="C297" value="C">  C testDScc91<br>
            <input type="checkbox" name="D297" value="D">  D testDScd91<hr>
        
            <h5>  10、testDS95</h5>
            <input type="checkbox" name="A301" value="A">  A testDScA95<br>
            <input type="checkbox" name="B301" value="B">  B testDScb95<br>
            <input type="checkbox" name="C301" value="C">  C testDScc95<br>
            <input type="checkbox" name="D301" value="D">  D testDScd95<hr>
        
            <h5>  11、testDS98</h5>
            <input type="checkbox" name="A304" value="A">  A testDScA98<br>
            <input type="checkbox" name="B304" value="B">  B testDScb98<br>
            <input type="checkbox" name="C304" value="C">  C testDScc98<br>
            <input type="checkbox" name="D304" value="D">  D testDScd98<hr>
        
            <h5>  12、testDS120</h5>
            <input type="checkbox" name="A326" value="A">  A testDScA120<br>
            <input type="checkbox" name="B326" value="B">  B testDScb120<br>
            <input type="checkbox" name="C326" value="C">  C testDScc120<br>
            <input type="checkbox" name="D326" value="D">  D testDScd120<hr>
        
            <h5>  13、testDS124</h5>
            <input type="checkbox" name="A330" value="A">  A testDScA124<br>
            <input type="checkbox" name="B330" value="B">  B testDScb124<br>
            <input type="checkbox" name="C330" value="C">  C testDScc124<br>
            <input type="checkbox" name="D330" value="D">  D testDScd124<hr>
        
            <h5>  14、testDS130</h5>
            <input type="checkbox" name="A336" value="A">  A testDScA130<br>
            <input type="checkbox" name="B336" value="B">  B testDScb130<br>
            <input type="checkbox" name="C336" value="C">  C testDScc130<br>
            <input type="checkbox" name="D336" value="D">  D testDScd130<hr>
        
            <h5>  15、testDS132</h5>
            <input type="checkbox" name="A338" value="A">  A testDScA132<br>
            <input type="checkbox" name="B338" value="B">  B testDScb132<br>
            <input type="checkbox" name="C338" value="C">  C testDScc132<br>
            <input type="checkbox" name="D338" value="D">  D testDScd132<hr>
        
            <h5>  16、testDS160</h5>
            <input type="checkbox" name="A366" value="A">  A testDScA160<br>
            <input type="checkbox" name="B366" value="B">  B testDScb160<br>
            <input type="checkbox" name="C366" value="C">  C testDScc160<br>
            <input type="checkbox" name="D366" value="D">  D testDScd160<hr>
        
            <h5>  17、testDS164</h5>
            <input type="checkbox" name="A370" value="A">  A testDScA164<br>
            <input type="checkbox" name="B370" value="B">  B testDScb164<br>
            <input type="checkbox" name="C370" value="C">  C testDScc164<br>
            <input type="checkbox" name="D370" value="D">  D testDScd164<hr>
        
            <h5>  18、testDS166</h5>
            <input type="checkbox" name="A372" value="A">  A testDScA166<br>
            <input type="checkbox" name="B372" value="B">  B testDScb166<br>
            <input type="checkbox" name="C372" value="C">  C testDScc166<br>
            <input type="checkbox" name="D372" value="D">  D testDScd166<hr>
        
            <h5>  19、testDS178</h5>
            <input type="checkbox" name="A384" value="A">  A testDScA178<br>
            <input type="checkbox" name="B384" value="B">  B testDScb178<br>
            <input type="checkbox" name="C384" value="C">  C testDScc178<br>
            <input type="checkbox" name="D384" value="D">  D testDScd178<hr>
        
            <h5>  20、testDS179</h5>
            <input type="checkbox" name="A385" value="A">  A testDScA179<br>
            <input type="checkbox" name="B385" value="B">  B testDScb179<br>
            <input type="checkbox" name="C385" value="C">  C testDScc179<br>
            <input type="checkbox" name="D385" value="D">  D testDScd179<hr>
        
            <h5>  21、testDS185</h5>
            <input type="checkbox" name="A391" value="A">  A testDScA185<br>
            <input type="checkbox" name="B391" value="B">  B testDScb185<br>
            <input type="checkbox" name="C391" value="C">  C testDScc185<br>
            <input type="checkbox" name="D391" value="D">  D testDScd185<hr>
        
            <h5>  22、testDS193</h5>
            <input type="checkbox" name="A399" value="A">  A testDScA193<br>
            <input type="checkbox" name="B399" value="B">  B testDScb193<br>
            <input type="checkbox" name="C399" value="C">  C testDScc193<br>
            <input type="checkbox" name="D399" value="D">  D testDScd193<hr>
        
            <h5>  23、testDS194</h5>
            <input type="checkbox" name="A400" value="A">  A testDScA194<br>
            <input type="checkbox" name="B400" value="B">  B testDScb194<br>
            <input type="checkbox" name="C400" value="C">  C testDScc194<br>
            <input type="checkbox" name="D400" value="D">  D testDScd194<hr>
        
        <input style="width: 120px;height: 50px;font-size: 30px;position: relative;left: 45%;" type="submit" name="submit" value="交卷">
        <div style="width: 90%;height: 8px;"></div>
    </form></div>

</body>
<script>
    
</script>
</html>

Background php code:

<?php
    class Exam {
        function exam(){
            
            $this->display();
            
        }    
        function result(){
            $arr=$_POST;
            $arry= array();
            print_r (array_keys($arr));
            foreach(array_keys($arr) as $key=>$value){
            $name=substr($value,1); //提取题目的id号
            $arry[$name]=$arry[$name].$_POST["$value"];
            }
            print_r($arry);
            foreach($arry as $key=>$value){
                $m=D("exam");
                $data=$m->field("value,score")->where(array("id"=>$key))->find();
                
                if($data[value]==$value){
                    $c=$c+$data[score];
                }
                print_r($data);
                
            }
            
            $user=D("userexam");
            ​​$a[user]=$arry[adgeNo];
            $a[score]=$c;
            $user->insert($a);
            
            echo "Your score is ".$c." points";
        }
            
    }

The point to note is that I use the brophp mvc framework for php, so those who don’t know how to take a look at it can take a moment to look at it. The structure of the specific database can depend on what you like. It doesn’t have to be the same. The above codes are all If you have a successful experiment, you can privately message me if you have any questions, Xiaobai, and everyone will work hard to learn.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521094&siteId=291194637