Skip to content

Commit

Permalink
Assessment question update
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant-Archibald-MS committed Dec 14, 2024
1 parent 923f024 commit f988f68
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 44 deletions.
32 changes: 31 additions & 1 deletion site/_plugins/interactive_assessment/interactive_assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,41 @@ def render(context)
fetch('/powerfuldev-testing/assets/js/#{@json_file}')
.then(response => response.json())
.then(surveyJSON => {
console.log(surveyJSON);
const survey = new Survey.Model(surveyJSON);
survey.showTitle = false;
survey.showCompleteButton = false;
survey.render(document.getElementById("surveyContainer"));
survey.onCurrentPageChanging.add(function (survey, options) {
var oldPage = options.oldCurrentPage;
var newPage = options.newCurrentPage;
if (newPage.visibleIndex === 0) { // Check if the new page is the first page
survey.pages.forEach(function (page) {
page.questions.forEach(function (question) {
question.clearValue();
});
});
}
else {
if (newPage.visibleIndex < oldPage.visibleIndex) {
oldPage.questions.forEach(function (q) {
q.clearValue();
});
}
}
});
survey.onValueChanged.add(function (survey, options) {
var currentPageIndex = survey.currentPageNo;
var visiblePages = survey.visiblePageCount;
survey.pages.forEach(function (page, index) {
if (index > currentPageIndex && index < visiblePages - 1) {
page.questions.forEach(function (question) {
question.clearValue();
});
}
});
});
})
.catch(error => console.error('Error loading survey questions:', error));
});
Expand Down
Loading

0 comments on commit f988f68

Please sign in to comment.