").addClass("qsm-tooltip-arrow").addClass(feedback.vertical).addClass(feedback.horizontal).appendTo(this);}}});jQuery('.qmn_quiz_container input').on('keypress',function(e){if(e.which===13){e.preventDefault();}});jQuery(document).on('click',".qsm-submit-btn",function(event){event.preventDefault();let quiz_id=+jQuery(this).closest('.qmn_quiz_container').find('.qmn_quiz_id').val();let form_id="quizForm"+quiz_id;jQuery(document).trigger('qsm_quiz_submit_trigger',[quiz_id]);let recaptcha=jQuery('#'+form_id).find("#qsm_grecaptcha_v3");if(!recaptcha.length){qmnFormSubmit(form_id);return false;} let site_key=jQuery('#'+form_id).find("#qsm_grecaptcha_v3_sitekey").val();let submit_action=jQuery('#'+form_id).find("#qsm_grecaptcha_v3_nonce").val();grecaptcha.ready(function(){grecaptcha.execute(site_key,{action:submit_action}).then(function(token){jQuery('#'+form_id).find("#qsm_grecaptcha_v3_response").val(token);qmnFormSubmit(form_id);});});});jQuery(document).on('click','.btn-reload-quiz',function(e){e.preventDefault();var quiz_id=jQuery(this).data('quiz_id');var parent_div=jQuery(this).parents('.qsm-quiz-container');qsmDisplayLoading(parent_div,quiz_id);jQuery.ajax({type:'POST',url:qmn_ajax_object.ajaxurl,data:{action:"qsm_get_quiz_to_reload",quiz_id:quiz_id,},success:function(response){parent_div.replaceWith(response);qmnDoInit();if(1!=qmn_quiz_data[quiz_id].disable_mathjax){MathJax.typesetPromise();} jQuery(document).trigger('qsm_retake_quiz',[quiz_id]);},error:function(errorThrown){console.log('error');}});});jQuery(document).on('change','.qmn-multiple-choice-input, .qsm_dropdown',function(e){let $i_this=jQuery(this);var quizID=jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();var $quizForm=QSM.getQuizForm(quizID);let value=jQuery(this).val();let $this=jQuery(this).parents('.quiz_section');let question_id=$i_this.attr('name').split('question')[1];if(qmn_quiz_data[quizID].enable_quick_result_mc==1){qsm_show_inline_result(quizID,question_id,value,$this,'radio',$i_this)} jQuery(document).trigger('qsm_after_select_answer',[quizID,question_id,value,$this,'radio']);if(qmn_quiz_data[quizID].end_quiz_if_wrong>0&&!jQuery(this).parents('.qsm-quiz-container').find('.mlw_next:visible').length){qsm_submit_quiz_if_answer_wrong(question_id,value,$this,$quizForm);}});let qsm_inline_result_timer;jQuery(document).on('keyup','.mlw_answer_open_text, .mlw_answer_number, .qmn_fill_blank ',function(e){let $i_this=jQuery(this);let quizID=jQuery(this).parents('.qsm-quiz-container').find('.qmn_quiz_id').val();let question_id=$i_this.attr('name').split('question')[1];let value=$i_this.val();let $this=$i_this.parents('.quiz_section');clearTimeout(qsm_inline_result_timer);qsm_inline_result_timer=setTimeout(()=>{if(qmn_quiz_data[quizID].enable_quick_result_mc==1){qsm_show_inline_result(quizID,question_id,value,$this,'input',$i_this,$this.find('.qmn_fill_blank').index($i_this));} jQuery(document).trigger('qsm_after_select_answer',[quizID,question_id,value,$this,'input',$this.find('.qmn_fill_blank').index($i_this)]);},2000);});const videoAttributePatterns=[/\ssrc="([^"]+)"/,/\smp4="([^"]+)"/,/\sm4v="([^"]+)"/,/\swebm="([^"]+)"/,/\sogv="([^"]+)"/,/\swmv="([^"]+)"/,/\sflv="([^"]+)"/,/\swidth="(\d+)"/,/\sheight="(\d+)"/];function parseAttributes(match,src,width,height){let videoAttrs={src:'',width:'',height:''};videoAttributePatterns.forEach(pattern=>{const attrMatch=match.match(pattern);if(attrMatch){const value=attrMatch[1]||'';if(pattern.toString().includes('width')){videoAttrs.width=value;}else if(pattern.toString().includes('height')){videoAttrs.height=value;}else{videoAttrs.src=value;}}});return videoAttrs;} function generateVideoTag(src,width,height,content){return`
`;} function qsm_check_shortcode(message=null){const videoContentRegex=/\[video(?:\s(?:src|mp4|m4v|webm|ogv|wmv|flv|width|height)="[^"]*")*\](.*?)\[\/video\]/g;let videoMatch=message.match(videoContentRegex);if(videoMatch){let videoHTML=message.replace(videoContentRegex,function(match,content){const{src,width,height}=parseAttributes(match);const videoTag=generateVideoTag(src,width,height,content);return`
${videoTag}
`;});return videoHTML;} let imageRegex=/\[img(?:(?:\ssrc="([^"]+)")|(?:\salt="([^"]+)")|(?:\swidth="(\d+)")|(?:\sheight="(\d+)")){0,4}\s*\]/g;let imageMatch=message.match(imageRegex);if(imageMatch){let imageHTML=message.replace(imageRegex,function(match,src,alt,width,height){return'
';});return'
'+imageHTML+'
';} return message;} function qsm_show_inline_result(quizID,question_id,value,$this,answer_type,$i_this,index=null){jQuery('.qsm-spinner-loader').remove();addSpinnerLoader($this,$i_this);let data=qsm_question_quick_result_js(question_id,value,answer_type,qmn_quiz_data[quizID].enable_quick_correct_answer_info,quizID);$this.find('.quick-question-res-p, .qsm-inline-correct-info').remove();$this.find('.qmn_radio_answers').children().removeClass('data-correct-answer');if(0
'+qmn_quiz_data[quizID].quick_result_correct_answer_text+'
') $this.append('
'+qsm_check_shortcode(data.message)+'
');}else if(0