消息关闭
    暂无新消息!
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,user-scalable=no,maximum-scale=1,initial-scale=1"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="format-detection" content="telephone=no"/>
<link href="../addons/zombie_fighting/template/style/css/common.css" rel="stylesheet" type="text/css">
<link href="../addons/zombie_fighting/template/style/css/survey.css" rel="stylesheet" type="text/css">
<link href="../addons/zombie_fighting/template/style/css/exam.css" rel="stylesheet" type="text/css">

</head>
<body>
<div class="wrapper"> 

<img class="bg" src="../addons/zombie_fighting/template/style/images/bg_exam.jpg" />
<div class="top">
<div class="time"></div>
<div class="score">10 积分</div>
</div>

<div class="question">
<div class="title">目前最常用的脱毒药物是(   ),它是一种阿片受体激动剂,适用于海洛因毒瘾较深者。</div>
<input type="hidden" name="fid" id="fid" value="1" />
<input type="hidden" name="qestionid"  id="qestionid" value="42" />
<input type="hidden" name="answerNum"  id="answerNum" value="3" />
            <input type="hidden" name="openid"  id="openid" value="ojoIMwHPoDUtWs55Tbibcc1Uf0V8" />

<div class="options">
<div class="option" data-value="A">
<img class="oimg" src="../addons/zombie_fighting/template/style/images/option_bg_green.png" />
<img class="oimg-sel" src="../addons/zombie_fighting/template/style/images/option_sel_bg_green.png" />
<div class="text">
<div class="i" style="margin-left:23px;padding-top:0px;float:left;">A</div>
<div class="otext"> 吗啡</div>
</div>
</div>

<div class="option" data-value="B">
<img class="oimg" src="../addons/zombie_fighting/template/style/images/option_bg_blue.png" />
<img class="oimg-sel" src="../addons/zombie_fighting/template/style/images/option_sel_bg_blue.png" />
<div class="text">
<div class="i" style="margin-left:23px;padding-top:0px;float:left;">B</div>
<div class="otext"> 美沙酮</div>
</div>
</div>

   <div class="option" data-value="C">
<img class="oimg" src="../addons/zombie_fighting/template/style/images/option_bg_pink.png" />
<img class="oimg-sel" src="../addons/zombie_fighting/template/style/images/option_sel_bg_pink.png" />
<div class="text">
<div class="i" style="margin-left:23px;padding-top:0px;float:left;">C</div>
<div class="otext"> 可待因</div>
</div>
</div>
        </div>
<img id="submit" src="../addons/zombie_fighting/template/style/images/exam_submit.png" />
</div>

</div>
 
<div class="result-right loading-mask">
<div class="content">
<img class="timg" src="../addons/zombie_fighting/template/style/images/tick.png">
<div class="text">恭喜你,答对了</div>
<button class="next-btn">进入下一题</button>
</div>
</div>
<div class="result-wrong loading-mask">
<div class="content">
<img class="timg" src="../addons/zombie_fighting/template/style/images/wrong.png">
<div class="text">对不起,你答错了。</div>
<div class="answer">正确的答案是:<strong></strong></div>
<button class="next-btn">进入下一题</button>
</div>
</div>
<div class="result-timeout loading-mask">
<div class="content">
<img class="timg" src="../addons/zombie_fighting/template/style/images/timeout.png">
<div class="text">啊哦,答题超时了</div>
<button class="next-btn">进入下一题</button>
</div>
</div>

<div id="loading" class="loading-mask">
<img class="gimg" src="../addons/zombie_fighting/template/style/images/ajax-loader.gif">
</div>
<audio id="musicBg" src="../addons/zombie_fighting/template/style/mp3/timer.mp3" preload="auto" autoplay loop></audio>
<audio id="musicRight" src="../addons/zombie_fighting/template/style/mp3/right.mp3" preload="auto"></audio>
<audio id="musicWrong" src="../addons/zombie_fighting/template/style/mp3/wrong.wav" preload="auto"></audio>
<audio id="musicNear" src="../addons/zombie_fighting/template/style/mp3/timerNear.mp3" preload="auto"></audio>
</body>

