Khi em click vào nút hoành thành e sẽ tìm đến từng câu hỏi để check câu answer nào được checked
.
Nhưng em chưa biết làm sao để làm được như vậy.
function displayQuestionCustomer(surveyObj){
if(!(surveyObj && surveyObj.listQuestion.length > 0)){
return;
}
time=surveyObj.surveyTime;
if(surveyObj.random==true){
shuffle(surveyObj.listQuestion);
}
var htmlArr = [];
htmlArr.push('<div class="survey-show">');
htmlArr.push('<div id="survey-id" style="display:none">'+surveyObj.testId+'</div>');
htmlArr.push('<div id="survey-name"><h2>'+surveyObj.name+'</h2></div>');
htmlArr.push('<div class="timeout" float:right><span>Thời gian còn lại: </span><span id="m">Phút</span> : <span id="s">Giây</span></div>');
resultObject.testId=surveyObj.testId;
resultObject.display=surveyObj.display_all;
if(surveyObj.display_all==3){
resultObject.id=surveyObj.customerId;
}
else if(surveyObj.display_all==1 || surveyObj.display_all==2){
resultObject.id=surveyObj.userId;
}
htmlArr.push('<div class="question-list">');
surveyObj.listQuestion.forEach(question=>{
htmlArr.push('<div id="'+question.questionId+'" class="question">');
htmlArr.push('<h3>'+question.content+'</h3>');
htmlArr.push('<div class="answer-list">');
question.listAnswer.forEach(answer=>{
htmlArr.push('<div class="answer">');
htmlArr.push('<input type="radio" name="answerId" class="answer-input" id="'+answer.answerId+'" value="'+answer.answerId+'" >');
htmlArr.push('<label for="answer-'+answer.answerId+'">'+answer.content+'</label>');
htmlArr.push('</div>');
});
htmlArr.push('</div>');
htmlArr.push('</div>');
})
htmlArr.push('</div>');
htmlArr.push('</div>');
console.log(resultObject);
htmlArr.push('<button class="btn btn-success btn-finish" type="button">Hoàn thành</button>');
jQuery('#survey').append(htmlArr.join('\n'));
countDownTime(surveyObj.surveyTime);
jQuery('#survey').find('.btn-finish').click(function(){
console.log(resultObject);
var data= JSON.stringify(resultObject);
save(data);
console.log(data);
jQuery('#survey .survey-show').hide();
jQuery('#survey .btn-finish').hide();
jQuery('#survey .test-result').show();
});
jQuery('#survey').find('.btn-finish').click(function(){
console.log(resultObject);
var data= JSON.stringify(resultObject);
save(data);
console.log(data);
jQuery('#survey .survey-show').hide();
jQuery('#survey .btn-finish').hide();
jQuery('#survey .test-result').show();
});
if(surveyObj.surveyTime==0){
jQuery('#survey .timeout').hide();
}
else{
jQuery('#survey .timeout').show();
countDownTime(surveyObj.surveyTime);
}
}