use of de.tum.in.www1.artemis.domain.LearningGoal 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.LearningGoal 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.LearningGoal in project ArTEMiS by ls1intum.
the class LectureUnitService method disconnectLectureUnitAndLearningGoal.
/**
* Remove connection between lecture unit and learning goal in the database
*
* @param lectureUnit Lecture unit connected to learning goal
* @param learningGoal Learning goal connected to lecture unit
*/
public void disconnectLectureUnitAndLearningGoal(LectureUnit lectureUnit, LearningGoal learningGoal) {
Optional<LearningGoal> learningGoalFromDbOptional = learningGoalRepository.findByIdWithLectureUnitsBidirectional(learningGoal.getId());
if (learningGoalFromDbOptional.isPresent()) {
LearningGoal learningGoalFromDb = learningGoalFromDbOptional.get();
learningGoalFromDb.removeLectureUnit(lectureUnit);
learningGoalRepository.save(learningGoalFromDb);
}
}
use of de.tum.in.www1.artemis.domain.LearningGoal in project ArTEMiS by ls1intum.
the class LearningGoalResource method getPrerequisites.
/**
* GET /courses/:courseId/prerequisites
* @param courseId the id of the course for which the learning goals should be fetched
* @return the ResponseEntity with status 200 (OK) and with body the found learning goals
*/
@GetMapping("/courses/{courseId}/prerequisites")
@PreAuthorize("hasRole('USER')")
public ResponseEntity<List<LearningGoal>> getPrerequisites(@PathVariable Long courseId) {
log.debug("REST request to get prerequisites for course with id: {}", courseId);
Course course = courseRepository.findByIdElseThrow(courseId);
// Authorization check is skipped when course is open to self-registration
if (!course.isRegistrationEnabled()) {
User user = userRepository.getUserWithGroupsAndAuthorities();
authorizationCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.STUDENT, course, user);
}
Set<LearningGoal> prerequisites = learningGoalRepository.findPrerequisitesByCourseId(courseId);
// Remove all lecture units as not needed for now
for (LearningGoal prerequisite : prerequisites) {
prerequisite.setLectureUnits(Collections.emptySet());
}
return ResponseEntity.ok(new ArrayList<>(prerequisites));
}
use of de.tum.in.www1.artemis.domain.LearningGoal in project ArTEMiS by ls1intum.
the class LearningGoalResource method getLearningGoalProgressOfCourse.
/**
* GET /courses/:courseId/goals/:learningGoalId/course-progress gets the learning goal progress for the whole course
*
* @param courseId the id of the course to which the learning goal belongs
* @param learningGoalId the id of the learning goal for which to get the progress
* @param useParticipantScoreTable use the participant score table instead of going through participation -> submission -> result
* @return the ResponseEntity with status 200 (OK) and with the learning goal course performance in the body
*/
@GetMapping("/courses/{courseId}/goals/{learningGoalId}/course-progress")
@PreAuthorize("hasRole('INSTRUCTOR')")
public ResponseEntity<CourseLearningGoalProgress> getLearningGoalProgressOfCourse(@PathVariable Long learningGoalId, @PathVariable Long courseId, @RequestParam(defaultValue = "false", required = false) boolean useParticipantScoreTable) {
log.debug("REST request to get course progress for LearningGoal : {}", learningGoalId);
var learningGoal = findLearningGoal(Role.INSTRUCTOR, learningGoalId, courseId);
CourseLearningGoalProgress courseLearningGoalProgress = learningGoalService.calculateLearningGoalCourseProgress(learningGoal, useParticipantScoreTable);
return ResponseEntity.ok().body(courseLearningGoalProgress);
}
Aggregations