Getting the next question
function getQuestion(_formId : text,_submissionId : text,_questionId : text) do
let training := first(select Training where 'Submit ID' = _submissionId);
if _questionId = "" or _questionId = null then
first(training.Questions[Question.Type != 1 and Question.Type != 2 and not _ANSWERED])
end
end;
function _getNextQuestion(_formId : text,_submissionId : text,_currentQuestionId : text) do
let training := first(select Training where 'Submit ID' = _submissionId);
if _currentQuestionId = "" or _currentQuestionId = null then
let firstQuestion := first(training.Questions[Question.Type != 1 and Question.Type != 2 and not _ANSWERED]);
if firstQuestion != null then
firstQuestion._JSON
else
{
type: "end",
label: "Thank you",
description: "We thank you for your submission",
imgUrl: "",
progress: 100
}
end
else
let currentQuestion := first(training.Questions[Question.'Question ID' = _currentQuestionId]);
let nextQuestion := first(training.Questions[number(ID) > number(currentQuestion)]);
if nextQuestion != null then
nextQuestion._JSON
else
{
type: "end",
label: "Thank you",
description: "We thank you for your submission",
imgUrl: "",
progress: 100
}
end
end
end;
function getNextQuestion(_formId : text,_submissionId : text) do
_getNextQuestion(_formId, _submissionId, "")
end;Last updated