Search in sources :

Example 1 with ModelingSubmission

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

the class ModelingSubmissionResourceIntTest method updateModelingSubmission.

@Test
@Transactional
public void updateModelingSubmission() throws Exception {
    // Initialize the database
    modelingSubmissionRepository.saveAndFlush(modelingSubmission);
    int databaseSizeBeforeUpdate = modelingSubmissionRepository.findAll().size();
    // Update the modelingSubmission
    ModelingSubmission updatedModelingSubmission = modelingSubmissionRepository.findOne(modelingSubmission.getId());
    updatedModelingSubmission.submissionPath(UPDATED_SUBMISSION_PATH);
    restModelingSubmissionMockMvc.perform(put("/api/modeling-submissions").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(updatedModelingSubmission))).andExpect(status().isOk());
    // Validate the ModelingSubmission in the database
    List<ModelingSubmission> modelingSubmissionList = modelingSubmissionRepository.findAll();
    assertThat(modelingSubmissionList).hasSize(databaseSizeBeforeUpdate);
    ModelingSubmission testModelingSubmission = modelingSubmissionList.get(modelingSubmissionList.size() - 1);
    assertThat(testModelingSubmission.getSubmissionPath()).isEqualTo(UPDATED_SUBMISSION_PATH);
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ModelingSubmission

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

the class ModelingSubmissionResource method getModelingSubmission.

/**
 * GET  /modeling-submissions/:id : get the "id" modelingSubmission.
 *
 * @param id the id of the modelingSubmission to retrieve
 * @return the ResponseEntity with status 200 (OK) and with body the modelingSubmission, or with status 404 (Not Found)
 */
@GetMapping("/modeling-submissions/{id}")
@Timed
public ResponseEntity<ModelingSubmission> getModelingSubmission(@PathVariable Long id) {
    log.debug("REST request to get ModelingSubmission : {}", id);
    ModelingSubmission modelingSubmission = modelingSubmissionRepository.findOne(id);
    return ResponseUtil.wrapOrNotFound(Optional.ofNullable(modelingSubmission));
}
Also used : ModelingSubmission(de.tum.in.www1.artemis.domain.ModelingSubmission) Timed(com.codahale.metrics.annotation.Timed)

Example 3 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class AssessmentKnowledgeIntegrationTest method testSetModelAssessmentKnowledgeToModelElements.

/**
 * Tests that a ModelAssessmentKnowledge is correctly set to model elements
 * based on the ModelAssessmentKnowledge of the respective exercise
 *
 * @throws Exception might be thrown from Network Call to Artemis API
 */
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void testSetModelAssessmentKnowledgeToModelElements() throws Exception {
    ModelingSubmission submission1 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.json"), true);
    submission1.setId(1L);
    ModelingSubmission submission2 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.cpy.json"), true);
    submission2.setId(2L);
    ModelingSubmission submission3 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.cpy.json"), true);
    submission3.setId(3L);
    ModelingSubmission submission4 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.54727.cpy.json"), true);
    submission4.setId(4L);
    Course course = database.addEmptyCourse();
    ModelingExercise exercise1 = modelingExerciseUtilService.createModelingExercise(course.getId());
    ModelingExercise exercise2 = modelingExerciseUtilService.createModelingExercise(course.getId());
    modelAssessmentKnowledgeService = new ModelAssessmentKnowledgeService(modelAssesmentKnowledgeRepository, modelingExerciseRepository);
    exercise1.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
    exercise2.setKnowledge(modelAssessmentKnowledgeService.createNewKnowledge());
    ModelClusterFactory modelClusterFactory = new ModelClusterFactory();
    List<ModelCluster> modelClusters1 = modelClusterFactory.buildClusters(List.of(submission1, submission2), exercise1);
    List<ModelCluster> modelClusters2 = modelClusterFactory.buildClusters(List.of(submission3, submission4), exercise2);
    ModelCluster modelCluster = modelClusters1.get(0);
    for (ModelElement element : modelCluster.getModelElements()) {
        assertThat(element.getKnowledge().getId()).isEqualTo(exercise1.getKnowledge().getId());
    }
    modelCluster = modelClusters2.get(0);
    for (ModelElement element : modelCluster.getModelElements()) {
        assertThat(element.getKnowledge().getId()).isEqualTo(exercise2.getKnowledge().getId());
    }
    assertThat(exercise1.getKnowledge().getId()).isNotEqualTo(exercise2.getKnowledge().getId());
}
Also used : ModelClusterFactory(de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory) ModelElement(de.tum.in.www1.artemis.domain.modeling.ModelElement) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) ModelAssessmentKnowledgeService(de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService) ModelCluster(de.tum.in.www1.artemis.domain.modeling.ModelCluster) Course(de.tum.in.www1.artemis.domain.Course) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.jupiter.api.Test)

