Search in sources :

Example 11 with ModelElement

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

the class FeedbackSelectorTest method testLongestFeedbackTextSelection.

@Test
public void testLongestFeedbackTextSelection() {
    Feedback feedback1 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2123").text("feedback text");
    Feedback feedback2 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2124").text("short");
    Feedback feedback3 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2125").text("very long feedback text");
    Result result = new Result();
    ModelElement modelElement = new ModelElement();
    modelElement.setModelElementType("Class");
    modelElement.setModelElementId("6aba5764-d102-4740-9675-b2bd0a4f2127");
    Feedback selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2), result);
    assertThat(selectedFeedback).as("feedback was selected").isNotNull();
    assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
    assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("feedback text");
    selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2, feedback3), result);
    assertThat(selectedFeedback).as("feedback was selected").isNotNull();
    assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
    assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("very long feedback text");
}
Also used : ModelElement(de.tum.in.www1.artemis.domain.modeling.ModelElement) Feedback(de.tum.in.www1.artemis.domain.Feedback) Result(de.tum.in.www1.artemis.domain.Result) Test(org.junit.jupiter.api.Test)

Example 12 with ModelElement

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

the class ModelingSubmissionService method setNumberOfAffectedSubmissionsPerElement.

/**
 * Sets number of potential automatic Feedback's for each model element belonging to the `Result`'s submission.
 * This number determines how many other submissions would be affected if the user were to submit a certain element feedback.
 * For each ModelElement of the submission, this method finds how many other ModelElements exist in the same cluster.
 * This number is represented with the `numberOfAffectedSubmissions` field which is set here for each
 * ModelElement of this submission
 *
 * @param submission Result for the Submission acting as a reference for the modeling submission to be searched.
 */
public void setNumberOfAffectedSubmissionsPerElement(@NotNull ModelingSubmission submission) {
    List<ModelElementRepository.ModelElementCount> elementCounts = modelElementRepository.countOtherElementsInSameClusterForSubmissionId(submission.getId());
    submission.setSimilarElements(elementCounts.stream().map(modelElementCount -> {
        SimilarElementCount similarElementCount = new SimilarElementCount();
        similarElementCount.setElementId(modelElementCount.getElementId());
        similarElementCount.setNumberOfOtherElements(modelElementCount.getNumberOfOtherElements());
        return similarElementCount;
    }).collect(Collectors.toSet()));
}
Also used : SimilarElementCount(de.tum.in.www1.artemis.domain.modeling.SimilarElementCount)

Example 13 with ModelElement

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

the class FeedbackSelectorTest method testLongestFeedbackTextSelection.

@Test
public void testLongestFeedbackTextSelection() {
    Feedback feedback1 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2123").text("feedback text");
    Feedback feedback2 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2124").text("short");
    Feedback feedback3 = new Feedback().credits(1.0).reference("Class:6aba5764-d102-4740-9675-b2bd0a4f2125").text("very long feedback text");
    Result result = new Result();
    ModelElement modelElement = new ModelElement();
    modelElement.setModelElementType("Class");
    modelElement.setModelElementId("6aba5764-d102-4740-9675-b2bd0a4f2127");
    Feedback selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2), result);
    assertThat(selectedFeedback).as("feedback was selected").isNotNull();
    assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
    assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("feedback text");
    selectedFeedback = FeedbackSelector.selectFeedback(modelElement, List.of(feedback1, feedback2, feedback3), result);
    assertThat(selectedFeedback).as("feedback was selected").isNotNull();
    assertThat(selectedFeedback.getReference()).as("feedback is assigned to the element").isEqualTo("Class:6aba5764-d102-4740-9675-b2bd0a4f2127");
    assertThat(selectedFeedback.getText()).as("feedback text of element is correct").isEqualTo("very long feedback text");
}
Also used : ModelElement(de.tum.in.www1.artemis.domain.modeling.ModelElement) Feedback(de.tum.in.www1.artemis.domain.Feedback) Result(de.tum.in.www1.artemis.domain.Result) Test(org.junit.jupiter.api.Test)

Example 14 with ModelElement

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

the class ModelClusterFactoryTest method testBuildingClustersWithSimilarElements.

@Test
public void testBuildingClustersWithSimilarElements() 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);
    ModelingSubmission submission5 = ModelFactory.generateModelingSubmission(FileUtils.loadFileFromResources("test-data/model-submission/model.one-element.json"), true);
    submission5.setId(5L);
    ModelingExercise exercise = new ModelingExercise();
    List<ModelCluster> modelClusters = modelClusterFactory.buildClusters(List.of(submission1, submission2, submission3, submission4, submission5), exercise);
    assertThat(modelClusters).as("model clusters created").hasSize(10);
    ModelCluster modelCluster = modelClusters.get(0);
    assertThat(modelCluster.getModelElements()).as("all elements are created").hasSize(4);
    for (ModelElement element : modelCluster.getModelElements()) {
        assertThat(element.getCluster()).as("created elements keeps the cluster").isEqualTo(modelCluster);
    }
}
Also used : 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) ModelCluster(de.tum.in.www1.artemis.domain.modeling.ModelCluster) Test(org.junit.jupiter.api.Test)

Aggregations

ModelElement (de.tum.in.www1.artemis.domain.modeling.ModelElement)12 Feedback (de.tum.in.www1.artemis.domain.Feedback)8 Result (de.tum.in.www1.artemis.domain.Result)8 Test (org.junit.jupiter.api.Test)8 ModelCluster (de.tum.in.www1.artemis.domain.modeling.ModelCluster)6 ModelingExercise (de.tum.in.www1.artemis.domain.modeling.ModelingExercise)6 ModelingSubmission (de.tum.in.www1.artemis.domain.modeling.ModelingSubmission)6 ModelClusterFactory (de.tum.in.www1.artemis.service.compass.controller.ModelClusterFactory)4 java.util (java.util)4 Course (de.tum.in.www1.artemis.domain.Course)2 GradingInstruction (de.tum.in.www1.artemis.domain.GradingInstruction)2 AssessmentType (de.tum.in.www1.artemis.domain.enumeration.AssessmentType)2 FeedbackType (de.tum.in.www1.artemis.domain.enumeration.FeedbackType)2 SimilarElementCount (de.tum.in.www1.artemis.domain.modeling.SimilarElementCount)2 StudentParticipation (de.tum.in.www1.artemis.domain.participation.StudentParticipation)2 de.tum.in.www1.artemis.repository (de.tum.in.www1.artemis.repository)2 ModelAssessmentKnowledgeService (de.tum.in.www1.artemis.service.ModelAssessmentKnowledgeService)2 FeedbackSelector (de.tum.in.www1.artemis.service.compass.controller.FeedbackSelector)2 UMLElement (de.tum.in.www1.artemis.service.compass.umlmodel.UMLElement)2 CompassConfiguration (de.tum.in.www1.artemis.service.compass.utils.CompassConfiguration)2