use of de.tum.in.www1.artemis.domain.TextExercise in project ArTEMiS by ls1intum.
the class PlagiarismIntegrationTest method updatePlagiarismComparisonFinalStatusForStudentA.
/**
* Checks the method updatePlagiarismComparisonFinalStatus as instructor
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void updatePlagiarismComparisonFinalStatusForStudentA() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
plagiarismComparison.setInstructorStatementA(INSTRUCTOR_STATEMENT_A);
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison.setStatusA(PlagiarismStatus.NONE);
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparisonRepository.save(plagiarismComparison);
var plagiarismComparisonStatus = new PlagiarismComparisonStatusDTO();
plagiarismComparisonStatus.setStatus(PlagiarismStatus.CONFIRMED);
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/final-status/student1", plagiarismComparisonStatus, HttpStatus.OK);
var updatedPlagiarismComparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
assertThat(updatedPlagiarismComparison.getStatusA()).as("should update status for studentA").isEqualTo(PlagiarismStatus.CONFIRMED);
}
use of de.tum.in.www1.artemis.domain.TextExercise in project ArTEMiS by ls1intum.
the class PlagiarismIntegrationTest method saveStudentStatementForStudentA.
/**
* Checks the method updatePlagiarismComparisonStudentStatement for student A
*/
@Test
@WithMockUser(username = "student1", roles = "USER")
public void saveStudentStatementForStudentA() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
plagiarismComparison.setInstructorStatementA(INSTRUCTOR_STATEMENT_A);
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparisonRepository.save(plagiarismComparison);
var statement = new PlagiarismResource.PlagiarismStatementDTO();
statement.statement = "test statement";
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/student-statement", statement, HttpStatus.OK);
var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
assertThat(comparison.getStudentStatementA()).as("should update student statement").isEqualTo("test statement");
}
use of de.tum.in.www1.artemis.domain.TextExercise in project ArTEMiS by ls1intum.
the class PlagiarismIntegrationTest method saveInstructorStatementForStudentA.
/**
* Checks the method updatePlagiarismComparisonInstructorStatement for student A
*/
@Test
@WithMockUser(username = "instructor1", roles = "INSTRUCTOR")
public void saveInstructorStatementForStudentA() throws Exception {
Course course = database.addCourseWithOneFinishedTextExercise();
TextExercise textExercise = textExerciseRepository.findByCourseIdWithCategories(course.getId()).get(0);
TextPlagiarismResult textPlagiarismResult = database.createTextPlagiarismResultForExercise(textExercise);
PlagiarismComparison<TextSubmissionElement> plagiarismComparison = new PlagiarismComparison<>();
plagiarismComparison.setPlagiarismResult(textPlagiarismResult);
PlagiarismSubmission<TextSubmissionElement> submissionA = new PlagiarismSubmission<>();
submissionA.setStudentLogin("student1");
plagiarismComparison.setSubmissionA(submissionA);
plagiarismComparisonRepository.save(plagiarismComparison);
var statement = new PlagiarismResource.PlagiarismStatementDTO();
statement.statement = "test statement";
request.put("/api/courses/" + course.getId() + "/plagiarism-comparisons/" + plagiarismComparison.getId() + "/instructor-statement/student1", statement, HttpStatus.OK);
var comparison = plagiarismComparisonRepository.findByIdWithSubmissionsStudentsElseThrow(plagiarismComparison.getId());
assertThat(comparison.getInstructorStatementA()).as("should update instructor statement").isEqualTo("test statement");
}
use of de.tum.in.www1.artemis.domain.TextExercise in project ArTEMiS by ls1intum.
the class ModelingExerciseImportService method copyModelingExerciseBasis.
/**
* This helper method copies all attributes of the {@code importedExercise} into the new exercise.
* Here we ignore all external entities as well as the start-, end-, and assessment due date.
*
* @param importedExercise The exercise from which to copy the basis
* @return the cloned TextExercise basis
*/
@NotNull
private ModelingExercise copyModelingExerciseBasis(Exercise importedExercise) {
log.debug("Copying the exercise basis from {}", importedExercise);
ModelingExercise newExercise = new ModelingExercise();
super.copyExerciseBasis(newExercise, importedExercise);
newExercise.setDiagramType(((ModelingExercise) importedExercise).getDiagramType());
newExercise.setExampleSolutionModel(((ModelingExercise) importedExercise).getExampleSolutionModel());
newExercise.setExampleSolutionExplanation(((ModelingExercise) importedExercise).getExampleSolutionExplanation());
return newExercise;
}
use of de.tum.in.www1.artemis.domain.TextExercise in project ArTEMiS by ls1intum.
the class DatabaseUtilService method generateTestRunForInstructor.
public StudentExam generateTestRunForInstructor(Exam exam, User instructor, List<Exercise> exercises) {
var testRun = ModelFactory.generateExamTestRun(exam);
testRun.setUser(instructor);
examRepository.findWithExerciseGroupsAndExercisesById(exam.getId()).get();
for (final var exercise : exercises) {
testRun.addExercise(exercise);
assertThat(exercise.isExamExercise()).isTrue();
Submission submission;
if (exercise instanceof ModelingExercise) {
submission = addModelingSubmission((ModelingExercise) exercise, ModelFactory.generateModelingSubmission("", false), instructor.getLogin());
} else if (exercise instanceof TextExercise) {
submission = saveTextSubmission((TextExercise) exercise, ModelFactory.generateTextSubmission("", null, false), instructor.getLogin());
} else {
submission = new ProgrammingSubmission().submitted(true);
addProgrammingSubmission((ProgrammingExercise) exercise, (ProgrammingSubmission) submission, instructor.getLogin());
submission = submissionRepository.save(submission);
}
var studentParticipation = (StudentParticipation) submission.getParticipation();
studentParticipation.setTestRun(true);
studentParticipationRepo.save(studentParticipation);
}
return testRun;
}
Aggregations