吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1319|回复: 6
收起左侧

[求助] 怎么在控制台执行函数

[复制链接]
xfzsun 发表于 2022-3-2 19:50
本帖最后由 xfzsun 于 2022-3-2 19:51 编辑

麻烦大家提供个思路,怎么在控制台执行getuseranswer()函数并返回结果,谢谢
[JavaScript] 纯文本查看 复制代码



<!-- lpstart-->
<div id="score_ladyout" class="easyui-layout" style="width:100%;height:100%;">
<div region="center"  style="padding:5px;">
<div style="width:100%;height:100%;">
 <table id="score_exam" style="width:85%;margin:0 auto;word-break:break-all;">
<tr style="text-align: center;"><td id="score_name"></td></tr>
<tr><td id="score_description"></td></tr>
<tr><td style="border-bottom: dashed 1px black;"></td></tr>
</table> 
</div>
</div>
<div region="east" split="true"  style="width:300px;" title="考试信息统计">
<div id="useranwser_info">
</div>
</div>
<!-- lpend -->
<script type="text/javascript">
var IndexTips=new Array("一","二","三","四");
$(function() {
    $.ajax({
        url: 'action/exam/getexamquestion.do',
        success: function(data) {
                $('#score_name').html("<h2>"+data.examname+"</h2>");
        /*         $("#infoexamname").text(data.examname);
                $("#infoexamstime").text(dateformat(examstartime.getTime())); */
            $('#score_description').html("<font color='red'>考试说明:" + data.examdescription+"</font>");
            //选择题
            var questionhtml="";
            var questIndex=0;
            if(data.options!=undefined&&data.options.length!=0){
            $('#score_exam').append("<tr><td><h4>"+IndexTips[0]+".单选题</h4></td></tr>");
                   IndexTips.shift(); 
                   questionhtml="";
                    $.each(data.options,function(index,item){
           
                    questionhtml+="<tr><td id=\""+item.questionid+"\"><b>"+(++questIndex)+"."+item.question+"</b></td></tr>";
                    if(item.options!=null){
                            questionhtml+="<tr><td>";
                            $.each(item.options,function(opindex,opitem){
                                    questionhtml +="<p style='text-indent:2em;'>" +opitem.options + ".<input type='radio' name=radio_"+opitem.questionid+" value="+opitem.options+" id=\"radio_"+opitem.questionid+"_"+opitem.options+"\" />" +opitem.optiontext + "</p>";
            
                            });
                            questionhtml+="</td></tr>";
                    }
             });
             $('#score_exam').append(questionhtml);
            }  
            
            //多选题
             if(data.mulits!=undefined&&data.mulits.length!=0){
            $('#score_exam').append("<tr><td><h4>"+IndexTips[0]+".多选题</h4></td></tr>");
           IndexTips.shift(); 
            questionhtml="";
                   $.each(data.mulits,function(index,item){
                           questionhtml+="<tr><td id=\""+item.questionid+"\"><b>"+(++questIndex)+"."+item.question+"</b></td></tr>";
                    if(item.options!=null){
                            questionhtml+="<tr><td>";
                            $.each(item.options,function(opindex,opitem){
                                    questionhtml +="<p style='text-indent:2em;'>" +opitem.options + ".<input type='checkbox' name=\"mulit_"+opitem.questionid+"\" value=\""+opitem.options+"\"  id=\"mulit_"+opitem.questionid+"_"+opitem.options+"\" />" +opitem.optiontext + "</label></p>";
                                    
                            });
                            questionhtml+="</td></tr>";
                    }
                    
                    
             });
             $('#score_exam').append(questionhtml);
            } 
            
            
            
            //判断题
             if(data.judges!=undefined&&data.judges.length!=0){
            $('#score_exam').append("<tr><td><h4>"+IndexTips[0]+".判断题</h4></td></tr>");
           IndexTips.shift(); 
            questionhtml="";
                   $.each(data.judges,function(index,item){
                           questionhtml+="<tr><td id=\""+item.questionid+"\"><b>"+(++questIndex)+"."+item.question+"</b></td></tr>";
                    if(item.options!=null){
                            questionhtml+="<tr><td>";
                            $.each(item.options,function(opindex,opitem){
                                    questionhtml +="<p style='text-indent:2em;'>" +opitem.options + ".<input type='radio' name=judge_"+opitem.questionid+" value="+opitem.options+"  id=\"judge_"+opitem.questionid+"_"+opitem.options+"\"/>" +opitem.optiontext + "</p>";
                            });
                            questionhtml+="</td></tr>";
                    }
                    
                    
             });
             $('#score_exam').append(questionhtml);
            } 
            
            //论述题
           
            if(data.essays!=undefined&&data.essays.length!=0){
                    $('#score_exam').append("<tr><td><h4>"+IndexTips[0]+".论述题</h4></td></tr>");
                    IndexTips.shift(); 
                    questionhtml="";
            $.each(data.essays,function(index,item){
                     questionhtml+="<tr><td id=\""+item.questionid+"\"><b>"+(++questIndex)+"."+item.question+"</b></td></tr>";
                    questionhtml+="<tr><td><textarea id=textarea_"+item.questionid+" name=textarea_"+item.questionid+" style='width:calc(100% - 100px);height:80px;' ></textarea></td></tr>";
                    
             });
             $('#score_exam').append(questionhtml);
            } 
            
          getuseranswer();
        },
        error: function() {
            showMessage("获取考题失败!");
        },
        data: {
            'examid': 'null',
            'taskid':'null'
           
        },
        type: 'post',
        dataType: 'json'
    });
});



