SEBSERV-417 do not deactivate teacher account (might be used by others)
This commit is contained in:
parent
27c5cff6f5
commit
bf7204660d
3 changed files with 2 additions and 33 deletions
|
@ -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<Exam> 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
|
||||
|
|
|
@ -127,20 +127,6 @@ public class TeacherAccountServiceImpl implements TeacherAccountService {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Exam> 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<String> getOneTimeTokenForTeacherAccount(
|
||||
final Exam exam,
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue