Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: new match dissolve reason: student did not turn in CoC #1186

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/notification/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { prisma } from '../prisma';
import { userForStudent } from '../user';
import * as Notification from '../../common/notification';
import { SpecificNotificationContext } from './actions';
import { dissolve_reason } from '@prisma/client';

registerStudentHook(
'deactivate-student',
'Account gets deactivated, matches are dissolved, courses are cancelled',
async (student) => {
await deactivateStudent(student, true, 'missing coc');
await deactivateStudent(student, true, 'missing coc', [dissolve_reason.accountDeactivatedNoCoC]);
} // the hook does not send out a notification again, the user already knows that their account was deactivated
);

Expand Down
9 changes: 7 additions & 2 deletions common/student/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import { userForStudent } from '../user';
import { CertificateState } from '../certificate';
import { removeAllPushSubcriptions } from '../notification/channels/push';

export async function deactivateStudent(student: Student, silent = false, reason?: string) {
export async function deactivateStudent(
student: Student,
silent = false,
reason?: string,
dissolveReasons: dissolve_reason[] = [dissolve_reason.accountDeactivated]
) {
if (!student.active) {
throw new Error('Student was already deactivated');
}
Expand All @@ -32,7 +37,7 @@ export async function deactivateStudent(student: Student, silent = false, reason
},
});
for (const match of matches) {
await dissolveMatch(match, [dissolve_reason.accountDeactivated], student, dissolved_by_enum.student);
await dissolveMatch(match, dissolveReasons, student, dissolved_by_enum.student);
}

// Remove any pending certificates, so that they no longer show up in pupil dashboards
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "dissolve_reason" ADD VALUE 'accountDeactivatedNoCoC';
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@ enum dissolved_by_enum {

enum dissolve_reason {
accountDeactivated // The account was deactivated, causing any active matches to be dissolved automatically
accountDeactivatedNoCoC // The account was deactivated because the student did not hand in a Certificate of Conduct
ghosted // "Mein:e Lernpartner:in hat sich nicht zurückgemeldet"
noMoreHelpNeeded // "Mein:e Lernpartner:in benötigt keine Unterstützung mehr" and "Ich benötige keine Unterstützung mehr"
isOfNoHelp // "Ich konnte meinem/meiner Lernpartner:in nicht behilflich sein" and "Mein:e Lernpartner:in konnte mir nicht behilflich sein"
Expand Down
Loading