Skip to content

Commit

Permalink
Assessment: Fix an issue where instructors accidentally override pres…
Browse files Browse the repository at this point in the history
…entation scores (#10143)
  • Loading branch information
krusche authored Jan 21, 2025
1 parent 0610eb0 commit 1946a89
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
8 changes: 0 additions & 8 deletions src/main/java/de/tum/cit/aet/artemis/core/domain/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,6 @@ public boolean getComplaintsEnabled() {
return this.maxComplaintTimeDays > 0;
}

public Set<Post> getPosts() {
return posts;
}

public void setPosts(Set<Post> posts) {
this.posts = posts;
}

public boolean getRequestMoreFeedbackEnabled() {
return maxRequestMoreFeedbackTimeDays > 0;
}
Expand Down
25 changes: 5 additions & 20 deletions src/main/java/de/tum/cit/aet/artemis/core/web/CourseResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import de.tum.cit.aet.artemis.assessment.service.AssessmentDashboardService;
import de.tum.cit.aet.artemis.assessment.service.ComplaintService;
import de.tum.cit.aet.artemis.assessment.service.CourseScoreCalculationService;
import de.tum.cit.aet.artemis.assessment.service.GradingScaleService;
import de.tum.cit.aet.artemis.athena.service.AthenaModuleService;
import de.tum.cit.aet.artemis.atlas.api.LearnerProfileApi;
import de.tum.cit.aet.artemis.atlas.api.LearningPathApi;
Expand Down Expand Up @@ -170,8 +169,6 @@ public class CourseResource {

private final TutorialGroupsConfigurationService tutorialGroupsConfigurationService;

private final GradingScaleService gradingScaleService;

private final CourseScoreCalculationService courseScoreCalculationService;

private final GradingScaleRepository gradingScaleRepository;
Expand All @@ -197,10 +194,10 @@ public CourseResource(UserRepository userRepository, CourseService courseService
Optional<OnlineCourseConfigurationService> onlineCourseConfigurationService, AuthorizationCheckService authCheckService,
TutorParticipationRepository tutorParticipationRepository, SubmissionService submissionService, Optional<VcsUserManagementService> optionalVcsUserManagementService,
AssessmentDashboardService assessmentDashboardService, ExerciseRepository exerciseRepository, Optional<CIUserManagementService> optionalCiUserManagementService,
FileService fileService, TutorialGroupsConfigurationService tutorialGroupsConfigurationService, GradingScaleService gradingScaleService,
CourseScoreCalculationService courseScoreCalculationService, GradingScaleRepository gradingScaleRepository, LearningPathApi learningPathApi,
ConductAgreementService conductAgreementService, Optional<AthenaModuleService> athenaModuleService, ExamRepository examRepository, ComplaintService complaintService,
TeamRepository teamRepository, LearnerProfileApi learnerProfileApi) {
FileService fileService, TutorialGroupsConfigurationService tutorialGroupsConfigurationService, CourseScoreCalculationService courseScoreCalculationService,
GradingScaleRepository gradingScaleRepository, LearningPathApi learningPathApi, ConductAgreementService conductAgreementService,
Optional<AthenaModuleService> athenaModuleService, ExamRepository examRepository, ComplaintService complaintService, TeamRepository teamRepository,
LearnerProfileApi learnerProfileApi) {
this.courseService = courseService;
this.courseRepository = courseRepository;
this.exerciseService = exerciseService;
Expand All @@ -215,7 +212,6 @@ public CourseResource(UserRepository userRepository, CourseService courseService
this.exerciseRepository = exerciseRepository;
this.fileService = fileService;
this.tutorialGroupsConfigurationService = tutorialGroupsConfigurationService;
this.gradingScaleService = gradingScaleService;
this.courseScoreCalculationService = courseScoreCalculationService;
this.gradingScaleRepository = gradingScaleRepository;
this.learningPathApi = learningPathApi;
Expand Down Expand Up @@ -278,17 +274,6 @@ public ResponseEntity<Course> updateCourse(@PathVariable Long courseId, @Request
}
}

if (courseUpdate.getPresentationScore() != null && courseUpdate.getPresentationScore() != 0) {
Optional<GradingScale> gradingScale = gradingScaleService.findGradingScaleByCourseId(courseUpdate.getId());
if (gradingScale.isPresent() && gradingScale.get().getPresentationsNumber() != null) {
throw new BadRequestAlertException("You cannot set a presentation score if the grading scale is already set up for graded presentations", Course.ENTITY_NAME,
"gradedPresentationAlreadySet", true);
}
if (courseUpdate.getPresentationScore() < 0) {
throw new BadRequestAlertException("The presentation score cannot be negative", Course.ENTITY_NAME, "negativePresentationScore", true);
}
}

// Make sure to preserve associations in updated entity
courseUpdate.setId(courseId);
courseUpdate.setPrerequisites(existingCourse.getPrerequisites());
Expand Down Expand Up @@ -1353,7 +1338,7 @@ public ResponseEntity<Void> removeUserFromCourseGroup(String userLogin, User ins
public ResponseEntity<CourseManagementDetailViewDTO> getCourseDTOForDetailView(@PathVariable Long courseId) {
Course course = courseRepository.findByIdElseThrow(courseId);
authCheckService.checkHasAtLeastRoleInCourseElseThrow(Role.TEACHING_ASSISTANT, course, null);
GradingScale gradingScale = gradingScaleService.findGradingScaleByCourseId(courseId).orElse(null);
GradingScale gradingScale = gradingScaleRepository.findByCourseId(courseId).orElse(null);
CourseManagementDetailViewDTO managementDetailViewDTO = courseService.getStatsForDetailView(course, gradingScale);
return ResponseEntity.ok(managementDetailViewDTO);
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/webapp/app/course/manage/course-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,18 @@ export class CourseUpdateComponent implements OnInit {
file = base64StringToBlob(base64Data, 'image/*');
}

const course = this.courseForm.getRawValue();
const course = this.courseForm.getRawValue() as Course;
// NOTE: prevent overriding this value accidentally
// TODO: move presentationScore to gradingScale to avoid this
course.presentationScore = this.course.presentationScore;

if (this.communicationEnabled && this.messagingEnabled) {
course['courseInformationSharingConfiguration'] = CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING;
course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.COMMUNICATION_AND_MESSAGING;
} else if (this.communicationEnabled && !this.messagingEnabled) {
course['courseInformationSharingConfiguration'] = CourseInformationSharingConfiguration.COMMUNICATION_ONLY;
course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.COMMUNICATION_ONLY;
} else {
this.communicationEnabled = false;
course['courseInformationSharingConfiguration'] = CourseInformationSharingConfiguration.DISABLED;
course.courseInformationSharingConfiguration = CourseInformationSharingConfiguration.DISABLED;
}

if (!course.enrollmentEnabled) {
Expand Down

0 comments on commit 1946a89

Please sign in to comment.