2
0

feat(template): 📝 Add Quizz

This commit is contained in:
Baptiste Arnaud
2022-04-08 18:07:14 -05:00
parent 4c9f97b254
commit 5aac8229d2
5 changed files with 997 additions and 10 deletions

View File

@ -18,7 +18,9 @@ export const parseVariables =
})
if (!variable) return ''
return (
(options.fieldToParse === 'value' ? variable.value : variable.id) || ''
(options.fieldToParse === 'value'
? variable.value?.toString()
: variable.id) || ''
)
})
}
@ -32,7 +34,7 @@ export const evaluateExpression = (variables: Variable[]) => (str: string) => {
)
)
const evaluatedResult = func(...variables.map((v) => v.value))
return isNotDefined(evaluatedResult) ? '' : evaluatedResult.toString()
return isNotDefined(evaluatedResult) ? '' : evaluatedResult
} catch (err) {
console.log(err)
return str