Search in sources :

Example 21 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class DatabaseUtilService method addCourseWithModelingAndTextAndFileUploadExercise.

public Course addCourseWithModelingAndTextAndFileUploadExercise() {
    Course course = ModelFactory.generateCourse(null, pastTimestamp, futureFutureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "instructor");
    ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, DiagramType.ClassDiagram, course);
    modelingExercise.setTitle("Modeling");
    course.addExercises(modelingExercise);
    TextExercise textExercise = ModelFactory.generateTextExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, course);
    textExercise.setTitle("Text");
    course.addExercises(textExercise);
    FileUploadExercise fileUploadExercise = ModelFactory.generateFileUploadExercise(pastTimestamp, pastTimestamp, futureFutureTimestamp, "png,pdf", course);
    fileUploadExercise.setTitle("FileUpload");
    course.addExercises(fileUploadExercise);
    course = courseRepo.save(course);
    exerciseRepo.save(modelingExercise);
    exerciseRepo.save(textExercise);
    exerciseRepo.save(fileUploadExercise);
    return course;
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Example 22 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class DatabaseUtilService method addModelingSubmissionWithResultAndAssessor.

public ModelingSubmission addModelingSubmissionWithResultAndAssessor(ModelingExercise exercise, ModelingSubmission submission, String login, String assessorLogin) {
    StudentParticipation participation = createAndSaveParticipationForExercise(exercise, login);
    participation.addSubmission(submission);
    submission = modelingSubmissionRepo.save(submission);
    Result result = new Result();
    result.setAssessor(getUserByLogin(assessorLogin));
    result.setAssessmentType(AssessmentType.MANUAL);
    result = resultRepo.save(result);
    submission = modelingSubmissionRepo.save(submission);
    studentParticipationRepo.save(participation);
    result = resultRepo.save(result);
    result.setSubmission(submission);
    submission.setParticipation(participation);
    submission.addResult(result);
    submission.getParticipation().addResult(result);
    submission = modelingSubmissionRepo.save(submission);
    studentParticipationRepo.save(participation);
    return submission;
}
Also used : TextPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult) ModelingPlagiarismResult(de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)

Example 23 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class DatabaseUtilService method addCourseWithOneModelingExercise.

/**
 * @param title The title of the to be added modeling exercise
 * @return A course with one specified modeling exercise
 */
public Course addCourseWithOneModelingExercise(String title) {
    long currentCourseRepoSize = courseRepo.count();
    long currentExerciseRepoSize = exerciseRepo.count();
    Course course = ModelFactory.generateCourse(null, pastTimestamp, futureFutureTimestamp, new HashSet<>(), "tumuser", "tutor", "editor", "instructor");
    ModelingExercise modelingExercise = ModelFactory.generateModelingExercise(pastTimestamp, futureTimestamp, futureFutureTimestamp, DiagramType.ClassDiagram, course);
    modelingExercise.setTitle(title);
    modelingExercise.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
    course.addExercises(modelingExercise);
    course.setMaxComplaintTimeDays(14);
    course = courseRepo.save(course);
    modelingExercise = exerciseRepo.save(modelingExercise);
    assertThat(exerciseRepo.count()).as("one exercise got stored").isEqualTo(currentExerciseRepoSize + 1L);
    assertThat(courseRepo.count()).as("a course got stored").isEqualTo(currentCourseRepoSize + 1L);
    assertThat(course.getExercises()).as("course contains the exercise").containsExactlyInAnyOrder(modelingExercise);
    assertThat(modelingExercise.getPresentationScoreEnabled()).as("presentation score is enabled").isTrue();
    return course;
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise)

Example 24 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseResourceIntTest method updateModelingExercise.

@Test
@Transactional
public void updateModelingExercise() throws Exception {
    // Initialize the database
    modelingExerciseRepository.saveAndFlush(modelingExercise);
    int databaseSizeBeforeUpdate = modelingExerciseRepository.findAll().size();
    // Update the modelingExercise
    ModelingExercise updatedModelingExercise = modelingExerciseRepository.findOne(modelingExercise.getId());
    updatedModelingExercise.baseFilePath(UPDATED_BASE_FILE_PATH);
    restModelingExerciseMockMvc.perform(put("/api/modeling-exercises").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedModelingExercise))).andExpect(status().isOk());
    // Validate the ModelingExercise in the database
    List<ModelingExercise> modelingExerciseList = modelingExerciseRepository.findAll();
    assertThat(modelingExerciseList).hasSize(databaseSizeBeforeUpdate);
    ModelingExercise testModelingExercise = modelingExerciseList.get(modelingExerciseList.size() - 1);
    assertThat(testModelingExercise.getBaseFilePath()).isEqualTo(UPDATED_BASE_FILE_PATH);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with ModelingExercise

use of de.tum.in.www1.artemis.domain.modeling.ModelingExercise in project ArTEMiS by ls1intum.

the class ModelingExerciseResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(ModelingExercise.class);
    ModelingExercise modelingExercise1 = new ModelingExercise();
    modelingExercise1.setId(1L);
    ModelingExercise modelingExercise2 = new ModelingExercise();
    modelingExercise2.setId(modelingExercise1.getId());
    assertThat(modelingExercise1).isEqualTo(modelingExercise2);
    modelingExercise2.setId(2L);
    assertThat(modelingExercise1).isNotEqualTo(modelingExercise2);
    modelingExercise1.setId(null);
    assertThat(modelingExercise1).isNotEqualTo(modelingExercise2);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.ModelingExercise) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)196 WithMockUser (org.springframework.security.test.context.support.WithMockUser)132 Test (org.junit.jupiter.api.Test)126 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)96 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)72 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)28 ExerciseGroup (de.tum.in.www1.artemis.domain.exam.ExerciseGroup)26 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)16 BeforeEach (org.junit.jupiter.api.BeforeEach)16 Course (de.tum.in.www1.artemis.domain.Course)14 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)14 ZonedDateTime (java.time.ZonedDateTime)12 Exam (de.tum.in.www1.artemis.domain.exam.Exam)10 QuizExercise (de.tum.in.www1.artemis.domain.quiz.QuizExercise)10 TeamAssignmentPayload (de.tum.in.www1.artemis.web.websocket.dto.TeamAssignmentPayload)9 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8