打开/关闭菜单
Toggle preferences menu
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Gadget-tikuRenderModule.js:修订间差异

MediaWiki界面页面
无编辑摘要
(导入1个版本)
 
(未显示同一用户的64个中间版本)
第1行: 第1行:
getdata()
//设置
function tikuConfig(){
var prefixDic = {
     return {isDev:false}
     formId:'timuForm-',
    radioName:'radio-',
    radioId:'radio-input-',
    checkBoxName:'checkbox-',
    checkBoxId:'checkbox-input-',
    selectId:'select-',
    selectName:'select-',
    textInputName:'text-',
    textInputId:'text-'
}
}
function getdata(){
 
    var data = $('.data')
 
    var dataLength = data.length
//主函数
    var errs = {}
function renderTimuFromSessionStorage(){
    for(var i=0;i<dataLength;i++){
var timuList = gDomTimuList()
        var singleData = $(data[i]).html().replace(/\n/g,'\\n')
// console.log(timuList)
        var html = singleData
var order = timuList.order
        console.log(singleData)
var timu = timuList.timu
        if($(data[i]).children().length>0){
var errors = timuList.errors
            $(data[i]).children().each(
var repeatSource = timuList.repeatSource
                function (i,v) {
for(var i=0;i<order.length;i++){
                    console.log(v)
if(order[i].isError){
                    var innerHTML = entityToString(v)
var errorWidget = new OO.ui.MessageWidget( {
                    console.log(innerHTML)
type: 'error',
                    var escape  = ''
showClose:true,
                    escape = innerHTML.replace(/"/g,'\\"')
label: 'id='+i+'的题目加载错误,错误信息:'+errors[i].info.name+':'+errors[i].info.message+'\n'+'对应文本:'+errors[i].dataText
                    console.log(escape)
} )
                    singleData = singleData.replace(innerHTML,escape)
render(i,'A',$('<di></div>').append(errorWidget.$element,'<hr>'))
                }
}else{
            )
var dataJSON = timu[i].dataJSON
        }
             var o = newTimu(i,dataJSON,{})[dataJSON.type]()
        $(data[i]).html(html)
            render(i,dataJSON.type,o)
        console.log(singleData)
            var needCheck = $('#noRepeatCheck').length<=0
        if(tikuConfig().isDev){
             if(repeatSource[i]!==undefined&&needCheck){
            var jsonData = $.parseJSON(singleData)
            var warningWidget = new OO.ui.MessageWidget( {
                for(var n in jsonData){
type: 'warning',
                jsonData[n] = jsonData[n].replace(/\\n/g,'\n')
label: '本题与本页面id为'+repeatSource[i]+'的题目source参数重复,本参数重复可能引起错误,请检查并修改!'
                }
} )
            console.log(jsonData)
render(i,'A',warningWidget.$element)
             setTimeout(function(jsonData,i,dataLength){
                var o = eval('newTimu('+i+','+JSON.stringify(jsonData)+',true).'+jsonData.type+'()')
                render(i,jsonData.type,o)
                console.log('加载题目:'+(i+1)+'/'+dataLength)
            },0,jsonData,i,dataLength)
        }else {
             try{
                var jsonData = $.parseJSON(singleData)
                for(var n in jsonData){
                jsonData[n] = jsonData[n].replace(/\\n/g,'\n')
                }
                setTimeout(function(jsonData,i,dataLength){
                    var o = eval('newTimu('+i+','+JSON.stringify(jsonData)+',true).'+jsonData.type+'()')
                    render(i,jsonData.type,o)
                    console.log('加载题目:'+(i+1)+'/'+dataLength)
                },0,jsonData,i,dataLength)
            }catch (e) {
                render(i,'A',$('<div id="'+i+'"><p style="color: red">第'+(i+1)+'题加载错误,错误类型:'+e.name+'</p></div>'))
                errs[i] = e
             }
             }
         }
}
}
}
 
 
//题目渲染函数
//生成info
function infoInline(info){
    return $('<div class="info">'+info+'</div>')
}
//单行题干的处理titleInline(type, source, title)
//生成titleGroup
function titlesGroup(titlesList){
    var group = $('<div class="titlesGroup"></div>')
    for(var i=0;i<titlesList.length;i++){
         group.append(titlesList[i])
     }
     }
     var errText = $('<div style="width:100%;border:solid 3px red;padding-left:15px"><p><b style="color:red">本页存在题目加载错误</b></p></div>')
     return group
     var isNoErr = true
}
    for (var n in errs){
//生成titleInline
         errText.append('<p><b style="color:red;margin-left:8px">--->ID:'+n+'|可能对应题号:'+(n*1+1)+'</b> '+errs[n]+'</p>')
function titleInline(id, type,originalSource, sourceSuffix,title, classes){
         isNoErr = false
    classes = classes===undefined?'':classes
    return $('<div id="title-'+id+'" class="'+classes+'"></div>').append(
            titleInlineType(type),
            titleInlineSource(originalSource,sourceSuffix,type),
            titleInlineTitle(title)
        )
}
function titleInlineType(type){
     var typeChinese = {
        A:'A',
         A2:'A2',
        A3:'A3',
        B:'B',
        C:'C',
        X:'X',
        TK:'填空',
        PD:'判断',
         MJ:'名解'
     }
     }
     if(!isNoErr){
     return $('<p class="type">'+typeChinese[type]+'</p>')
        $('.mw-parser-output').prepend(errText)
}
//从有中文的source中提取最后一个连续数字作为真实的source
function getRealSource(source){
    // console.log(source)
var getContinueNumber = source.match(/[0-9]+/g)
var splitContinueNumber = source.split(/[0-9]+/g)
    var realSource = getContinueNumber[getContinueNumber.length-1]*1
    var prefix = ''
    for(var i=0;i<getContinueNumber.length;i++){
    prefix += splitContinueNumber[i]
     }
     }
    return {prefix:prefix,source:realSource}
}
//返回source的obj
function titleInlineSource(originalSource, suffix , type){
    var realSource = type==='A3'?{prefix:'', source:originalSource}: getRealSource(originalSource)
   
    var prefix = realSource.prefix
    var source = realSource.source
    var suffix = suffix === undefined ? '':'-'+suffix


    return $('<p class="source">'+prefix+source+suffix+'</p>')
}
}
function decodeSpecialCharacters(text) {
//返回sourceRange的obj
     special
function rangeInline(originalSource, sourceRange, type){
     text.replace()
     var source = getRealSource(originalSource).source
     var end = source*1+sourceRange*1 -1
 
    var rangeText = '第 '+source +' 到 ' + end + ' 题'
    var suffix = type==='B'?'共用备选答案':'共用题干'
 
    return $('<div class="sourceRange">'+rangeText + suffix +'</div>')
}
}
function entityToString(entity){
//返回title 的 obj
     var div=$('<div></div>');
function titleInlineTitle(title){
    div.html(entity)
     return $('<p class="title">'+title+'</p>')
    var res=div.html();
    console.log(entity,'->',res);
    return res;
}
}
function addAfterIDData(id,content) {
//生成buttonGroup
     var data = $('.data')
function buttonGroup(showSubmitBtn, showEditBtn, id, type, correctAnswer, hoverTarget){
     content.insertAfter(data[id])
    // console.log(showEditBtn)
     var buttonGroupObj = $('<div class="buttonGroup"></div>')
    if(showSubmitBtn){buttonGroupObj.append(
        new OO.ui.ButtonWidget( {
            id:'showThisAnswer-'+id,
            label: '提交',
            flags: [
                'progressive'
            ]
        } ).$element.bind("click",function (){
            showThisAnswer(id,type,correctAnswer)
        })
     )}
    if(showEditBtn){
        buttonGroupObj.append(
            // $('<a class="editThisBtn" style="" href="javascript:void(0)"><span class="" id="editThis-' + id + '">题目有误?点击编辑本题</span></a>'),
            new OO.ui.ButtonWidget( {
                id:'editThis-' + id,
                classes:['editThisBtn'],
                framed: false,
                flags: [
                    'progressive'
                ],
                icon: 'edit',
                label: '题目有误?点击编辑本题'
            } ).$element.bind("click",function (){
                editThis(id)
            })
        )
        hoverTarget.hover(function () {
            buttonGroupObj.children('.editThisBtn').fadeIn(10)
        },function (){
            buttonGroupObj.children('.editThisBtn').fadeOut(70)
        })
    }
    return buttonGroupObj
}
}
function isObjExist(t){
//resultGroup: answer和explain的显示框
     var l = $(t).length
function resultGroup(id, items, answerInline,explainInline){
     if(l>0){
     var group = $('<div id="resultGroup-'+id+'" class="resultGroup"></div>')
         return true
    for(var i=0;i<items.length;i++){
     }else {
        group.append(items[i])
         return false
    }
    return group
}
//生成answerInline
function answerInline(answer){
    return $('<div class="answerInline"><label>正确答案:</label>'+answer+'</div>')
}
//生成explainInline
function explainInline(explain){
    return $('<div class="explainInline"><label>解析:</label>'+explain+'</div>')
}
 
//生成subject 的form, 顺序items顺序添加 (title, options, buttonGroup)
function subjectFrom(id, type, items){
    var form =  $('<form id="'+prefixDic.formId+id+'" class="subjectForm"></form>')
    //绑定变化事件
     form.change(function(){
    // 如果开启了暂存,则暂存
        if(!gWebPageTimuSettings().noTemp){
            formChangeListener(id, type)
         }
     })
    for(var i=0;i<items.length;i++){
         form.append(items[i])
     }
     }
    return form
}
}
function render(id,type,obj,parent,isAfter){
function subjectDIV(id,type,items){
     parent =parent !==undefined ?parent : '#subjectContainer-'+type
     var div= $('<div id="'+prefixDic.formId+id+'" class="subjectForm"></div>')
     if(typeof(parent)!=='object'){
     for(var i=0;i<items.length;i++){
         parent = $(parent)
         div.append(items[i])
     }
     }
     if(isObjExist(parent)){
     return div
         if(isAfter){
}
             parent.after(obj)
 
         }else {
//生成填空输入框
             obj.appendTo(parent)
function fillBlank(id, title, pos, classes){
    // console.log(pos)
    var posReg = new RegExp(pos,'g')
    var blankLen = title.match(posReg).length
    var split = title.split(posReg)
    // console.log(blankLen)
    var newTitle = ''
    for(var i=0;i<(blankLen+split.length);i++){
         if(i%2===0){
             newTitle +=  '<p class="title">'+split[Math.floor(i/2)]+'</div>'
         }else{
             newTitle +=  new OO.ui.TextInputWidget( {
                name:prefixDic.textInputName+id+'-'+Math.floor(i/2),
                id:prefixDic.textInputId+id+'-'+Math.floor(i/2),
                classes:classes
            } ).$element.prop('outerHTML')
         }
         }
    }else {
          
         addAfterIDData(id,obj)
     }
     }
    return newTitle
}
}
function dicLen(dic){
//生成B、C型题的选择框
     var count=0;
function dropDownInputWidget(id, availabelOptions){
     for(var key in dic){
     var options = []
         console.log(key+'='+dic[key]);
    var select = $('<select class="dorpdown" id="'+prefixDic.selectId+id+'" name="'+prefixDic.selectName+id+'"></select>')
        count++;
     for(var i=0;i<availabelOptions.length;i++){
         select.append('<option class="dropdown-option" value="'+availabelOptions[i]+'">'+availabelOptions[i]+'</option>')
     }
     }
     return count
     return select
}
//生成options(options 是 Map对象)
function optionsGroup(type,id,options){
    var flexClass = (type==='B')||(type==='C') ? 'optionsGroup-flex':''
    var inputType = type==='X' ? 'checkbox':'radio'
    var optionGroupObj = $('<div class="optionsGroup '+flexClass+'"></div>')
    options.forEach(function(value, key, map){
        optionGroupObj.append(optionInline(id, key, value, !((type==='B')||(type==='C')), inputType))
    })
    return optionGroupObj
}
//生成optionInline
function optionInline(id, option, content,input,inputType){
    var idPrefix = inputType === 'checkbox' ? prefixDic.checkBoxId:prefixDic.radioId
    var namePrefix = inputType === 'checkbox' ? prefixDic.checkBoxName:prefixDic.radioName // 这个和外部的div的id一样就共用了
 
    var input = input ? $('<input id="'+ idPrefix + id+'-'+option+'" name="'+ namePrefix + id + '" type="'+inputType+'" value="' + option + '" />'):''
    var optionLabel = $('<label for="'+ idPrefix + id+'-'+option+'">'+option+'. </label>')
    var contentLabel = $('<label for="'+ idPrefix + id+'-'+option+'">'+content+'</label>')
    return $('<div id="'+ namePrefix +id+'-'+option+'" class="optionInline"></div>').append(input,optionLabel,contentLabel)
}
//清理json中的choice(清除空项并排序),接收Obj,
function cleanAndMakeSameLenOptions(options){
//清除空项
var options = filterEmptyEntries(options)
//让所有option长度一样
var maxOptionLen = getStrLength(Object.values(options).sort(function(a,b){return getStrLength(b) - getStrLength(a)})[0])
for(var i in options){
var minus = maxOptionLen - getStrLength(options[i])
for(var n=0;n<minus;n++){
options[i] += '&ensp;'
}
}
// console.log(options)
    return sortDicByKey(options) //返回一个 Map 对象
}
}
function newTimu(id,json,editButton,hideButton,addHr,parent){
function newTimu(id,json, settings){
     parent = parent !== undefined ? parent : ''
    settings = json.settings===undefined||json.isA3 ? settings:json.settings//检测json是否带有settings或者是否为A3子题目
     if(addHr===undefined){addHr=true}
 
     if(hideButton===undefined){hideButton=false}
     parent = settings.parent === undefined ? '' : settings.parent
     var type = json.type
     showHr = settings.showHr == undefined ? true : settings.showHr
    showSubmitBtn = settings.showSubmitBtn === undefined ? true : settings.showSubmitBtn
     showEditBtn = settings.showEditBtn === undefined ? true : settings.showEditBtn
     showBtnGroup = settings.showBtnGroup === undefined? true:settings.showBtnGroup
 
     var o = new Object()
     var o = new Object()
    o.type = json.type
    o.pos = json.pos
    o.inputBox = json.inputBox
    o.source = json.source
    o.sourceRange = json.sourceRange
    o.info = json.info
    o.title = json.title
    o.options = json.choices
    // console.log(o.options)
    //将choice 统一为Array的转换为obj
    if(typeOfObj(o.options)==='[object Array]'&&o.options.length===1&&o.type!=='A3'){
    o.options = o.options[0]
    }
    o.options = o.options!==undefined? cleanAndMakeSameLenOptions(o.options):''
    // console.log(o.options)
    o.answer = json.answer
    o.explain = json.explain
     o.temp = {
     o.temp = {
         main:$('<div name="timu-'+(id+1)+'" id="'+id+'" class="type'+type+' timuContainer"></div>'),
         main:$('<div name="timu-'+(id+1)+'" id="'+id+'" class="type'+o.type+' timuContainer"><p class="timuID">'+id+'</p></div>'),
        subject:$('<div class="subject"></div>'),
        range:$('<div class="sourceRange"></div>'),
        info:$('<div class="info"></div>'),
        titleCon:$('<div class="titleContainer"></div>'),
        type:$('<p class="source"></p>'),
        source:$('<p class="source"></p>'),
        title:$('<p class="title"></p>'),
        options:$('<div class="options"></div>'),
        btn:$('<button class="button-small button-pill button button-caution" id="showSingle-' + id + '" class="showSingleBtn">提交</button>'),
        editBtn:$('<a class="editThisButton" style="display: none;font-size: 14px;margin-left: 5px" href="javascript:void(0)"><span class="" id="editThis-' + id + '">题目有误?点击编辑本题</span></a>'),
        ansCon:$('<div id="ansContainer" class="ansContainer noDisplay"></div>'),
        correct:$('<p style="display:inline;"><b>正确答案:</b></p><p class="correctAnswer"></p><br>'),
        explain:$('<p style="display:inline;"><b>解析: </b></p><p class="explain"></p><br>'),
        select:$('<select class="button-small button-rounded button"></select>'),
        subTitle:$('<div id=""></div>')
     }
     }
    o.hideButton = hideButton
 
     o.parent = parent
     o.parent = parent
     if(type!=='A3'&&type!=='PD'){
     // if(this.type==='A3'){
        o.temp.btn.bind("click",function (){
    //    $(this).children('.subject').children('.editThisButton').fadeIn(1)
            showChoiceAnswer(id,type,json.answer)
    //    }
        })
    o.temp.main.hover(function () {
    }
        $('editThis-' + id).fadeIn(10)
    if(type!=='A3'&&type!=='PD'){
    },function (){
        o.temp.editBtn.bind("click",function (){
        $('editThis-' + id).fadeOut(70)
            editThis(id)
     })
            $(this).fadeOut(1)
 
        })
        o.temp.main.hover(function () {
            $(this).children('.subject').children('.editThisButton').fadeIn(10)
        },function (){
            $('.editThisButton').fadeOut(70)
        })
     }
    if(!editButton){
        o.temp.editBtn = $('')
    }
     o.A = function () {
     o.A = function () {
         this.temp.type.text(json.type)
        //subjectForm
         this.temp.source.text(json.source)
         this.type = json.isA3?'A3':'A'
         this.temp.title.html(json.title)
         var optionsGroupObj = optionsGroup(this.type, id, this.options)
        this.temp.correct.nextAll('.correctAnswer').html(json.answer)
         if(json.isA3){
        this.temp.explain.nextAll('.explain').html(json.explain)
            var titleInlineObj = titleInline(id, 'A3',this.source,undefined,this.title,'titleInline')
         var options = formatAnsDic(json.choices)
         }else{
        for(var k in options) {
             var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
             var label = '<label id="' + k + '"><input name="singelChoice-' + id + '" type="radio" value="' + k + '" />' + k + ':' + options[k] + '</label>'
            this.temp.options.append(label)
         }
         }
         this.temp.titleCon.append(this.temp.type,this.temp.source,this.temp.title)
          
         this.temp.ansCon.append(this.temp.correct,this.temp.explain)
        var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main):''
         this.temp.subject.append(this.temp.titleCon,this.temp.options)
         var subjectForm = subjectFrom(id,this.type, [titleInlineObj, optionsGroupObj])
         if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
        //resultGroupObj
         this.temp.main.append(this.temp.subject,this.temp.ansCon)
        var answerInlineObj = answerInline(this.answer)
         var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
         var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])
 
         this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )


         if(addHr){this.temp.main.append('<hr>')}
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.A2 = function () {
     o.A2 = function () {
         this.temp.type.text(json.type)
         //subjectForm
         this.temp.source.text(json.source)
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        this.temp.title.html(json.title)
         var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
         this.temp.correct.nextAll('.correctAnswer').html(json.answer)
         var buttonGroupObj = buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main)
        this.temp.explain.nextAll('.explain').html(json.explain)
         var subjectForm = subjectFrom(id,this.type, [titleInlineObj, optionsGroupObj])
         var options = formatAnsDic(json.choices)
         //resultGroupObj
        for(var k in options) {
         var answerInlineObj = answerInline(this.answer)
            var label = '<label id="' + k + '"><input name="singelChoice-' + id + '" type="radio" value="' + k + '" />' + k + ':' + options[k] + '</label>'
         var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
            this.temp.options.append(label)
         var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])
         }
 
         this.temp.titleCon.append(this.temp.type,this.temp.source,this.temp.title)
         this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )
         this.temp.ansCon.append(this.temp.correct,this.temp.explain)
         this.temp.subject.append(this.temp.titleCon,this.temp.options)
        if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
         this.temp.main.append(this.temp.subject,this.temp.ansCon)


         if(addHr){this.temp.main.append('<hr>')}
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.A3 = function () {
     o.A3 = function () {
         var subIDs = []
        // console.log(settings)
         var s = json.source*1;var e = json.source*1+json.sourceRange*1 -1
         var realSource = getRealSource(json.source)
         this.temp.range.text('第 '+s+' 到 '+e+' 题')
         var sourcePrefix = realSource.prefix===''?'':realSource.prefix
         for(var i=0;i<json.title.length;i++){
        //subjectForm
            subIDs.push(id+'-'+i)
        var range = rangeInline(this.source, this.sourceRange)
             if(json.explain[i]==undefined){
         var info = infoInline(this.info)
                 json.explain[i] = '暂无解析'
 
        var subTitlesList = []
         for(var i=0;i<this.title.length;i++){
             if(this.explain[i]==undefined){
                 this.explain[i] = '暂无解析'
             }
             }
             var data = {
             var data = {
                'isA3':true,
                 "type":"A",
                 "type":"A",
                 "source":json.source+'-'+(i+1),
                 "source":sourcePrefix+realSource.source+'-'+(i+1),
                 "title":json.title[i],
                 "title":this.title[i],
                 "answer":json.answer[i],
                 "answer":this.answer[i],
                 "explain":json.explain[i],
                 "explain":this.explain[i],
                 "choices":json.choices[i],
                 "choices":this.options.get(i+''),
             }
             }
             var newA = newTimu(id+'-'+i,data,false, true,false).A()
             // console.log(data)
            render(id+'-'+i,'A',newA,this.temp.titleCon)
            // console.log(this.options)
            subTitlesList.push(newTimu(id+'-'+i,data,{
                showHr:false,
                showEditBtn:false,
                showSubmitBtn:false,
                showBtnGroup:false
            }).A())
         }
         }
         o.temp.btn.bind("click",function (){
          
            showChoiceAnswer(subIDs,type,json.answer)
         // console.log(this.answer)
        })
         var buttonGroupObj  = buttonGroup(true, false, id, this.type, this.answer, this.temp.main)
         this.temp.info.text(json.info)
         // console.log(buttonGroupObj)
         this.temp.subject.append(this.temp.range,this.temp.info,this.temp.titleCon)
        var subjectFormObj = subjectDIV(id,this.type, [subTitlesList])
         if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
         this.temp.main.append(range,info, subjectFormObj, buttonGroupObj)
         this.temp.main.append(this.temp.subject)


         if(addHr){this.temp.main.append('<hr>')}
         this.temp.main.append('<hr>')
         return this.temp.main
         return this.temp.main
     }
     }
     o.B = function () {
     o.B = function () {
         this.temp.type.text(json.type)
         var realSource = getRealSource(json.source)
         var s = json.source*1;var e = json.source*1+json.sourceRange*1 -1
         var sourcePrefix = realSource.prefix===''?'':realSource.prefix
         this.temp.range.text(''+s+' '+e+' ')
        //subjectForm
        var range = rangeInline(this.source, this.sourceRange)
         var optionsGroupObj = optionsGroup(this.type, id, this.options)
        var titleInlineList = []
        for(var i=0;i<this.title.length;i++){
            var dropdown = dropDownInputWidget(id+'-'+i, mapKeysList(this.options))
            var titleInlineObj = titleInline(id+'-'+i, this.type, json.source, i, this.title[i],'titleInline')
            titleInlineObj.append(dropdown)
            titleInlineList.push(titleInlineObj)
        }
        var titlesGroupObj = titlesGroup(titleInlineList)
        var buttonGroupObj = buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main)
 
        var subjectForm = subjectFrom(id,this.type, [optionsGroupObj, titlesGroupObj])


         var options = formatAnsDic(json.choices)
         //resultGroupObj
         for(var k in options){
         var resultGroupList = []
            var label = '<li id="'+k+'">'+k+':'+options[k]+'</li>'
         for(var i=0;i<this.answer.length;i++){
            this.temp.options.append(label)
             var answerInlineObj = answerInline(this.answer[i])
            this.temp.select.append('<option value="'+k+'">'+k+'</option>')
             var explainInlineObj = this.explain[i] === undefined || this.explain[i] === '' ? '暂无解析' : explainInline(this.explain[i])
        }
             resultGroupList.push(
         for(var i=0;i<json.title.length;i++){
                    '<b>'+sourcePrefix+realSource.source+'-'+i+'</b>',
             var reg1 = /\(\)/g
                    $('<div style="margin-left:10px"></div>').append(answerInlineObj),
             var text = json.title[i]
                    $('<div style="margin-left:10px"></div>').append(explainInlineObj)
            if(reg1.test(text)){
                )
                text = text.replace("()",this.temp.select.prop("outerHTML"))
            }else{
                text += this.temp.select.prop("outerHTML")
            }
            this.temp.subTitle.attr('id',id+'-'+i)
            this.temp.source.text(s+i)
             this.temp.subTitle.html(this.temp.source.prop("outerHTML")+text)
            this.temp.titleCon.append(this.temp.subTitle.prop("outerHTML"))
        }
        for(var i=0;i<json.answer.length;i++){
            this.temp.correct.nextAll('.correctAnswer').append('<p id="ans-'+id +'-'+i+'">'+(s+i)+''+json.answer[i]+'</p>')
            this.temp.correct.nextAll('p').each(function () {
                $(this).css('display','none')
            })
        }
        for(var i=0;i<json.explain.length;i++){
            this.temp.explain.nextAll('.explain').append('<p id="exp-'+id +'-'+i+'">'+(s+i)+':'+json.explain[i]+'</p>')
         }
         }
        var resultGroupObj = resultGroup(id, resultGroupList)


         this.temp.subject.append(this.temp.range,this.temp.options,this.temp.titleCon)
         this.temp.main.append(range ,subjectForm,resultGroupObj, buttonGroupObj)
        if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
        this.temp.ansCon.append(this.temp.correct,this.temp.explain)
        this.temp.main.append(this.temp.subject,this.temp.ansCon)


         if(addHr){this.temp.main.append('<hr>')}
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.C = function () {
     o.C = function () {
         this.temp.type.text(json.type)
         var realSource = getRealSource(json.source)
         var s = json.source*1;var e = json.source*1+json.sourceRange*1 -1
         var sourcePrefix = realSource.prefix===''?'':realSource.prefix
         this.temp.range.text(''+s+' '+e+' ')
        //subjectForm
        var range = rangeInline(this.source, this.sourceRange)
         var optionsGroupObj = optionsGroup(this.type, id, this.options)
        var titleInlineList = []
        for(var i=0;i<this.title.length;i++){
            var dropdown = dropDownInputWidget(id+'-'+i, mapKeysList(this.options))
            var titleInlineObj = titleInline(id+'-'+i, this.type, json.source, i, this.title[i],'titleInline')
            titleInlineObj.append(dropdown)
            titleInlineList.push(titleInlineObj)
        }
        var titlesGroupObj = titlesGroup(titleInlineList)
        var buttonGroupObj = buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main)


         var options = formatAnsDic(json.choices)
         var subjectForm = subjectFrom(id,this.type, [titlesGroupObj, optionsGroupObj])
         for(var k in options){
 
            var label = '<li id="'+k+'">'+k+':'+options[k]+'</li>'
         //resultGroupObj
            this.temp.options.append(label)
        var resultGroupList = []
            this.temp.select.append('<option value="'+k+'">'+k+'</option>')
         for(var i=0;i<this.answer.length;i++){
        }
             var answerInlineObj = answerInline(this.answer[i])
         for(var i=0;i<json.title.length;i++){
             var explainInlineObj = this.explain[i] === undefined || this.explain[i] === '' ? '暂无解析' : explainInline(this.explain[i])
             var reg1 = /\(\)/g
             resultGroupList.push(
             var text = json.title[i]
                    '<b>'+sourcePrefix+realSource.source+'-'+i+'</b>',
            if(reg1.test(text)){
                    $('<div style="margin-left:10px"></div>').append(answerInlineObj),
                text = text.replace("()",this.temp.select.prop("outerHTML"))
                    $('<div style="margin-left:10px"></div>').append(explainInlineObj)
            }else{
                )
                text += this.temp.select.prop("outerHTML")
            }
            this.temp.subTitle.attr('id',id+'-'+i)
            this.temp.source.text(s+i)
             this.temp.subTitle.html(this.temp.source.prop("outerHTML")+text)
            this.temp.titleCon.append(this.temp.subTitle.prop("outerHTML"))
        }
        for(var i=0;i<json.answer.length;i++){
            this.temp.correct.nextAll('.correctAnswer').append('<p id="ans-'+id +'-'+i+'">'+(s+i)+''+json.answer[i]+'</p>')
            this.temp.correct.nextAll('p').each(function () {
                $(this).css('display','none')
            })
        }
        for(var i=0;i<json.explain.length;i++){
            this.temp.explain.nextAll('.explain').append('<p id="exp-'+id +'-'+i+'">'+(s+i)+':'+json.explain[i]+'</p>')
         }
         }
        var resultGroupObj = resultGroup(id, resultGroupList)


         this.temp.subject.append(this.temp.range,this.temp.titleCon,this.temp.options)
         this.temp.main.append(range ,subjectForm,resultGroupObj, buttonGroupObj)
        if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
        this.temp.ansCon.append(this.temp.correct,this.temp.explain)
        this.temp.main.append(this.temp.subject,this.temp.ansCon)


         if(addHr){this.temp.main.append('<hr>')}
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.X = function () {
     o.X = function () {
         this.temp.type.text(json.type)
         //subjectForm
         this.temp.source.text(json.source)
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        this.temp.title.html(json.title)
         var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
         this.temp.correct.nextAll('.correctAnswer').html(json.answer)
         var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main):''
        this.temp.explain.nextAll('.explain').html(json.explain)
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj, optionsGroupObj])
         var options = formatAnsDic(json.choices)
        //resultGroupObj
         for(var k in options){
         var answerInlineObj = answerInline(this.answer)
            var label = '<label id="'+k+'"><input name="singelChoice-'+id+'" type="checkbox" value="'+k+'" />'+k+':'+options[k]+'</label>'
         var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
            this.temp.options.append(label)
         var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])
         }


         this.temp.titleCon.append(this.temp.type,this.temp.source,this.temp.title)
         this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )
        this.temp.ansCon.append(this.temp.correct,this.temp.explain)
        this.temp.subject.append(this.temp.titleCon,this.temp.options)
        if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
        this.temp.main.append(this.temp.subject,this.temp.ansCon)


         if(addHr){this.temp.main.append('<hr>')}
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.PD = function () {
     o.PD = function () {
        this.temp.type.text('判断')
    var dic = {
        this.temp.source.text(json.source)
      right: ['对', '正确', 't', '', '√', '1', 'true'],
        this.temp.title.html(json.title)
      wrong: ['错', '错误', '×', 'x', 'f', 'false', 'wrong', '0']
        this.temp.explain.nextAll('.explain').html(json.explain)
    }
         var ans = ''
         var ans = ''
         if(json.answer=='T' || json.answer=='正确' || json.answer=='1' || json.answer=='√'){
         var ansOption = ''
        if(isInArray(dic.right, json.answer.toLowerCase())){
             ans = '正确'
             ans = '正确'
         }else if(json.answer=='F' || json.answer=='错误' || json.answer=='0' || json.answer=='×'){
            ansOption = 'A'
         }else if(isInArray(dic.wrong, json.answer.toLowerCase())){
             ans = '错误'
             ans = '错误'
            ansOption = 'B'
        }else {
        ans = '系统错误:该判断题答案不符合标准格式'
         }
         }
        this.temp.correct.nextAll('.correctAnswer').html(ans)
        o.temp.btn.bind("click",function (){
            showChoiceAnswer(id,'A',ans)
        })
        this.temp.options.append('<label id="正确" style="display: inline;"><input name="singelChoice-'+id+'" type="radio" value="正确" />正确</label>' +
            '<label id="错误" style="display: inline;"><input name="singelChoice-'+id+'" type="radio" value="错误" />错误</label>')
        this.temp.titleCon.append(this.temp.type,this.temp.source,this.temp.title)
        this.temp.ansCon.append(this.temp.correct,this.temp.explain)
        this.temp.subject.append(this.temp.titleCon,this.temp.options)
        if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
        this.temp.main.append(this.temp.subject,this.temp.ansCon)


         if(addHr){this.temp.main.append('<hr>')}
        //subjectForm
        var option = new Map()
        option.set('A', '正确')
        option.set('B', '错误')
        var optionsGroupObj = optionsGroup(this.type, id, option)
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
        var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, 'A', ansOption, this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj,optionsGroupObj])
        //resultGroupObj
        var answerInlineObj = answerInline(ans)
        var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
        var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])
 
        this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )
 
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.TK = function () {
     o.TK = function () {
         this.temp.type.text('填空')
         var tkTitle = fillBlank(id, this.title, this.pos, ['text-input-tk'])
         this.temp.source.text(json.source)
         var titleInlineObj = titleInline(id, this.type,this.source,undefined,tkTitle, 'titleInline-no-flex')
        var form = $('<form id="form-'+id+'" class="title"></form>')
         titleInlineObj.children('.text-input-tk').each(function(i,v){
         var pos = json.pos
            // console.log(i,v)
        var posReg = new RegExp(pos,'g')
             $(this).children('input').css(
        var posCount = json.title.match(posReg).length
                'display','inline'
        for(var i=0;i<posCount;i++){
            )
             json.title = json.title.replace(pos,'<input name="'+id+'-'+i+'" id="'+id+'-'+i+'" type="text" form="form-'+id+'"/>')
            $(this).children('input').css(
         }
                'width','200px'
         form.html(json.title)
            )
        this.temp.title.html(json.title)
         })
        this.temp.correct.nextAll('.correctAnswer').html(json.answer)
         var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main):''
         this.temp.explain.nextAll('.explain').html(json.explain)
         var subjectForm = subjectFrom(id,this.type, [titleInlineObj])


        this.temp.titleCon.append(this.temp.type,this.temp.source,form)
         this.temp.main.append(subjectForm, buttonGroupObj)
        this.temp.ansCon.append(this.temp.correct,this.temp.explain)
        this.temp.subject.append(this.temp.titleCon,this.temp.options)
        if(!hideButton){this.temp.subject.append(this.temp.btn,this.temp.editBtn)}
         this.temp.main.append(this.temp.subject,this.temp.ansCon)


         if(addHr){this.temp.main.append('<hr>')}
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     o.MJ = function () {
     o.MJ = function () {
         this.temp.type.text('名解')
         var mjTitle = ''
         this.temp.source.text(json.source)
         if(this.inputBox===0){
        this.temp.title.html(json.title + ':<span class="blur" tabindex="0" style="display:inline;outline=0;" onclick="">' + json.answer +'</span>')
            mjTitle = json.title + ':<span class="blur" tabindex="0" style="display:inline;outline=0;" onclick="">' + json.answer +'</span>'
         this.temp.titleCon.append(this.temp.type,this.temp.source,this.temp.title)
         }else{
         this.temp.subject.append(this.temp.titleCon,this.temp.options)
            mjTitle = fillBlank(id, this.title+':()', '()', ['text-input-mj'])
         this.temp.main.append(this.temp.subject)
        }
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,mjTitle, 'titleInline-no-flex')
         titleInlineObj.children('.text-input-mj').each(function(i,v){
            // console.log(i,v)
            $(this).children('input').css(
                'display','inline'
            )
            $(this).children('input').css(
                'width','auto'
            )
         })
        var buttonGroupObj = this.inputBox!==0 ? buttonGroup(showSubmitBtn, showEditBtn, id, 'TK', [this.answer], this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj])


         if(addHr){this.temp.main.append('<hr>')}
        this.temp.main.append(subjectForm, buttonGroupObj)
         if(showHr){this.temp.main.append('<hr>')}
         return this.temp.main
         return this.temp.main
     }
     }
     return o
     return o
}
}
function formatAnsDic(d) {
 
     var c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
// // 获取select的选项
     var dic = {}
function getSelectedAnswer(id){
     for(var i=0;i<c.length;i++){
     var data = formToJSON('#'+prefixDic.formId + id,true)
        if(d[c[i]]===undefined){d[c[i]]=''}
    console.log(data)
        if(d[c[i]].length>0){
    return data
            dic[c[i]] = d[c[i]]
}
        }
// // 获取checkbox值
    }
function  getCheckBoxValue(name) {
    return dic
     var ids = $('input:checkbox[name="'+name+'"]:checked');
     var data = [];
    for (var i = 0; i < ids.length; i ++) {
        data.push(ids[i].value)
    }
    return data
}
}
function showThisAnswer(id,type,correctAnswer){
var isRight = false
    var resultGroup = $('#resultGroup-'+id)
    resultGroup.fadeIn(100)
    $('#showThisAnswer-'+id).fadeOut(1)


function showChoiceAnswer(id,type,correctAnswer){
    var subjectCon = $('#'+id)
    var titleCon = subjectCon.children('.subject').children('.titleContainer')
    var ansCon = subjectCon.children('.ansContainer')
    var answers = subjectCon.children('.subject').children('.options')
    console.log(correctAnswer)
     if(type==="A" || type ==='A2'){
     if(type==="A" || type ==='A2'){
         var correctAnsText = correctAnswer
         var optionGroupName = prefixDic.radioName+id
         var choice = $('input[name="singelChoice-'+id+'"]:checked').val();
         var optionInlinePrefixID = prefixDic.radioName+id
        console.log(choice)
        var usersChoice = getSelectedAnswer(id)[optionGroupName]
         var showCorrect = answers.children('#'+correctAnsText)
console.log(usersChoice)
         var showChoice = answers.children('#'+choice)
         var correctDivObj = $('#'+optionInlinePrefixID + '-' + correctAnswer)
        console.log('#showSingle-'+id)
         var usersChoiceDivObj = $('#'+optionInlinePrefixID + '-' + usersChoice)
        $('#showSingle-'+id).fadeOut(1)
          
         ansCon.fadeIn(100)
         if(usersChoice===correctAnswer){
         if(choice===correctAnsText){
             correctDivObj.addClass('correct')
             showCorrect.addClass('correct')
            isRight = true
         }else{
         }else{
             showCorrect.addClass('correct')
             correctDivObj.addClass('correct')
             showChoice.addClass('wrong')
             usersChoiceDivObj.addClass('wrong')
         }
         }
        setTimeout(function (){
            removeBackground(showChoice)
            removeBackground(showCorrect)
        }, 4000);


        setTimeout(function (){
            showCorrect.removeClass('no-background')
            showChoice.removeClass('no-background')
            showCorrect.removeClass('correct')
            showChoice.removeClass('wrong')
        }, 5000);
     }else if(type==='A3'){
     }else if(type==='A3'){
        $('#showSingle-'+id).fadeOut(1)
         for(var i=0;i<correctAnswer.length;i++){
         for(var i=0;i<id.length;i++){
            var subID = id[i]
            var mainID = subID.split('-')[0]
            console.log(subID)
            console.log(mainID)
            subjectCon = $('#'+ id[i])
            titleCon = subjectCon.children('.subject').children('.titleContainer')
            ansCon = subjectCon.children('.ansContainer')
            answers = subjectCon.children('.subject').children('.options')
            $('#showSingle-'+id).fadeOut(1)
            var correctAns= correctAnswer[i]
             //以下与A型题时一样的代码,知识用subID替换ID变量
             //以下与A型题时一样的代码,知识用subID替换ID变量
             showChoiceAnswer(subID,'A',correctAns)
             showThisAnswer(id+'-'+i,'A',correctAnswer[i])
         }
         }
    } else if(type==='B'){
        var dropDownInputPrefix = 'select-'+id +'-'
        var usersChoice = getSelectedAnswer(id)
        // console.log(usersChoice)


    } else if(type==='B'){
         for(var i in usersChoice){
         console.log(titleCon)
             var dorpdownID = i.replace(dropDownInputPrefix,'')//获取子ID
        titleCon.children('div').each(function (index,i){
             var subTimuID = id+'-'+dorpdownID
            console.log(i)
             var thisTimuUsersChoice = usersChoice[i]
             var subTitleID = $(i).attr('id')
             var thisTimuCorrectAnswer = correctAnswer[dorpdownID]
             var ans = correctAnswer[index]
             var subTimuDiv = $('#title-'+subTimuID)
            var choice = $('#'+id+'-'+index).find("option:selected").text();
             $('#showSingle-'+id).fadeOut(1)
             ansCon.fadeIn(100)
            console.log(choice)
            if(choice==ans){
                $('#'+id+'-'+index).addClass('correct')
             }else {
                $('#'+id+'-'+index).addClass('wrong')
                $('<p class="answerTip">正确答案:'+ans+'</p>').appendTo($('#'+id+'-'+index))


            if(thisTimuUsersChoice===thisTimuCorrectAnswer){
                subTimuDiv.addClass('correct')
            }else{
                subTimuDiv.addClass('wrong')
                subTimuDiv.append('<label class="answerTip">正确答案:'+thisTimuCorrectAnswer+'</label>')
             }
             }
            setTimeout(function (){
         }
                $('#'+id+'-'+index).removeClass('correct')
                $('#'+id+'-'+index).removeClass('wrong')
            }, 5000);
         })
     } else if(type=="C"){
     } else if(type=="C"){
         console.log(titleCon)
         var dropDownInputPrefix = 'select-'+id +'-'
        $('#showSingle-'+id).fadeOut(1)
        var usersChoice = getSelectedAnswer(id)
         ansCon.fadeIn(100)
         // console.log(usersChoice)
         titleCon.children('div').each(function (index,i){
 
            console.log(i)
         for(var i in usersChoice){
             var subTitleID = $(i).attr('id')
             var dorpdownID = i.replace(dropDownInputPrefix,'')//获取子ID
             var ans = correctAnswer[index]
             var subTimuID = id+'-'+dorpdownID
            var choice = $('#'+id+'-'+index).find("option:selected").text();
             var thisTimuUsersChoice = usersChoice[i]
             console.log(choice)
             var thisTimuCorrectAnswer = correctAnswer[dorpdownID]
             if(choice==ans){
             var subTimuDiv = $('#title-'+subTimuID)
                $('#'+id+'-'+index).addClass('correct')
             }else {
                $('#'+id+'-'+index).addClass('wrong')
                $('<p class="answerTip">正确答案:'+ans+'</p>').appendTo($('#'+id+'-'+index))


            if(thisTimuUsersChoice===thisTimuCorrectAnswer){
                subTimuDiv.addClass('correct')
            }else{
                subTimuDiv.addClass('wrong')
                subTimuDiv.append('<label class="answerTip">正确答案:'+thisTimuCorrectAnswer+'</label>')
             }
             }
            setTimeout(function (){
         }
                $('#'+id+'-'+index).removeClass('correct')
                $('#'+id+'-'+index).removeClass('wrong')
            }, 5000);
         })
     }else if(type=="X"){
     }else if(type=="X"){
         var correctAnsText = correctAnswer
         var optionGroupName = 'checkbox-'+id
         var choice = ""
         var optionInlinePrefixID = 'checkbox-'+id
        $('input[name="singelChoice-'+id+'"]:checked').each(function (){
        var usersChoice = getCheckBoxValue(optionGroupName).sort()
            choice += $(this).val()
         correctAnswer = correctAnswer.match(/[A-Z]/g).sort()
         })
         var lenCorrect = correctAnswer.length
        console.log(choice)
         var lenUser = usersChoice.length
         console.log(correctAnsText)
         // console.log(correctAnswer)
         $('#showSingle-'+id).fadeOut(1)
         for(var i=0;i<lenUser;i++){
         ansCon.fadeIn(100)
             // console.log(isInArray(correctAnswer, usersChoice[i]),usersChoice[i] ,correctAnswer)
         for(var i=0;i<choice.length;i++){
             if(!isInArray(correctAnswer, usersChoice[i])){
             var showCorrect = answers.children('#'+correctAnsText[i])
                 $('#'+optionInlinePrefixID + '-' + usersChoice[i]).addClass('wrong')
            var showChoice = answers.children('#'+choice[i])
             if(correctAnsText.indexOf(choice[i])!=-1){
                 showChoice.addClass('correct')
            }else{
                showChoice.addClass('wrong')
             }
             }
         }
         }
         for(var i=0;i<correctAnsText.length;i++){
 
             console.log(i)
         for(var i=0;i<lenCorrect;i++){
            var showCorrect = answers.children('#'+correctAnsText[i])
             if(!isInArray(usersChoice,correctAnswer[i])){
             $('<p class="answerTip">✓</p>').appendTo(showCorrect)
                $('#'+optionInlinePrefixID + '-' + correctAnswer[i]).addClass('notChoiced')
             }else {
                $('#'+optionInlinePrefixID + '-' + correctAnswer[i]).addClass('correct')
            }
         }
         }
        answers.children('label').each(function (){
 
            var a = $(this)
          
            setTimeout(function (){
                removeBackground(a)
            }, 4000);
            setTimeout(function (){
                a.removeClass('no-background')
                a.removeClass('correct')
                a.removeClass('wrong')
            }, 5000);
         })
     }else if(type=="TK"){
     }else if(type=="TK"){
        $('#showSingle-'+id).fadeOut(1)
         var textInputPrefix = prefixDic.textInputId+id+'-'
        ansCon.fadeIn(100)
         var usersChoice = getSelectedAnswer(id)
         var answers = correctAnswer
         for(var i in usersChoice){
        console.log(answers[0])
             var inputID = i.replace(textInputPrefix,'')
        var form =$('#form-'+id).serializeArray()
            // console.log('#'+i)
         var myAns = []
            var corrcetAnswerText = correctAnswer[inputID]===undefined?'暂无答案':correctAnswer[inputID]
        console.log(form[0]['value'])
             if(usersChoice[i]===correctAnswer[inputID]){
         for(var i=0;i<form.length;i++){
                 $('#'+i).html('<label class="answerTip correct">'+corrcetAnswerText+'</label>')
             var input = $('#form-'+id).children('#'+id+'-'+i)
             if(answers[i] != form[i]['value']){
                 $('<p class="wrong TKcheck">'+answers[i]+'</p>').insertAfter(input)
             }else{
             }else{
                 $('<p class="correct TKcheck">'+answers[i]+'</p>').insertAfter(input)
                 $('#'+i).after('<label class="answerTip wrong">'+corrcetAnswerText+'</label>')
             }
             }
         }
         }
    }
    if(isRight){
    locateTo(id+1)
     }
     }
}
}

