Engine
/**
* Loads and intializes the Pickzen engine
* @param code Quiz code
* @param server Pickzen server (https://admin.pickzen.com by default)
* @param config Map to overwrite default settings
* @returns {Promise}
*/
load(code, server, config={}, preview, preload)
/**
* Return the quiz state
* @returns
* 'init' Initializing the quiz, for example while some asynchronous requests are called to fetch initial state data
* 'start' Cover slide
* 'doing' Question slides (informative, filter, feedback, etc.)
* 'help' Help slide
* 'end' End slide (Recommendation slide for example)
*/
getState()
/**
* Returns true if the current state is the state provided
* @param stateId
* @returns {boolean}
*/
inState(stateId)
/**
* Get the current slide type
* @returns {string}
* 'cover' Cover slide
* 'info' Informative slide
* 'filter' Filter slide
* 'form' Form slide
* 'end' End slide (Recommendation slide for example)
*/
getSlideType()
/**
* Return the current slide object
*
* @returns {FormSlide|EndSlide|QuestionSlide|CoverSlide|FeedbackSlide}
*/
getSlide()
/**
* Returns true if the quiz has a cover slide
* @returns {boolean}
*/
hasCoverSlide()
/**
* Return the cover slide object
*
* @returns {CoverSlide}
*/
getCoverSlide()
/**
* Return the end slide object
*
* @returns {EndSlide}
*/
getEndSlide()
/**
* Returns true if the quiz is completed: The recommendations slide is being displayed.
*
* @returns {boolean}
*/
isFinished()
/**
* Return true if we can go to the next slide.
* For example, in case of a slide with mandatory question, we can only go to the next slide when an answer is selected.
*
* @returns {boolean}
*/
canNext()
/**
* Return true if we can go back to the previous slide.
* For example, we can't go back before the first slide.
*
* @returns {boolean}
*/
canBack()
/**
* Return true if we can skip the current slide.
* For example, a slide with mandatory answers can't be skipped.
*
* @returns {boolean}
*/
canSkip()
/**
* Returns a flat array with the IDs of the selected options (answers)
*
* @param onlyToFilter If true, only the options of filter type slides will be returned.
* @returns {[]}
*/
getSelectedOptionIds(onlyToFilter)
/**
* Returns the results that mactch with the current selected options.
*
* @returns {Promise}
*/
getPartialResults()
/**
*
*/
getDatasheets(dsIds)
/**
* Returns the progress of the quiz
*
* @param includeCover If true, take into account the cover slide to calculate the progress
* @param startAtZero If true, the current slide will be taken into account when the slide is displayed. otherwise, it will only by taken into account when the slide is passed.
* @returns {number}
*/
getProgress(includeCover=false, startAtZero=true)
/**
* TODO
*/
getProgressBar()
/**
* TODO
*/
getStep()
/**
* Returns a quiz setting.
*
* @param param Id of the setting.
* @returns {*}
*
* @deprecated use getSetting
*/
getConfig(param)
/**
* Returns a quiz setting.
*
* @param param Id of the setting.
* @returns {*}
*/
getSetting(key)
/**
* TODO
*/
getThemeSetting(key)
/**
* Returns the selected option IDs for the provided slideId.
*
* @param slideId
* @returns {[]}
*/
getSelection(slideId)
/**
* Returns the form field value for the provided fieldId.
*
* @param fieldId
* @returns {*}
*/
getFormAnswer(fieldId)
/**
* Returns true if the provided optionId has been selected.
* @param optionId
* @returns {*|boolean}
*/
isSelectedOption(optionId)
/**
* Sets a global value that will reach the backend. It can be used to add additional data to a generated lead for example.
*
* @param id
* @param value
*/
setGlobalValue(id, value)
/**
* Returns a global value.
* @param id
* @returns {*}
*/
getGlobalValue(id)
/**
* Sets a session value that won't reach the server.
* @param id
* @param value
*/
setSessionValue(id, value)
/**
* Returns a session value.
* @param id
* @returns {*}
*/
getSessionValue(id)
/**
* Prevents the provided slides to be displayed.
*
* @param slideIds Array with the slide Ids.
*/
avoidSlides(slideIds)
/**
* Allows the provided slides, avoided previously, to be displayed.
*
* @param slideIds
*/
allowSlides(slideIds)
/**
* Clear the responses and results from a previously taken quiz, so the user sees a fresh new quiz.
*/
clearStoredResults()
/**
* Bypass the default branching logic to show as next slide, the provided slide.
*
* @param slideId
*/
forceNextSlide(slideId)
/**
* Indicates that a slide have not to be stored in the session historic, so it won't appear when going backwards.
* Its data also won't be sent to the server.
*
* It can be called before or after the slide is displayed.
*
* @param slideId
*/
noHistory(slideId)
/**
* It allows to show again a slide previously dispayed.
*
* @param slideId
*/
allowReask(slideId)
/**
* Returns true if the quiz has been reloaded. For example, when the user restart a completed quiz at another time.
*
* @returns {*}
*/
isReloaded()
/**
* Returns the current user Id. The user Id is persistent, so the user will have always the same id, unless the browser history is cleared.
* @returns {id}
*/
getUserId()
/**
* Send information to the server indicating a dropoff has ocurred.
*/
dropOff()
/**
* Prepopulates form fields
*
* @param fields {id:value}. For example: [{101:'John', 102:'john@pickzen.com'}]
*/
prepopulateFields(fields)
/**
* Returns the Id that will identify this user's responses.
*
* Whenever the user restarts or goes back from the end slide, a new Id will be generated.
*
* @returns string
*/
getCurrentResponsesId()
/**
* Sets a key value into the sandboxed localstorage
*/
setLocalStorageItem(key, value)
/**
* Removes a key from the sandboxed localstorage
*/
removeLocalStorageItem(key)
/**
* Returns a key value from the sandboxed localstorage
*/
getLocalStorageItem(key, defaultValue)
/**
* Returns the assistant code
*/
getCode()
/**
* Interpolates a text changing its parameters
*/
interpolate(text)
/**
* Registers a new field validator
*/
addValidator(validatorId, fn)
/**
* Makes an HTTP GET request
*/
httpGet(url)
/**
* Makes an HTTP POST request
*/
httpPost(url, payload)
/**
* Uploads a file into the user account
*/
httpUpload(url, file, type, filePath, policy, isPublic, signature, credential, expiration)
Last updated