Skip to content

Commit

Permalink
skip quiz item if not linked
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfrase3 committed Mar 6, 2024
1 parent 567ba8d commit d4d720d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/util/quizProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ const loadScores = async ({ csvUrl, expiry }) => {
};

const processQuizItem = async (app, item) => {
const trainings = await app.service('trainings').find({
query: {
itemIds: item._id,
},
paginate: false,
});
if (!trainings.length) return;
const allResults = await loadScores(item);
const usernames = _.uniq(allResults.map((v) => v.username)).filter(Boolean);
const emails = _.uniq(allResults.map((v) => v.email)).filter(Boolean);
Expand All @@ -74,12 +81,7 @@ const processQuizItem = async (app, item) => {
},
paginate: false,
});
const trainings = await app.service('trainings').find({
query: {
itemIds: item._id,
},
paginate: false,
});
if (!users.length) return;
const allCompletions = await app.service('completions').find({
query: {
userId: { $in: users.map((u) => u._id) },
Expand Down

0 comments on commit d4d720d

Please sign in to comment.