2023年6月29日 (四) 15:04的最新版本

//设置
var prefixDic = {
    formId:'timuForm-',
    radioName:'radio-',
    radioId:'radio-input-',
    checkBoxName:'checkbox-',
    checkBoxId:'checkbox-input-',
    selectId:'select-',
    selectName:'select-',
    textInputName:'text-',
    textInputId:'text-'
}


//主函数
function renderTimuFromSessionStorage(){
	var timuList = gDomTimuList()
	// console.log(timuList)
	var order = timuList.order
	var timu = timuList.timu
	var errors = timuList.errors
	var repeatSource = timuList.repeatSource
	for(var i=0;i<order.length;i++){
		if(order[i].isError){
			var errorWidget = new OO.ui.MessageWidget( {
				type: 'error',
				showClose:true,
				label: 'id='+i+'的题目加载错误,错误信息:'+errors[i].info.name+':'+errors[i].info.message+'\n'+'对应文本:'+errors[i].dataText
			} )
			render(i,'A',$('<di></div>').append(errorWidget.$element,'<hr>'))
		}else{
			var dataJSON = timu[i].dataJSON
            var o = newTimu(i,dataJSON,{})[dataJSON.type]()
            render(i,dataJSON.type,o)
            var needCheck = $('#noRepeatCheck').length<=0
            if(repeatSource[i]!==undefined&&needCheck){
            	var warningWidget = new OO.ui.MessageWidget( {
					type: 'warning',
					label: '本题与本页面id为'+repeatSource[i]+'的题目source参数重复,本参数重复可能引起错误,请检查并修改!'
				} )
				render(i,'A',warningWidget.$element)
            }
		}
	}
}


