use of de.tum.in.www1.artemis.domain.participation.Participant in project Artemis by ls1intum.
the class LearningGoalService method calculateLearningGoalCourseProgress.
/**
* Calculate the progress in a learning goal for a whole course
*
* @param useParticipantScoreTable use the participant score table instead of going through participation -> submission -> result
* @param learningGoal learning goal to get the progress for
* @return progress of the course in the learning goal
*/
public CourseLearningGoalProgress calculateLearningGoalCourseProgress(LearningGoal learningGoal, boolean useParticipantScoreTable) {
CourseLearningGoalProgress courseLearningGoalProgress = new CourseLearningGoalProgress();
courseLearningGoalProgress.courseId = learningGoal.getCourse().getId();
courseLearningGoalProgress.learningGoalId = learningGoal.getId();
courseLearningGoalProgress.learningGoalTitle = learningGoal.getTitle();
courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = 0.0;
courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal = 0.0;
// The progress will be calculated from a subset of the connected lecture units (currently only from released exerciseUnits)
List<ExerciseUnit> exerciseUnitsUsableForProgressCalculation = learningGoal.getLectureUnits().parallelStream().filter(LectureUnit::isVisibleToStudents).filter(lectureUnit -> lectureUnit instanceof ExerciseUnit).map(lectureUnit -> (ExerciseUnit) lectureUnit).collect(Collectors.toList());
Set<CourseLearningGoalProgress.CourseLectureUnitProgress> progressInLectureUnits = this.calculateExerciseUnitsProgressForCourse(exerciseUnitsUsableForProgressCalculation, useParticipantScoreTable);
// updating learningGoalPerformance by summing up the points of the individual lecture unit progress
courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = progressInLectureUnits.stream().map(lectureUnitProgress -> lectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal = progressInLectureUnits.stream().map(lectureUnitProgress -> (lectureUnitProgress.averageScoreAchievedByStudentInLectureUnit / 100.0) * lectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
courseLearningGoalProgress.progressInLectureUnits = new ArrayList<>(progressInLectureUnits);
return courseLearningGoalProgress;
}
use of de.tum.in.www1.artemis.domain.participation.Participant in project Artemis by ls1intum.
the class DatabaseUtilService method createParticipationSubmissionAndResult.
public Result createParticipationSubmissionAndResult(long exerciseId, Participant participant, Double points, Double bonusPoints, long scoreAwarded, boolean rated) {
Exercise exercise = exerciseRepo.findById(exerciseId).get();
if (!exercise.getMaxPoints().equals(points)) {
exercise.setMaxPoints(points);
}
if (!exercise.getBonusPoints().equals(bonusPoints)) {
exercise.setBonusPoints(bonusPoints);
}
exercise = exerciseRepo.saveAndFlush(exercise);
StudentParticipation studentParticipation = participationService.startExercise(exercise, participant, false);
return createSubmissionAndResult(studentParticipation, scoreAwarded, rated);
}
use of de.tum.in.www1.artemis.domain.participation.Participant in project Artemis by ls1intum.
the class DatabaseUtilService method addComplaints.
public void addComplaints(String studentLogin, Participation participation, int numberOfComplaints, ComplaintType complaintType) {
for (int i = 0; i < numberOfComplaints; i++) {
Result dummyResult = new Result().participation(participation);
dummyResult = resultRepo.save(dummyResult);
Complaint complaint = new Complaint().participant(getUserByLogin(studentLogin)).result(dummyResult).complaintType(complaintType);
complaintRepo.save(complaint);
}
}
use of de.tum.in.www1.artemis.domain.participation.Participant in project ArTEMiS by ls1intum.
the class LearningGoalService method calculateLearningGoalCourseProgress.
/**
* Calculate the progress in a learning goal for a whole course
*
* @param useParticipantScoreTable use the participant score table instead of going through participation -> submission -> result
* @param learningGoal learning goal to get the progress for
* @return progress of the course in the learning goal
*/
public CourseLearningGoalProgress calculateLearningGoalCourseProgress(LearningGoal learningGoal, boolean useParticipantScoreTable) {
CourseLearningGoalProgress courseLearningGoalProgress = new CourseLearningGoalProgress();
courseLearningGoalProgress.courseId = learningGoal.getCourse().getId();
courseLearningGoalProgress.learningGoalId = learningGoal.getId();
courseLearningGoalProgress.learningGoalTitle = learningGoal.getTitle();
courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = 0.0;
courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal = 0.0;
// The progress will be calculated from a subset of the connected lecture units (currently only from released exerciseUnits)
List<ExerciseUnit> exerciseUnitsUsableForProgressCalculation = learningGoal.getLectureUnits().parallelStream().filter(LectureUnit::isVisibleToStudents).filter(lectureUnit -> lectureUnit instanceof ExerciseUnit).map(lectureUnit -> (ExerciseUnit) lectureUnit).collect(Collectors.toList());
Set<CourseLearningGoalProgress.CourseLectureUnitProgress> progressInLectureUnits = this.calculateExerciseUnitsProgressForCourse(exerciseUnitsUsableForProgressCalculation, useParticipantScoreTable);
// updating learningGoalPerformance by summing up the points of the individual lecture unit progress
courseLearningGoalProgress.totalPointsAchievableByStudentsInLearningGoal = progressInLectureUnits.stream().map(lectureUnitProgress -> lectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
courseLearningGoalProgress.averagePointsAchievedByStudentInLearningGoal = progressInLectureUnits.stream().map(lectureUnitProgress -> (lectureUnitProgress.averageScoreAchievedByStudentInLectureUnit / 100.0) * lectureUnitProgress.totalPointsAchievableByStudentsInLectureUnit).reduce(0.0, Double::sum);
courseLearningGoalProgress.progressInLectureUnits = new ArrayList<>(progressInLectureUnits);
return courseLearningGoalProgress;
}
use of de.tum.in.www1.artemis.domain.participation.Participant in project ArTEMiS by ls1intum.
the class DatabaseUtilService method addComplaintToSubmission.
public void addComplaintToSubmission(Submission submission, String userLogin, ComplaintType type) {
Result result = submission.getLatestResult();
if (result != null) {
result.hasComplaint(true);
resultRepo.save(result);
}
Complaint complaint = new Complaint().participant(getUserByLogin(userLogin)).result(result).complaintType(type);
complaintRepo.save(complaint);
}
Aggregations