function getuseranswer(){
        $.ajax({
        url:'action/exam/getuseranswer.do',
        success:function(data){
                if(data.answer!=null){
                         $.each(data.answer,function(index,item){
                                var questioninfo=item.questionid.split("_");
                                if(item.score==0)
                                        $("#"+questioninfo[1]).css("background-color","#FFB5B5");
                                        
                                if(questioninfo[0]=="radio"||questioninfo[0]=="judge"||questioninfo[0]=="mulit"){
                                        $("#"+questioninfo[1]).html($("#"+questioninfo[1]).html()+"   (正确答案:"+item.rightkey+")"+"   <span style='padding-left:15px;'>得分:"+item.score+"分<span>");
                                        if(questioninfo[0]!="mulit"){
                                                $("#"+item.questionid+"_"+item.useranswer).attr("checked",true);
                                        }else{
                                                var userswers=item.useranswer.split(",");
                                                $.each(userswers,function(anindex,anitem){
                                                        $("#"+item.questionid+"_"+anitem).attr("checked",true);
                                                });
                                        }
                                }
                                if(questioninfo[0]=="textarea"){
                                        if(item.score!="批改中"){
                                                $("#"+questioninfo[1]).html($("#"+questioninfo[1]).html()+" <span style='padding-left:15px;'>得分:"+item.score+"分<span>");
                                        }else{
                                                $("#"+questioninfo[1]).html($("#"+questioninfo[1]).html()+" <span style='padding-left:15px;'>得分:"+item.score+"<span>");
                                        }
                                        $("#"+item.questionid).val(item.useranswer);
                                        var questanaly="暂无解析";
                                                if(item.rightkey!="null")
                                                        questanaly=item.rightkey;
                                        $("#textarea_"+questioninfo[1]).parent().append("<p>解析:"+questanaly+"</p>");
                                }
                                
                        }); 
                }
                var userexamsum=data.examsumscore*0.6+"";
                if(userexamsum.length>5)
                        userexamsum=userexamsum.substring(0,5);
                var useranwser_infohtml="<p><b>试卷总分:</b>"+data.examsumscore+"分</p>";
                useranwser_infohtml+="<p><b>单选题得分:</b>"+data.optionscore+"</p>";
                useranwser_infohtml+="<p><b>多选题得分:</b>"+data.mulitscore+"</p>";
                useranwser_infohtml+="<p><b>判断题得分:</b>"+data.judgescore+"</p>";
                useranwser_infohtml+="<p><b>论述题得分:</b>"+data.essayscore+"</p>";
                useranwser_infohtml+="<p><b>总得分:"+data.usersumscore+"</b></p>";
                useranwser_infohtml+="<br><p><font color='#ff0000'>Tip:得分达到总分60%("+userexamsum+"分),视为合格!</font></p>";
                $("#useranwser_info").html(useranwser_infohtml);
        },
        error:function(){
                showMessage("获取用户答题记录失败!");
        },
        dataType:'json',
        type:'post',
        data:{
        'scoreid':'null'
        }
        });
}

</script>

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

闷骚小贱男 发表于 2022-3-2 21:27
F12 console
输入getuseranswer()
回车会运行getuseranswer
返回?好像并没有return,只是修改了html页面$("#useranwser_info")
sgvvvv 发表于 2022-3-3 00:12
在控制台输入函数名执行就行吧
现在具体是什么问题 有报错吗
52liu 发表于 2022-3-3 08:51
 楼主| xfzsun 发表于 2022-3-3 10:00
123.png 执行后这么显示
ilovezll 发表于 2022-3-3 11:35
xfzsun 发表于 2022-3-3 10:00
执行后这么显示

你这个源页面没有引入jquery的js
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-28 03:13

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表