//题目渲染函数
//生成info
function infoInline(info){
    return $('<div class="info">'+info+'</div>')
}
//单行题干的处理titleInline(type, source, title)
//生成titleGroup
function titlesGroup(titlesList){
    var group = $('<div class="titlesGroup"></div>')
    for(var i=0;i<titlesList.length;i++){
        group.append(titlesList[i])
    }
    return group
}
//生成titleInline
function titleInline(id, type,originalSource, sourceSuffix,title, classes){
    classes = classes===undefined?'':classes
    return $('<div id="title-'+id+'" class="'+classes+'"></div>').append(
            titleInlineType(type),
            titleInlineSource(originalSource,sourceSuffix,type),
            titleInlineTitle(title)
        )
}
function titleInlineType(type){
    var typeChinese = {
        A:'A',
        A2:'A2',
        A3:'A3',
        B:'B',
        C:'C',
        X:'X',
        TK:'填空',
        PD:'判断',
        MJ:'名解'
    }
    return $('<p class="type">'+typeChinese[type]+'</p>')
}
//从有中文的source中提取最后一个连续数字作为真实的source
function getRealSource(source){
    // console.log(source)
	var getContinueNumber = source.match(/[0-9]+/g)
	var splitContinueNumber = source.split(/[0-9]+/g)
    var realSource = getContinueNumber[getContinueNumber.length-1]*1
    var prefix = ''
    for(var i=0;i<getContinueNumber.length;i++){
    	prefix += splitContinueNumber[i]
    }
    return {prefix:prefix,source:realSource}
}
//返回source的obj
function titleInlineSource(originalSource, suffix , type){
    var realSource = type==='A3'?{prefix:'', source:originalSource}: getRealSource(originalSource)
    
    var prefix = realSource.prefix
    var source = realSource.source
    var suffix = suffix === undefined ? '':'-'+suffix

    return $('<p class="source">'+prefix+source+suffix+'</p>')
}
//返回sourceRange的obj
function rangeInline(originalSource, sourceRange, type){
    var source = getRealSource(originalSource).source
    var end = source*1+sourceRange*1 -1

    var rangeText = '第 '+source +' 到 ' + end + ' 题'
    var suffix = type==='B'?'共用备选答案':'共用题干'

    return $('<div class="sourceRange">'+rangeText + suffix +'</div>')
}
//返回title 的 obj
function titleInlineTitle(title){
    return $('<p class="title">'+title+'</p>')
}
//生成buttonGroup
function buttonGroup(showSubmitBtn, showEditBtn, id, type, correctAnswer, hoverTarget){
    // console.log(showEditBtn)
    var buttonGroupObj = $('<div class="buttonGroup"></div>')
    if(showSubmitBtn){buttonGroupObj.append(
        new OO.ui.ButtonWidget( {
            id:'showThisAnswer-'+id,
            label: '提交',
            flags: [
                'progressive'
            ]
        } ).$element.bind("click",function (){
            showThisAnswer(id,type,correctAnswer)
        })
    )}
    if(showEditBtn){
        buttonGroupObj.append(
            // $('<a class="editThisBtn" style="" href="javascript:void(0)"><span class="" id="editThis-' + id + '">题目有误?点击编辑本题</span></a>'),
            new OO.ui.ButtonWidget( {
                id:'editThis-' + id,
                classes:['editThisBtn'],
                framed: false,
                flags: [
                    'progressive'
                ],
                icon: 'edit',
                label: '题目有误?点击编辑本题'
            } ).$element.bind("click",function (){
                editThis(id)
            })
        )
        hoverTarget.hover(function () {
            buttonGroupObj.children('.editThisBtn').fadeIn(10)
        },function (){
            buttonGroupObj.children('.editThisBtn').fadeOut(70)
        })
    }
    return buttonGroupObj
}
//resultGroup: answer和explain的显示框
function resultGroup(id, items, answerInline,explainInline){
    var group = $('<div id="resultGroup-'+id+'" class="resultGroup"></div>')
    for(var i=0;i<items.length;i++){
        group.append(items[i])
    }
    return group
}
//生成answerInline
function answerInline(answer){
    return $('<div class="answerInline"><label>正确答案:</label>'+answer+'</div>')
}
//生成explainInline
function explainInline(explain){
    return $('<div class="explainInline"><label>解析:</label>'+explain+'</div>')
}

