In developing a test/quiz app using Meteor, I have all the questions, possible answers, etc. stored in a local MongoDB in the following format:
{
type: "someType",
skillType: "someSkillType",
questions: [
{
questionID: 1,
question: "Some question",
answer: 2,
option1: "Some possible answer",
option2: "Another one",
option3: "Etc."
},
{
questionID: 2,
question: "Some question 2",
answer: 1,
option1: "Some possible answer",
option2: "Another one",
option3: "Etc."
}
]
}
I have extensively tested and ensured that the issue does not lie with my Meteor.Collection
,
Meteor.publish / Meteor.subscribe
, or connection to the database. The data is present, and can be accessed from the console without any issues.
The template structure is as follows:
<template name="test">
<form name="testForm" id="testForm" role="form">
{{#each testQuestions}}
<div class="jumbotron">
<p><b>{{questionID}}.</b> {{question}}</p>
<div class="radio">
<label>
<input type="radio" name="qNumber{{questionID}}" value="1" required>
{{option1}}
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="qNumber{{questionID}}" value="2">
{{option2}}
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="qNumber{{questionID}}" value="3">
{{option3}}
</label>
</div>
</div>
{{/each}}
</form>
</template>
A template helper has been created to retrieve the data:
Template.test.testQuestions = function () {
questionsAll = allQuestions.findOne({"type": "someType", "skillType": "someSkillType"}, {fields: {"_id": 0, "type": 0, "skillType": 0, "questions.answer": 0 }});
questionsAll1 = EJSON.toJSONValue((questionsAll.questions)); // Attempted both with and without this part.
return questionsAll1;
}
However, the rendering fails and a lengthy error appears in the console starting with:
"Exception from Deps recompute function: .observeChanges@.......
When directly inserting a static array in the template helper, it functions correctly. Despite trying various solutions, I am unable to pinpoint the root of the issue. Any suggestions or assistance would be greatly appreciated.