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 1 commit
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
2 changes: 1 addition & 1 deletion common/notification/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ registerStudentHook(
'deactivate-student',
'Account gets deactivated, matches are dissolved, courses are cancelled',
async (student) => {
await deactivateStudent(student, true, 'missing coc');
await deactivateStudent(student, true, true, 'missing coc');
} // the hook does not send out a notification again, the user already knows that their account was deactivated
);

Expand Down
5 changes: 3 additions & 2 deletions common/student/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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, noCoC = false, reason?: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should just allow to pass dissovle reasons instead of using a flag for a special case.

if (!student.active) {
throw new Error('Student was already deactivated');
}
Expand All @@ -32,7 +32,8 @@ 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);
const dissolveReason = noCoC ? dissolve_reason.accountDeactivatedNoCoC : dissolve_reason.accountDeactivated;
await dissolveMatch(match, [dissolveReason], student, dissolved_by_enum.student);
}

// Remove any pending certificates, so that they no longer show up in pupil dashboards
Expand Down
2 changes: 1 addition & 1 deletion graphql/me/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class MutateMeResolver {

if (isSessionStudent(context)) {
const student = await getSessionStudent(context);
const updatedStudent = await deactivateStudent(student, false, reason);
const updatedStudent = await deactivateStudent(student, false, false, reason);

const roles: Role[] = [];
await evaluateStudentRoles(updatedStudent, roles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function deactivateInactiveAccounts() {
}

for (const student of persons.students) {
await deactivateStudent(student, true, DEACTIVATION_MESSAGE);
await deactivateStudent(student, true, false, DEACTIVATION_MESSAGE);
}

logger.info('End deactivating inactive accounts');
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