Skip to content

Commit

Permalink
Programming exercises: Do not always show the request feedback button…
Browse files Browse the repository at this point in the history
… in the online code editor (#9475)
  • Loading branch information
krusche authored Oct 13, 2024
1 parent ba666c4 commit 45a18f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if (!isExamExercise) {
@if (!isExamExercise && requestFeedbackEnabled) {
@if (athenaEnabled) {
@if (exercise().type === ExerciseType.TEXT) {
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ParticipationService } from 'app/exercises/shared/participation/partici
export class RequestFeedbackButtonComponent implements OnInit {
faPenSquare = faPenSquare;
athenaEnabled = false;
requestFeedbackEnabled = false;
isExamExercise: boolean;
participation?: StudentParticipation;

Expand All @@ -34,7 +35,6 @@ export class RequestFeedbackButtonComponent implements OnInit {
exercise = input.required<Exercise>();
generatingFeedback = output<void>();

private feedbackSent = false;
private profileService = inject(ProfileService);
private alertService = inject(AlertService);
private courseExerciseService = inject(CourseExerciseService);
Expand All @@ -52,6 +52,7 @@ export class RequestFeedbackButtonComponent implements OnInit {
if (this.isExamExercise || !this.exercise().id) {
return;
}
this.requestFeedbackEnabled = this.exercise().allowFeedbackRequests ?? false;
this.updateParticipation();
}

Expand All @@ -77,7 +78,6 @@ export class RequestFeedbackButtonComponent implements OnInit {
next: (participation: StudentParticipation) => {
if (participation) {
this.generatingFeedback.emit();
this.feedbackSent = true;
this.alertService.success('artemisApp.exercise.feedbackRequestSent');
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('RequestFeedbackButtonComponent', () => {
submissions: [{ id: 1, submitted: true }],
testRun: false,
} as StudentParticipation;
const exercise = { id: 1, type: ExerciseType.TEXT, course: undefined, studentParticipations: [participation] } as Exercise;
const exercise = { id: 1, type: ExerciseType.TEXT, course: undefined, studentParticipations: [participation], allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);
mockExerciseDetails(exercise);

Expand All @@ -75,7 +75,7 @@ describe('RequestFeedbackButtonComponent', () => {

it('should display the button when Athena is enabled and it is not an exam exercise', fakeAsync(() => {
setAthenaEnabled(true);
const exercise = { id: 1, type: ExerciseType.TEXT, course: {} } as Exercise; // course undefined means exam exercise
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, allowFeedbackRequests: true } as Exercise; // course undefined means exam exercise
fixture.componentRef.setInput('exercise', exercise);
mockExerciseDetails(exercise);

Expand Down Expand Up @@ -104,7 +104,7 @@ describe('RequestFeedbackButtonComponent', () => {

it('should disable the button when participation is missing', fakeAsync(() => {
setAthenaEnabled(true);
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, studentParticipations: undefined } as Exercise;
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, studentParticipations: undefined, allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);
mockExerciseDetails(exercise);

Expand All @@ -123,7 +123,7 @@ describe('RequestFeedbackButtonComponent', () => {
id: 1,
submissions: [{ id: 1, submitted: true }],
} as StudentParticipation;
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, studentParticipations: [participation] } as Exercise;
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, studentParticipations: [participation], allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);
component.isExamExercise = false;
mockExerciseDetails(exercise);
Expand All @@ -146,7 +146,7 @@ describe('RequestFeedbackButtonComponent', () => {
submissions: [{ id: 1, submitted: false }],
testRun: false,
} as StudentParticipation;
const exercise = { id: 1, type: ExerciseType.PROGRAMMING, studentParticipations: [participation], course: {} } as Exercise;
const exercise = { id: 1, type: ExerciseType.PROGRAMMING, studentParticipations: [participation], course: {}, allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);

mockExerciseDetails(exercise);
Expand All @@ -173,7 +173,7 @@ describe('RequestFeedbackButtonComponent', () => {
it('should show an alert when requestFeedback() is called and conditions are not satisfied', fakeAsync(() => {
setAthenaEnabled(true);

const exercise = { id: 1, type: ExerciseType.TEXT, course: {} } as Exercise;
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);

jest.spyOn(component, 'hasAthenaResultForLatestSubmission').mockReturnValue(true);
Expand All @@ -191,7 +191,7 @@ describe('RequestFeedbackButtonComponent', () => {
submissions: [{ id: 1, submitted: false }],
testRun: false,
} as StudentParticipation;
const exercise = { id: 1, type: ExerciseType.TEXT, studentParticipations: [participation], course: {} } as Exercise;
const exercise = { id: 1, type: ExerciseType.TEXT, studentParticipations: [participation], course: {}, allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);
fixture.componentRef.setInput('isGeneratingFeedback', false);
mockExerciseDetails(exercise);
Expand All @@ -212,7 +212,7 @@ describe('RequestFeedbackButtonComponent', () => {
submissions: [{ id: 1, submitted: true }],
testRun: false,
} as StudentParticipation;
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, studentParticipations: [participation] } as Exercise;
const exercise = { id: 1, type: ExerciseType.TEXT, course: {}, studentParticipations: [participation], allowFeedbackRequests: true } as Exercise;
fixture.componentRef.setInput('exercise', exercise);
fixture.componentRef.setInput('isGeneratingFeedback', false);
mockExerciseDetails(exercise);
Expand Down

0 comments on commit 45a18f8

Please sign in to comment.