From bf7204660d135a9945b093e322371c36694e5c5f Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 18 Jun 2024 10:57:41 +0200 Subject: [PATCH] SEBSERV-417 do not deactivate teacher account (might be used by others) --- .../authorization/TeacherAccountService.java | 12 +----------- .../impl/TeacherAccountServiceImpl.java | 14 -------------- .../lms/impl/FullLmsIntegrationServiceImpl.java | 9 +-------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java index 48ed5bb8..e5e18723 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/TeacherAccountService.java @@ -17,7 +17,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.FullLmsIntegrationServi /** Service used to maintain Teacher Ad-Hoc Accounts */ public interface TeacherAccountService { - String AD_HOC_TEACHER_ID_PREFIX = "AD_HOC_TEACHER_"; + String AD_HOC_TEACHER_ID_PREFIX = "TEACHER_ACCOUNT_"; /** Creates an Ad-Hoc Teacher account for a given existing Exam. * @@ -52,16 +52,6 @@ public interface TeacherAccountService { */ String getTeacherAccountIdentifier(String lmsId, String userId); - /** Deactivates a certain ad-hoc Teacher account - * Usually called when an exam is deleted. Checks if Teacher account for exam - * is not used by other active exams and if so, deactivates unused ad-hoc accounts - * - * @param exam The Exam for witch to deactivate all applied ad-hoc Teacher accounts - * if they are not used anymore. - * @return Result refer to the given exam or to an error when happened - */ - Result deactivateTeacherAccountsForExam(Exam exam); - /** Get a One Time Access JWT Token for auto-login for a specific ad-hoc Teacher account. * * @param exam The involved Exam instance diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java index 984f2277..38e8e803 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/authorization/impl/TeacherAccountServiceImpl.java @@ -127,20 +127,6 @@ public class TeacherAccountServiceImpl implements TeacherAccountService { }); } - @Override - public Result deactivateTeacherAccountsForExam(final Exam exam) { - return Result.tryCatch(() -> { - - exam.supporter.stream() - .map(userUUID -> userDAO.byModelId(userUUID).getOr(null)) - .filter(user -> user != null && user.roles.contains(UserRole.TEACHER.name())) - .filter( user -> user.roles.size() == 1) - .forEach( user -> userDAO.setActive(user, false)); - - return exam; - }); - } - @Override public Result getOneTimeTokenForTeacherAccount( final Exam exam, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java index 145cffd7..6be32741 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/FullLmsIntegrationServiceImpl.java @@ -53,7 +53,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.ConnectionConfigu import ch.ethz.seb.sebserver.webservice.servicelayer.session.ScreenProctoringService; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -159,7 +158,6 @@ public class FullLmsIntegrationServiceImpl implements FullLmsIntegrationService @Override public void notifyExamDeletion(final ExamDeletionEvent event) { event.ids.forEach( examId -> this.examDAO.byPK(examId) - .flatMap(this.teacherAccountServiceImpl::deactivateTeacherAccountsForExam) .map(exam -> applyExamData(exam, true)) .onError(error -> log.warn("Failed delete teacher accounts for exam: {}", examId)) ); @@ -187,12 +185,7 @@ public class FullLmsIntegrationServiceImpl implements FullLmsIntegrationService // remove all active exam data for involved exams before deactivate them this.examDAO .allActiveForLMSSetup(Arrays.asList(lmsSetup.id)) - .getOrThrow() - .forEach( exam -> { - this.teacherAccountServiceImpl.deactivateTeacherAccountsForExam(exam) - .map(e -> applyExamData(e, true)) - .onError(error -> log.warn("Failed delete teacher accounts for exam: {}", exam.name)); - }); + .getOrThrow(); // delete full integration on Moodle side due to deactivation this.deleteFullLmsIntegration(lmsSetup.id) .getOrThrow();