use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class ComplaintResponseIntegrationTest method initTestCase.
@BeforeEach
public void initTestCase() throws Exception {
// creating the users student1-student5, tutor1-tutor10 and instructors1-instructor10
this.database.addUsers(5, 10, 0, 10);
// Add users that are not in the course
userRepository.save(ModelFactory.generateActivatedUser("student42"));
userRepository.save(ModelFactory.generateActivatedUser("tutor42"));
userRepository.save(ModelFactory.generateActivatedUser("instructor42"));
userRepository.flush();
// creating course
// students: student1-student 5 | tutors: tutor1-tutor10 | instructors: instructor1 - instructor10
Course course = this.database.createCourse();
// creating text exercise
TextExercise textExercise = ModelFactory.generateTextExercise(null, null, null, course);
textExercise.setMaxPoints(10.0);
textExercise.setBonusPoints(0.0);
textExercise = exerciseRepository.saveAndFlush(textExercise);
// creating participation of student1 by starting the exercise
User student1 = userRepository.findOneByLogin("student1").get();
StudentParticipation studentParticipation = participationService.startExercise(textExercise, student1, false);
// creating submission of student1
TextSubmission submission = new TextSubmission();
submission.setType(SubmissionType.MANUAL);
submission.setParticipation(studentParticipation);
submission.setSubmitted(Boolean.TRUE);
submission.setSubmissionDate(ZonedDateTime.now());
submission.text("hello world");
submission = submissionRepository.saveAndFlush(submission);
// creating assessment by tutor1
User tutor1 = userRepository.findOneByLogin("tutor1").get();
Result result = ModelFactory.generateResult(true, 50D);
result.setAssessor(tutor1);
result.setHasComplaint(true);
result.setHasFeedback(false);
result.setParticipation(studentParticipation);
result = resultRepository.saveAndFlush(result);
submission.addResult(result);
result.setSubmission(submission);
submission = submissionRepository.saveAndFlush(submission);
// creating complaint by student 1
complaint = new Complaint();
complaint.setComplaintType(ComplaintType.COMPLAINT);
complaint.setComplaintText("Unfair");
complaint.setResult(result);
complaint.setAccepted(null);
complaint.setSubmittedTime(null);
complaint.setParticipant(student1);
complaint = complaintRepository.saveAndFlush(complaint);
}
use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class ContinuousIntegrationTestService method setup.
/**
* This method initializes the test case by setting up a local repo
*/
public void setup(MockDelegate mockDelegate, ContinuousIntegrationService continuousIntegrationService) throws Exception {
this.mockDelegate = mockDelegate;
this.continuousIntegrationService = continuousIntegrationService;
database.addUsers(2, 0, 0, 0);
database.addCourseWithOneProgrammingExercise();
programmingExercise = programmingExerciseRepository.findAll().get(0);
// init local repo
String currentLocalFileName = "currentFileName";
String currentLocalFileContent = "testContent";
String currentLocalFolderName = "currentFolderName";
localRepo.configureRepos("testLocalRepo", "testOriginRepo");
// add file to the repository folder
Path filePath = Path.of(localRepo.localRepoFile + "/" + currentLocalFileName);
var file = Files.createFile(filePath).toFile();
// write content to the created file
FileUtils.write(file, currentLocalFileContent, Charset.defaultCharset());
// add folder to the repository folder
filePath = Path.of(localRepo.localRepoFile + "/" + currentLocalFolderName);
Files.createDirectory(filePath).toFile();
GitUtilService.MockFileRepositoryUrl localRepoUrl = new GitUtilService.MockFileRepositoryUrl(localRepo.localRepoFile);
// create a participation
participation = database.addStudentParticipationForProgrammingExerciseForLocalRepo(programmingExercise, "student1", localRepoUrl.getURI());
assertThat(programmingExercise).as("Exercise was correctly set").isEqualTo(participation.getProgrammingExercise());
// mock return of git path
doReturn(gitService.getExistingCheckedOutRepositoryByLocalPath(localRepo.localRepoFile.toPath(), null)).when(gitService).getOrCheckoutRepository(participation.getVcsRepositoryUrl(), true);
doReturn(gitService.getExistingCheckedOutRepositoryByLocalPath(localRepo.localRepoFile.toPath(), null)).when(gitService).getOrCheckoutRepository(participation.getVcsRepositoryUrl(), false);
}
use of de.tum.in.www1.artemis.domain.participation.Participation 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);
}
use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class ProgrammingExerciseParticipation method isLocked.
/**
* Check if the participation is locked.
* This is the case when the participation is a ProgrammingExerciseStudentParticipation,
* the buildAndTestAfterDueDate of the exercise is set and the due date has passed,
* or if manual correction is involved and the due date has passed.
*
* Locked means that the student can't make any changes to their repository anymore.
* While we can control this easily in the remote VCS, we need to check this manually
* for the local repository on the Artemis server.
*
* @return true if repository is locked, false if not.
*/
@JsonIgnore
default boolean isLocked() {
if (!(this instanceof ProgrammingExerciseStudentParticipation)) {
return false;
}
final ProgrammingExercise programmingExercise = getProgrammingExercise();
final ZonedDateTime now = ZonedDateTime.now();
boolean isAfterDueDate = false;
if (getIndividualDueDate() != null) {
isAfterDueDate = now.isAfter(getIndividualDueDate());
} else if (programmingExercise.getDueDate() != null) {
isAfterDueDate = now.isAfter(programmingExercise.getDueDate());
}
// Editing is allowed if build and test after due date is not set and no manual correction is involved
// (this should match CodeEditorStudentContainerComponent.repositoryIsLocked on the client-side)
boolean isEditingAfterDueAllowed = programmingExercise.getBuildAndTestStudentSubmissionsAfterDueDate() == null && programmingExercise.getAssessmentType() != AssessmentType.MANUAL && programmingExercise.getAssessmentType() != AssessmentType.SEMI_AUTOMATIC && !programmingExercise.areManualResultsAllowed();
return isAfterDueDate && !isEditingAfterDueAllowed;
}
use of de.tum.in.www1.artemis.domain.participation.Participation in project ArTEMiS by ls1intum.
the class TextSubmissionService method save.
/**
* Saves the given submission. Is used for creating and updating text submissions.
*
* @param textSubmission the submission that should be saved
* @param participation the participation the submission belongs to
* @param textExercise the exercise the submission belongs to
* @param principal the principal of the user
* @return the textSubmission entity that was saved to the database
*/
public TextSubmission save(TextSubmission textSubmission, StudentParticipation participation, TextExercise textExercise, Principal principal) {
// update submission properties
textSubmission.setSubmissionDate(ZonedDateTime.now());
textSubmission.setType(SubmissionType.MANUAL);
textSubmission.setParticipation(participation);
// remove result from submission (in the unlikely case it is passed here), so that students cannot inject a result
textSubmission.setResults(new ArrayList<>());
textSubmission = textSubmissionRepository.save(textSubmission);
// versioning of submission
try {
if (textExercise.isTeamMode()) {
submissionVersionService.saveVersionForTeam(textSubmission, principal.getName());
} else if (textExercise.isExamExercise()) {
submissionVersionService.saveVersionForIndividual(textSubmission, principal.getName());
}
} catch (Exception ex) {
log.error("Text submission version could not be saved", ex);
}
participation.addSubmission(textSubmission);
participation.setInitializationState(InitializationState.FINISHED);
StudentParticipation savedParticipation = studentParticipationRepository.save(participation);
if (textSubmission.getId() == null) {
Optional<Submission> optionalTextSubmission = savedParticipation.findLatestSubmission();
if (optionalTextSubmission.isPresent()) {
textSubmission = (TextSubmission) optionalTextSubmission.get();
}
}
return textSubmission;
}
Aggregations