CHanged Event admin layout

This commit is contained in:
PxlLoewe
2025-03-10 18:11:28 -07:00
parent 77b266e0bf
commit c01e618a56
17 changed files with 918 additions and 170 deletions

View File

@@ -2,6 +2,8 @@ import { getMoodleCourseCompletionStatus, getMoodleUserById } from "./moodle";
import { CronJob } from "cron";
import { prisma } from "@repo/db";
import { eventCompleted } from "@repo/ui/helper";
import { sendCourseCompletedEmail } from "modules/mail";
import { handleParticipantFinished } from "modules/event";
const syncMoodleIds = async () => {
try {
@@ -57,7 +59,7 @@ const updateParticipantMoodleResults = async () => {
);
if (quizzResult?.completionstatus?.completed === true) {
await prisma.participant.update({
return prisma.participant.update({
where: {
id: p.id,
},
@@ -65,7 +67,7 @@ const updateParticipantMoodleResults = async () => {
finisherMoodleCurseCompleted: true,
statusLog: {
push: {
event: "Finisher course completed",
event: "Moodle-Kurs abgeschlossen",
timestamp: new Date(),
user: "system",
},
@@ -77,33 +79,40 @@ const updateParticipantMoodleResults = async () => {
);
};
export const checkedFinishedParticipants = async () => {
export const checkFinishedParticipants = async () => {
console.log("Checking finished participants");
const participantsPending = await prisma.participant.findMany({
where: {
finished: false,
completetionWorkflowFinished: false,
},
include: {
Event: true,
User: true,
},
});
participantsPending.forEach(async (p) => {
if (!p.User) return;
if (!p.User.moodleId) return;
const completed = eventCompleted(p.Event, p);
if (!completed) return;
handleParticipantFinished(p.Event, p, p.User);
});
};
CronJob.from({ cronTime: "0 * * * *", onTick: syncMoodleIds, start: true });
CronJob.from({
cronTime: "*/5 * * * *",
cronTime: "*/1 * * * *",
onTick: async () => {
console.log("Updating participant moodle results");
await updateParticipantMoodleResults();
await checkFinishedParticipants();
},
start: true,
});
updateParticipantMoodleResults();
const debug = async () => {
await updateParticipantMoodleResults();
await checkFinishedParticipants();
};
debug();