//生成subject 的form, 顺序items顺序添加 (title, options, buttonGroup)
function subjectFrom(id, type, items){
    var form =  $('<form id="'+prefixDic.formId+id+'" class="subjectForm"></form>')
    //绑定变化事件
    form.change(function(){
    	// 如果开启了暂存,则暂存
        if(!gWebPageTimuSettings().noTemp){
            formChangeListener(id, type)
        }
    })
    for(var i=0;i<items.length;i++){
        form.append(items[i])
    }
    return form
}
function subjectDIV(id,type,items){
    var div=  $('<div id="'+prefixDic.formId+id+'" class="subjectForm"></div>')
    for(var i=0;i<items.length;i++){
        div.append(items[i])
    }
    return div
}

//生成填空输入框
function fillBlank(id, title, pos, classes){
    // console.log(pos)
    var posReg = new RegExp(pos,'g')
    var blankLen = title.match(posReg).length
    var split = title.split(posReg)
    // console.log(blankLen)
    var newTitle = ''
    for(var i=0;i<(blankLen+split.length);i++){
        if(i%2===0){
            newTitle +=  '<p class="title">'+split[Math.floor(i/2)]+'</div>'
        }else{
            newTitle +=  new OO.ui.TextInputWidget( {
                name:prefixDic.textInputName+id+'-'+Math.floor(i/2),
                id:prefixDic.textInputId+id+'-'+Math.floor(i/2),
                classes:classes
            } ).$element.prop('outerHTML')
        }
        
    }
    return newTitle
}
//生成B、C型题的选择框
function dropDownInputWidget(id, availabelOptions){
    var options = []
    var select = $('<select class="dorpdown" id="'+prefixDic.selectId+id+'" name="'+prefixDic.selectName+id+'"></select>')
    for(var i=0;i<availabelOptions.length;i++){
        select.append('<option class="dropdown-option" value="'+availabelOptions[i]+'">'+availabelOptions[i]+'</option>')
    }
    return select
}
//生成options(options 是 Map对象)
function optionsGroup(type,id,options){
    var flexClass = (type==='B')||(type==='C') ? 'optionsGroup-flex':''
    var inputType = type==='X' ? 'checkbox':'radio'
    var optionGroupObj = $('<div class="optionsGroup '+flexClass+'"></div>')
    options.forEach(function(value, key, map){
        optionGroupObj.append(optionInline(id, key, value, !((type==='B')||(type==='C')), inputType))
    })
    return optionGroupObj
}
//生成optionInline
function optionInline(id, option, content,input,inputType){
    var idPrefix = inputType === 'checkbox' ? prefixDic.checkBoxId:prefixDic.radioId
    var namePrefix = inputType === 'checkbox' ? prefixDic.checkBoxName:prefixDic.radioName // 这个和外部的div的id一样就共用了

    var input = input ? $('<input id="'+ idPrefix + id+'-'+option+'" name="'+ namePrefix + id + '" type="'+inputType+'" value="' + option + '" />'):''
    var optionLabel = $('<label for="'+ idPrefix + id+'-'+option+'">'+option+'. </label>')
    var contentLabel = $('<label for="'+ idPrefix + id+'-'+option+'">'+content+'</label>')
    return $('<div id="'+ namePrefix +id+'-'+option+'" class="optionInline"></div>').append(input,optionLabel,contentLabel)
}
//清理json中的choice(清除空项并排序),接收Obj,
function cleanAndMakeSameLenOptions(options){
	//清除空项
	var options = filterEmptyEntries(options)
	//让所有option长度一样
	var maxOptionLen = getStrLength(Object.values(options).sort(function(a,b){return getStrLength(b) - getStrLength(a)})[0])
	for(var i in options){
		var minus = maxOptionLen - getStrLength(options[i])
		for(var n=0;n<minus;n++){
			options[i] += '&ensp;'
		}
	}
	// console.log(options)
    return sortDicByKey(options) //返回一个 Map 对象
}
function newTimu(id,json, settings){
    settings = json.settings===undefined||json.isA3 ? settings:json.settings//检测json是否带有settings或者是否为A3子题目

    parent = settings.parent === undefined ? '' : settings.parent
    showHr = settings.showHr == undefined ? true : settings.showHr
    showSubmitBtn = settings.showSubmitBtn === undefined ? true : settings.showSubmitBtn
    showEditBtn = settings.showEditBtn === undefined ? true : settings.showEditBtn
    showBtnGroup = settings.showBtnGroup === undefined? true:settings.showBtnGroup

    var o = new Object()
    o.type = json.type
    o.pos = json.pos
    o.inputBox = json.inputBox
    o.source = json.source
    o.sourceRange = json.sourceRange
    o.info = json.info
    o.title = json.title
    o.options = json.choices
    // console.log(o.options)
    //将choice 统一为Array的转换为obj
    if(typeOfObj(o.options)==='[object Array]'&&o.options.length===1&&o.type!=='A3'){
    	o.options = o.options[0]
    }
    o.options = o.options!==undefined? cleanAndMakeSameLenOptions(o.options):''
    // console.log(o.options)

    o.answer = json.answer
    o.explain = json.explain

    o.temp = {
        main:$('<div name="timu-'+(id+1)+'" id="'+id+'" class="type'+o.type+' timuContainer"><p class="timuID">'+id+'</p></div>'),
    }

    o.parent = parent
    // if(this.type==='A3'){
    //     	$(this).children('.subject').children('.editThisButton').fadeIn(1)
    //     }
    o.temp.main.hover(function () {
        $('editThis-' + id).fadeIn(10)
    },function (){
        $('editThis-' + id).fadeOut(70)
    })

    o.A = function () {
        //subjectForm 
        this.type = json.isA3?'A3':'A'
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        if(json.isA3){
            var titleInlineObj = titleInline(id, 'A3',this.source,undefined,this.title,'titleInline')
        }else{
            var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
        }
        
        var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj, optionsGroupObj])
        //resultGroupObj
        var answerInlineObj = answerInline(this.answer)
        var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
        var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])

        this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.A2 = function () {
        //subjectForm 
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
        var buttonGroupObj = buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main)
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj, optionsGroupObj])
        //resultGroupObj
        var answerInlineObj = answerInline(this.answer)
        var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
        var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])

        this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.A3 = function () {
        // console.log(settings)
        var realSource = getRealSource(json.source)
        var sourcePrefix = realSource.prefix===''?'':realSource.prefix
        //subjectForm 
        var range = rangeInline(this.source, this.sourceRange)
        var info = infoInline(this.info)

        var subTitlesList = []
        for(var i=0;i<this.title.length;i++){
            if(this.explain[i]==undefined){
                this.explain[i] = '暂无解析'
            }
            var data = {
                'isA3':true,
                "type":"A",
                "source":sourcePrefix+realSource.source+'-'+(i+1),
                "title":this.title[i],
                "answer":this.answer[i],
                "explain":this.explain[i],
                "choices":this.options.get(i+''),
            }
            // console.log(data)
            // console.log(this.options)
            subTitlesList.push(newTimu(id+'-'+i,data,{
                showHr:false,
                showEditBtn:false,
                showSubmitBtn:false,
                showBtnGroup:false
            }).A())
        }
        
        // console.log(this.answer)
        var buttonGroupObj  = buttonGroup(true, false, id, this.type, this.answer, this.temp.main)
        // console.log(buttonGroupObj)
        var subjectFormObj = subjectDIV(id,this.type, [subTitlesList])
        this.temp.main.append(range,info, subjectFormObj, buttonGroupObj)

        this.temp.main.append('<hr>')
        return this.temp.main
    }
    o.B = function () {
        var realSource = getRealSource(json.source)
        var sourcePrefix = realSource.prefix===''?'':realSource.prefix
        //subjectForm 
        var range = rangeInline(this.source, this.sourceRange)
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        var titleInlineList = []
        for(var i=0;i<this.title.length;i++){
            var dropdown = dropDownInputWidget(id+'-'+i, mapKeysList(this.options))
            var titleInlineObj = titleInline(id+'-'+i, this.type, json.source, i, this.title[i],'titleInline')
            titleInlineObj.append(dropdown)
            titleInlineList.push(titleInlineObj)
        }
        var titlesGroupObj = titlesGroup(titleInlineList)
        var buttonGroupObj = buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main)

        var subjectForm = subjectFrom(id,this.type, [optionsGroupObj, titlesGroupObj])

        //resultGroupObj
        var resultGroupList = []
        for(var i=0;i<this.answer.length;i++){
            var answerInlineObj = answerInline(this.answer[i])
            var explainInlineObj = this.explain[i] === undefined || this.explain[i] === '' ? '暂无解析' : explainInline(this.explain[i])
            resultGroupList.push(
                    '<b>'+sourcePrefix+realSource.source+'-'+i+'</b>',
                    $('<div style="margin-left:10px"></div>').append(answerInlineObj),
                    $('<div style="margin-left:10px"></div>').append(explainInlineObj)
                )
        }
        var resultGroupObj = resultGroup(id, resultGroupList)

        this.temp.main.append(range ,subjectForm,resultGroupObj, buttonGroupObj)

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.C = function () {
        var realSource = getRealSource(json.source)
        var sourcePrefix = realSource.prefix===''?'':realSource.prefix
        //subjectForm 
        var range = rangeInline(this.source, this.sourceRange)
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        var titleInlineList = []
        for(var i=0;i<this.title.length;i++){
            var dropdown = dropDownInputWidget(id+'-'+i, mapKeysList(this.options))
            var titleInlineObj = titleInline(id+'-'+i, this.type, json.source, i, this.title[i],'titleInline')
            titleInlineObj.append(dropdown)
            titleInlineList.push(titleInlineObj)
        }
        var titlesGroupObj = titlesGroup(titleInlineList)
        var buttonGroupObj = buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main)

        var subjectForm = subjectFrom(id,this.type, [titlesGroupObj, optionsGroupObj])

        //resultGroupObj
        var resultGroupList = []
        for(var i=0;i<this.answer.length;i++){
            var answerInlineObj = answerInline(this.answer[i])
            var explainInlineObj = this.explain[i] === undefined || this.explain[i] === '' ? '暂无解析' : explainInline(this.explain[i])
            resultGroupList.push(
                    '<b>'+sourcePrefix+realSource.source+'-'+i+'</b>',
                    $('<div style="margin-left:10px"></div>').append(answerInlineObj),
                    $('<div style="margin-left:10px"></div>').append(explainInlineObj)
                )
        }
        var resultGroupObj = resultGroup(id, resultGroupList)

        this.temp.main.append(range ,subjectForm,resultGroupObj, buttonGroupObj)

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.X = function () {
        //subjectForm 
        var optionsGroupObj = optionsGroup(this.type, id, this.options)
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
        var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj, optionsGroupObj])
        //resultGroupObj
        var answerInlineObj = answerInline(this.answer)
        var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
        var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])

        this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.PD = function () {
    	var dic = {
		      right: ['对', '正确', 't', '✓', '√', '1', 'true'],
		      wrong: ['错', '错误', '×', 'x', 'f', 'false', 'wrong', '0']
		    }
        var ans = ''
        var ansOption = ''
        if(isInArray(dic.right, json.answer.toLowerCase())){
            ans = '正确'
            ansOption = 'A'
        }else if(isInArray(dic.wrong, json.answer.toLowerCase())){
            ans = '错误'
            ansOption = 'B'
        }else {
        	ans = '系统错误:该判断题答案不符合标准格式'
        }

        //subjectForm 
        var option = new Map()
        option.set('A', '正确')
        option.set('B', '错误')
        var optionsGroupObj = optionsGroup(this.type, id, option)
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,this.title,'titleInline')
        var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, 'A', ansOption, this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj,optionsGroupObj])
        //resultGroupObj
        var answerInlineObj = answerInline(ans)
        var explainInlineObj = this.explain === undefined || this.explain === '' ? '暂无解析' : explainInline(this.explain)
        var resultGroupObj = resultGroup(id, [answerInlineObj, explainInlineObj])

        this.temp.main.append(subjectForm,resultGroupObj,buttonGroupObj )

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.TK = function () {
        var tkTitle = fillBlank(id, this.title, this.pos, ['text-input-tk'])
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,tkTitle, 'titleInline-no-flex')
        titleInlineObj.children('.text-input-tk').each(function(i,v){
            // console.log(i,v)
            $(this).children('input').css(
                'display','inline'
            )
            $(this).children('input').css(
                'width','200px'
            )
        })
        var buttonGroupObj = showBtnGroup? buttonGroup(showSubmitBtn, showEditBtn, id, this.type, this.answer, this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj])

        this.temp.main.append(subjectForm, buttonGroupObj)

        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    o.MJ = function () {
        var mjTitle = ''
        if(this.inputBox===0){
            mjTitle = json.title + ':<span class="blur" tabindex="0" style="display:inline;outline=0;" onclick="">' + json.answer +'</span>'
        }else{
            mjTitle = fillBlank(id, this.title+':()', '()', ['text-input-mj'])
        }
        var titleInlineObj = titleInline(id, this.type,this.source,undefined,mjTitle, 'titleInline-no-flex')
        titleInlineObj.children('.text-input-mj').each(function(i,v){
            // console.log(i,v)
            $(this).children('input').css(
                'display','inline'
            )
            $(this).children('input').css(
                'width','auto'
            )
        })
        var buttonGroupObj = this.inputBox!==0 ? buttonGroup(showSubmitBtn, showEditBtn, id, 'TK', [this.answer], this.temp.main):''
        var subjectForm = subjectFrom(id,this.type, [titleInlineObj])

        this.temp.main.append(subjectForm, buttonGroupObj)
        if(showHr){this.temp.main.append('<hr>')}
        return this.temp.main
    }
    return o
}

