Skip to content

Commit f1c58f6

Browse files
Merge branch 'develop' into feature/localVC/failed-access-logging
2 parents 121de51 + 59066cc commit f1c58f6

22 files changed

+40
-109
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Refer to [Using JHipster in production](http://www.jhipster.tech/production) for
193193
The following command can automate the deployment to a server. The example shows the deployment to the main Artemis test server (which runs a virtual machine):
194194

195195
```shell
196-
./artemis-server-cli deploy username@artemis-test0.artemis.in.tum.de -w build/libs/Artemis-7.10.3.war
196+
./artemis-server-cli deploy username@artemis-test0.artemis.in.tum.de -w build/libs/Artemis-8.0.0.war
197197
```
198198

199199
## Architecture

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ plugins {
2828
}
2929

3030
group = "de.tum.cit.aet.artemis"
31-
version = "7.10.3"
31+
version = "8.0.0"
3232
description = "Interactive Learning with Individual Feedback"
3333

3434
java {

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "artemis",
3-
"version": "7.10.3",
3+
"version": "8.0.0",
44
"description": "Interactive Learning with Individual Feedback",
55
"private": true,
66
"license": "MIT",

src/main/java/de/tum/cit/aet/artemis/core/domain/AbstractAuditingEntity.java

-12
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public String getCreatedBy() {
4646
return createdBy;
4747
}
4848

49-
public void setCreatedBy(String createdBy) {
50-
this.createdBy = createdBy;
51-
}
52-
5349
public Instant getCreatedDate() {
5450
return createdDate;
5551
}
@@ -62,15 +58,7 @@ public String getLastModifiedBy() {
6258
return lastModifiedBy;
6359
}
6460

65-
public void setLastModifiedBy(String lastModifiedBy) {
66-
this.lastModifiedBy = lastModifiedBy;
67-
}
68-
6961
public Instant getLastModifiedDate() {
7062
return lastModifiedDate;
7163
}
72-
73-
public void setLastModifiedDate(Instant lastModifiedDate) {
74-
this.lastModifiedDate = lastModifiedDate;
75-
}
7664
}

src/main/java/de/tum/cit/aet/artemis/core/service/CourseService.java

-6
Original file line numberDiff line numberDiff line change
@@ -1044,9 +1044,6 @@ public ResponseEntity<Set<User>> getAllUsersInGroup(Course course, String groupN
10441044
user.setActivationKey(null);
10451045
user.setLangKey(null);
10461046
user.setLastNotificationRead(null);
1047-
user.setLastModifiedBy(null);
1048-
user.setLastModifiedDate(null);
1049-
user.setCreatedBy(null);
10501047
user.setCreatedDate(null);
10511048
});
10521049
removeUserVariables(usersInGroup);
@@ -1201,9 +1198,6 @@ private void removeUserVariables(Iterable<User> usersInGroup) {
12011198
user.setActivationKey(null);
12021199
user.setLangKey(null);
12031200
user.setLastNotificationRead(null);
1204-
user.setLastModifiedBy(null);
1205-
user.setLastModifiedDate(null);
1206-
user.setCreatedBy(null);
12071201
user.setCreatedDate(null);
12081202
});
12091203
}

src/main/java/de/tum/cit/aet/artemis/exam/domain/event/ExamLiveEvent.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import org.hibernate.annotations.Cache;
1515
import org.hibernate.annotations.CacheConcurrencyStrategy;
16+
import org.springframework.data.annotation.CreatedBy;
1617
import org.springframework.data.annotation.CreatedDate;
1718
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
1819

