Skip to content

Commit 805666a

Browse files
Development: Remove delete all exam room versions (#11441)
1 parent a439593 commit 805666a

File tree

9 files changed

+3
-179
lines changed

9 files changed

+3
-179
lines changed

src/main/java/de/tum/cit/aet/artemis/exam/service/ExamRoomService.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,6 @@ public ExamRoomAdminOverviewDTO getExamRoomAdminOverview() {
352352
return new ExamRoomAdminOverviewDTO(numberOfStoredExamRooms, numberOfStoredExamSeats, numberOfStoredLayoutStrategies, examRoomDTOS);
353353
}
354354

355-
/**
356-
* Purges the DB of all exam room related data.
357-
*/
358-
public void deleteAllExamRooms() {
359-
examRoomRepository.deleteAll();
360-
}
361-
362355
/**
363356
* Deletes all outdated and unused exam rooms.
364357
* <p/>

src/main/java/de/tum/cit/aet/artemis/exam/web/admin/AdminExamResource.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,6 @@ public ResponseEntity<ExamRoomAdminOverviewDTO> getExamRoomAdminOverview() {
114114
return ResponseEntity.ok(examRoomAdminOverviewDTO);
115115
}
116116

117-
/**
118-
* DELETE /exam-rooms: Deletes <strong>everything</strong> related to exam rooms.
119-
*
120-
* @return a response entity with status 204 and empty body.
121-
*/
122-
@DeleteMapping("exam-rooms")
123-
public ResponseEntity<Void> deleteAllExamRooms() {
124-
log.info("REST request to delete ALL exam rooms");
125-
126-
examRoomService.deleteAllExamRooms();
127-
return ResponseEntity.noContent().build();
128-
}
129-
130117
/**
131118
* DELETE /exam-rooms/outdated-and-unused: Delete all outdated and unused exam rooms.
132119
*

src/main/webapp/app/core/admin/exam-rooms/exam-rooms.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ <h2><span jhiTranslate="artemisApp.examRooms.adminOverview.title"></span></h2>
1313
<button id="roomDataUpload" jhiTranslate="entity.action.save" class="btn btn-primary" (click)="upload()" [disabled]="!canUpload()"></button>
1414
</div>
1515
<div class="mt-2">
16-
<button id="roomDataDeleteAll" jhiTranslate="artemisApp.examRooms.adminOverview.deleteAllExamRooms" class="btn btn-danger" (click)="clearExamRooms()"></button>
1716
<button
1817
id="roomDataDeleteOutdatedAndUnused"
1918
jhiTranslate="artemisApp.examRooms.adminOverview.deleteExamRoomsSafe"

src/main/webapp/app/core/admin/exam-rooms/exam-rooms.component.spec.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -313,38 +313,6 @@ describe('ExamRoomsComponentTest', () => {
313313
return examRoom;
314314
}
315315

316-
it('should call deletion service on delete all button click', () => {
317-
// GIVEN
318-
fixture.detectChanges(); // initial render
319-
jest.spyOn(service, 'deleteAllExamRooms').mockReturnValue(of(convertBodyToHttpResponse<void>()));
320-
const deleteAllButton = fixture.debugElement.nativeElement.querySelector('#roomDataDeleteAll');
321-
322-
// WHEN
323-
deleteAllButton.click();
324-
fixture.detectChanges();
325-
326-
// THEN
327-
expect(service.deleteAllExamRooms).toHaveBeenCalledOnce();
328-
// once from the initial load, once from the button click
329-
expect(service.getAdminOverview).toHaveBeenCalledTimes(2);
330-
});
331-
332-
it('should not reload overview if deletion fails on delete all button click', () => {
333-
// GIVEN
334-
fixture.detectChanges(); // initial render
335-
jest.spyOn(service, 'deleteAllExamRooms').mockReturnValue(throwError(() => new Error()));
336-
const deleteAllButton = fixture.debugElement.nativeElement.querySelector('#roomDataDeleteAll');
337-
338-
// WHEN
339-
deleteAllButton.click();
340-
fixture.detectChanges();
341-
342-
// THEN
343-
expect(service.deleteAllExamRooms).toHaveBeenCalledOnce();
344-
// once from the initial load
345-
expect(service.getAdminOverview).toHaveBeenCalledOnce();
346-
});
347-
348316
it('should call delete outdated and unused service on delete outdated and unused button click', () => {
349317
// GIVEN
350318
fixture.detectChanges(); // initial render

src/main/webapp/app/core/admin/exam-rooms/exam-rooms.component.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, EventEmitter, Signal, WritableSignal, computed, effect, inject, signal } from '@angular/core';
1+
import { Component, Signal, WritableSignal, computed, effect, inject, signal } from '@angular/core';
22
import {
33
ExamRoomAdminOverviewDTO,
44
ExamRoomDTO,
@@ -15,10 +15,6 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
1515
import { faSort } from '@fortawesome/free-solid-svg-icons';
1616
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
1717
import { ExamRoomsService } from 'app/core/admin/exam-rooms/exam-rooms.service';
18-
import { DeleteDialogService } from 'app/shared/delete-dialog/service/delete-dialog.service';
19-
import { ActionType } from 'app/shared/delete-dialog/delete-dialog.model';
20-
import { ButtonType } from 'app/shared/components/buttons/button/button.component';
21-
import { Subject } from 'rxjs';
2218
import { MAX_FILE_SIZE } from 'app/shared/constants/input.constants';
2319
import { TranslateService } from '@ngx-translate/core';
2420
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
@@ -36,7 +32,6 @@ export class ExamRoomsComponent {
3632

3733
private examRoomsService: ExamRoomsService = inject(ExamRoomsService);
3834
private sortService: SortService = inject(SortService);
39-
private deleteDialogService: DeleteDialogService = inject(DeleteDialogService);
4035
private translateService: TranslateService = inject(TranslateService);
4136
private alertService: AlertService = inject(AlertService);
4237

@@ -107,10 +102,6 @@ export class ExamRoomsComponent {
107102
sortAttribute: 'roomNumber' | 'name' | 'building' | 'maxCapacity' = 'roomNumber';
108103
ascending: boolean = true;
109104

110-
// Fields for working with DeletionDialogService
111-
private dialogErrorSource = new Subject<string>();
112-
private dialogError = this.dialogErrorSource.asObservable();
113-
114105
initEffect = effect(() => {
115106
this.loadExamRoomOverview();
116107
});
@@ -186,46 +177,6 @@ export class ExamRoomsComponent {
186177
});
187178
}
188179

189-
/**
190-
* REST request to delete ALL exam room related data.
191-
*/
192-
clearExamRooms(): void {
193-
const deleteEmitter = new EventEmitter<{ [key: string]: boolean }>();
194-
195-
deleteEmitter.subscribe(() => {
196-
this.actionStatus.set('deleting');
197-
this.examRoomsService.deleteAllExamRooms().subscribe({
198-
next: () => {
199-
this.actionStatus.set('deletionSuccess');
200-
this.actionInformation.set(undefined);
201-
this.loadExamRoomOverview();
202-
},
203-
error: (errorResponse: HttpErrorResponse) => {
204-
this.showErrorNotification('deletionError', {}, errorResponse.message);
205-
this.actionStatus.set(undefined);
206-
},
207-
complete: () => {
208-
// We need to call this, or else the deleteDialogService can't progress.
209-
// By doing next('') here, we tell the delete dialog service not to call the alert service.
210-
// We don't want the delete dialog service to call the alert service, as we can do that with
211-
// the 'this.showErrorNotification' function ourselves, which then also allows us to specify
212-
// just a translation key, rather than a hardcoded string.
213-
this.dialogErrorSource.next('');
214-
},
215-
});
216-
});
217-
218-
this.deleteDialogService.openDeleteDialog({
219-
deleteQuestion: `${this.baseTranslationPath}.deleteAllExamRoomsQuestion`,
220-
buttonType: ButtonType.ERROR,
221-
actionType: ActionType.Delete,
222-
delete: deleteEmitter,
223-
dialogError: this.dialogError,
224-
requireConfirmationOnlyForAdditionalChecks: false,
225-
translateValues: {},
226-
});
227-
}
228-
229180
/**
230181
* REST request to delete all outdated and unused exam rooms.
231182
* An exam room is outdated if there exists a newer entry of the same (number, name) combination.

src/main/webapp/app/core/admin/exam-rooms/exam-rooms.service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ export class ExamRoomsService {
2828
return this.http.post<ExamRoomUploadInformationDTO>(`${this.baseUrl}/upload`, formData, { observe: 'response' });
2929
}
3030

31-
/**
32-
* Send a DELETE request to remove everything related to exam rooms.
33-
* This also removes exam rooms that are connected to an exam.
34-
*/
35-
deleteAllExamRooms(): Observable<HttpResponse<void>> {
36-
return this.http.delete<void>(`${this.baseUrl}`, { observe: 'response' });
37-
}
38-
3931
/**
4032
* Send a DELETE request to remove all outdated and unused exam rooms. Besides keeping the newest version of
4133
* each room, this also keeps all versions that are (still) being connected to an exam.

src/main/webapp/i18n/de/examRooms.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"invalidFile": "Mit der Datei die du hochgeladen hast ist etwas nicht in Ordnung",
99
"fileSizeTooBig": "Die Dateigröße darf {{ MAX_FILE_SIZE }} MB nicht überschreiten",
1010
"noZipFile": "Nur .zip Dateien werden akzeptiert",
11-
"deleteAllExamRooms": "Lösche alle Prüfungsraumdaten",
12-
"deleteAllExamRoomsQuestion": "Dies wird alle Prüfungsraumdaten löschen, inklusive derer die noch Examina zugeordnet sind. Bist du sicher, dass du fortfahren willst?",
13-
"deleteExamRoomsSafe": "Lösche veraltete Prüfungsraumdaten",
11+
"deleteExamRoomsSafe": "Lösche veraltete und unbenutzte Prüfungsraumversionen",
1412
"uploadError": "Beim Verarbeiten der Räume ist ein Fehler aufgetreten",
1513
"deleting": "Löschen...",
1614
"deletionError": "Beim Löschen der Räume ist ein Fehler aufgetreten",

src/main/webapp/i18n/en/examRooms.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"invalidFile": "Something is wrong with the file you selected",
99
"fileSizeTooBig": "File size cannot exceed {{ MAX_FILE_SIZE }} MB",
1010
"noZipFile": "Only .zip files are accepted",
11-
"deleteAllExamRooms": "Delete all exam rooms",
12-
"deleteAllExamRoomsQuestion": "This will delete all exam rooms, including those that may still be in use. Are you sure you want to proceed?",
13-
"deleteExamRoomsSafe": "Delete outdated and unused exam rooms",
11+
"deleteExamRoomsSafe": "Delete outdated and unused exam room versions",
1412
"uploadError": "An error occurred while processing the rooms",
1513
"deleting": "Deleting...",
1614
"deletionError": "An error occurred while deleting the rooms",

src/test/java/de/tum/cit/aet/artemis/exam/ExamRoomIntegrationTest.java

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -337,68 +337,6 @@ void testGetAdminOverviewSingleRoomIntoExistingData() throws Exception {
337337
validateAdminOverview(adminOverview, 64 + 1, 16_141 + 528, 224 + 4, ExamRoomZipFiles.singleExamRoomName);
338338
}
339339

340-
/* Tests for the DELETE /exam-rooms endpoint */
341-
342-
@Test
343-
@WithMockUser(username = STUDENT_LOGIN, roles = "USER")
344-
void testDeleteAllExamRoomDataAsStudent() throws Exception {
345-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.FORBIDDEN);
346-
}
347-
348-
@Test
349-
@WithMockUser(username = TUTOR_LOGIN, roles = "TA")
350-
void testDeleteAllExamRoomDataAsTutor() throws Exception {
351-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.FORBIDDEN);
352-
}
353-
354-
@Test
355-
@WithMockUser(username = EDITOR_LOGIN, roles = "EDITOR")
356-
void testDeleteAllExamRoomDataAsEditor() throws Exception {
357-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.FORBIDDEN);
358-
}
359-
360-
@Test
361-
@WithMockUser(username = INSTRUCTOR_LOGIN, roles = "INSTRUCTOR")
362-
void testDeleteAllExamRoomDataAsInstructor() throws Exception {
363-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.FORBIDDEN);
364-
}
365-
366-
@Test
367-
@WithMockUser(username = "admin", roles = "ADMIN")
368-
void testDeleteAllExamRoomDataAsAdmin() throws Exception {
369-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.NO_CONTENT);
370-
}
371-
372-
@Test
373-
@WithMockUser(username = "admin", roles = "ADMIN")
374-
void testDeleteAllExamRoomDataEmpty() throws Exception {
375-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.NO_CONTENT);
376-
validateDbStoredElementCounts(0, 0, 0);
377-
}
378-
379-
@Test
380-
@WithMockUser(username = "admin", roles = "ADMIN")
381-
void testDeleteAllRealisticRoomData() throws Exception {
382-
request.postMultipartFileOnly("/api/exam/admin/exam-rooms/upload", ExamRoomZipFiles.zipFileRealisticScenario, HttpStatus.OK);
383-
assertThat(examRoomRepository.count()).isPositive();
384-
385-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.NO_CONTENT);
386-
validateDbStoredElementCounts(0, 0, 0);
387-
}
388-
389-
@Test
390-
@WithMockUser(username = "admin", roles = "ADMIN")
391-
void testDeleteAllTonsOfExamRoomData() throws Exception {
392-
for (int i = 0; i < 10; i++) {
393-
request.postMultipartFileOnly("/api/exam/admin/exam-rooms/upload", ExamRoomZipFiles.zipFileRealisticScenario, HttpStatus.OK);
394-
}
395-
396-
assertThat(examRoomRepository.count()).isPositive();
397-
398-
request.delete("/api/exam/admin/exam-rooms", HttpStatus.NO_CONTENT);
399-
validateDbStoredElementCounts(0, 0, 0);
400-
}
401-
402340
/* Tests for the DELETE /exam-rooms/outdated-and-unused endpoint */
403341

404342
@Test

0 commit comments

Comments
 (0)