use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method importModelingExerciseFromExamToCourse.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void importModelingExerciseFromExamToCourse() throws Exception {
ExerciseGroup exerciseGroup1 = database.addExerciseGroupWithExamAndCourse(true);
ModelingExercise modelingExercise = ModelFactory.generateModelingExerciseForExam(DiagramType.ClassDiagram, exerciseGroup1);
Course course1 = database.addEmptyCourse();
modelingExerciseRepository.save(modelingExercise);
modelingExercise.setCourse(course1);
modelingExercise.setExerciseGroup(null);
request.postWithResponseBody("/api/modeling-exercises/import/" + modelingExercise.getId(), modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method createModelingExercise_setValidExampleSolutionPublicationDate.
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void createModelingExercise_setValidExampleSolutionPublicationDate() throws Exception {
final var baseTime = ZonedDateTime.now();
final Course course = database.addCourseWithOneModelingExercise();
ModelingExercise modelingExercise = modelingExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
modelingExercise.setId(null);
modelingExercise.setAssessmentDueDate(null);
modelingExercise.setIncludedInOverallScore(IncludedInOverallScore.INCLUDED_COMPLETELY);
modelingExercise.setReleaseDate(baseTime.plusHours(1));
modelingExercise.setDueDate(baseTime.plusHours(2));
var exampleSolutionPublicationDate = baseTime.plusHours(3);
modelingExercise.setExampleSolutionPublicationDate(exampleSolutionPublicationDate);
var result = request.postWithResponseBody("/api/modeling-exercises/", modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
assertThat(result.getExampleSolutionPublicationDate()).isEqualTo(exampleSolutionPublicationDate);
modelingExercise.setIncludedInOverallScore(IncludedInOverallScore.NOT_INCLUDED);
modelingExercise.setReleaseDate(baseTime.plusHours(1));
modelingExercise.setDueDate(baseTime.plusHours(3));
exampleSolutionPublicationDate = baseTime.plusHours(2);
modelingExercise.setExampleSolutionPublicationDate(exampleSolutionPublicationDate);
result = request.postWithResponseBody("/api/modeling-exercises/", modelingExercise, ModelingExercise.class, HttpStatus.CREATED);
assertThat(result.getExampleSolutionPublicationDate()).isEqualTo(exampleSolutionPublicationDate);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseIntegrationTest method testCreateModelingExercise_instructorNotInCourse.
@Test
@WithMockUser(username = "instructor2", roles = "INSTRUCTOR")
public void testCreateModelingExercise_instructorNotInCourse() throws Exception {
ModelingExercise modelingExercise = modelingExerciseUtilService.createModelingExercise(classExercise.getCourseViaExerciseGroupOrCourseMember().getId());
request.post("/api/modeling-exercises", modelingExercise, HttpStatus.FORBIDDEN);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class SubmissionExportIntegrationTest method initTestCase.
@BeforeEach
public void initTestCase() {
List<User> users = database.addUsers(3, 1, 0, 1);
users.remove(database.getUserByLogin("admin"));
Course course1 = database.addCourseWithModelingAndTextAndFileUploadExercise();
course1.getExercises().forEach(exercise -> {
database.createAndSaveParticipationForExercise(exercise, "student1");
database.createAndSaveParticipationForExercise(exercise, "student2");
database.createAndSaveParticipationForExercise(exercise, "student3");
if (exercise instanceof ModelingExercise) {
modelingExercise = (ModelingExercise) exercise;
try {
modelingSubmission1 = database.addModelingSubmissionFromResources(modelingExercise, "test-data/model-submission/model.54727.json", "student1");
modelingSubmission2 = database.addModelingSubmissionFromResources(modelingExercise, "test-data/model-submission/model.54742.json", "student2");
modelingSubmission3 = database.addModelingSubmissionFromResources(modelingExercise, "test-data/model-submission/model.54745.json", "student3");
} catch (Exception e) {
e.printStackTrace();
}
} else if (exercise instanceof TextExercise) {
textExercise = (TextExercise) exercise;
textSubmission1 = database.saveTextSubmission(textExercise, ModelFactory.generateTextSubmission("example text", Language.ENGLISH, true), "student1");
textSubmission2 = database.saveTextSubmission(textExercise, ModelFactory.generateTextSubmission("some other text", Language.ENGLISH, true), "student2");
textSubmission3 = database.saveTextSubmission(textExercise, ModelFactory.generateTextSubmission("a third text", Language.ENGLISH, true), "student3");
} else if (exercise instanceof FileUploadExercise) {
fileUploadExercise = (FileUploadExercise) exercise;
fileUploadSubmission1 = database.addFileUploadSubmission(fileUploadExercise, ModelFactory.generateFileUploadSubmissionWithFile(true, "test1.pdf"), "student1");
fileUploadSubmission2 = database.addFileUploadSubmission(fileUploadExercise, ModelFactory.generateFileUploadSubmissionWithFile(true, "test2.pdf"), "student2");
fileUploadSubmission3 = database.addFileUploadSubmission(fileUploadExercise, ModelFactory.generateFileUploadSubmissionWithFile(true, "test3.pdf"), "student3");
try {
saveEmptySubmissionFile(fileUploadExercise, fileUploadSubmission1);
saveEmptySubmissionFile(fileUploadExercise, fileUploadSubmission2);
saveEmptySubmissionFile(fileUploadExercise, fileUploadSubmission3);
} catch (IOException e) {
fail("Could not create submission files", e);
}
}
});
baseExportOptions = new SubmissionExportOptionsDTO();
baseExportOptions.setExportAllParticipants(true);
baseExportOptions.setFilterLateSubmissions(false);
}
use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.
the class TeamIntegrationTest method getCourseWithExercisesAndParticipationsForTeam_AsTutor.
@Test
@WithMockUser(username = "tutor1", roles = "TA")
public void getCourseWithExercisesAndParticipationsForTeam_AsTutor() throws Exception {
List<Course> courses = database.createCoursesWithExercisesAndLectures(false);
Course course = courses.get(0);
ProgrammingExercise programmingExercise = (ProgrammingExercise) course.getExercises().stream().filter(exercise -> exercise instanceof ProgrammingExercise).findAny().orElseThrow();
TextExercise textExercise = (TextExercise) course.getExercises().stream().filter(exercise -> exercise instanceof TextExercise).findAny().orElseThrow();
ModelingExercise modelingExercise = (ModelingExercise) course.getExercises().stream().filter(exercise -> exercise instanceof ModelingExercise).findAny().orElseThrow();
// make exercises team-based
Stream.of(programmingExercise, textExercise, modelingExercise).forEach(exercise -> {
exercise.setMode(ExerciseMode.TEAM);
exerciseRepo.save(exercise);
});
String shortNamePrefix1 = "team";
String shortNamePrefix2 = "otherTeam";
Team team1a = database.addTeamsForExercise(programmingExercise, shortNamePrefix1, "team1astudent", 1, tutor).get(0);
Team team1b = database.addTeamsForExercise(textExercise, shortNamePrefix1, "team1bstudent", 1, tutor).get(0);
Team team1c = database.addTeamsForExercise(modelingExercise, shortNamePrefix1, "team1cstudent", 1, tutor).get(0);
Team team2a = database.addTeamsForExercise(programmingExercise, shortNamePrefix2, "team2astudent", 1, null).get(0);
Team team2b = database.addTeamsForExercise(textExercise, shortNamePrefix2, "team2bstudent", 1, null).get(0);
assertThat(Stream.of(team1a, team1b, team1c).map(Team::getShortName).distinct()).as("Teams 1 need the same short name for this test").hasSize(1);
assertThat(Stream.of(team2a, team2b).map(Team::getShortName).distinct()).as("Teams 2 need the same short name for this test").hasSize(1);
assertThat(Stream.of(team1a, team1b, team1c, team2a, team2b).map(Team::getShortName).distinct()).as("Teams 1 and Teams 2 need different short names").hasSize(2);
database.addTeamParticipationForExercise(programmingExercise, team1a.getId());
database.addTeamParticipationForExercise(textExercise, team1b.getId());
database.addTeamParticipationForExercise(programmingExercise, team2a.getId());
database.addTeamParticipationForExercise(textExercise, team2b.getId());
Course course1 = request.get(resourceUrlCourseWithExercisesAndParticipationsForTeam(course, team1a), HttpStatus.OK, Course.class);
assertThat(course1.getExercises()).as("All exercises of team 1 in course were returned").hasSize(3);
assertThat(course1.getExercises().stream().map(Exercise::getTeams).collect(Collectors.toSet())).as("All team instances of team 1 in course were returned").hasSize(3);
assertThat(course1.getExercises().stream().flatMap(exercise -> exercise.getStudentParticipations().stream()).collect(Collectors.toSet())).as("All participations of team 1 in course were returned").hasSize(2);
Course course2 = request.get(resourceUrlCourseWithExercisesAndParticipationsForTeam(course, team2a), HttpStatus.OK, Course.class);
assertThat(course2.getExercises()).as("All exercises of team 2 in course were returned").hasSize(2);
StudentParticipation studentParticipation = course2.getExercises().iterator().next().getStudentParticipations().iterator().next();
assertThat(studentParticipation.getSubmissionCount()).as("Participation includes submission count").isNotNull();
// Submission and Result should be present for Team of which the user is the Team Owner
final String submissionText = "Hello World";
TextSubmission submission = ModelFactory.generateTextSubmission(submissionText, Language.ENGLISH, true);
database.saveTextSubmissionWithResultAndAssessor(textExercise, submission, team1b.getId(), tutor.getLogin());
Course course3 = request.get(resourceUrlCourseWithExercisesAndParticipationsForTeam(course, team1a), HttpStatus.OK, Course.class);
StudentParticipation participation = course3.getExercises().stream().filter(exercise -> exercise.equals(textExercise)).findAny().orElseThrow().getStudentParticipations().iterator().next();
assertThat(participation.getSubmissions()).as("Latest submission is present").hasSize(1);
assertThat(((TextSubmission) participation.getSubmissions().iterator().next()).getText()).as("Latest submission is present").isEqualTo(submissionText);
assertThat(participation.getResults()).as("Latest result is present").hasSize(1);
// Submission and Result should not be present for a Team of which the user is not (!) the Team Owner
submission = ModelFactory.generateTextSubmission(submissionText, Language.ENGLISH, true);
database.saveTextSubmissionWithResultAndAssessor(textExercise, submission, team2b.getId(), "tutor2");
Course course4 = request.get(resourceUrlCourseWithExercisesAndParticipationsForTeam(course, team2a), HttpStatus.OK, Course.class);
participation = course4.getExercises().stream().filter(exercise -> exercise.equals(textExercise)).findAny().orElseThrow().getStudentParticipations().iterator().next();
assertThat(participation.getSubmissions()).as("Latest submission is not present").isEmpty();
assertThat(participation.getResults()).as("Latest result is not present").isEmpty();
}
Aggregations