// // 获取select的选项
function getSelectedAnswer(id){
    var data = formToJSON('#'+prefixDic.formId + id,true)
    console.log(data)
    return data
}
// // 获取checkbox值
function  getCheckBoxValue(name) {
    var  ids = $('input:checkbox[name="'+name+'"]:checked');
    var data = [];
     for (var i = 0; i < ids.length; i ++) {
         data.push(ids[i].value)
     }
     return data
}
function showThisAnswer(id,type,correctAnswer){
	var isRight = false
    var resultGroup = $('#resultGroup-'+id)
    resultGroup.fadeIn(100)
    $('#showThisAnswer-'+id).fadeOut(1)

    if(type==="A" || type ==='A2'){
        var optionGroupName = prefixDic.radioName+id
        var optionInlinePrefixID = prefixDic.radioName+id
        var usersChoice = getSelectedAnswer(id)[optionGroupName]
		console.log(usersChoice)
        var correctDivObj = $('#'+optionInlinePrefixID + '-' + correctAnswer)
        var usersChoiceDivObj = $('#'+optionInlinePrefixID + '-' + usersChoice)
        
        if(usersChoice===correctAnswer){
            correctDivObj.addClass('correct')
            isRight = true
        }else{
            correctDivObj.addClass('correct')
            usersChoiceDivObj.addClass('wrong')
        }

    }else if(type==='A3'){
        for(var i=0;i<correctAnswer.length;i++){
            //以下与A型题时一样的代码,知识用subID替换ID变量
            showThisAnswer(id+'-'+i,'A',correctAnswer[i])
        }
    } else if(type==='B'){
        var dropDownInputPrefix = 'select-'+id +'-'
        var usersChoice = getSelectedAnswer(id)
        // console.log(usersChoice)

        for(var i in usersChoice){
            var dorpdownID = i.replace(dropDownInputPrefix,'')//获取子ID
            var subTimuID = id+'-'+dorpdownID
            var thisTimuUsersChoice = usersChoice[i]
            var thisTimuCorrectAnswer = correctAnswer[dorpdownID]
            var subTimuDiv = $('#title-'+subTimuID)

            if(thisTimuUsersChoice===thisTimuCorrectAnswer){
                subTimuDiv.addClass('correct')
            }else{
                subTimuDiv.addClass('wrong')
                subTimuDiv.append('<label class="answerTip">正确答案:'+thisTimuCorrectAnswer+'</label>')
            }
        }
    } else if(type=="C"){
        var dropDownInputPrefix = 'select-'+id +'-'
        var usersChoice = getSelectedAnswer(id)
        // console.log(usersChoice)

        for(var i in usersChoice){
            var dorpdownID = i.replace(dropDownInputPrefix,'')//获取子ID
            var subTimuID = id+'-'+dorpdownID
            var thisTimuUsersChoice = usersChoice[i]
            var thisTimuCorrectAnswer = correctAnswer[dorpdownID]
            var subTimuDiv = $('#title-'+subTimuID)

            if(thisTimuUsersChoice===thisTimuCorrectAnswer){
                subTimuDiv.addClass('correct')
            }else{
                subTimuDiv.addClass('wrong')
                subTimuDiv.append('<label class="answerTip">正确答案:'+thisTimuCorrectAnswer+'</label>')
            }
        }
    }else if(type=="X"){
        var optionGroupName = 'checkbox-'+id
        var optionInlinePrefixID = 'checkbox-'+id
        var usersChoice = getCheckBoxValue(optionGroupName).sort()
        correctAnswer = correctAnswer.match(/[A-Z]/g).sort()
        var lenCorrect = correctAnswer.length
        var lenUser = usersChoice.length
        // console.log(correctAnswer)
        for(var i=0;i<lenUser;i++){
            // console.log(isInArray(correctAnswer, usersChoice[i]),usersChoice[i] ,correctAnswer)
            if(!isInArray(correctAnswer, usersChoice[i])){
                $('#'+optionInlinePrefixID + '-' + usersChoice[i]).addClass('wrong')
            }
        }

        for(var i=0;i<lenCorrect;i++){
            if(!isInArray(usersChoice,correctAnswer[i])){
                $('#'+optionInlinePrefixID + '-' + correctAnswer[i]).addClass('notChoiced')
            }else {
                $('#'+optionInlinePrefixID + '-' + correctAnswer[i]).addClass('correct')
            }
        }

        
    }else if(type=="TK"){
        var textInputPrefix = prefixDic.textInputId+id+'-'
        var usersChoice = getSelectedAnswer(id)
        for(var i in usersChoice){
            var inputID = i.replace(textInputPrefix,'')
            // console.log('#'+i)
            var corrcetAnswerText = correctAnswer[inputID]===undefined?'暂无答案':correctAnswer[inputID]
            if(usersChoice[i]===correctAnswer[inputID]){
                $('#'+i).html('<label class="answerTip correct">'+corrcetAnswerText+'</label>')
            }else{
                $('#'+i).after('<label class="answerTip wrong">'+corrcetAnswerText+'</label>')
            }
        }
    }
    if(isRight){
    	locateTo(id+1)
    }
}
function removeBackground(obj){
    obj.addClass('no-background')
}