Example 4 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ParticipationTeamWebsocketService method updateSubmission.

/**
 * Updates a modeling or text submission
 *
 * @param participationId id of participation
 * @param submission      updated modeling text submission
 * @param principal       principal of user who wants to update the submission
 * @param topicPath       path of websocket destination topic where to send the new submission
 */
private void updateSubmission(@DestinationVariable Long participationId, @Payload Submission submission, Principal principal, String topicPath) {
    // Without this, custom jpa repository methods don't work in websocket channel.
    SecurityUtils.setAuthorizationObject();
    final StudentParticipation participation = studentParticipationRepository.findByIdElseThrow(participationId);
    // user must belong to the team who owns the participation in order to update a submission
    if (!participation.isOwnedBy(principal.getName())) {
        return;
    }
    final User user = userRepository.getUserWithGroupsAndAuthorities(principal.getName());
    final Exercise exercise = exerciseRepository.findByIdElseThrow(participation.getExercise().getId());
    if (submission instanceof ModelingSubmission && exercise instanceof ModelingExercise) {
        submission = modelingSubmissionService.save((ModelingSubmission) submission, (ModelingExercise) exercise, principal.getName());
        modelingSubmissionService.hideDetails(submission, user);
    } else if (submission instanceof TextSubmission && exercise instanceof TextExercise) {
        submission = textSubmissionService.handleTextSubmission((TextSubmission) submission, (TextExercise) exercise, principal);
        textSubmissionService.hideDetails(submission, user);
    } else {
        throw new IllegalArgumentException("Submission type '" + submission.getType() + "' not allowed.");
    }
    // update the last action date for the user and send out list of team members
    updateValue(lastActionTracker, participationId, principal.getName());
    sendOnlineTeamStudents(participationId);
    SubmissionSyncPayload payload = new SubmissionSyncPayload(submission, user);
    messagingTemplate.convertAndSend(getDestination(participationId, topicPath), payload);
}
Also used : ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) SubmissionSyncPayload(de.tum.in.www1.artemis.web.websocket.dto.SubmissionSyncPayload) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) StudentParticipation(de.tum.in.www1.artemis.domain.participation.StudentParticipation)

Example 5 with ModelingSubmission

use of de.tum.in.www1.artemis.domain.modeling.ModelingSubmission in project Artemis by ls1intum.

the class ProgrammingSubmissionIntegrationTest method triggerFailedBuildSubmissionNotFound.

@Test
@WithMockUser(username = "student1", roles = "USER")
void triggerFailedBuildSubmissionNotFound() throws Exception {
    String login = "student1";
    Course course = database.addCourseWithDifferentModelingExercises();
    ModelingExercise classExercise = database.findModelingExerciseWithTitle(course.getExercises(), "ClassDiagram");
    ModelingSubmission modelingSubmission = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/empty-class-diagram.json"), true);
    modelingSubmission = database.addModelingSubmission(classExercise, modelingSubmission, login);
    String url = "/api/programming-submissions/" + modelingSubmission.getParticipation().getId() + "/trigger-failed-build";
    request.postWithoutLocation(url, null, HttpStatus.NOT_FOUND, new HttpHeaders());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ModelingSubmission(de.tum.in.www1.artemis.domain.modeling.ModelingSubmission) ModelingExercise(de.tum.in.www1.artemis.domain.modeling.ModelingExercise) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AbstractSpringIntegrationBambooBitbucketJiraTest(de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)156 Test (org.junit.jupiter.api.Test)108 WithMockUser (org.springframework.security.test.context.support.WithMockUser)106 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)36 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 AbstractSpringIntegrationBambooBitbucketJiraTest (de.tum.in.www1.artemis.AbstractSpringIntegrationBambooBitbucketJiraTest)16 ModelingPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.modeling.ModelingPlagiarismResult)16 TextPlagiarismResult (de.tum.in.www1.artemis.domain.plagiarism.text.TextPlagiarismResult)12 JsonParser.parseString (com.google.gson.JsonParser.parseString)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)8 ModelingSubmission (de.tum.in.www1.artemis.domain.ModelingSubmission)6 Result (de.tum.in.www1.artemis.domain.Result)6 ModelElement (de.tum.in.www1.artemis.domain.modeling.ModelElement)6 ModelClusterFactory (de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory)6 StudentExam (de.tum.in.www1.artemis.domain.exam.StudentExam)4 ExerciseHint (de.tum.in.www1.artemis.domain.hestia.ExerciseHint)4 Participation (de.tum.in.www1.artemis.domain.participation.Participation)4 PlagiarismComparison (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismComparison)4 PlagiarismSubmission (de.tum.in.www1.artemis.domain.plagiarism.PlagiarismSubmission)4