use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getModelSubmissionWithSimilarElements.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getModelSubmissionWithSimilarElements() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmission(classExercise, submission, "student1");
ModelingSubmission submission2 = ModelFactory.generateModelingSubmission(validSameModel, true);
database.addModelingSubmission(classExercise, submission2, "student2");
database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
compassService.build(classExercise);
ModelingSubmission storedSubmission = request.get("/api/exercises/" + classExercise.getId() + "/modeling-submission-without-assessment?lock=true", HttpStatus.OK, ModelingSubmission.class);
assertThat(storedSubmission).as("submission was found").isNotNull();
assertThat(storedSubmission.getSimilarElements()).as("similarity count is set").isNotNull();
assertThat(storedSubmission.getSimilarElements()).as("similarity count is set").hasSize(10);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method createModelingSubmission_studentNotInCourse.
@Test
@WithMockUser(username = "student4", roles = "USER")
public void createModelingSubmission_studentNotInCourse() throws Exception {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
request.postWithResponseBody("/api/exercises/" + classExercise.getId() + "/modeling-submissions", submission, ModelingSubmission.class, HttpStatus.FORBIDDEN);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class LearningGoalIntegrationTest method createParticipationSubmissionAndResult.
private void createParticipationSubmissionAndResult(Long idOfExercise, Participant participant, Double pointsOfExercise, Double bonusPointsOfExercise, long scoreAwarded, boolean rated) {
Exercise exercise = exerciseRepository.findById(idOfExercise).get();
if (!exercise.getMaxPoints().equals(pointsOfExercise)) {
exercise.setMaxPoints(pointsOfExercise);
}
if (!exercise.getBonusPoints().equals(bonusPointsOfExercise)) {
exercise.setBonusPoints(bonusPointsOfExercise);
}
exercise = exerciseRepository.save(exercise);
StudentParticipation studentParticipation = participationService.startExercise(exercise, participant, false);
Submission submission;
if (exercise instanceof ProgrammingExercise) {
submission = new ProgrammingSubmission();
} else if (exercise instanceof ModelingExercise) {
submission = new ModelingSubmission();
} else if (exercise instanceof TextExercise) {
submission = new TextSubmission();
} else if (exercise instanceof FileUploadExercise) {
submission = new FileUploadSubmission();
} else if (exercise instanceof QuizExercise) {
submission = new QuizSubmission();
} else {
throw new RuntimeException("Unsupported exercise type: " + exercise);
}
submission.setType(SubmissionType.MANUAL);
submission.setParticipation(studentParticipation);
submission = submissionRepository.save(submission);
// result
Result result = ModelFactory.generateResult(rated, scoreAwarded);
result.setParticipation(studentParticipation);
result.setCompletionDate(ZonedDateTime.now());
result = resultRepository.save(result);
submission.addResult(result);
result.setSubmission(submission);
submissionRepository.save(submission);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ResultServiceIntegrationTest method createExampleResult.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createExampleResult() throws Exception {
var modelingSubmission = database.addSubmission(modelingExercise, new ModelingSubmission(), "student1");
var exampleSubmission = ModelFactory.generateExampleSubmission(modelingSubmission, modelingExercise, false);
exampleSubmission = database.addExampleSubmission(exampleSubmission);
modelingSubmission.setExampleSubmission(true);
submissionRepository.save(modelingSubmission);
request.postWithResponseBody("/api/exercises/" + modelingExercise.getId() + "/example-submissions/" + modelingSubmission.getId() + "/example-results", exampleSubmission, Result.class, HttpStatus.CREATED);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ResultServiceIntegrationTest method createExampleResult_wrongExerciseId.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createExampleResult_wrongExerciseId() throws Exception {
var modelingSubmission = database.addSubmission(modelingExercise, new ModelingSubmission(), "student1");
var exampleSubmission = ModelFactory.generateExampleSubmission(modelingSubmission, modelingExercise, false);
exampleSubmission = database.addExampleSubmission(exampleSubmission);
modelingSubmission.setExampleSubmission(true);
submissionRepository.save(modelingSubmission);
long randomId = 1874;
request.postWithResponseBody("/api/exercises/" + randomId + "/example-submissions/" + modelingSubmission.getId() + "/example-results", exampleSubmission, Result.class, HttpStatus.BAD_REQUEST);
}
Aggregations