@@ -36,6 +37,7 @@
3637
@EntityListeners(AuditingEntityListener.class)
3738
public abstract class ExamLiveEvent extends DomainObject {
3839

40+
@CreatedBy
3941
@Column(name = "created_by", nullable = false, length = 50, updatable = false)
4042
private String createdBy;
4143

@@ -53,18 +55,10 @@ public String getCreatedBy() {
5355
return createdBy;
5456
}
5557

56-
public void setCreatedBy(String createdBy) {
57-
this.createdBy = createdBy;
58-
}
59-
6058
public Instant getCreatedDate() {
6159
return createdDate;
6260
}
6361

64-
public void setCreatedDate(Instant createdDate) {
65-
this.createdDate = createdDate;
66-
}
67-
6862
public Long getExamId() {
6963
return examId;
7064
}

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

+8-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.springframework.stereotype.Service;
88

99
import de.tum.cit.aet.artemis.communication.service.WebsocketMessagingService;
10-
import de.tum.cit.aet.artemis.core.domain.User;
1110
import de.tum.cit.aet.artemis.exam.domain.Exam;
1211
import de.tum.cit.aet.artemis.exam.domain.StudentExam;
1312
import de.tum.cit.aet.artemis.exam.domain.event.ExamAttendanceCheckEvent;
@@ -66,15 +65,13 @@ public ExamLiveEventsService(WebsocketMessagingService websocketMessagingService
6665
*
6766
* @param exam the exam to send the announcement to.
6867
* @param message The message to send.
69-
* @param sentBy The user who sent the message.
7068
* @return The created event.
7169
*/
72-
public ExamWideAnnouncementEvent createAndDistributeExamAnnouncementEvent(Exam exam, String message, User sentBy) {
70+
public ExamWideAnnouncementEvent createAndDistributeExamAnnouncementEvent(Exam exam, String message) {
7371
var event = new ExamWideAnnouncementEvent();
7472

7573
// Common fields
7674
event.setExamId(exam.getId());
77-
event.setCreatedBy(sentBy.getName());
7875

7976
// Specific fields
8077
event.setTextContent(message);
@@ -87,16 +84,14 @@ public ExamWideAnnouncementEvent createAndDistributeExamAnnouncementEvent(Exam e
8784
*
8885
* @param studentExam The student exam the where the popup should be shown
8986
* @param message The message to send.
90-
* @param sentBy The user who sent the message.
9187
* @return The created event.
9288
*/
93-
public ExamAttendanceCheckEvent createAndSendExamAttendanceCheckEvent(StudentExam studentExam, String message, User sentBy) {
89+
public ExamAttendanceCheckEvent createAndSendExamAttendanceCheckEvent(StudentExam studentExam, String message) {
9490
var event = new ExamAttendanceCheckEvent();
9591

9692
// Common fields
9793
event.setExamId(studentExam.getExam().getId());
9894
event.setStudentExamId(studentExam.getId());
99-
event.setCreatedBy(sentBy.getName());
10095

10196
// specific fields
10297
event.setTextContent(message);
@@ -111,15 +106,13 @@ public ExamAttendanceCheckEvent createAndSendExamAttendanceCheckEvent(StudentExa
111106
* @param newWorkingTime The new working time in seconds
112107
* @param oldWorkingTime The old working time in seconds
113108
* @param courseWide set to true if this event is caused by a course wide update that affects all students; false otherwise
114-
* @param sentBy The user who performed the update
115109
*/
116-
public void createAndSendWorkingTimeUpdateEvent(StudentExam studentExam, int newWorkingTime, int oldWorkingTime, boolean courseWide, User sentBy) {
110+
public void createAndSendWorkingTimeUpdateEvent(StudentExam studentExam, int newWorkingTime, int oldWorkingTime, boolean courseWide) {
117111
var event = new WorkingTimeUpdateEvent();
118112

119113
// Common fields
120114
event.setExamId(studentExam.getExam().getId());
121115
event.setStudentExamId(studentExam.getId());
122-
event.setCreatedBy(sentBy.getName());
123116

124117
// Specific fields
125118
event.setNewWorkingTime(newWorkingTime);
@@ -132,15 +125,14 @@ public void createAndSendWorkingTimeUpdateEvent(StudentExam studentExam, int new
132125
/**
133126
* Send a problem statement update to all affected students.
134127
*
135-
* @param exercise The exam exercise the problem statement was updated for
136-
* @param message The message to send
137-
* @param instructor The user who performed the update
128+
* @param exercise The exam exercise the problem statement was updated for
129+
* @param message The message to send
138130
*/
139131
@Async
140-
public void createAndSendProblemStatementUpdateEvent(Exercise exercise, String message, User instructor) {
132+
public void createAndSendProblemStatementUpdateEvent(Exercise exercise, String message) {
141133
Exam exam = exercise.getExam();
142134
studentExamRepository.findAllWithExercisesByExamId(exam.getId()).stream().filter(studentExam -> studentExam.getExercises().contains(exercise))
143-
.forEach(studentExam -> this.createAndSendProblemStatementUpdateEvent(studentExam, exercise, message, instructor));
135+
.forEach(studentExam -> this.createAndSendProblemStatementUpdateEvent(studentExam, exercise, message));
144136
}
145137

146138
/**
@@ -149,15 +141,13 @@ public void createAndSendProblemStatementUpdateEvent(Exercise exercise, String m
149141
* @param studentExam The student exam containing the exercise with updated problem statement
150142
* @param exercise The updated exercise
151143
* @param message The message to send
152-
* @param sentBy The user who performed the update
153144
*/
154-
public void createAndSendProblemStatementUpdateEvent(StudentExam studentExam, Exercise exercise, String message, User sentBy) {
145+
public void createAndSendProblemStatementUpdateEvent(StudentExam studentExam, Exercise exercise, String message) {
155146
var event = new ProblemStatementUpdateEvent();
156147

157148
// Common fields
158149
event.setExamId(studentExam.getExam().getId());
159150
event.setStudentExamId(studentExam.getId());
160-
event.setCreatedBy(sentBy.getName());
161151

162152
// Specific fields
163153
event.setTextContent(message);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ public void updateStudentExamsAndRescheduleExercises(Exam exam, int originalExam
14471447

14481448
// NOTE: if the exam is already visible, notify the student about the working time change
14491449
if (now.isAfter(exam.getVisibleDate())) {
1450-
examLiveEventsService.createAndSendWorkingTimeUpdateEvent(studentExam, studentExam.getWorkingTime(), originalStudentWorkingTime, true, instructor);
1450+
examLiveEventsService.createAndSendWorkingTimeUpdateEvent(studentExam, studentExam.getWorkingTime(), originalStudentWorkingTime, true);
14511451
}
14521452
}
14531453
studentExamRepository.saveAll(studentExams);

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastInstructor;
7777
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastStudent;
7878
import de.tum.cit.aet.artemis.core.security.annotations.EnforceAtLeastTutor;
79-
import de.tum.cit.aet.artemis.core.security.annotations.enforceRoleInCourse.EnforceAtLeastInstructorInCourse;
8079
import de.tum.cit.aet.artemis.core.service.AuthorizationCheckService;
8180
import de.tum.cit.aet.artemis.core.service.feature.Feature;
8281
import de.tum.cit.aet.artemis.core.service.feature.FeatureToggle;
@@ -361,7 +360,7 @@ public ResponseEntity<ExamWideAnnouncementEventDTO> createExamAnnouncement(@Path
361360
throw new BadRequestAlertException("Exam is not visible to students", "exam", "examNotVisible");
362361
}
363362

364-
var event = examLiveEventsService.createAndDistributeExamAnnouncementEvent(exam, message, userRepository.getUser());
363+
var event = examLiveEventsService.createAndDistributeExamAnnouncementEvent(exam, message);
365364
log.debug("createExamAnnouncement took {} for exam {}", TimeLogUtil.formatDurationFrom(start), examId);
366365
return ResponseEntity.ok(event.asDTO());
367366
}
@@ -1335,8 +1334,9 @@ public ResponseEntity<Set<SuspiciousExamSessionsDTO>> getAllSuspiciousExamSessio
13351334
* @return the ResponseEntity with status 200 (OK) and with body a summary of the deletion of the exam
13361335
*/
13371336
@GetMapping("courses/{courseId}/exams/{examId}/deletion-summary")
1338-
@EnforceAtLeastInstructorInCourse
1337+
@EnforceAtLeastInstructor
13391338
public ResponseEntity<ExamDeletionSummaryDTO> getDeletionSummary(@PathVariable long courseId, @PathVariable long examId) {
1339+
examAccessService.checkCourseAndExamAccessForInstructorElseThrow(courseId, examId);
13401340
log.debug("REST request to get deletion summary for exam : {}", examId);
13411341
return ResponseEntity.ok(examDeletionService.getExamDeletionSummary(examId));
13421342
}

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ public class StudentExamResource {
124124

125125
private final ExamLiveEventRepository examLiveEventRepository;
126126

127-
private static final boolean IS_TEST_RUN = false;
128-
129127
@Value("${info.student-exam-store-session-data:#{true}}")
130128
private boolean storeSessionDataInStudentExamSession;
131129

@@ -251,7 +249,7 @@ public ResponseEntity<StudentExam> updateWorkingTime(@PathVariable Long courseId
251249
Exam exam = examService.findByIdWithExerciseGroupsAndExercisesElseThrow(examId, false);
252250
if (now.isAfter(exam.getVisibleDate())) {
253251
instanceMessageSendService.sendStudentExamIndividualWorkingTimeChangeDuringConduction(studentExamId);
254-
examLiveEventsService.createAndSendWorkingTimeUpdateEvent(savedStudentExam, workingTime, originalWorkingTime, false, userRepository.getUser());
252+
examLiveEventsService.createAndSendWorkingTimeUpdateEvent(savedStudentExam, workingTime, originalWorkingTime, false);
255253
}
256254
if (now.isBefore(examDateService.getLatestIndividualExamEndDate(exam))) {
257255
// potentially re-schedule clustering of modeling submissions (in case Compass is active)
@@ -279,7 +277,7 @@ public ResponseEntity<ExamAttendanceCheckEventDTO> attendanceCheck(@PathVariable
279277

280278
var student = userRepository.getUserByLoginElseThrow(studentLogin);
281279

282-
StudentExam studentExam = studentExamRepository.findWithExercisesByUserIdAndExamId(student.getId(), examId, IS_TEST_RUN).orElseThrow();
280+
StudentExam studentExam = studentExamRepository.findWithExercisesByUserIdAndExamId(student.getId(), examId, false).orElseThrow();
283281

284282
examAccessService.checkCourseAndExamAndStudentExamAccessElseThrow(courseId, examId, studentExam.getId());
285283

@@ -288,8 +286,7 @@ public ResponseEntity<ExamAttendanceCheckEventDTO> attendanceCheck(@PathVariable
288286
throw new BadRequestAlertException("Exam is not visible to students", "exam", "examNotVisible");
289287
}
290288

291-
User currentUser = userRepository.getUser();
292-
var event = examLiveEventsService.createAndSendExamAttendanceCheckEvent(studentExam, message, currentUser);
289+
var event = examLiveEventsService.createAndSendExamAttendanceCheckEvent(studentExam, message);
293290

294291
return ResponseEntity.ok(event.asDTO());
295292
}
@@ -364,7 +361,7 @@ public ResponseEntity<StudentExam> getStudentExamForConduction(@PathVariable Lon
364361
HttpServletRequest request) {
365362
long start = System.currentTimeMillis();
366363
User currentUser = userRepository.getUserWithGroupsAndAuthorities();
367-
log.debug("REST request to get the student exam of user {} for exam {}", currentUser.getLogin(), examId);
364+
log.debug("REST request to get the student exam of user {} for exam {} for conduction", currentUser.getLogin(), examId);
368365

369366
StudentExam studentExam = studentExamRepository.findByIdWithExercisesElseThrow(studentExamId);
370367

src/main/java/de/tum/cit/aet/artemis/exercise/repository/TeamRepository.java

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE;
44
import static org.springframework.data.jpa.repository.EntityGraph.EntityGraphType.LOAD;
55

6-
import java.time.Instant;
76
import java.util.ArrayList;
87
import java.util.Collection;
98
import java.util.List;
@@ -139,11 +138,6 @@ default Team save(Exercise exercise, Team team) {
139138
if (!conflicts.isEmpty()) {
140139
throw new StudentsAlreadyAssignedException(conflicts);
141140
}
142-
// audit information is normally updated automatically but since changes in the many-to-many relationships are not registered,
143-
// we need to trigger the audit explicitly by modifying a column of the team entity itself
144-
if (team.getId() != null) {
145-
team.setLastModifiedDate(Instant.now());
146-
}
147141
team.setExercise(exercise);
148142
team = save(team);
149143
return findWithStudentsByIdElseThrow(team.getId());

src/main/java/de/tum/cit/aet/artemis/exercise/service/ExerciseService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ public void notifyAboutExerciseChanges(Exercise originalExercise, Exercise updat
796796
else if (now().plusMinutes(EXAM_START_WAIT_TIME_MINUTES).isAfter(originalExercise.getExam().getStartDate()) && originalExercise.isExamExercise()
797797
&& !StringUtils.equals(originalExercise.getProblemStatement(), updatedExercise.getProblemStatement())) {
798798
User instructor = userRepository.getUser();
799-
this.examLiveEventsService.createAndSendProblemStatementUpdateEvent(updatedExercise, notificationText, instructor);
799+
this.examLiveEventsService.createAndSendProblemStatementUpdateEvent(updatedExercise, notificationText);
800800
}
801801
}
802802

src/main/java/de/tum/cit/aet/artemis/plagiarism/web/PlagiarismResultResponseBuilder.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package de.tum.cit.aet.artemis.plagiarism.web;
22

3-
import static de.tum.cit.aet.artemis.core.config.Constants.SYSTEM_ACCOUNT;
4-
5-
import java.util.Objects;
63
import java.util.stream.DoubleStream;
74
import java.util.stream.Stream;
85

@@ -19,8 +16,6 @@
1916
*/
2017
public class PlagiarismResultResponseBuilder {
2118

22-
private static final String CONTINUOUS_PLAGIARISM_CONTROL_CREATED_BY_VALUE = "CPC";
23-
2419
private PlagiarismResultResponseBuilder() {
2520
}
2621

@@ -41,22 +36,12 @@ public static <E extends PlagiarismResult<? extends PlagiarismSubmissionElement>
4136
.flatMap(comparison -> Stream.of(comparison.getSubmissionA().getSubmissionId(), comparison.getSubmissionB().getSubmissionId())).distinct().count();
4237
double averageSimilarity = getSimilarities(plagiarismResult).average().orElse(0.0);
4338
double maximalSimilarity = getSimilarities(plagiarismResult).max().orElse(0.0);
44-
var createdBy = getCreatedBy(plagiarismResult);
45-
var stats = new PlagiarismResultStats(numberOfDetectedSubmissions, averageSimilarity, maximalSimilarity, createdBy);
39+
var stats = new PlagiarismResultStats(numberOfDetectedSubmissions, averageSimilarity, maximalSimilarity, plagiarismResult.getCreatedBy());
4640

4741
return ResponseEntity.ok(new PlagiarismResultDTO<>(plagiarismResult, stats));
4842
}
4943

5044
private static DoubleStream getSimilarities(PlagiarismResult<?> plagiarismResult) {
5145
return plagiarismResult.getComparisons().stream().mapToDouble(PlagiarismComparison::getSimilarity);
5246
}
53-
54-
private static String getCreatedBy(PlagiarismResult<?> result) {
55-
if (Objects.equals(result.getCreatedBy(), SYSTEM_ACCOUNT)) {
56-
return CONTINUOUS_PLAGIARISM_CONTROL_CREATED_BY_VALUE;
57-
}
58-
else {
59-
return result.getCreatedBy();
60-
}
61-
}
6247
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ void testExamAnnouncementSent() throws Exception {
866866

867867
assertThat(result.id()).isGreaterThan(0L);
868868
assertThat(result.text()).isEqualTo(testMessage);
869-
assertThat(result.createdBy()).isEqualTo(userUtilService.getUserByLogin(TEST_PREFIX + "instructor1").getName());
869+
assertThat(result.createdBy()).isEqualTo(userUtilService.getUserByLogin(TEST_PREFIX + "instructor1").getLogin());
870870
assertThat(result.createdDate()).isCloseTo(Instant.now(), within(5, ChronoUnit.SECONDS));
871871

872872
var event = captureExamLiveEventForId(exam1.getId(), true);
@@ -897,7 +897,7 @@ void testExamAttendanceCheck() throws Exception {
897897

898898
assertThat(result.id()).isGreaterThan(0L);
899899
assertThat(result.text()).isEqualTo(testMessage);
900-
assertThat(result.createdBy()).isEqualTo(userUtilService.getUserByLogin(TEST_PREFIX + "instructor1").getName());
900+
assertThat(result.createdBy()).isEqualTo(userUtilService.getUserByLogin(TEST_PREFIX + "instructor1").getLogin());
901901
assertThat(result.createdDate()).isCloseTo(Instant.now(), within(5, ChronoUnit.SECONDS));
902902

903903
}

0 commit comments

Comments
 (0)