Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming exercises: Do not always show the request feedback button in the online code editor #9475

Merged
merged 5 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
krusche marked this conversation as resolved.
Show resolved Hide resolved
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
Loading