Skip to content

Commit

Permalink
Replace Boolean with boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-boehm committed Oct 18, 2023
1 parent 850835f commit 7173948
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class StudentExam extends AbstractAuditingEntity {
private Boolean submitted;

@Column(name = "abandoned")
private Boolean abandoned;
private boolean abandoned = false;

/**
* The individual working time per student in seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public ResponseEntity<Void> submitStudentExam(@PathVariable Long courseId, @Path
return ResponseEntity.ok().build();
}

if (Boolean.TRUE.equals(studentExamFromClient.isAbandoned()) || Boolean.TRUE.equals(existingStudentExam.isAbandoned())) {
if (studentExamFromClient.isAbandoned() || existingStudentExam.isAbandoned()) {
log.error("Student exam with id {} for user {} is abandoned.", studentExamFromClient.getId(), currentUser.getLogin());
throw new BadRequestException("Exam is already abandoned");
}
Expand Down Expand Up @@ -323,7 +323,7 @@ public ResponseEntity<Void> abandonStudentExam(@PathVariable Long courseId, @Pat
throw new BadRequestException("Exam is already submitted");
}

if (Boolean.TRUE.equals(studentExamFromClient.isAbandoned()) || Boolean.TRUE.equals(existingStudentExam.isAbandoned())) {
if (studentExamFromClient.isAbandoned() || existingStudentExam.isAbandoned()) {
log.error("Student exam with id {} for user {} is already abandoned.", studentExamFromClient.getId(), currentUser.getLogin());
throw new BadRequestException("Exam is already abandoned");
}
Expand Down
50 changes: 30 additions & 20 deletions src/test/javascript/spec/service/exam-participation.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,7 @@ describe('Exam Participation Service', () => {
});

it('should load a StudentExam in the version of server', async () => {
/*configure exercises of this student Exam*/
const exercise = new TextExercise(new Course(), undefined);
const studentParticipation = new StudentParticipation();
const participationResult = new Result();
participationResult.participation = studentParticipation;
studentParticipation.results = [participationResult];
const submission = new TextSubmission();
submission.results = [new Result()];
submission.participation = studentParticipation;
getLatestSubmissionResult(submission)!.participation = studentParticipation;
getLatestSubmissionResult(submission)!.submission = submission;
studentParticipation.submissions = [submission];
exercise.studentParticipations = [studentParticipation];
/*configure the exam of a student exam*/
const examToSend = new Exam();

const returnedFromService = Object.assign(studentExam, {
exercises: [exercise],
exam: examToSend,
});
const returnedFromService = studentExamPayload();
service
.submitStudentExam(2, 2, returnedFromService)
.pipe(take(1))
Expand Down Expand Up @@ -265,4 +246,33 @@ describe('Exam Participation Service', () => {
const req = httpMock.expectOne({ method: 'GET' });
req.flush(returnedFromService);
});

it('should call student-exam/abandon', async () => {
const objectToSend = studentExamPayload();
service.abandonStudentExam(2, 2, objectToSend).subscribe();
const url = service.getResourceURL(2, 2) + '/student-exams/abandon';

httpMock.expectOne({ method: 'POST', url: url });
});

const studentExamPayload = () => {
const exercise = new TextExercise(new Course(), undefined);
const studentParticipation = new StudentParticipation();
const participationResult = new Result();
participationResult.participation = studentParticipation;
studentParticipation.results = [participationResult];
const submission = new TextSubmission();
submission.results = [new Result()];
submission.participation = studentParticipation;
getLatestSubmissionResult(submission)!.participation = studentParticipation;
getLatestSubmissionResult(submission)!.submission = submission;
studentParticipation.submissions = [submission];
exercise.studentParticipations = [studentParticipation];
const examToSend = new Exam();

return Object.assign(studentExam, {
exercises: [exercise],
exam: examToSend,
});
};
});

0 comments on commit 7173948

Please sign in to comment.