use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ComplaintResource method filterOutUselessDataFromComplaint.
private void filterOutUselessDataFromComplaint(Complaint complaint) {
if (complaint.getResult() == null) {
return;
}
StudentParticipation originalParticipation = (StudentParticipation) complaint.getResult().getParticipation();
if (originalParticipation != null && originalParticipation.getExercise() != null) {
Exercise exerciseWithOnlyTitle = originalParticipation.getExercise();
if (exerciseWithOnlyTitle instanceof TextExercise) {
exerciseWithOnlyTitle = new TextExercise();
} else if (exerciseWithOnlyTitle instanceof ModelingExercise) {
exerciseWithOnlyTitle = new ModelingExercise();
} else if (exerciseWithOnlyTitle instanceof FileUploadExercise) {
exerciseWithOnlyTitle = new FileUploadExercise();
} else if (exerciseWithOnlyTitle instanceof ProgrammingExercise) {
exerciseWithOnlyTitle = new ProgrammingExercise();
}
exerciseWithOnlyTitle.setTitle(originalParticipation.getExercise().getTitle());
exerciseWithOnlyTitle.setId(originalParticipation.getExercise().getId());
originalParticipation.setExercise(exerciseWithOnlyTitle);
}
Submission originalSubmission = complaint.getResult().getSubmission();
if (originalSubmission != null) {
Submission submissionWithOnlyId;
if (originalSubmission instanceof TextSubmission) {
submissionWithOnlyId = new TextSubmission();
} else if (originalSubmission instanceof ModelingSubmission) {
submissionWithOnlyId = new ModelingSubmission();
} else if (originalSubmission instanceof FileUploadSubmission) {
submissionWithOnlyId = new FileUploadSubmission();
} else if (originalSubmission instanceof ProgrammingSubmission) {
submissionWithOnlyId = new ProgrammingSubmission();
} else {
return;
}
submissionWithOnlyId.setId(originalSubmission.getId());
complaint.getResult().setSubmission(submissionWithOnlyId);
}
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method getAllSubmissionsOfExercise.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void getAllSubmissionsOfExercise() throws Exception {
ModelingSubmission submission1 = database.addModelingSubmission(classExercise, submittedSubmission, "student1");
ModelingSubmission submission2 = database.addModelingSubmission(classExercise, unsubmittedSubmission, "student2");
List<ModelingSubmission> submissions = request.getList("/api/exercises/" + classExercise.getId() + "/modeling-submissions", HttpStatus.OK, ModelingSubmission.class);
assertThat(submissions).as("contains both submissions").containsExactlyInAnyOrder(submission1, submission2);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method saveExercise_afterDueDateWithParticipationStartAfterDueDate.
@Test
@WithMockUser(username = "student3", roles = "USER")
public void saveExercise_afterDueDateWithParticipationStartAfterDueDate() throws Exception {
database.updateExerciseDueDate(classExercise.getId(), ZonedDateTime.now().minusHours(1));
afterDueDateParticipation.setInitializationDate(ZonedDateTime.now());
studentParticipationRepository.saveAndFlush(afterDueDateParticipation);
ModelingSubmission storedSubmission = request.postWithResponseBody("/api/exercises/" + classExercise.getId() + "/modeling-submissions", unsubmittedSubmission, ModelingSubmission.class, HttpStatus.OK);
assertThat(storedSubmission.isSubmitted()).isFalse();
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method saveAndSubmitModelingSubmission_objectDiagram.
@Test
@WithMockUser(username = "student1")
public void saveAndSubmitModelingSubmission_objectDiagram() throws Exception {
database.createAndSaveParticipationForExercise(objectExercise, "student1");
String emptyObjectModel = FileUtils.loadFileFromResources("test-data/model-submission/empty-object-diagram.json");
ModelingSubmission submission = ModelFactory.generateModelingSubmission(emptyObjectModel, false);
ModelingSubmission returnedSubmission = performInitialModelSubmission(objectExercise.getId(), submission);
database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), emptyObjectModel);
checkDetailsHidden(returnedSubmission, true);
String validObjectModel = FileUtils.loadFileFromResources("test-data/model-submission/object-model.json");
returnedSubmission.setModel(validObjectModel);
returnedSubmission.setSubmitted(true);
returnedSubmission = performUpdateOnModelSubmission(objectExercise.getId(), returnedSubmission);
database.checkModelingSubmissionCorrectlyStored(returnedSubmission.getId(), validObjectModel);
checkDetailsHidden(returnedSubmission, true);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.
the class ModelingSubmissionIntegrationTest method createNineLockedSubmissionsForDifferentExercisesAndUsers.
private void createNineLockedSubmissionsForDifferentExercisesAndUsers(String assessor) {
ModelingSubmission submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student1", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student2", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(classExercise, submission, "student3", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(activityExercise, submission, "student1", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(activityExercise, submission, "student2", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(activityExercise, submission, "student3", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(objectExercise, submission, "student1", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(objectExercise, submission, "student2", assessor);
submission = ModelFactory.generateModelingSubmission(validModel, true);
database.addModelingSubmissionWithResultAndAssessor(objectExercise, submission, "student3", assessor);
}
Aggregations