Plugin Directory

Changeset 3249137


Ignore:
Timestamp:
03/02/2025 09:31:14 AM (12 months ago)
Author:
expresstech
Message:

10.0.2 to trunk

Location:
quiz-master-next/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • quiz-master-next/trunk/blocks/block.php

    r3183301 r3249137  
    455455                foreach ( $quiz_data as $key => $quiz ) {
    456456
    457                     $question_data = QSM_Questions::load_questions_by_pages( $quiz['quiz_id'] );
     457                    $question_data = QSM_Questions::load_questions_by_pages( $quiz['quiz_id'], 'qsm_block' );
    458458                    $quiz_data[ $key ]['questions'] = $question_data;
    459459
     
    623623            //save quiz name
    624624            if ( ! empty(  $_POST['quizData']['quiz'] ) && ! empty(  $_POST['quizData']['quiz']['quiz_name'] ) ) {
    625                 $quiz_name = sanitize_key( wp_unslash( $_POST['quizData']['quiz']['quiz_name'] ) );
     625                $quiz_name = sanitize_text_field( wp_unslash( $_POST['quizData']['quiz']['quiz_name'] ) );
    626626                if ( ! empty( $quiz_id ) && ! empty( $post_id ) && ! empty( $quiz_name ) ) {
    627627                    //update quiz name
  • quiz-master-next/trunk/blocks/build/index.asset.php

    r3099722 r3249137  
    11<?php return array(
    22    'dependencies' => array( 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-editor', 'wp-element', 'wp-escape-html', 'wp-html-entities', 'wp-i18n', 'wp-notices' ),
    3     'version'      => '655ad6063fe3b7fe7a65',
     3    'version'      => '079252090a5b53f90c43',
    44);
  • quiz-master-next/trunk/blocks/build/index.js

    r3099722 r3249137  
    1 (()=>{"use strict";var e,t={550:(e,t,n)=>{const a=window.wp.blocks,s=window.wp.element,i=window.wp.i18n,r=window.wp.apiFetch;var o=n.n(r);const l=window.wp.htmlEntities,u=window.wp.blockEditor,c=window.wp.notices,m=window.wp.data,p=window.wp.editor,d=window.wp.components,q=e=>null==e||""===e,g=e=>{var t=document.createElement("textarea");return t.innerHTML=e,t.value},_=(e=!1)=>{let t=new FormData;if(t.append("qsm_block_api_call","1"),!1!==e)for(let n in e)e.hasOwnProperty(n)&&t.append(n,e[n]);return t},h=e=>{let t="";const n=new Uint8Array(e);window.crypto.getRandomValues(n);for(let a=0;a<e;a++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[n[a]%62];return t},z=(e="",t=!1)=>`${e}${h(8)}${t?`.${h(7)}`:""}`,b=(e,t="")=>q(e)?t:e,w=window.wp.escapeHtml,f=()=>{};function v({className:e="",quizAttr:t,setAttributes:n,data:a,onChangeFunc:i=f}){var r,o,l,u,c;const m=(()=>{if(a.defaultvalue=a.default,!q(a?.options))switch(a.type){case"checkbox":1===a.options.length&&(a.type="toggle"),a.label=a.options[0].label;break;case"radio":1==a.options.length?(a.label=a.options[0].label,a.type="toggle"):a.type="select"}return a.label=q(a.label)?"":(0,w.escapeAttribute)(a.label),a.help=q(a.help)?"":(0,w.escapeAttribute)(a.help),a})(),{id:p,label:g="",type:_,help:h="",options:z=[],defaultvalue:b}=m;return(0,s.createElement)(s.Fragment,null,"toggle"===_&&(0,s.createElement)(d.ToggleControl,{label:g,help:h,checked:!q(t[p])&&"1"==t[p],onChange:()=>i(q(t[p])||"1"!=t[p]?1:0,p)}),"select"===_&&(0,s.createElement)(d.SelectControl,{label:g,value:null!==(r=t[p])&&void 0!==r?r:b,options:z,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"number"===_&&(0,s.createElement)(d.TextControl,{type:"number",label:g,value:null!==(o=t[p])&&void 0!==o?o:b,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"text"===_&&(0,s.createElement)(d.TextControl,{type:"text",label:g,value:null!==(l=t[p])&&void 0!==l?l:b,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"textarea"===_&&(0,s.createElement)(d.TextareaControl,{label:g,value:null!==(u=t[p])&&void 0!==u?u:b,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"checkbox"===_&&(0,s.createElement)(d.CheckboxControl,{label:g,help:h,checked:!q(t[p])&&"1"==t[p],onChange:()=>i(q(t[p])||"1"!=t[p]?1:0,p)}),"radio"===_&&(0,s.createElement)(d.RadioControl,{label:g,help:h,selected:null!==(c=t[p])&&void 0!==c?c:b,options:z,onChange:e=>i(e,p)}))}const E=()=>(0,s.createElement)(d.Icon,{icon:()=>(0,s.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,s.createElement)("rect",{width:"24",height:"24",rx:"3",fill:"black"}),(0,s.createElement)("path",{d:"M17.8146 17.8349C19.3188 16.3426 20.25 14.2793 20.25 12C20.2485 7.44425 16.5267 3.75 11.9348 3.75C7.34282 3.75 3.62109 7.44425 3.62109 12C3.62109 16.5558 7.34282 20.25 11.9348 20.25H18.9988C19.4682 20.25 19.7074 19.7112 19.3813 19.3885L17.8146 17.8334V17.8349ZM11.8753 17.5195C8.72666 17.5195 6.17388 15.0737 6.17388 12.0569C6.17388 9.04022 8.72666 6.59442 11.8753 6.59442C15.024 6.59442 17.5768 9.04022 17.5768 12.0569C17.5768 15.0737 15.024 17.5195 11.8753 17.5195Z",fill:"white"}))});window.wp.compose,(0,a.registerBlockType)("qsm/quiz",{icon:E,edit:function(e){if("undefined"==typeof qsmBlockData)return null;const{className:t,attributes:n,setAttributes:a,isSelected:r,clientId:h,context:w}=e,f=w.postId,{createNotice:y}=(0,m.useDispatch)(c.store),k=qsmBlockData.globalQuizsetting,{quizID:x,postID:D,quizAttr:I=k}=n,[C,B]=(0,s.useState)(qsmBlockData.QSMQuizList),[S,A]=(0,s.useState)({error:!1,msg:""}),[N,O]=(0,s.useState)(!1),[P,T]=(0,s.useState)(!1),[M,Q]=(0,s.useState)(!1),[H,F]=(0,s.useState)([]),j=qsmBlockData.quizOptions,L=(0,m.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:n}=e(p.store);return n()&&!t()}),[]),K=(0,m.useSelect)((e=>e("core/editor")),[]),{getBlock:R}=(0,m.useSelect)(u.store);(0,s.useEffect)((()=>{let e=!0;if(e&&("0"==qsmBlockData.is_pro_activated&&setTimeout((()=>{V()}),100),!q(x)&&0<x)){let e=!1;C.forEach((t=>{if(x==t.value)return e=!0,!0})),e?$(x):(a({quizID:void 0}),A({error:!0,msg:(0,i.__)("Quiz not found. Please select an existing quiz or create a new one.","quiz-master-next")}))}return()=>{e=!1}}),[]);const V=()=>{let e=document.getElementById("modal-advanced-question-type");q(e)&&o()({path:"/quiz-survey-master/v1/quiz/advance-ques-type-upgrade-popup",method:"POST"}).then((e=>{let t=document.getElementById("wpbody-content");q(t)||"success"!=e.status||t.insertAdjacentHTML("afterbegin",e.result)})).catch((e=>{console.log("error",e)}))},$=e=>{!q(e)&&0<e&&o()({path:"/quiz-survey-master/v1/quiz/structure",method:"POST",data:{quizID:e}}).then((t=>{if("success"==t.status){A({error:!1,msg:""});let n=t.result;if(a({quizID:parseInt(e),postID:n.post_id,quizAttr:{...I,...n}}),!q(n.qpages)){let e=[];n.qpages.forEach((t=>{let n=[];q(t.question_arr)||t.question_arr.forEach((e=>{if(!q(e)){let t=[];!q(e.answers)&&0<e.answers.length&&e.answers.forEach(((e,n)=>{t.push(["qsm/quiz-answer-option",{optionID:n,content:e[0],points:e[1],isCorrect:e[2],caption:b(e[3])}])})),n.push(["qsm/quiz-question",{questionID:e.question_id,type:e.question_type_new,answerEditor:e.settings.answerEditor,title:e.settings.question_title,description:e.question_name,required:e.settings.required,hint:e.hints,answers:e.answers,correctAnswerInfo:e.question_answer_info,category:e.category,multicategories:e.multicategories,commentBox:e.comments,matchAnswer:e.settings.matchAnswer,featureImageID:e.settings.featureImageID,featureImageSrc:e.settings.featureImageSrc,settings:e.settings},t])}})),e.push(["qsm/quiz-page",{pageID:t.id,pageKey:t.pagekey,hidePrevBtn:t.hide_prevbtn,quizID:t.quizID},n])})),F(e)}}else console.log("error "+t.msg)})).catch((e=>{console.log("error",e)}))},Z=(e,t)=>{let n=I;n[t]=e,a({quizAttr:{...n}})};(0,s.useEffect)((()=>{if(L){let e=(()=>{let e=R(h);if(q(e))return!1;e=e.innerBlocks;let t={quiz_id:I.quiz_id,post_id:I.post_id,quiz:{},pages:[],qpages:[],questions:[]},n=0;return e.forEach((e=>{if("qsm/quiz-page"===e.name){let a=e.attributes.pageID,s=[];!q(e.innerBlocks)&&0<e.innerBlocks.length&&e.innerBlocks.forEach((e=>{if("qsm/quiz-question"!==e.name)return!0;let a=e.attributes,i=b(a?.answerEditor,"text"),r=[];!q(e.innerBlocks)&&0<e.innerBlocks.length&&e.innerBlocks.forEach((e=>{if("qsm/quiz-answer-option"!==e.name)return!0;let t=e.attributes,n=b(t?.content);q(a?.answerEditor)||"rich"!==a.answerEditor||(n=g((0,l.decodeEntities)(n)));let s=[n,b(t?.points),b(t?.isCorrect)];"image"!==i||q(t?.caption)||s.push(t?.caption),r.push(s)})),s.push(a.questionID),a.isChanged&&t.questions.push({id:a.questionID,quizID:I.quiz_id,postID:I.post_id,answerEditor:i,type:b(a?.type,"0"),name:g(b(a?.description)),question_title:b(a?.title),answerInfo:g(b(a?.correctAnswerInfo)),comments:b(a?.commentBox,"1"),hint:b(a?.hint),category:b(a?.category),multicategories:b(a?.multicategories,[]),required:b(a?.required,0),answers:r,featureImageID:b(a?.featureImageID),featureImageSrc:b(a?.featureImageSrc),page:n,other_settings:{...b(a?.settings,{}),required:b(a?.required,0),question_title:b(a?.title),answerEditor:i}})})),t.pages.push(s),t.qpages.push({id:a,quizID:I.quiz_id,pagekey:q(e.attributes.pageKey)?z():e.attributes.pageKey,hide_prevbtn:e.attributes.hidePrevBtn,questions:s}),n++}})),t.quiz={quiz_name:I.quiz_name,quiz_id:I.quiz_id,post_id:I.post_id},M&&["form_type","system","timer_limit","pagination","enable_contact_form","enable_pagination_quiz","show_question_featured_image_in_result","progress_bar","require_log_in","disable_first_page","comment_section"].forEach((e=>{void 0!==I[e]&&null!==I[e]&&(t.quiz[e]=I[e])})),t})();T(!0);let t="publish";q(K)||(t=K.getEditedPostAttribute("status")),q(t)&&(t="publish"),e=_({save_entire_quiz:"1",quizData:JSON.stringify(e),qsm_block_quiz_nonce:qsmBlockData.nonce,page_post_id:q(f)?0:f,post_status:t,nonce:qsmBlockData.saveNonce}),o()({path:"/quiz-survey-master/v1/quiz/save_quiz",method:"POST",body:e}).then((e=>{y(e.status,e.msg,{isDismissible:!0,type:"snackbar"})})).catch((e=>{console.log("error",e),y("error",e.message,{isDismissible:!0,type:"snackbar"})}))}}),[L]);const J=(0,u.useBlockProps)(),U=(0,u.useInnerBlocksProps)(J,{template:H,allowedBlocks:["qsm/quiz-page"]});return(0,s.createElement)(s.Fragment,null,(0,s.createElement)(u.InspectorControls,null,(0,s.createElement)(d.PanelBody,{title:(0,i.__)("Quiz settings","quiz-master-next"),initialOpen:!0},(0,s.createElement)("label",{className:"qsm-inspector-label"},(0,i.__)("Status","quiz-master-next")+":",(0,s.createElement)("span",{className:"qsm-inspector-label-value"},I.post_status)),(0,s.createElement)(d.TextControl,{label:(0,i.__)("Quiz Name *","quiz-master-next"),help:(0,i.__)("Enter a name for this Quiz","quiz-master-next"),value:I?.quiz_name||"",onChange:e=>Z(e,"quiz_name"),className:"qsm-no-mb"}),(!q(x)||"0"!=x)&&(0,s.createElement)("p",null,(0,s.createElement)(d.ExternalLink,{href:qsmBlockData.quiz_settings_url+"&quiz_id="+x+"&tab=options"},(0,i.__)("Advance Quiz Settings","quiz-master-next"))))),q(x)||"0"==x?(0,s.createElement)("div",{...J}," ",(0,s.createElement)(d.Placeholder,{className:"qsm-placeholder-wrapper",icon:E,label:(0,i.__)("Quiz And Survey Master","quiz-master-next"),instructions:(0,i.__)("Easily and quickly add quizzes and surveys inside the block editor.","quiz-master-next")},(0,s.createElement)(s.Fragment,null,!q(C)&&0<C.length&&(0,s.createElement)("div",{className:"qsm-placeholder-select-create-quiz"},(0,s.createElement)(d.SelectControl,{label:(0,i.__)("","quiz-master-next"),value:x,options:C,onChange:e=>$(e),disabled:N,__nextHasNoMarginBottom:!0}),(0,s.createElement)("span",null,(0,i.__)("OR","quiz-master-next")),(0,s.createElement)(d.Button,{variant:"link",onClick:()=>O(!N)},(0,i.__)("Add New","quiz-master-next"))),(q(C)||N)&&(0,s.createElement)(d.__experimentalVStack,{spacing:"3",className:"qsm-placeholder-quiz-create-form"},(0,s.createElement)(d.TextControl,{label:(0,i.__)("Quiz Name *","quiz-master-next"),help:(0,i.__)("Enter a name for this Quiz","quiz-master-next"),value:I?.quiz_name||"",onChange:e=>Z(e,"quiz_name")}),(0,s.createElement)(d.Button,{variant:"link",onClick:()=>Q(!M)},(0,i.__)("Advance options","quiz-master-next")),(0,s.createElement)("div",{className:"qsm-advance-settings"},M&&j.map((e=>(0,s.createElement)(v,{key:"qsm-settings"+e.id,data:e,quizAttr:I,setAttributes:a,onChangeFunc:Z})))),(0,s.createElement)(d.Button,{variant:"primary",disabled:P||q(I.quiz_name),onClick:()=>(()=>{if(q(I.quiz_name))return void console.log("empty quiz_name");T(!0);let e=_({quiz_name:I.quiz_name,qsm_new_quiz_nonce:qsmBlockData.qsm_new_quiz_nonce});["form_type","system","timer_limit","pagination","enable_contact_form","enable_pagination_quiz","show_question_featured_image_in_result","progress_bar","require_log_in","disable_first_page","comment_section"].forEach((t=>void 0===I[t]||null===I[t]?"":e.append(t,I[t]))),o()({path:"/quiz-survey-master/v1/quiz/create_quiz",method:"POST",body:e}).then((e=>{if(T(!1),"success"==e.status){let t=_({id:null,quizID:e.quizID,answerEditor:"text",type:"0",name:"",question_title:"",answerInfo:"",comments:"1",hint:"",category:"",required:0,answers:[],page:0});o()({path:"/quiz-survey-master/v1/questions",method:"POST",body:t}).then((t=>{if("success"==t.status){let n=t.id,a=_({action:qsmBlockData.save_pages_action,quiz_id:e.quizID,nonce:qsmBlockData.saveNonce,post_id:e.quizPostID});a.append("pages[0][]",n),a.append("qpages[0][id]",1),a.append("qpages[0][quizID]",e.quizID),a.append("qpages[0][pagekey]",z()),a.append("qpages[0][hide_prevbtn]",0),a.append("qpages[0][questions][]",n),o()({url:qsmBlockData.ajax_url,method:"POST",body:a}).then((t=>{"success"==t.status&&$(e.quizID)}))}})).catch((e=>{console.log("error",e),y("error",e.message,{isDismissible:!0,type:"snackbar"})}))}y(e.status,e.msg,{isDismissible:!0,type:"snackbar"})})).catch((e=>{console.log("error",e),y("error",e.message,{isDismissible:!0,type:"snackbar"})}))})()},(0,i.__)("Create Quiz","quiz-master-next"))),S.error&&(0,s.createElement)("p",{className:"qsm-error-text"},S.msg)))," "):(0,s.createElement)("div",{...U}))},save:e=>null})}},n={};function a(e){var s=n[e];if(void 0!==s)return s.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,a),i.exports}a.m=t,e=[],a.O=(t,n,s,i)=>{if(!n){var r=1/0;for(c=0;c<e.length;c++){for(var[n,s,i]=e[c],o=!0,l=0;l<n.length;l++)(!1&i||r>=i)&&Object.keys(a.O).every((e=>a.O[e](n[l])))?n.splice(l--,1):(o=!1,i<r&&(r=i));if(o){e.splice(c--,1);var u=s();void 0!==u&&(t=u)}}return t}i=i||0;for(var c=e.length;c>0&&e[c-1][2]>i;c--)e[c]=e[c-1];e[c]=[n,s,i]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={826:0,431:0};a.O.j=t=>0===e[t];var t=(t,n)=>{var s,i,[r,o,l]=n,u=0;if(r.some((t=>0!==e[t]))){for(s in o)a.o(o,s)&&(a.m[s]=o[s]);if(l)var c=l(a)}for(t&&t(n);u<r.length;u++)i=r[u],a.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return a.O(c)},n=globalThis.webpackChunkqsm=globalThis.webpackChunkqsm||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var s=a.O(void 0,[431],(()=>a(550)));s=a.O(s)})();
     1(()=>{"use strict";var e,t={550:(e,t,n)=>{const s=window.wp.blocks,a=window.wp.element,i=window.wp.i18n,r=window.wp.apiFetch;var o=n.n(r);const l=window.wp.htmlEntities,u=window.wp.blockEditor,c=window.wp.notices,m=window.wp.data,p=window.wp.editor,d=window.wp.components,q=e=>null==e||""===e,g=e=>{var t=document.createElement("textarea");return t.innerHTML=e,t.value},_=(e=!1)=>{let t=new FormData;if(t.append("qsm_block_api_call","1"),!1!==e)for(let n in e)e.hasOwnProperty(n)&&t.append(n,e[n]);return t},h=e=>{let t="";const n=new Uint8Array(e);window.crypto.getRandomValues(n);for(let s=0;s<e;s++)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"[n[s]%62];return t},z=(e="",t=!1)=>`${e}${h(8)}${t?`.${h(7)}`:""}`,b=(e,t="")=>q(e)?t:e,w=window.wp.escapeHtml,f=()=>{};function v({className:e="",quizAttr:t,setAttributes:n,data:s,onChangeFunc:i=f}){var r,o,l,u,c;const m=(()=>{if(s.defaultvalue=s.default,!q(s?.options))switch(s.type){case"checkbox":1===s.options.length&&(s.type="toggle"),s.label=s.options[0].label;break;case"radio":1==s.options.length?(s.label=s.options[0].label,s.type="toggle"):s.type="select"}return s.label=q(s.label)?"":(0,w.escapeAttribute)(s.label),s.help=q(s.help)?"":(0,w.escapeAttribute)(s.help),s})(),{id:p,label:g="",type:_,help:h="",options:z=[],defaultvalue:b}=m;return(0,a.createElement)(a.Fragment,null,"toggle"===_&&(0,a.createElement)(d.ToggleControl,{label:g,help:h,checked:!q(t[p])&&"1"==t[p],onChange:()=>i(q(t[p])||"1"!=t[p]?1:0,p)}),"select"===_&&(0,a.createElement)(d.SelectControl,{label:g,value:null!==(r=t[p])&&void 0!==r?r:b,options:z,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"number"===_&&(0,a.createElement)(d.TextControl,{type:"number",label:g,value:null!==(o=t[p])&&void 0!==o?o:b,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"text"===_&&(0,a.createElement)(d.TextControl,{type:"text",label:g,value:null!==(l=t[p])&&void 0!==l?l:b,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"textarea"===_&&(0,a.createElement)(d.TextareaControl,{label:g,value:null!==(u=t[p])&&void 0!==u?u:b,onChange:e=>i(e,p),help:h,__nextHasNoMarginBottom:!0}),"checkbox"===_&&(0,a.createElement)(d.CheckboxControl,{label:g,help:h,checked:!q(t[p])&&"1"==t[p],onChange:()=>i(q(t[p])||"1"!=t[p]?1:0,p)}),"radio"===_&&(0,a.createElement)(d.RadioControl,{label:g,help:h,selected:null!==(c=t[p])&&void 0!==c?c:b,options:z,onChange:e=>i(e,p)}))}const y=()=>(0,a.createElement)(d.Icon,{icon:()=>(0,a.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)("rect",{width:"24",height:"24",rx:"3",fill:"black"}),(0,a.createElement)("path",{d:"M17.8146 17.8349C19.3188 16.3426 20.25 14.2793 20.25 12C20.2485 7.44425 16.5267 3.75 11.9348 3.75C7.34282 3.75 3.62109 7.44425 3.62109 12C3.62109 16.5558 7.34282 20.25 11.9348 20.25H18.9988C19.4682 20.25 19.7074 19.7112 19.3813 19.3885L17.8146 17.8334V17.8349ZM11.8753 17.5195C8.72666 17.5195 6.17388 15.0737 6.17388 12.0569C6.17388 9.04022 8.72666 6.59442 11.8753 6.59442C15.024 6.59442 17.5768 9.04022 17.5768 12.0569C17.5768 15.0737 15.024 17.5195 11.8753 17.5195Z",fill:"white"}))});window.wp.compose,(0,s.registerBlockType)("qsm/quiz",{icon:y,edit:function(e){if("undefined"==typeof qsmBlockData)return null;const{className:t,attributes:n,setAttributes:s,isSelected:r,clientId:h,context:w}=e,f=w.postId,{createNotice:E}=(0,m.useDispatch)(c.store),k=qsmBlockData.globalQuizsetting,{quizID:x,postID:D,quizAttr:I=k}=n,[C,B]=(0,a.useState)(qsmBlockData.QSMQuizList),[S,P]=(0,a.useState)({error:!1,msg:""}),[A,N]=(0,a.useState)(!1),[O,T]=(0,a.useState)(!1),[M,Q]=(0,a.useState)(!1),[H,F]=(0,a.useState)([]),j=qsmBlockData.quizOptions,L=(0,m.useSelect)((e=>{const{isAutosavingPost:t,isSavingPost:n}=e(p.store);return n()&&!t()}),[]),K=(0,m.useSelect)((e=>e("core/editor")),[]),{getBlock:R}=(0,m.useSelect)(u.store);(0,a.useEffect)((()=>{let e=!0;if(e&&("0"==qsmBlockData.is_pro_activated&&setTimeout((()=>{V()}),100),!q(x)&&0<x)){let e=!1;C.forEach((t=>{if(x==t.value)return e=!0,!0})),e?$(x):(s({quizID:void 0}),P({error:!0,msg:(0,i.__)("Quiz not found. Please select an existing quiz or create a new one.","quiz-master-next")}))}return()=>{e=!1}}),[]);const V=()=>{let e=document.getElementById("modal-advanced-question-type");q(e)&&o()({path:"/quiz-survey-master/v1/quiz/advance-ques-type-upgrade-popup",method:"POST"}).then((e=>{let t=document.getElementById("wpbody-content");q(t)||"success"!=e.status||t.insertAdjacentHTML("afterbegin",e.result)})).catch((e=>{console.log("error",e)}))},$=e=>{!q(e)&&0<e&&o()({path:"/quiz-survey-master/v1/quiz/structure",method:"POST",data:{quizID:e}}).then((t=>{if("success"==t.status){P({error:!1,msg:""});let n=t.result;if(s({quizID:parseInt(e),postID:n.post_id,quizAttr:{...I,...n}}),!q(n.qpages)){let e=[];n.qpages.forEach((t=>{let n=[];q(t.question_arr)||t.question_arr.forEach((e=>{if(!q(e)){let t=[];!q(e.answers)&&0<e.answers.length&&e.answers.forEach(((e,n)=>{t.push(["qsm/quiz-answer-option",{optionID:n,content:e[0],points:e[1],isCorrect:e[2],caption:b(e[3])}])})),n.push(["qsm/quiz-question",{questionID:e.question_id,isPublished:void 0!==e.settings.isPublished?e.settings.isPublished:1,linked_question:void 0!==e.linked_question?e.linked_question:"",type:e.question_type_new,answerEditor:e.settings.answerEditor,title:e.settings.question_title,description:e.question_name,required:"0"==e.settings.required?"1":"0",hint:e.hints,answers:e.answers,correctAnswerInfo:e.question_answer_info,category:e.category,multicategories:e.multicategories,commentBox:e.comments,matchAnswer:e.settings.matchAnswer,featureImageID:e.settings.featureImageID,featureImageSrc:e.settings.featureImageSrc,settings:e.settings},t])}})),e.push(["qsm/quiz-page",{pageID:t.id,pageKey:t.pagekey,hidePrevBtn:t.hide_prevbtn,quizID:t.quizID},n])})),F(e)}}else console.log("error "+t.msg)})).catch((e=>{console.log("error",e)}))},Z=(e,t)=>{let n=I;n[t]=e,s({quizAttr:{...n}})};(0,a.useEffect)((()=>{if(L){let e=(()=>{let e=R(h);if(q(e))return!1;e=e.innerBlocks;let t={quiz_id:I.quiz_id,post_id:I.post_id,quiz:{},pages:[],qpages:[],questions:[]},n=0;return e.forEach((e=>{if("qsm/quiz-page"===e.name){let s=e.attributes.pageID,a=[];!q(e.innerBlocks)&&0<e.innerBlocks.length&&e.innerBlocks.forEach((e=>{if("qsm/quiz-question"!==e.name)return!0;let s=e.attributes,i=b(s?.answerEditor,"text"),r=[];!q(e.innerBlocks)&&0<e.innerBlocks.length&&e.innerBlocks.forEach((e=>{if("qsm/quiz-answer-option"!==e.name)return!0;let t=e.attributes,n=b(t?.content);q(s?.answerEditor)||"rich"!==s.answerEditor||(n=g((0,l.decodeEntities)(n)));let a=[n,b(t?.points),b(t?.isCorrect)];"image"!==i||q(t?.caption)||a.push(t?.caption),r.push(a)})),a.push(s.questionID),s.isChanged&&t.questions.push({id:s.questionID,quizID:I.quiz_id,postID:I.post_id,answerEditor:i,type:b(s?.type,"0"),name:g(b(s?.description)),question_title:b(s?.title),answerInfo:g(b(s?.correctAnswerInfo)),comments:b(s?.commentBox,"1"),hint:b(s?.hint),category:b(s?.category),multicategories:b(s?.multicategories,[]),required:"0"==b(s?.required,"1")?"1":"0",is_published:b(s?.isPublished,1),merged_question:b(s?.linked_question,""),answers:r,featureImageID:b(s?.featureImageID),featureImageSrc:b(s?.featureImageSrc),page:n,other_settings:{...b(s?.settings,{}),required:"0"==b(s?.required,"1")?"1":"0",isPublished:b(s?.isPublished,1),question_title:b(s?.title),answerEditor:i}})})),t.pages.push(a),t.qpages.push({id:s,quizID:I.quiz_id,pagekey:q(e.attributes.pageKey)?z():e.attributes.pageKey,hide_prevbtn:e.attributes.hidePrevBtn,questions:a}),n++}})),t.quiz={quiz_name:I.quiz_name,quiz_id:I.quiz_id,post_id:I.post_id},M&&["form_type","system","timer_limit","pagination","enable_contact_form","enable_pagination_quiz","show_question_featured_image_in_result","progress_bar","require_log_in","disable_first_page","comment_section"].forEach((e=>{void 0!==I[e]&&null!==I[e]&&(t.quiz[e]=I[e])})),t})();T(!0);let t="publish";q(K)||(t=K.getEditedPostAttribute("status")),q(t)&&(t="publish"),e=_({save_entire_quiz:"1",quizData:JSON.stringify(e),qsm_block_quiz_nonce:qsmBlockData.nonce,page_post_id:q(f)?0:f,post_status:t,nonce:qsmBlockData.saveNonce}),o()({path:"/quiz-survey-master/v1/quiz/save_quiz",method:"POST",body:e}).then((e=>{E(e.status,e.msg,{isDismissible:!0,type:"snackbar"})})).catch((e=>{console.log("error",e),E("error",e.message,{isDismissible:!0,type:"snackbar"})}))}}),[L]);const J=(0,u.useBlockProps)(),U=(0,u.useInnerBlocksProps)(J,{template:H,allowedBlocks:["qsm/quiz-page"]});return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(u.InspectorControls,null,(0,a.createElement)(d.PanelBody,{title:(0,i.__)("Quiz settings","quiz-master-next"),initialOpen:!0},(0,a.createElement)("label",{className:"qsm-inspector-label"},(0,i.__)("Status","quiz-master-next")+":",(0,a.createElement)("span",{className:"qsm-inspector-label-value"},I.post_status)),(0,a.createElement)(d.TextControl,{label:(0,i.__)("Quiz Name *","quiz-master-next"),help:(0,i.__)("Enter a name for this Quiz","quiz-master-next"),value:I?.quiz_name||"",onChange:e=>Z(e,"quiz_name"),className:"qsm-no-mb"}),(!q(x)||"0"!=x)&&(0,a.createElement)("p",null,(0,a.createElement)(d.ExternalLink,{href:qsmBlockData.quiz_settings_url+"&quiz_id="+x+"&tab=options"},(0,i.__)("Advance Quiz Settings","quiz-master-next"))))),q(x)||"0"==x?(0,a.createElement)("div",{...J}," ",(0,a.createElement)(d.Placeholder,{className:"qsm-placeholder-wrapper",icon:y,label:(0,i.__)("Quiz And Survey Master","quiz-master-next"),instructions:(0,i.__)("Easily and quickly add quizzes and surveys inside the block editor.","quiz-master-next")},(0,a.createElement)(a.Fragment,null,!q(C)&&0<C.length&&(0,a.createElement)("div",{className:"qsm-placeholder-select-create-quiz"},(0,a.createElement)(d.SelectControl,{label:(0,i.__)("","quiz-master-next"),value:x,options:C,onChange:e=>$(e),disabled:A,__nextHasNoMarginBottom:!0}),(0,a.createElement)("span",null,(0,i.__)("OR","quiz-master-next")),(0,a.createElement)(d.Button,{variant:"link",onClick:()=>N(!A)},(0,i.__)("Add New","quiz-master-next"))),(q(C)||A)&&(0,a.createElement)(d.__experimentalVStack,{spacing:"3",className:"qsm-placeholder-quiz-create-form"},(0,a.createElement)(d.TextControl,{label:(0,i.__)("Quiz Name *","quiz-master-next"),help:(0,i.__)("Enter a name for this Quiz","quiz-master-next"),value:I?.quiz_name||"",onChange:e=>Z(e,"quiz_name")}),(0,a.createElement)(d.Button,{variant:"link",onClick:()=>Q(!M)},(0,i.__)("Advance options","quiz-master-next")),(0,a.createElement)("div",{className:"qsm-advance-settings"},M&&j.map((e=>0!=I.form_type&&"system"==e.id?null:(0,a.createElement)(v,{key:"qsm-settings"+e.id,data:e,quizAttr:I,setAttributes:s,onChangeFunc:Z})))),(0,a.createElement)(d.Button,{variant:"primary",disabled:O||q(I.quiz_name),onClick:()=>(()=>{if(q(I.quiz_name))return void console.log("empty quiz_name");T(!0);let e=_({quiz_name:I.quiz_name,qsm_new_quiz_nonce:qsmBlockData.qsm_new_quiz_nonce});["form_type","system","timer_limit","pagination","enable_contact_form","enable_pagination_quiz","show_question_featured_image_in_result","progress_bar","require_log_in","disable_first_page","comment_section"].forEach((t=>void 0===I[t]||null===I[t]?"":e.append(t,I[t]))),o()({path:"/quiz-survey-master/v1/quiz/create_quiz",method:"POST",body:e}).then((e=>{if(T(!1),"success"==e.status){let t=_({id:null,quizID:e.quizID,answerEditor:"text",type:"0",name:"",question_title:"",answerInfo:"",comments:"1",hint:"",category:"",required:0,isPublished:1,answers:[],page:0});o()({path:"/quiz-survey-master/v1/questions",method:"POST",body:t}).then((t=>{if("success"==t.status){let n=t.id,s=_({action:qsmBlockData.save_pages_action,quiz_id:e.quizID,nonce:qsmBlockData.saveNonce,post_id:e.quizPostID});s.append("pages[0][]",n),s.append("qpages[0][id]",1),s.append("qpages[0][quizID]",e.quizID),s.append("qpages[0][pagekey]",z()),s.append("qpages[0][hide_prevbtn]",0),s.append("qpages[0][questions][]",n),o()({url:qsmBlockData.ajax_url,method:"POST",body:s}).then((t=>{"success"==t.status&&$(e.quizID)}))}})).catch((e=>{console.log("error",e),E("error",e.message,{isDismissible:!0,type:"snackbar"})}))}E(e.status,e.msg,{isDismissible:!0,type:"snackbar"})})).catch((e=>{console.log("error",e),E("error",e.message,{isDismissible:!0,type:"snackbar"})}))})()},(0,i.__)("Create Quiz","quiz-master-next"))),S.error&&(0,a.createElement)("p",{className:"qsm-error-text"},S.msg)))," "):(0,a.createElement)("div",{...U}))},save:e=>null})}},n={};function s(e){var a=n[e];if(void 0!==a)return a.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,s),i.exports}s.m=t,e=[],s.O=(t,n,a,i)=>{if(!n){var r=1/0;for(c=0;c<e.length;c++){for(var[n,a,i]=e[c],o=!0,l=0;l<n.length;l++)(!1&i||r>=i)&&Object.keys(s.O).every((e=>s.O[e](n[l])))?n.splice(l--,1):(o=!1,i<r&&(r=i));if(o){e.splice(c--,1);var u=a();void 0!==u&&(t=u)}}return t}i=i||0;for(var c=e.length;c>0&&e[c-1][2]>i;c--)e[c]=e[c-1];e[c]=[n,a,i]},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={826:0,431:0};s.O.j=t=>0===e[t];var t=(t,n)=>{var a,i,[r,o,l]=n,u=0;if(r.some((t=>0!==e[t]))){for(a in o)s.o(o,a)&&(s.m[a]=o[a]);if(l)var c=l(s)}for(t&&t(n);u<r.length;u++)i=r[u],s.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return s.O(c)},n=globalThis.webpackChunkqsm=globalThis.webpackChunkqsm||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var a=s.O(void 0,[431],(()=>s(550)));a=s.O(a)})();
  • quiz-master-next/trunk/blocks/build/page/block.json

    r3060561 r3249137  
    3535  "supports": {
    3636    "html": false,
    37     "multiple": false
     37    "multiple": true
    3838  },
    3939  "textdomain": "main-block",
  • quiz-master-next/trunk/blocks/build/question/block.json

    r3060561 r3249137  
    7474      "default": "0"
    7575    },
     76    "isPublished": {
     77      "type": "number",
     78      "default": 1
     79    },
     80    "linked_question": {
     81      "type": "string"
     82    },
    7683    "media": {
    7784      "type": "object"
  • quiz-master-next/trunk/blocks/build/question/index.asset.php

    r3097878 r3249137  
    11<?php return array(
    22    'dependencies' => array( 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-escape-html', 'wp-hooks', 'wp-i18n', 'wp-notices' ),
    3     'version'      => '5e548fd7e3646043ca1e',
     3    'version'      => 'dd588e744de051517c95',
    44);
  • quiz-master-next/trunk/blocks/build/question/index.js

    r3097878 r3249137  
    1 (()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,a=window.wp.element,n=window.wp.i18n,r=window.wp.escapeHtml,l=window.wp.apiFetch;var i=e.n(l);const o=window.wp.blockEditor,s=window.wp.notices,c=window.wp.data,m=window.wp.components,u=(window.wp.hooks,window.wp.blob),d=window.wp.coreData,p=e=>null==e||""===e,_=e=>p(e)||!Array.isArray(e)?e:e.filter(((e,t,a)=>a.indexOf(e)===t)),g=e=>{var t=document.createElement("textarea");return t.innerHTML=e,t.value},h=(e=!1)=>{let t=new FormData;if(t.append("qsm_block_api_call","1"),!1!==e)for(let a in e)e.hasOwnProperty(a)&&t.append(a,e[a]);return t},q=(e,t="")=>p(e)?t:e,E=["image"],f=(0,n.__)("Featured image"),w=(0,n.__)("Set featured image"),x=(0,a.createElement)("p",null,(0,n.__)("To edit the featured image, you need permission to upload media.")),C=({featureImageID:e,onUpdateImage:t,onRemoveImage:r})=>{const{createNotice:l}=(0,c.useDispatch)(s.store),i=(0,a.useRef)(),[_,g]=(0,a.useState)(!1),[h,q]=(0,a.useState)(void 0),{mediaFeature:C,mediaUpload:b}=(0,c.useSelect)((t=>{const{getMedia:a}=t(d.store);return{mediaFeature:p(h)&&!p(e)&&a(e),mediaUpload:t(o.store).getSettings().mediaUpload}}),[]);function y(e){b({allowedTypes:["image"],filesList:e,onFileChange([e]){(0,u.isBlobURL)(e?.url)?g(!0):(t(e),g(!1))},onError(e){l("error",e,{isDismissible:!0,type:"snackbar"})}})}return(0,a.useEffect)((()=>{let t=!0;return t&&(p(C)||"object"!=typeof C||q({id:e,width:C.media_details.width,height:C.media_details.height,url:C.source_url,alt_text:C.alt_text,slug:C.slug})),()=>{t=!1}}),[C]),(0,a.createElement)("div",{className:"editor-post-featured-image"},h&&(0,a.createElement)("div",{id:`editor-post-featured-image-${e}-describedby`,className:"hidden"},h.alt_text&&(0,n.sprintf)(
     1(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,a=window.wp.element,n=window.wp.i18n,l=window.wp.escapeHtml,r=window.wp.apiFetch;var i=e.n(r);const o=window.wp.blockEditor,s=window.wp.notices,c=window.wp.data,m=window.wp.components,u=(window.wp.hooks,window.wp.blob),d=window.wp.coreData,p=e=>null==e||""===e,_=e=>p(e)||!Array.isArray(e)?e:e.filter(((e,t,a)=>a.indexOf(e)===t)),g=e=>{var t=document.createElement("textarea");return t.innerHTML=e,t.value},h=(e=!1)=>{let t=new FormData;if(t.append("qsm_block_api_call","1"),!1!==e)for(let a in e)e.hasOwnProperty(a)&&t.append(a,e[a]);return t},q=(e,t="")=>p(e)?t:e,E=["image"],f=(0,n.__)("Featured image"),w=(0,n.__)("Set featured image"),x=(0,a.createElement)("p",null,(0,n.__)("To edit the featured image, you need permission to upload media.")),b=({featureImageID:e,onUpdateImage:t,onRemoveImage:l})=>{const{createNotice:r}=(0,c.useDispatch)(s.store),i=(0,a.useRef)(),[_,g]=(0,a.useState)(!1),[h,q]=(0,a.useState)(void 0),{mediaFeature:b,mediaUpload:C}=(0,c.useSelect)((t=>{const{getMedia:a}=t(d.store);return{mediaFeature:p(h)&&!p(e)&&a(e),mediaUpload:t(o.store).getSettings().mediaUpload}}),[]);function y(e){C({allowedTypes:["image"],filesList:e,onFileChange([e]){(0,u.isBlobURL)(e?.url)?g(!0):(t(e),g(!1))},onError(e){r("error",e,{isDismissible:!0,type:"snackbar"})}})}return(0,a.useEffect)((()=>{let t=!0;return t&&(p(b)||"object"!=typeof b||q({id:e,width:b.media_details.width,height:b.media_details.height,url:b.source_url,alt_text:b.alt_text,slug:b.slug})),()=>{t=!1}}),[b]),(0,a.createElement)("div",{className:"editor-post-featured-image"},h&&(0,a.createElement)("div",{id:`editor-post-featured-image-${e}-describedby`,className:"hidden"},h.alt_text&&(0,n.sprintf)(
    22// Translators: %s: The selected image alt text.
    33(0,n.__)("Current image: %s"),h.alt_text),!h.alt_text&&(0,n.sprintf)(
    44// Translators: %s: The selected image filename.
    5 (0,n.__)("The current image has no alternative text. The file name is: %s"),h.slug)),(0,a.createElement)(o.MediaUploadCheck,{fallback:x},(0,a.createElement)(o.MediaUpload,{title:f,onSelect:e=>{q(e),t(e)},unstableFeaturedImageFlow:!0,allowedTypes:E,modalClass:"editor-post-featured-image__media-modal",render:({open:t})=>(0,a.createElement)("div",{className:"editor-post-featured-image__container"},(0,a.createElement)(m.Button,{ref:i,className:e?"editor-post-featured-image__preview":"editor-post-featured-image__toggle",onClick:t,"aria-label":e?(0,n.__)("Edit or replace the image"):null,"aria-describedby":e?`editor-post-featured-image-${e}-describedby`:null},!!e&&h&&(0,a.createElement)(m.ResponsiveWrapper,{naturalWidth:h.width,naturalHeight:h.height,isInline:!0},(0,a.createElement)("img",{src:h.url,alt:h.alt_text})),_&&(0,a.createElement)(m.Spinner,null),!e&&!_&&w),!!e&&(0,a.createElement)(m.__experimentalHStack,{className:"editor-post-featured-image__actions"},(0,a.createElement)(m.Button,{className:"editor-post-featured-image__action",onClick:t,"aria-hidden":"true"},(0,n.__)("Replace")),(0,a.createElement)(m.Button,{className:"editor-post-featured-image__action",onClick:()=>{r(),i.current.focus()}},(0,n.__)("Remove"))),(0,a.createElement)(m.DropZone,{onFilesDrop:y})),value:e})))},b=({isCategorySelected:e,setUnsetCatgory:t})=>{const[r,l]=(0,a.useState)(!1),[o,s]=(0,a.useState)(""),[c,u]=(0,a.useState)(0),[d,_]=(0,a.useState)(!1),[g,q]=(0,a.useState)(!1),[E,f]=(0,a.useState)(qsmBlockData?.hierarchicalCategoryList),w=e=>{let t={};return e.forEach((e=>{if(t[e.id]=e,0<e.children.length){let a=w(e.children);t={...t,...a}}})),t},[x,C]=(0,a.useState)(p(qsmBlockData?.hierarchicalCategoryList)?{}:w(qsmBlockData.hierarchicalCategoryList)),b=(0,n.__)("Add New Category ","quiz-master-next"),y=`— ${(0,n.__)("Parent Category ","quiz-master-next")} —`,k=e=>{let t=[];return e.forEach((e=>{if(t.push(e.name),0<e.children.length){let a=k(e.children);t=[...t,...a]}})),t},v=n=>n.map((n=>(0,a.createElement)("div",{key:n.id,className:"editor-post-taxonomies__hierarchical-terms-choice"},(0,a.createElement)(m.CheckboxControl,{label:n.name,checked:e(n.id),onChange:()=>t(n.id,x)}),!!n.children.length&&(0,a.createElement)("div",{className:"editor-post-taxonomies__hierarchical-terms-subchoices"},v(n.children)))));return(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Categories","quiz-master-next"),initialOpen:!0},(0,a.createElement)("div",{className:"editor-post-taxonomies__hierarchical-terms-list",tabIndex:"0",role:"group","aria-label":(0,n.__)("Categories","quiz-master-next")},v(E)),(0,a.createElement)("div",{className:"qsm-ptb-1"},(0,a.createElement)(m.Button,{variant:"link",onClick:()=>l(!r)},b)),r&&(0,a.createElement)("form",{onSubmit:async e=>{e.preventDefault(),g||p(o)||d||(_(!0),i()({url:qsmBlockData.ajax_url,method:"POST",body:h({action:"save_new_category",name:o,parent:c})}).then((e=>{if(!p(e.term_id)){let a=e.term_id;i()({path:"/quiz-survey-master/v1/quiz/hierarchical-category-list",method:"POST"}).then((e=>{"success"==e.status&&(f(e.result),C(e.result),s(""),u(0),t(a,w(term.id)),_(!1))}))}})))}},(0,a.createElement)(m.Flex,{direction:"column",gap:"1"},(0,a.createElement)(m.TextControl,{__nextHasNoMarginBottom:!0,className:"editor-post-taxonomies__hierarchical-terms-input",label:(0,n.__)("Category Name","quiz-master-next"),value:o,onChange:e=>((e,t)=>{t=k(t),console.log("categories",t),t.includes(e)?q(e):(q(!1),s(e))})(e,E),required:!0}),0<E.length&&(0,a.createElement)(m.TreeSelect,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Parent Category","quiz-master-next"),noOptionLabel:y,onChange:e=>u(e),selectedId:c,tree:E}),(0,a.createElement)(m.FlexItem,null,(0,a.createElement)(m.Button,{variant:"secondary",type:"submit",className:"editor-post-taxonomies__hierarchical-terms-submit",disabled:g||d},b)),(0,a.createElement)(m.FlexItem,null,(0,a.createElement)("p",{className:"qsm-error-text"},!1!==g&&(0,n.__)("Category ","quiz-master-next")+g+(0,n.__)(" already exists.","quiz-master-next"))))))},y=()=>(0,a.createElement)(m.Icon,{icon:()=>(0,a.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false"},(0,a.createElement)("path",{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}))}),k=JSON.parse('{"u2":"qsm/quiz-question"}');(0,t.registerBlockType)(k.u2,{icon:()=>(0,a.createElement)(m.Icon,{icon:()=>(0,a.createElement)("svg",{width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)("rect",{x:"0.102539",y:"0.101562",width:"24",height:"24",rx:"4.68852",fill:"#ADADAD"}),(0,a.createElement)("path",{d:"M17.0475 17.191C17.2367 17.3683 17.3313 17.5752 17.3313 17.8117C17.3313 18.06 17.2426 18.2787 17.0653 18.4679C16.8879 18.6453 16.6751 18.734 16.4268 18.734C16.1667 18.734 15.9538 18.6512 15.7883 18.4857L14.937 17.6521C13.8492 18.4088 12.5959 18.7872 11.177 18.7872C10.0301 18.7872 9.01325 18.533 8.12646 18.0245C7.2515 17.5161 6.57163 16.8126 6.08685 15.914C5.6139 15.0035 5.37742 13.9631 5.37742 12.7925C5.37742 11.5273 5.64937 10.41 6.19327 9.44044C6.74898 8.45907 7.48206 7.70234 8.3925 7.17027C9.31475 6.6382 10.308 6.37216 11.3721 6.37216C12.4481 6.37216 13.459 6.64411 14.4049 7.18801C15.3508 7.72008 16.1075 8.46498 16.6751 9.42271C17.2426 10.3804 17.5264 11.4505 17.5264 12.6329C17.5264 14.0636 17.1007 15.3287 16.2494 16.4283L17.0475 17.191ZM11.177 17.1732C12.0874 17.1732 12.9269 16.9249 13.6955 16.4283L12.5604 15.311C12.3949 15.1454 12.3121 14.9799 12.3121 14.8144C12.3121 14.6015 12.4244 14.3887 12.6491 14.1759C12.8855 13.9631 13.122 13.8566 13.3585 13.8566C13.5122 13.8566 13.6364 13.9039 13.7309 13.9985L14.9724 15.1868C15.4927 14.4183 15.7528 13.5492 15.7528 12.5797C15.7528 11.7284 15.5518 10.9539 15.1498 10.2563C14.7596 9.54686 14.2335 8.99114 13.5713 8.58913C12.9092 8.18712 12.1998 7.98611 11.443 7.98611C10.6981 7.98611 9.99462 8.18121 9.33249 8.57139C8.67036 8.94975 8.13828 9.49956 7.73627 10.2208C7.34609 10.9421 7.15099 11.7756 7.15099 12.7216C7.15099 13.6083 7.32244 14.3887 7.66533 15.0627C8.02005 15.7366 8.49891 16.2569 9.10192 16.6234C9.71676 16.99 10.4085 17.1732 11.177 17.1732Z",fill:"white"}))}),edit:function(e){var l;if("undefined"==typeof qsmBlockData)return null;const{className:u,attributes:d,setAttributes:E,isSelected:f,clientId:w,context:x}=e,k=(0,c.useSelect)((e=>f||e("core/block-editor").hasSelectedInnerBlock(w,!0))),v=x["quiz-master-next/quizID"],{quiz_name:B,post_id:z,rest_nonce:D}=x["quiz-master-next/quizAttr"],{createNotice:I}=(x["quiz-master-next/pageID"],(0,c.useDispatch)(s.store)),{getBlockRootClientId:N,getBlockIndex:S}=(0,c.useSelect)(o.store),{insertBlock:A}=(0,c.useDispatch)(o.store),{isChanged:T=!1,questionID:M,type:P,description:L,title:F,correctAnswerInfo:O,commentBox:H,category:Q,multicategories:R=[],hint:U,featureImageID:j,featureImageSrc:V,answers:W,answerEditor:Z,matchAnswer:$,required:G,settings:J={}}=d,[K,X]=(0,a.useState)(!p(O)),[Y,ee]=(0,a.useState)(!1),te="1"==qsmBlockData.is_pro_activated,ae=e=>14<parseInt(e),ne=qsmBlockData.file_upload_type.options,re=()=>{let e=J?.file_upload_type||qsmBlockData.file_upload_type.default;return p(e)?[]:e.split(",")};(0,a.useEffect)((()=>{let e=!0;if(e&&(p(M)||"0"==M||!p(M)&&((e,t)=>{const a=(0,c.select)("core/block-editor").getClientIdsWithDescendants();return!p(a)&&a.some((a=>{const{questionID:n}=(0,c.select)("core/block-editor").getBlockAttributes(a);return t!==a&&n===e}))})(M,w))){let e=h({id:null,rest_nonce:D,quizID:v,quiz_name:B,postID:z,answerEditor:q(Z,"text"),type:q(P,"0"),name:g(q(L)),question_title:q(F),answerInfo:g(q(O)),comments:q(H,"1"),hint:q(U),category:q(Q),multicategories:[],required:q(G,0),answers:W,page:0,featureImageID:j,featureImageSrc:V,matchAnswer:null});i()({path:"/quiz-survey-master/v1/questions",method:"POST",body:e}).then((e=>{if("success"==e.status){let t=e.id;E({questionID:t})}})).catch((e=>{console.log("error",e),I("error",e.message,{isDismissible:!0,type:"snackbar"})}))}return()=>{e=!1}}),[]),(0,a.useEffect)((()=>{let e=!0;return e&&f&&!1===T&&E({isChanged:!0}),()=>{e=!1}}),[M,P,L,F,O,H,Q,R,U,j,V,W,Z,$,G,J]);const le=(0,o.useBlockProps)({className:k?" in-editing-mode is-highlighted ":""}),ie=(e,t)=>{let a=[];if(!p(t[e])&&"0"!=t[e].parent&&(e=t[e].parent,a.push(e),!p(t[e])&&"0"!=t[e].parent)){let n=ie(e,t);a=[...a,...n]}return _(a)},oe=["12","7","3","5","14"].includes(P)?(0,n.__)("Note: Add only correct answer options with their respective points score.","quiz-master-next"):"",se=()=>{if(p(e?.name))return console.log("block name not found"),!0;const a=(0,t.createBlock)(e.name);A(a,S(w)+1,N(w),!0)};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.BlockControls,null,(0,a.createElement)(m.ToolbarGroup,null,(0,a.createElement)(m.ToolbarButton,{icon:"plus-alt2",label:(0,n.__)("Add New Question","quiz-master-next"),onClick:()=>se()}),(0,a.createElement)(m.ToolbarButton,{icon:"welcome-add-page",label:(0,n.__)("Add New Page","quiz-master-next"),onClick:()=>(()=>{const e=(0,t.createBlock)("qsm/quiz-page"),a=N(w),n=S(a)+1,r=N(a);A(e,n,r,!0)})()}))),Y&&(0,a.createElement)(m.Modal,{contentLabel:(0,n.__)("Use QSM Editor for Advanced Question","quiz-master-next"),className:"qsm-advance-q-modal",isDismissible:!1,size:"small",__experimentalHideHeader:!0},(0,a.createElement)("div",{className:"qsm-modal-body"},(0,a.createElement)("h3",{className:"qsm-title"},(0,a.createElement)(m.Icon,{icon:()=>(0,a.createElement)("svg",{width:"54",height:"54",viewBox:"0 0 54 54",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)("path",{d:"M27.1855 23.223V28.0626M15.1794 32.4196C14.0618 34.3554 15.4595 36.7739 17.6934 36.7739H36.6776C38.9102 36.7739 40.3079 34.3554 39.1916 32.4196L29.7008 15.9675C28.5832 14.0317 25.7878 14.0317 24.6702 15.9675L15.1794 32.4196ZM27.1855 31.9343H27.1945V31.9446H27.1855V31.9343Z",stroke:"#B45309",strokeWidth:"1.65929",strokeLinecap:"round",strokeLinejoin:"round"}))}),(0,a.createElement)("br",null),(0,n.__)("Use QSM editor for Advanced Question","quiz-master-next")),(0,a.createElement)("p",{className:"qsm-description"},(0,n.__)("Currently, the block editor doesn't support advanced question type. We are working on it. Alternatively, you can add advanced questions from your QSM's quiz editor.","quiz-master-next")),(0,a.createElement)("div",{className:"qsm-modal-btn-wrapper"},(0,a.createElement)(m.Button,{variant:"secondary",onClick:()=>ee(!1)},(0,n.__)("Cancel","quiz-master-next")),(0,a.createElement)(m.Button,{variant:"primary",onClick:()=>{}},(0,a.createElement)(m.ExternalLink,{href:qsmBlockData.quiz_settings_url+"&quiz_id="+v},(0,n.__)("Add Question from quiz editor","quiz-master-next")))))),ae(P)?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.InspectorControls,null,(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Question settings","quiz-master-next"),initialOpen:!0},(0,a.createElement)("h2",{className:"block-editor-block-card__title"},(0,n.__)("ID","quiz-master-next")+": "+M),(0,a.createElement)("h3",null,(0,n.__)("Advanced Question Type","quiz-master-next")))),(0,a.createElement)("div",{...le},(0,a.createElement)("h4",{className:"qsm-question-title qsm-error-text"},(0,n.__)("Advanced Question Type : ","quiz-master-next")+F),(0,a.createElement)("p",null,(0,n.__)("Edit question in QSM ","quiz-master-next"),(0,a.createElement)(m.ExternalLink,{href:qsmBlockData.quiz_settings_url+"&quiz_id="+v},(0,n.__)("editor","quiz-master-next"))))):(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.InspectorControls,null,(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Question settings","quiz-master-next"),initialOpen:!0},(0,a.createElement)("h2",{className:"block-editor-block-card__title"},(0,n.__)("ID","quiz-master-next")+": "+M),(0,a.createElement)(m.SelectControl,{label:qsmBlockData.question_type.label,value:P||qsmBlockData.question_type.default,onChange:e=>(e=>{if(p(MicroModal)||te||!["15","16","17"].includes(e))te&&ae(e)?ee(!0):E({type:e});else{let e=document.getElementById("modal-advanced-question-type");p(e)||MicroModal.show("modal-advanced-question-type")}})(e),help:p(qsmBlockData.question_type_description[P])?"":qsmBlockData.question_type_description[P]+" "+oe,__nextHasNoMarginBottom:!0},!p(qsmBlockData.question_type.options)&&qsmBlockData.question_type.options.map((e=>(0,a.createElement)("optgroup",{label:e.category,key:"qtypes"+e.category},e.types.map((e=>(0,a.createElement)("option",{value:e.slug,key:"qtype"+e.slug},e.name))))))),["0","4","1","10","13"].includes(P)&&(0,a.createElement)(m.SelectControl,{label:qsmBlockData.answerEditor.label,value:Z||qsmBlockData.answerEditor.default,options:qsmBlockData.answerEditor.options,onChange:e=>E({answerEditor:e}),__nextHasNoMarginBottom:!0}),(0,a.createElement)(m.ToggleControl,{label:(0,n.__)("Required","quiz-master-next"),checked:!p(G)&&"1"==G,onChange:()=>E({required:p(G)||"1"!=G?1:0})}),(0,a.createElement)(m.ToggleControl,{label:(0,n.__)("Show Correct Answer Info","quiz-master-next"),checked:K,onChange:()=>X(!K)})),"11"==P&&(0,a.createElement)(m.PanelBody,{title:(0,n.__)("File Settings","quiz-master-next"),initialOpen:!1},(0,a.createElement)(m.TextControl,{type:"number",label:qsmBlockData.file_upload_limit.heading,value:null!==(l=J?.file_upload_limit)&&void 0!==l?l:qsmBlockData.file_upload_limit.default,onChange:e=>E({settings:{...J,file_upload_limit:e}})}),(0,a.createElement)("label",{className:"qsm-inspector-label"},qsmBlockData.file_upload_type.heading),Object.keys(qsmBlockData.file_upload_type.options).map((e=>{return(0,a.createElement)(m.CheckboxControl,{key:"filetype-"+e,label:ne[e],checked:(t=e,re().includes(t)),onChange:()=>(e=>{let t=re();t.includes(e)?t=t.filter((t=>t!=e)):t.push(e),t=t.join(","),E({settings:{...J,file_upload_type:t}})})(e)});var t}))),(0,a.createElement)(b,{isCategorySelected:e=>R.includes(e),setUnsetCatgory:(e,t)=>{let a=p(R)||0===R.length?p(Q)?[]:[Q]:R;if(a.includes(e))a=a.filter((t=>t!=e)),a.forEach((n=>{ie(n,t).includes(e)&&(a=a.filter((e=>e!=n)))}));else{a.push(e);let n=ie(e,t);a=[...a,...n]}a=_(a),E({category:"",multicategories:[...a]})}}),(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Hint","quiz-master-next"),initialOpen:!1},(0,a.createElement)(m.TextControl,{label:"",value:U,onChange:e=>E({hint:(0,r.escapeAttribute)(e)})})),(0,a.createElement)(m.PanelBody,{title:qsmBlockData.commentBox.heading,initialOpen:!1},(0,a.createElement)(m.SelectControl,{label:qsmBlockData.commentBox.label,value:H||qsmBlockData.commentBox.default,options:qsmBlockData.commentBox.options,onChange:e=>E({commentBox:e}),__nextHasNoMarginBottom:!0})),(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Featured image","quiz-master-next"),initialOpen:!0},(0,a.createElement)(C,{featureImageID:j,onUpdateImage:e=>{E({featureImageID:e.id,featureImageSrc:e.url})},onRemoveImage:e=>{E({featureImageID:void 0,featureImageSrc:void 0})}}))),(0,a.createElement)("div",{...le},(0,a.createElement)(o.RichText,{tagName:"h4",title:(0,n.__)("Question title","quiz-master-next"),"aria-label":(0,n.__)("Question title","quiz-master-next"),placeholder:(0,n.__)("Type your question here","quiz-master-next"),value:(0,r.escapeAttribute)(F),onChange:e=>E({title:(0,r.escapeAttribute)(e)}),allowedFormats:[],withoutInteractiveFormatting:!0,className:"qsm-question-title"}),k&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.RichText,{tagName:"p",title:(0,n.__)("Question description","quiz-master-next"),"aria-label":(0,n.__)("Question description","quiz-master-next"),placeholder:(0,n.__)("Description goes here... (optional)","quiz-master-next"),value:g(L),onChange:e=>E({description:e}),className:"qsm-question-description",__unstableEmbedURLOnPaste:!0,__unstableAllowPrefixTransformations:!0}),!["8","11","6","9"].includes(P)&&(0,a.createElement)(o.InnerBlocks,{allowedBlocks:["qsm/quiz-answer-option"],template:[["qsm/quiz-answer-option",{optionID:"0"}],["qsm/quiz-answer-option",{optionID:"1"}]]}),K&&(0,a.createElement)(o.RichText,{tagName:"p",title:(0,n.__)("Correct Answer Info","quiz-master-next"),"aria-label":(0,n.__)("Correct Answer Info","quiz-master-next"),placeholder:(0,n.__)("Correct answer info goes here","quiz-master-next"),value:g(O),onChange:e=>E({correctAnswerInfo:e}),className:"qsm-question-correct-answer-info",__unstableEmbedURLOnPaste:!0,__unstableAllowPrefixTransformations:!0}),k&&(0,a.createElement)("div",{className:"block-editor-block-list__insertion-point-inserter qsm-add-new-ques-wrapper"},(0,a.createElement)(m.Button,{icon:y,label:(0,n.__)("Add New Question","quiz-master-next"),tooltipPosition:"bottom",onClick:()=>se(),variant:"secondary",className:"add-new-question-btn block-editor-inserter__toggle"}))))))},__experimentalLabel(e,{context:t}){const{title:a}=e,n=e?.metadata?.name;if("list-view"===t&&(n||a?.length>0))return n||a}})})();
     5(0,n.__)("The current image has no alternative text. The file name is: %s"),h.slug)),(0,a.createElement)(o.MediaUploadCheck,{fallback:x},(0,a.createElement)(o.MediaUpload,{title:f,onSelect:e=>{q(e),t(e)},unstableFeaturedImageFlow:!0,allowedTypes:E,modalClass:"editor-post-featured-image__media-modal",render:({open:t})=>(0,a.createElement)("div",{className:"editor-post-featured-image__container"},(0,a.createElement)(m.Button,{ref:i,className:e?"editor-post-featured-image__preview":"editor-post-featured-image__toggle",onClick:t,"aria-label":e?(0,n.__)("Edit or replace the image"):null,"aria-describedby":e?`editor-post-featured-image-${e}-describedby`:null},!!e&&h&&(0,a.createElement)(m.ResponsiveWrapper,{naturalWidth:h.width,naturalHeight:h.height,isInline:!0},(0,a.createElement)("img",{src:h.url,alt:h.alt_text})),_&&(0,a.createElement)(m.Spinner,null),!e&&!_&&w),!!e&&(0,a.createElement)(m.__experimentalHStack,{className:"editor-post-featured-image__actions"},(0,a.createElement)(m.Button,{className:"editor-post-featured-image__action",onClick:t,"aria-hidden":"true"},(0,n.__)("Replace")),(0,a.createElement)(m.Button,{className:"editor-post-featured-image__action",onClick:()=>{l(),i.current.focus()}},(0,n.__)("Remove"))),(0,a.createElement)(m.DropZone,{onFilesDrop:y})),value:e})))},C=({isCategorySelected:e,setUnsetCatgory:t})=>{const[l,r]=(0,a.useState)(!1),[o,s]=(0,a.useState)(""),[c,u]=(0,a.useState)(0),[d,_]=(0,a.useState)(!1),[g,q]=(0,a.useState)(!1),[E,f]=(0,a.useState)(qsmBlockData?.hierarchicalCategoryList),w=e=>{let t={};return e.forEach((e=>{if(t[e.id]=e,0<e.children.length){let a=w(e.children);t={...t,...a}}})),t},[x,b]=(0,a.useState)(p(qsmBlockData?.hierarchicalCategoryList)?{}:w(qsmBlockData.hierarchicalCategoryList)),C=(0,n.__)("Add New Category ","quiz-master-next"),y=`— ${(0,n.__)("Parent Category ","quiz-master-next")} —`,k=e=>{let t=[];return e.forEach((e=>{if(t.push(e.name),0<e.children.length){let a=k(e.children);t=[...t,...a]}})),t},v=n=>n.map((n=>(0,a.createElement)("div",{key:n.id,className:"editor-post-taxonomies__hierarchical-terms-choice"},(0,a.createElement)(m.CheckboxControl,{label:n.name,checked:e(n.id),onChange:()=>t(n.id,x)}),!!n.children.length&&(0,a.createElement)("div",{className:"editor-post-taxonomies__hierarchical-terms-subchoices"},v(n.children)))));return(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Categories","quiz-master-next"),initialOpen:!0},(0,a.createElement)("div",{className:"editor-post-taxonomies__hierarchical-terms-list",tabIndex:"0",role:"group","aria-label":(0,n.__)("Categories","quiz-master-next")},v(E)),(0,a.createElement)("div",{className:"qsm-ptb-1"},(0,a.createElement)(m.Button,{variant:"link",onClick:()=>r(!l)},C)),l&&(0,a.createElement)("form",{onSubmit:async e=>{e.preventDefault(),g||p(o)||d||(_(!0),i()({url:qsmBlockData.ajax_url,method:"POST",body:h({action:"save_new_category",name:o,parent:c})}).then((e=>{if(!p(e.term_id)){let a=e.term_id;i()({path:"/quiz-survey-master/v1/quiz/hierarchical-category-list",method:"POST"}).then((e=>{"success"==e.status&&(f(e.result),b(e.result),s(""),u(0),t(a,w(term.id)),_(!1))}))}})))}},(0,a.createElement)(m.Flex,{direction:"column",gap:"1"},(0,a.createElement)(m.TextControl,{__nextHasNoMarginBottom:!0,className:"editor-post-taxonomies__hierarchical-terms-input",label:(0,n.__)("Category Name","quiz-master-next"),value:o,onChange:e=>((e,t)=>{t=k(t),console.log("categories",t),t.includes(e)?q(e):(q(!1),s(e))})(e,E),required:!0}),0<E.length&&(0,a.createElement)(m.TreeSelect,{__nextHasNoMarginBottom:!0,label:(0,n.__)("Parent Category","quiz-master-next"),noOptionLabel:y,onChange:e=>u(e),selectedId:c,tree:E}),(0,a.createElement)(m.FlexItem,null,(0,a.createElement)(m.Button,{variant:"secondary",type:"submit",className:"editor-post-taxonomies__hierarchical-terms-submit",disabled:g||d},C)),(0,a.createElement)(m.FlexItem,null,(0,a.createElement)("p",{className:"qsm-error-text"},!1!==g&&(0,n.__)("Category ","quiz-master-next")+g+(0,n.__)(" already exists.","quiz-master-next"))))))},y=()=>(0,a.createElement)(m.Icon,{icon:()=>(0,a.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false"},(0,a.createElement)("path",{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"}))}),k=JSON.parse('{"u2":"qsm/quiz-question"}');(0,t.registerBlockType)(k.u2,{icon:()=>(0,a.createElement)(m.Icon,{icon:()=>(0,a.createElement)("svg",{width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)("rect",{x:"0.102539",y:"0.101562",width:"24",height:"24",rx:"4.68852",fill:"#ADADAD"}),(0,a.createElement)("path",{d:"M17.0475 17.191C17.2367 17.3683 17.3313 17.5752 17.3313 17.8117C17.3313 18.06 17.2426 18.2787 17.0653 18.4679C16.8879 18.6453 16.6751 18.734 16.4268 18.734C16.1667 18.734 15.9538 18.6512 15.7883 18.4857L14.937 17.6521C13.8492 18.4088 12.5959 18.7872 11.177 18.7872C10.0301 18.7872 9.01325 18.533 8.12646 18.0245C7.2515 17.5161 6.57163 16.8126 6.08685 15.914C5.6139 15.0035 5.37742 13.9631 5.37742 12.7925C5.37742 11.5273 5.64937 10.41 6.19327 9.44044C6.74898 8.45907 7.48206 7.70234 8.3925 7.17027C9.31475 6.6382 10.308 6.37216 11.3721 6.37216C12.4481 6.37216 13.459 6.64411 14.4049 7.18801C15.3508 7.72008 16.1075 8.46498 16.6751 9.42271C17.2426 10.3804 17.5264 11.4505 17.5264 12.6329C17.5264 14.0636 17.1007 15.3287 16.2494 16.4283L17.0475 17.191ZM11.177 17.1732C12.0874 17.1732 12.9269 16.9249 13.6955 16.4283L12.5604 15.311C12.3949 15.1454 12.3121 14.9799 12.3121 14.8144C12.3121 14.6015 12.4244 14.3887 12.6491 14.1759C12.8855 13.9631 13.122 13.8566 13.3585 13.8566C13.5122 13.8566 13.6364 13.9039 13.7309 13.9985L14.9724 15.1868C15.4927 14.4183 15.7528 13.5492 15.7528 12.5797C15.7528 11.7284 15.5518 10.9539 15.1498 10.2563C14.7596 9.54686 14.2335 8.99114 13.5713 8.58913C12.9092 8.18712 12.1998 7.98611 11.443 7.98611C10.6981 7.98611 9.99462 8.18121 9.33249 8.57139C8.67036 8.94975 8.13828 9.49956 7.73627 10.2208C7.34609 10.9421 7.15099 11.7756 7.15099 12.7216C7.15099 13.6083 7.32244 14.3887 7.66533 15.0627C8.02005 15.7366 8.49891 16.2569 9.10192 16.6234C9.71676 16.99 10.4085 17.1732 11.177 17.1732Z",fill:"white"}))}),edit:function(e){var r;if("undefined"==typeof qsmBlockData)return null;const{className:u,attributes:d,setAttributes:E,isSelected:f,clientId:w,context:x}=e,k=(0,c.useSelect)((e=>f||e("core/block-editor").hasSelectedInnerBlock(w,!0))),v=x["quiz-master-next/quizID"],{quiz_name:B,post_id:z,rest_nonce:D}=x["quiz-master-next/quizAttr"],{createNotice:I}=(x["quiz-master-next/pageID"],(0,c.useDispatch)(s.store)),{getBlockRootClientId:N,getBlockIndex:S}=(0,c.useSelect)(o.store),{insertBlock:A}=(0,c.useDispatch)(o.store),{isChanged:T=!1,questionID:P,type:M,description:L,title:F,correctAnswerInfo:O,commentBox:H,category:Q,multicategories:R=[],hint:U,featureImageID:j,featureImageSrc:V,answers:W,answerEditor:Z,matchAnswer:$,required:G,isPublished:J,settings:K={}}=d,[X,Y]=(0,a.useState)(!p(O)),[ee,te]=(0,a.useState)(!1),ae="1"==qsmBlockData.is_pro_activated,ne=e=>14<parseInt(e),le=qsmBlockData.file_upload_type.options,re=()=>{let e=K?.file_upload_type||qsmBlockData.file_upload_type.default;return p(e)?[]:e.split(",")};(0,a.useEffect)((()=>{let e=!0;if(e&&(p(P)||"0"==P||!p(P)&&((e,t)=>{const a=(0,c.select)("core/block-editor").getClientIdsWithDescendants();return!p(a)&&a.some((a=>{const{questionID:n}=(0,c.select)("core/block-editor").getBlockAttributes(a);return t!==a&&n===e}))})(P,w))){let e=h({id:null,rest_nonce:D,quizID:v,quiz_name:B,postID:z,answerEditor:q(Z,"text"),type:q(M,"0"),name:g(q(L)),question_title:q(F),answerInfo:g(q(O)),comments:q(H,"1"),hint:q(U),category:q(Q),multicategories:[],required:q(G,0),isPublished:q(J,1),answers:W,page:0,featureImageID:j,featureImageSrc:V,matchAnswer:null});i()({path:"/quiz-survey-master/v1/questions",method:"POST",body:e}).then((e=>{if("success"==e.status){let t=e.id;E({questionID:t})}})).catch((e=>{console.log("error",e),I("error",e.message,{isDismissible:!0,type:"snackbar"})}))}return()=>{e=!1}}),[]),(0,a.useEffect)((()=>{let e=!0;return e&&f&&!1===T&&E({isChanged:!0}),()=>{e=!1}}),[P,J,M,L,F,O,H,Q,R,U,j,V,W,Z,$,G,K]);const ie=(0,o.useBlockProps)({className:k?" in-editing-mode is-highlighted ":""}),oe=(e,t)=>{let a=[];if(!p(t[e])&&"0"!=t[e].parent&&(e=t[e].parent,a.push(e),!p(t[e])&&"0"!=t[e].parent)){let n=oe(e,t);a=[...a,...n]}return _(a)},se=["12","7","3","5","14"].includes(M)?(0,n.__)("Note: Add only correct answer options with their respective points score.","quiz-master-next"):"",ce=()=>{if(p(e?.name))return console.log("block name not found"),!0;const a=(0,t.createBlock)(e.name);A(a,S(w)+1,N(w),!0)};return(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.BlockControls,null,(0,a.createElement)(m.ToolbarGroup,null,(0,a.createElement)(m.ToolbarButton,{icon:"plus-alt2",label:(0,n.__)("Add New Question","quiz-master-next"),onClick:()=>ce()}),(0,a.createElement)(m.ToolbarButton,{icon:"welcome-add-page",label:(0,n.__)("Add New Page","quiz-master-next"),onClick:()=>(()=>{const e=(0,t.createBlock)("qsm/quiz-page"),a=N(w),n=S(a)+1,l=N(a);A(e,n,l,!0)})()}))),ee&&(0,a.createElement)(m.Modal,{contentLabel:(0,n.__)("Use QSM Editor for Advanced Question","quiz-master-next"),className:"qsm-advance-q-modal",isDismissible:!1,size:"small",__experimentalHideHeader:!0},(0,a.createElement)("div",{className:"qsm-modal-body"},(0,a.createElement)("h3",{className:"qsm-title"},(0,a.createElement)(m.Icon,{icon:()=>(0,a.createElement)("svg",{width:"54",height:"54",viewBox:"0 0 54 54",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,a.createElement)("path",{d:"M27.1855 23.223V28.0626M15.1794 32.4196C14.0618 34.3554 15.4595 36.7739 17.6934 36.7739H36.6776C38.9102 36.7739 40.3079 34.3554 39.1916 32.4196L29.7008 15.9675C28.5832 14.0317 25.7878 14.0317 24.6702 15.9675L15.1794 32.4196ZM27.1855 31.9343H27.1945V31.9446H27.1855V31.9343Z",stroke:"#B45309",strokeWidth:"1.65929",strokeLinecap:"round",strokeLinejoin:"round"}))}),(0,a.createElement)("br",null),(0,n.__)("Use QSM editor for Advanced Question","quiz-master-next")),(0,a.createElement)("p",{className:"qsm-description"},(0,n.__)("Currently, the block editor doesn't support advanced question type. We are working on it. Alternatively, you can add advanced questions from your QSM's quiz editor.","quiz-master-next")),(0,a.createElement)("div",{className:"qsm-modal-btn-wrapper"},(0,a.createElement)(m.Button,{variant:"secondary",onClick:()=>te(!1)},(0,n.__)("Cancel","quiz-master-next")),(0,a.createElement)(m.Button,{variant:"primary",onClick:()=>{}},(0,a.createElement)(m.ExternalLink,{href:qsmBlockData.quiz_settings_url+"&quiz_id="+v},(0,n.__)("Add Question from quiz editor","quiz-master-next")))))),ne(M)?(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.InspectorControls,null,(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Question settings","quiz-master-next"),initialOpen:!0},(0,a.createElement)("h2",{className:"block-editor-block-card__title"},(0,n.__)("ID","quiz-master-next")+": "+P),(0,a.createElement)("h3",null,(0,n.__)("Advanced Question Type","quiz-master-next")))),(0,a.createElement)("div",{...ie},(0,a.createElement)("h4",{className:"qsm-question-title qsm-error-text"},(0,n.__)("Advanced Question Type : ","quiz-master-next")+F),(0,a.createElement)("p",null,(0,n.__)("Edit question in QSM ","quiz-master-next"),(0,a.createElement)(m.ExternalLink,{href:qsmBlockData.quiz_settings_url+"&quiz_id="+v},(0,n.__)("editor","quiz-master-next"))))):(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.InspectorControls,null,(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Question settings","quiz-master-next"),initialOpen:!0},(0,a.createElement)("h2",{className:"block-editor-block-card__title"},(0,n.__)("ID","quiz-master-next")+": "+P),(0,a.createElement)(m.ToggleControl,{label:(0,n.__)("Publish","quiz-master-next"),checked:!p(J)&&"1"==J,onChange:()=>E({isPublished:p(J)||"1"!=J?1:0})}),(0,a.createElement)(m.SelectControl,{label:qsmBlockData.question_type.label,value:M||qsmBlockData.question_type.default,onChange:e=>(e=>{if(p(MicroModal)||ae||!["15","16","17"].includes(e))ae&&ne(e)?te(!0):E({type:e});else{let e=document.getElementById("modal-advanced-question-type");p(e)||MicroModal.show("modal-advanced-question-type")}})(e),help:p(qsmBlockData.question_type_description[M])?"":qsmBlockData.question_type_description[M]+" "+se,__nextHasNoMarginBottom:!0},!p(qsmBlockData.question_type.options)&&qsmBlockData.question_type.options.map((e=>(0,a.createElement)("optgroup",{label:e.category,key:"qtypes"+e.category},e.types.map((e=>(0,a.createElement)("option",{value:e.slug,key:"qtype"+e.slug},e.name))))))),["0","4","1","10","13"].includes(M)&&(0,a.createElement)(m.SelectControl,{label:qsmBlockData.answerEditor.label,value:Z||qsmBlockData.answerEditor.default,options:qsmBlockData.answerEditor.options,onChange:e=>E({answerEditor:e}),__nextHasNoMarginBottom:!0}),(0,a.createElement)(m.ToggleControl,{label:(0,n.__)("Required","quiz-master-next"),checked:!p(G)&&"1"==G,onChange:()=>E({required:p(G)||"1"!=G?1:0})}),(0,a.createElement)(m.ToggleControl,{label:(0,n.__)("Show Correct Answer Info","quiz-master-next"),checked:X,onChange:()=>Y(!X)})),"11"==M&&(0,a.createElement)(m.PanelBody,{title:(0,n.__)("File Settings","quiz-master-next"),initialOpen:!1},(0,a.createElement)(m.TextControl,{type:"number",label:qsmBlockData.file_upload_limit.heading,value:null!==(r=K?.file_upload_limit)&&void 0!==r?r:qsmBlockData.file_upload_limit.default,onChange:e=>E({settings:{...K,file_upload_limit:e}})}),(0,a.createElement)("label",{className:"qsm-inspector-label"},qsmBlockData.file_upload_type.heading),Object.keys(qsmBlockData.file_upload_type.options).map((e=>{return(0,a.createElement)(m.CheckboxControl,{key:"filetype-"+e,label:le[e],checked:(t=e,re().includes(t)),onChange:()=>(e=>{let t=re();t.includes(e)?t=t.filter((t=>t!=e)):t.push(e),t=t.join(","),E({settings:{...K,file_upload_type:t}})})(e)});var t}))),(0,a.createElement)(C,{isCategorySelected:e=>R.includes(e),setUnsetCatgory:(e,t)=>{let a=p(R)||0===R.length?p(Q)?[]:[Q]:R;if(a.includes(e))a=a.filter((t=>t!=e)),a.forEach((n=>{oe(n,t).includes(e)&&(a=a.filter((e=>e!=n)))}));else{a.push(e);let n=oe(e,t);a=[...a,...n]}a=_(a),E({category:"",multicategories:[...a]})}}),(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Hint","quiz-master-next"),initialOpen:!1},(0,a.createElement)(m.TextControl,{label:"",value:U,onChange:e=>E({hint:(0,l.escapeAttribute)(e)})})),(0,a.createElement)(m.PanelBody,{title:qsmBlockData.commentBox.heading,initialOpen:!1},(0,a.createElement)(m.SelectControl,{label:qsmBlockData.commentBox.label,value:H||qsmBlockData.commentBox.default,options:qsmBlockData.commentBox.options,onChange:e=>E({commentBox:e}),__nextHasNoMarginBottom:!0})),(0,a.createElement)(m.PanelBody,{title:(0,n.__)("Featured image","quiz-master-next"),initialOpen:!0},(0,a.createElement)(b,{featureImageID:j,onUpdateImage:e=>{E({featureImageID:e.id,featureImageSrc:e.url})},onRemoveImage:e=>{E({featureImageID:void 0,featureImageSrc:void 0})}}))),(0,a.createElement)("div",{...ie},(0,a.createElement)(o.RichText,{tagName:"h4",title:(0,n.__)("Question title","quiz-master-next"),"aria-label":(0,n.__)("Question title","quiz-master-next"),placeholder:(0,n.__)("Type your question here","quiz-master-next"),value:(0,l.escapeAttribute)(F),onChange:e=>E({title:(0,l.escapeAttribute)(e)}),allowedFormats:[],withoutInteractiveFormatting:!0,className:"qsm-question-title"}),k&&(0,a.createElement)(a.Fragment,null,(0,a.createElement)(o.RichText,{tagName:"p",title:(0,n.__)("Question description","quiz-master-next"),"aria-label":(0,n.__)("Question description","quiz-master-next"),placeholder:(0,n.__)("Description goes here... (optional)","quiz-master-next"),value:g(L),onChange:e=>E({description:e}),className:"qsm-question-description",__unstableEmbedURLOnPaste:!0,__unstableAllowPrefixTransformations:!0}),!["8","11","6","9"].includes(M)&&(0,a.createElement)(o.InnerBlocks,{allowedBlocks:["qsm/quiz-answer-option"],template:[["qsm/quiz-answer-option",{optionID:"0"}],["qsm/quiz-answer-option",{optionID:"1"}]]}),X&&(0,a.createElement)(o.RichText,{tagName:"p",title:(0,n.__)("Correct Answer Info","quiz-master-next"),"aria-label":(0,n.__)("Correct Answer Info","quiz-master-next"),placeholder:(0,n.__)("Correct answer info goes here","quiz-master-next"),value:g(O),onChange:e=>E({correctAnswerInfo:e}),className:"qsm-question-correct-answer-info",__unstableEmbedURLOnPaste:!0,__unstableAllowPrefixTransformations:!0}),k&&(0,a.createElement)("div",{className:"block-editor-block-list__insertion-point-inserter qsm-add-new-ques-wrapper"},(0,a.createElement)(m.Button,{icon:y,label:(0,n.__)("Add New Question","quiz-master-next"),tooltipPosition:"bottom",onClick:()=>ce(),variant:"secondary",className:"add-new-question-btn block-editor-inserter__toggle"}))))))},__experimentalLabel(e,{context:t}){const{title:a}=e,n=e?.metadata?.name;if("list-view"===t&&(n||a?.length>0))return n||a}})})();
  • quiz-master-next/trunk/blocks/src/edit.js

    r3099722 r3249137  
    3434
    3535    const { className, attributes, setAttributes, isSelected, clientId, context } = props;
    36    
     36
    3737    const page_post_id = context['postId'];
    3838    const { createNotice } = useDispatch( noticesStore );
     
    7373        return select( 'core/editor' );
    7474    }, [] );
    75    
     75
    7676    const { getBlock } = useSelect( blockEditorStore );
    7777
     
    107107                    } );
    108108                }
    109                
     109
    110110            }
    111111        }
    112        
     112
    113113        //cleanup
    114114        return () => {
    115115            shouldSetQSMAttr = false;
    116116        };
    117        
     117
    118118    }, [ ] );
    119119
     
    127127            } ).then( ( res ) => {
    128128                let bodyEl = document.getElementById('wpbody-content');
    129                 if ( ! qsmIsEmpty( bodyEl ) && 'success' == res.status ) { 
     129                if ( ! qsmIsEmpty( bodyEl ) && 'success' == res.status ) {
    130130                    bodyEl.insertAdjacentHTML('afterbegin', res.result );
    131131                }
     
    146146                data: { quizID: quiz_id },
    147147            } ).then( ( res ) => {
    148                
     148
    149149                if ( 'success' == res.status ) {
    150150                    setQuizMessage( {
     
    153153                    } );
    154154                    let result = res.result;
    155                     setAttributes( { 
     155                    setAttributes( {
    156156                        quizID: parseInt( quiz_id ),
    157157                        postID: result.post_id,
     
    168168                                        //answers options blocks
    169169                                        if ( ! qsmIsEmpty( question.answers ) && 0 < question.answers.length ) {
    170                                            
     170
    171171                                            question.answers.forEach( ( answer, aIndex ) => {
    172172                                                answers.push(
     
    190190                                                {
    191191                                                    questionID: question.question_id,
     192                                                    isPublished: typeof question.settings.isPublished !== 'undefined' ? question.settings.isPublished : 1,
     193                                                    linked_question: typeof question.linked_question !== 'undefined' ? question.linked_question : '',
    192194                                                    type: question.question_type_new,
    193195                                                    answerEditor: question.settings.answerEditor,
    194196                                                    title: question.settings.question_title,
    195197                                                    description: question.question_name,
    196                                                     required: question.settings.required,
     198                                                    required: question.settings.required == '0' ? '1' : '0',
    197199                                                    hint:question.hints,
    198200                                                    answers: question.answers,
     
    212214                                });
    213215                            }
    214                            
     216
    215217                            quizTemp.push(
    216218                                [
     
    228230                        setQuizTemplate( quizTemp );
    229231                    }
    230                    
     232
    231233                } else {
    232234                    console.log( "error "+ res.msg );
     
    237239                }
    238240            );
    239            
     241
    240242        }
    241243    }
    242244
    243245    /**
    244      * 
     246     *
    245247     * @returns Placeholder for quiz in case quiz ID is not set
    246248     */
     
    255257                {
    256258                    <>
    257                     { ( ! qsmIsEmpty( quizList ) && 0 < quizList.length )&& 
     259                    { ( ! qsmIsEmpty( quizList ) && 0 < quizList.length )&&
    258260                    <div className='qsm-placeholder-select-create-quiz'>
    259261                    <SelectControl
     
    268270                    />
    269271                    <span>{ __( 'OR', 'quiz-master-next' ) }</span>
    270                     <Button 
     272                    <Button
    271273                    variant="link"
    272274                    onClick={ () => setCreateQuiz( ! createQuiz )   }
     
    277279                    }
    278280                    { ( qsmIsEmpty( quizList ) || createQuiz ) &&
    279                     <VStack 
     281                    <VStack
    280282                    spacing='3'
    281283                    className='qsm-placeholder-quiz-create-form'
     
    287289                            onChange={ ( val ) => setQuizAttributes( val, 'quiz_name') }
    288290                        />
    289                         <Button 
     291                        <Button
    290292                            variant="link"
    291293                            onClick={ () => setShowAdvanceOption( ! showAdvanceOption ) }
     
    294296                        </Button>
    295297                        <div className='qsm-advance-settings'>
    296                         { showAdvanceOption && quizOptions.map( qSetting => (
    297                             <InputComponent
    298                                 key={ 'qsm-settings'+qSetting.id }
    299                                 data={ qSetting }
    300                                 quizAttr={ quizAttr }
    301                                 setAttributes={ setAttributes }
    302                                 onChangeFunc={ setQuizAttributes }
    303                             />
    304                         ))
    305                         }
     298                            {showAdvanceOption && quizOptions.map(qSetting => {
     299                                if (quizAttr.form_type != 0 && qSetting.id == 'system') {
     300                                    return null; // Correct way to skip rendering
     301                                }
     302
     303                                return (
     304                                    <InputComponent
     305                                        key={'qsm-settings' + qSetting.id}
     306                                        data={qSetting}
     307                                        quizAttr={quizAttr}
     308                                        setAttributes={setAttributes}
     309                                        onChangeFunc={setQuizAttributes}
     310                                    />
     311                                );
     312                            })}
    306313                        </div>
    307                         <Button 
     314                        <Button
    308315                            variant="primary"
    309316                            disabled={ saveQuiz || qsmIsEmpty( quizAttr.quiz_name ) }
     
    337344
    338345    /**
    339      * Prepare quiz data e.g. quiz details, questions, answers etc to save 
     346     * Prepare quiz data e.g. quiz details, questions, answers etc to save
    340347     * @returns quiz data
    341348     */
    342     const getQuizDataToSave = ( ) => { 
    343         let blocks = getBlock( clientId ); 
     349    const getQuizDataToSave = ( ) => {
     350        let blocks = getBlock( clientId );
    344351        if ( qsmIsEmpty( blocks ) ) {
    345352            return false;
    346353        }
    347        
     354
    348355        blocks = blocks.innerBlocks;
    349356        let quizDataToSave = {
     
    361368                let pageID = block.attributes.pageID;
    362369                let questions = [];
    363                 if ( ! qsmIsEmpty( block.innerBlocks ) && 0 <  block.innerBlocks.length ) { 
     370                if ( ! qsmIsEmpty( block.innerBlocks ) && 0 <  block.innerBlocks.length ) {
    364371                    let questionBlocks = block.innerBlocks;
    365372                    //Question Blocks
     
    368375                            return true;
    369376                        }
    370                        
     377
    371378                        let questionAttr = questionBlock.attributes;
    372379                        let answerEditor = qsmValueOrDefault( questionAttr?.answerEditor, 'text' );
    373380                        let answers = [];
    374381                        //Answer option blocks
    375                         if ( ! qsmIsEmpty( questionBlock.innerBlocks ) && 0 <  questionBlock.innerBlocks.length ) { 
     382                        if ( ! qsmIsEmpty( questionBlock.innerBlocks ) && 0 <  questionBlock.innerBlocks.length ) {
    376383                            let answerOptionBlocks = questionBlock.innerBlocks;
    377384                            answerOptionBlocks.forEach( ( answerOptionBlock ) => {
     
    397404                            });
    398405                        }
    399                        
     406
    400407                        //questions Data
    401408                        questions.push( questionAttr.questionID );
     
    415422                                "category": qsmValueOrDefault( questionAttr?.category ),
    416423                                "multicategories": qsmValueOrDefault( questionAttr?.multicategories, [] ),
    417                                 "required": qsmValueOrDefault( questionAttr?.required, 0 ),
     424                                "required": qsmValueOrDefault(questionAttr?.required, '1') == '0' ? '1' : '0',
     425                                "is_published": qsmValueOrDefault(questionAttr?.isPublished, 1),
     426                                "merged_question": qsmValueOrDefault( questionAttr?.linked_question, '' ),
    418427                                "answers": answers,
    419428                                "featureImageID":qsmValueOrDefault( questionAttr?.featureImageID ),
     
    422431                                "other_settings": {
    423432                                    ...qsmValueOrDefault( questionAttr?.settings, {} ),
    424                                     "required": qsmValueOrDefault( questionAttr?.required, 0 ),
     433                                    "required": qsmValueOrDefault(questionAttr?.required, '1') == '0' ? '1' : '0',
     434                                    "isPublished": qsmValueOrDefault(questionAttr?.isPublished, 1),
    425435                                    "question_title": qsmValueOrDefault( questionAttr?.title ),
    426436                                    "answerEditor": answerEditor
     
    428438                            });
    429439                        }
    430                        
     440
    431441                    });
    432442                }
     
    441451                //page data
    442452                quizDataToSave.pages.push( questions );
    443                
     453
    444454                quizDataToSave.qpages.push( {
    445455                    'id': pageID,
     
    454464
    455465        //Quiz details
    456         quizDataToSave.quiz =  {   
     466        quizDataToSave.quiz =  {
    457467            'quiz_name': quizAttr.quiz_name,
    458468            'quiz_id': quizAttr.quiz_id,
     
    461471        if ( showAdvanceOption ) {
    462472            [
    463             'form_type', 
    464             'system', 
    465             'timer_limit', 
     473            'form_type',
     474            'system',
     475            'timer_limit',
    466476            'pagination',
    467             'enable_contact_form', 
    468             'enable_pagination_quiz', 
     477            'enable_contact_form',
     478            'enable_pagination_quiz',
    469479            'show_question_featured_image_in_result',
    470480            'progress_bar',
     
    472482            'disable_first_page',
    473483            'comment_section'
    474             ].forEach( ( item ) => { 
     484            ].forEach( ( item ) => {
    475485                if ( 'undefined' !== typeof quizAttr[ item ] && null !== quizAttr[ item ] ) {
    476486                    quizDataToSave.quiz[ item ] = quizAttr[ item ];
     
    492502            if ( ! qsmIsEmpty( editorSelectors ) ) {
    493503                post_status = editorSelectors.getEditedPostAttribute( 'status' );
    494             } 
     504            }
    495505            if ( qsmIsEmpty( post_status ) ) {
    496506                post_status = 'publish';
    497507            }
    498            
     508
    499509            quizData = qsmFormData({
    500510                'save_entire_quiz': '1',
     
    531541    /**
    532542     * Create new quiz and set quiz ID
    533      * 
     543     *
    534544     */
    535545    const createNewQuiz = () => {
     
    540550        //save quiz status
    541551        setSaveQuiz( true );
    542        
     552
    543553        let quizData = qsmFormData({
    544554            'quiz_name': quizAttr.quiz_name,
    545555            'qsm_new_quiz_nonce': qsmBlockData.qsm_new_quiz_nonce
    546556        });
    547        
    548         ['form_type', 
    549         'system', 
    550         'timer_limit', 
     557
     558        ['form_type',
     559        'system',
     560        'timer_limit',
    551561        'pagination',
    552         'enable_contact_form', 
    553         'enable_pagination_quiz', 
     562        'enable_contact_form',
     563        'enable_pagination_quiz',
    554564        'show_question_featured_image_in_result',
    555565        'progress_bar',
     
    581591                    "category": "",
    582592                    "required": 0,
     593                    "isPublished": 1,
    583594                    "answers": [],
    584595                    "page": 0
     
    590601                    body: newQuestion
    591602                } ).then( ( response ) => {
    592                    
     603
    593604                    if ( 'success' == response.status ) {
    594605                        let question_id = response.id;
     
    602613                        //  qpages[0][questions][]: 2512
    603614                        //  post_id: 111
    604                        
     615
    605616                        let newPage = qsmFormData( {
    606617                            "action": qsmBlockData.save_pages_action,
     
    623634                            body: newPage
    624635                        } ).then( ( pageResponse ) => {
    625                            
     636
    626637                            if ( 'success' == pageResponse.status ) {
    627638                                //set new quiz
     
    631642
    632643                    }
    633                    
     644
    634645                }).catch(
    635646                    ( error ) => {
     
    641652                    }
    642653                );
    643                
    644             } 
     654
     655            }
    645656
    646657            //create notice
     
    658669            }
    659670        );
    660      
     671
    661672    }
    662673
     
    671682        ]
    672683    } );
    673    
     684
    674685
    675686    return (
     
    683694            </span>
    684695        </label>
    685        
     696
    686697        <TextControl
    687698            label={ __( 'Quiz Name *', 'quiz-master-next' ) }
     
    692703        />
    693704        {
    694             ( ! qsmIsEmpty( quizID ) || '0' != quizID ) && 
     705            ( ! qsmIsEmpty( quizID ) || '0' != quizID ) &&
    695706            <p>
    696                 <ExternalLink 
     707                <ExternalLink
    697708                href={ qsmBlockData.quiz_settings_url+'&quiz_id='+quizID+'&tab=options' }
    698709                >
     
    703714        </PanelBody>
    704715    </InspectorControls>
    705     { ( qsmIsEmpty( quizID ) || '0' == quizID ) ? 
     716    { ( qsmIsEmpty( quizID ) || '0' == quizID ) ?
    706717    <div { ...blockProps }> { quizPlaceholder() } </div>
    707718    :
    708719    <div { ...innerBlocksProps } />
    709720    }
    710    
     721
    711722    </>
    712723    );
  • quiz-master-next/trunk/blocks/src/page/block.json

    r3060561 r3249137  
    3030    "supports": {
    3131        "html": false,
    32         "multiple": false
     32        "multiple": true
    3333    },
    3434    "textdomain": "main-block",
  • quiz-master-next/trunk/blocks/src/question/block.json

    r3060561 r3249137  
    7272            "default": "0"
    7373        },
     74        "isPublished": {
     75            "type": "number",
     76            "default": 1
     77        },
     78        "linked_question": {
     79            "type": "string"
     80        },
    7481        "media": {
    7582            "type": "object"
  • quiz-master-next/trunk/blocks/src/question/edit.js

    r3097878 r3249137  
    1818    ToggleControl,
    1919    SelectControl,
    20     ToolbarGroup, 
     20    ToolbarGroup,
    2121    ToolbarButton,
    2222    TextControl,
     
    4545/**
    4646 * https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md#allowedformats-array
    47  * 
     47 *
    4848 */
    4949export default function Edit( props ) {
     
    5252        return null;
    5353    }
    54    
     54
    5555    const { className, attributes, setAttributes, isSelected, clientId, context } = props;
    5656
     
    6868
    6969    //Get finstion to find index of blocks
    70     const { 
    71         getBlockRootClientId, 
    72         getBlockIndex 
     70    const {
     71        getBlockRootClientId,
     72        getBlockIndex
    7373    } = useSelect( blockEditorStore );
    7474
     
    9595        matchAnswer,
    9696        required,
     97        isPublished,
    9798        settings={},
    9899    } = attributes;
    99    
    100     //Variable to decide if correct answer info input field should be available 
     100
     101    //Variable to decide if correct answer info input field should be available
    101102    const [ enableCorrectAnsInfo, setEnableCorrectAnsInfo ] = useState( ! qsmIsEmpty( correctAnswerInfo ) );
    102103    //Advance Question modal
     
    134135        })
    135136    }
    136    
     137
    137138    /**Generate question id if not set or in case duplicate questionID ***/
    138139    useEffect( () => {
    139140        let shouldSetID = true;
    140141        if ( shouldSetID ) {
    141        
     142
    142143            if ( qsmIsEmpty( questionID ) || '0' == questionID || ( ! qsmIsEmpty( questionID ) && isQuestionIDReserved( questionID, clientId ) ) ) {
    143                
     144
    144145                //create a question
    145146                let newQuestion = qsmFormData( {
     
    158159                    "category": qsmValueOrDefault( category ),
    159160                    "multicategories": [],
    160                     "required": qsmValueOrDefault( required, 0 ),
     161                    "required": qsmValueOrDefault(required, 0),
     162                    "isPublished": qsmValueOrDefault(isPublished, 1),
    161163                    "answers": answers,
    162164                    "page": 0,
     
    172174                    body: newQuestion
    173175                } ).then( ( response ) => {
    174                    
     176
    175177                    if ( 'success' == response.status ) {
    176178                        let question_id = response.id;
     
    188190            }
    189191        }
    190        
     192
    191193        //cleanup
    192194        return () => {
    193195            shouldSetID = false;
    194196        };
    195        
     197
    196198    }, [] );
    197199
     
    200202        let shouldSetChanged = true;
    201203        if ( shouldSetChanged && isSelected  && false === isChanged ) {
    202            
     204
    203205            setAttributes( { isChanged: true } );
    204206        }
     
    210212    }, [
    211213        questionID,
     214        isPublished,
    212215        type,
    213216        description,
     
    258261                parents = [ ...parents, ...ancestor ];
    259262            }
    260         } 
    261        
     263        }
     264
    262265        return qsmUniqueArray( parents );
    263266     }
     
    269272    const setUnsetCatgory = ( termId, categories ) => {
    270273        let multiCat = ( qsmIsEmpty( multicategories ) || 0 === multicategories.length ) ? ( qsmIsEmpty( category ) ? [] : [ category ] ) : multicategories;
    271        
     274
    272275        //Case: category unselected
    273276        if ( multiCat.includes( termId ) ) {
     
    275278            multiCat = multiCat.filter( catID =>  catID != termId );
    276279            let children = [];
    277             //check for if any child is selcted 
     280            //check for if any child is selcted
    278281            multiCat.forEach( childCatID => {
    279282                //get ancestors of category
     
    296299        multiCat = qsmUniqueArray( multiCat );
    297300
    298         setAttributes({ 
     301        setAttributes({
    299302            category: '',
    300303            multicategories: [ ...multiCat ]
     
    327330        }
    328331        const blockToInsert = createBlock( props.name );
    329    
     332
    330333        const selectBlockOnInsert = true;
    331334        insertBlock(
     
    369372        </BlockControls>
    370373    { isOpenAdvanceQModal && (
    371         <Modal 
     374        <Modal
    372375        contentLabel={ __( 'Use QSM Editor for Advanced Question', 'quiz-master-next' ) }
    373376        className='qsm-advance-q-modal'
     
    390393                    </Button>
    391394                    <Button variant="primary" onClick={ () => {} }>
    392                         <ExternalLink 
     395                        <ExternalLink
    393396                            href={ qsmBlockData.quiz_settings_url+'&quiz_id='+quizID }
    394397                        >
     
    398401                </div>
    399402            </div>
    400            
     403
    401404        </Modal>
    402405    ) }
     
    408411                    <h3>{ __( 'Advanced Question Type', 'quiz-master-next' ) }</h3>
    409412                </PanelBody>
    410             </InspectorControls>   
     413            </InspectorControls>
    411414            <div  { ...blockProps } >
    412415            <h4 className={ 'qsm-question-title qsm-error-text' } >{ __( 'Advanced Question Type : ', 'quiz-master-next' ) + title }</h4>
    413             <p> 
     416            <p>
    414417            { __( 'Edit question in QSM ', 'quiz-master-next' ) }
    415             <ExternalLink 
     418            <ExternalLink
    416419                href={ qsmBlockData.quiz_settings_url+'&quiz_id='+quizID }
    417420            >
     
    426429            <PanelBody title={ __( 'Question settings', 'quiz-master-next' ) } initialOpen={ true }>
    427430            <h2 className="block-editor-block-card__title">{ __( 'ID', 'quiz-master-next' )+': '+questionID }</h2>
    428             { /** Question Type **/ }
     431            <ToggleControl
     432                label={ __( 'Publish', 'quiz-master-next' ) }
     433                checked={ ! qsmIsEmpty( isPublished ) && '1' == isPublished  }
     434                onChange={ () => setAttributes( { isPublished : ( ( ! qsmIsEmpty( isPublished ) && '1' == isPublished ) ? 0 : 1 ) } ) }
     435            />
     436            { /** Question Type **/}
    429437            <SelectControl
    430438                label={ qsmBlockData.question_type.label }
     
    437445            >
    438446                {
    439                 ! qsmIsEmpty( qsmBlockData.question_type.options ) && qsmBlockData.question_type.options.map( qtypes => 
     447                ! qsmIsEmpty( qsmBlockData.question_type.options ) && qsmBlockData.question_type.options.map( qtypes =>
    440448                    (
    441449                    <optgroup label={ qtypes.category } key={ "qtypes"+qtypes.category }  >
    442450                        {
    443                             qtypes.types.map( qtype => 
     451                            qtypes.types.map( qtype =>
    444452                                (
    445453                                <option value={ qtype.slug } key={ "qtype"+qtype.slug }  >{ qtype.name }</option>
     
    454462            {/**Answer Type */}
    455463            {
    456                 ['0','4','1','10','13'].includes( type ) && 
     464                ['0','4','1','10','13'].includes( type ) &&
    457465                <SelectControl
    458466                    label={ qsmBlockData.answerEditor.label }
     
    506514            )}
    507515            {/**Categories */}
    508             <SelectAddCategory 
     516            <SelectAddCategory
    509517                isCategorySelected={ isCategorySelected }
    510518                setUnsetCatgory={ setUnsetCatgory }
     
    532540            {/**Feature Image */}
    533541            <PanelBody title={ __( 'Featured image', 'quiz-master-next' ) } initialOpen={ true }>
    534                 <FeaturedImage 
     542                <FeaturedImage
    535543                featureImageID={ featureImageID }
    536544                onUpdateImage={ ( mediaDetails ) => {
    537                     setAttributes({ 
     545                    setAttributes({
    538546                        featureImageID: mediaDetails.id,
    539547                        featureImageSrc: mediaDetails.url
     
    541549                }  }
    542550                onRemoveImage={ ( id ) => {
    543                     setAttributes({ 
     551                    setAttributes({
    544552                        featureImageID: undefined,
    545553                        featureImageSrc: undefined,
     
    562570            />
    563571            {
    564                 isParentOfSelectedBlock && 
     572                isParentOfSelectedBlock &&
    565573                <>
    566574                <RichText
     
    598606                }
    599607                {
    600                     isParentOfSelectedBlock && ( 
     608                    isParentOfSelectedBlock && (
    601609                    <div className='block-editor-block-list__insertion-point-inserter qsm-add-new-ques-wrapper'>
    602                     <Button 
     610                    <Button
    603611                    icon={ plusIcon }
    604612                    label={ __( 'Add New Question', 'quiz-master-next' ) }
     
    612620                    )
    613621                }
    614                
     622
    615623                </>
    616624            }
  • quiz-master-next/trunk/js/qsm-create-quiz-script.js

    r3248261 r3249137  
    2626                jQuery(document).find('.qsm-dashboard-header-pagination > a').hide();
    2727                jQuery('.qsm-dashboard-journy-create-quiz').show();
    28             } 
     28            }
    2929            QSMAdminDashboard.showDependentAddons();
    3030        },
     
    195195                    QSMAdminDashboard.activatePlugin(pluginSlug, pluginPath, $parent, $element, installerActivated, isToggle, isButton);
    196196                }
    197             } else if( 1 == installerActivated ) { 
     197            } else if( 1 == installerActivated ) {
    198198                if (isToggle) {
    199199                    $parent.find('.qsm-dashboard-addon-status').text(qsm_admin_new_quiz.installing);
     
    318318                form_type = 2;
    319319            }
     320            0 == form_type ? jQuery('#qsm-quiz-options-system').show() : jQuery('#qsm-quiz-options-system').hide();
    320321            jQuery(`.qsm-create-quiz-more-settings select[name="form_type"]`).val(form_type);
    321322
    322             // Hide recommendetions
    323323            $('.qsm-dashboard-theme-recommended, .qsm-dashboard-addon-recommended').hide();
    324 
    325324            QSMAdminDashboard.showDependentAddons();
    326325        });
  • quiz-master-next/trunk/mlw_quizmaster2.php

    r3248667 r3249137  
    33 * Plugin Name: Quiz And Survey Master
    44 * Description: Easily and quickly add quizzes and surveys to your website.
    5  * Version: 10.0.1
     5 * Version: 10.0.2
    66 * Author: ExpressTech
    77 * Author URI: https://quizandsurveymaster.com/
     
    4444     * @since 4.0.0
    4545     */
    46     public $version = '10.0.1';
     46    public $version = '10.0.2';
    4747
    4848    /**
  • quiz-master-next/trunk/php/admin/functions.php

    r3248667 r3249137  
    694694            'progress_bar'                           => array(
    695695                'label'   => __( 'Show progress bar', 'quiz-master-next' ),
    696                 'value'   => $globalQuizsetting['enable_pagination_quiz'],
     696                'value'   => $globalQuizsetting['progress_bar'],
    697697                'type'    => 'toggle',
    698698                'options' => array(
     
    752752        );
    753753        $quiz_setting_option = apply_filters( 'qsm_quiz_wizard_settings_option', $quiz_setting_option );
    754 
     754        $fields = array();
    755755        foreach ( $quiz_setting_option as $key => $single_setting ) {
    756756            $single_setting['id'] = $key;
    757             echo '<div class="input-group" id="qsm-quiz-options-' . esc_html( $key ) . '">';
    758             QSM_Fields::generate_field( $single_setting, $single_setting['value'] );
    759             echo '</div>';
     757            if ( ! $require_field ) {
     758                echo '<div class="input-group" id="qsm-quiz-options-' . esc_html( $key ) . '">';
     759                QSM_Fields::generate_field( $single_setting, $single_setting['value'] );
     760                echo '</div>';
     761            } else {
     762                $fields[] = $single_setting;
     763            }
     764        }
     765        if ( $require_field ) {
     766            return $fields;
    760767        }
    761768    }
  • quiz-master-next/trunk/php/classes/class-qmn-quiz-creator.php

    r3248261 r3249137  
    301301            $deleted    = 0;
    302302            if ( $qsm_delete_questions_from_qb ) {
    303                
     303
    304304                $deleted = 1;
    305305                $wpdb->update(
  • quiz-master-next/trunk/readme.txt

    r3248667 r3249137  
    55Tested up to: 6.7
    66Requires PHP: 5.4
    7 Stable tag: 10.0.1
     7Stable tag: 10.0.2
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    222222
    223223== Changelog ==
     224= 10.0.2 ( March 02, 2025 ) =
     225* Hotfix: Fixed issue while creating new post/page
     226* Enhancement: Improved question saving option in QSM block
     227
    224228= 10.0.1 ( March 01, 2025 ) =
    225229* Hotfix: Resolved JS warning while saving email template
Note: See TracChangeset for help on using the changeset viewer.