<script src="../addons/zombie_fighting/template/style/js/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript" src="../addons/zombie_fighting/template/style/js/zepto.min.js?v=2014082901"></script>
<!--<script src="../addons/zombie_fighting/template/style/js/alert.js" type="text/javascript"></script>-->
<script type="text/javascript">
var answertime = '';
$(function(){
$(".option").on("click",function(){
var $option = $(this);
if(!$option.hasClass("option-sel")){
$(".options .option-sel").removeClass("option-sel");
$option.addClass("option-sel");
$("#submit").click();
}
});

$(".next-btn").on("click",function(e){
window.location.reload();
return false;
}).on("touchstart",function(e){
$(this).addClass("hover");
}).on("touchend",function(e){
$(this).removeClass("hover");
});

var answerNum =Number($("input[name='answerNum']").val());
$("#submit").on("click",function(){
var $btn = $(this);
var endTime = new Date();
if((endTime - startTime)/1000 > 10){
maxtime = -1;
$(".time").text("00:00");
alert("对不起,您的回答已超时!");
return false;
}
if($btn.hasClass("disabled")) return;
var $answer = $(".options .option-sel");
if($answer.size() == 0){
alert("请选择一个答案!");
return;
}
var qestionid = $("input[name='qestionid']").val() ;
var fid = $("input[name='fid']").val() ;
            var openid =$("input[name='openid']").val();
var submitData = {
"qestionid":qestionid,
"fid":fid,
"answerNum": answerNum,
                "openid":openid,
"answer":$answer.attr("data-value")
};
$btn.addClass("disabled");
clearInterval(timer);
$("#musicBg")[0].pause();
            var ajaxurl = "./index.php?i=5&c=entry&do=getAnswer&m=zombie_fighting";
$.ajax({
        type: "post",
        url: ajaxurl,
        data: submitData,
        dataType: "json",
        success: function (data) { 
         $btn.removeClass("disabled");
var $mask;
if (data.resultCode==1){
$("#musicRight")[0].play();
$mask = $(".result-right");
}else if(data.resultCode == 3){
window.location.reload();
} else{
$("#musicWrong")[0].play();
$mask = $(".result-wrong");
$mask.find(".answer strong").text(data.resultMsg);
}
$mask.show();
        },
        error: function(data) {
            alert("error:" + data.responseText);
window.location.reload();
        }
    });
    return false;
});

//一个小时,按秒计算,可以自己调整时间
var maxtime = 20 * 100;
function CountDown() {   
if(maxtime>=0) {   
seconds = Math.floor(maxtime/100);   
milliseconds = Math.floor(maxtime%100); 
seconds = seconds<10?("0" + seconds) : seconds;
milliseconds = milliseconds<10?("0" + milliseconds) : milliseconds;
$(".time").text(seconds + ":" + milliseconds);
if(maxtime == 270){
$("#musicNear")[0].play();
}
maxtime -= 10;   
}  else{   
clearInterval(timer);   
var qestionid = $("input[name='qestionid']").val() ;
var $answer = $(".options .option-sel");
var fid = $("input[name='fid']").val() ;
                var openid =$("input[name='openid']").val() ;
var submitData = {
"qestionid":qestionid,
"fid":fid,
                    "openid":openid,
"answerNum":answerNum,
"answer":$answer.attr("data-value")
};

                var ajaxurl = "./index.php?i=5&c=entry&do=getAnswer&m=zombie_fighting";
var $btn = $("#submit");
if($btn.hasClass("disabled")) return;
$("#musicBg")[0].pause();
$btn.addClass("disabled");

$.ajax({
        type: "post",
        url: ajaxurl,
        data: submitData,
        dataType: "json",
        success: function (data) {
         $btn.removeClass("disabled");
         var $mask = $(".result-timeout");
$("#musicWrong")[0].play();
if (data.resultCode==1){
$("#musicRight")[0].play();
$mask = $(".result-right");
}else if(data.resultCode == 3){
window.location.reload();
} else{
$("#musicWrong")[0].play();
$mask = $(".result-wrong");
$mask.find(".answer strong").text(data.resultMsg);
}
$mask.show();
        },
        error: function(data) {
            alert("error:" + data.responseText);
window.location.reload();
        }
    });

}   

timer = setInterval(CountDown, 100);
var startTime = new Date();
$(document).on('ajaxBeforeSend', function(e, xhr, options){
$("#loading").show();
}).on("ajaxComplete ",function(e, xhr, options){
$("#loading").hide();
});
});
</script>
</html>

4个回答

︿ 1
这就是代码,我想做成自动答题,不管对错都可以

我看了是$(".option").on("click"里面有个$("#submit").click();提交的,我在代码前加了,$("#submit").click();但是还是不自动提交啊,也不判断是否点击了,应该怎么做呢???

怎么让页面加载后就自动执行(".option").on("click",就是不用点击就模拟了这个点击

或者怎么自动执行$("#submit").on("click,让页面自动提交呢

20红包,没有更多了
︿ 0
选择一个答案后,会出现对错,然后出现下一题的弹框,然后进入下一题

怎么能让这些都自动完成呢??????不懂啊

20红包给上

版主呢