Skip to content

Commit ac9619c

Browse files
feat(ShowMyWork): Additional option to show detected ideas for OR and DG components (#2280)
1 parent 49b0e31 commit ac9619c

File tree

7 files changed

+39
-10
lines changed

7 files changed

+39
-10
lines changed

src/assets/wise5/components/component-show-work.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NodeService } from '../services/nodeService';
44

55
@Directive()
66
export abstract class ComponentShowWorkDirective {
7+
@Input() additionalSettings: any;
78
@Input() nodeId: string;
89
@Input() componentId: string;
910
@Input() componentState: any;

src/assets/wise5/components/dialogGuidance/dialog-guidance-show-work/dialog-guidance-show-work.component.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { UserService } from '../../../../../app/services/user.service';
99
describe('DialogGuidanceShowWorkComponent', () => {
1010
let component: DialogGuidanceShowWorkComponent;
1111
let fixture: ComponentFixture<DialogGuidanceShowWorkComponent>;
12+
let userService: UserService;
1213

1314
beforeEach(async () => {
1415
await TestBed.configureTestingModule({
@@ -24,14 +25,25 @@ describe('DialogGuidanceShowWorkComponent', () => {
2425
beforeEach(() => {
2526
fixture = TestBed.createComponent(DialogGuidanceShowWorkComponent);
2627
component = fixture.componentInstance;
28+
userService = TestBed.inject(UserService);
2729
spyOn(TestBed.inject(CRaterService), 'getCRaterRubric').and.returnValue(new CRaterRubric());
2830
component.componentState = {
2931
studentData: {}
3032
};
31-
fixture.detectChanges();
3233
});
3334

34-
it('should create', () => {
35-
expect(component).toBeTruthy();
35+
describe('ngOnInit', () => {
36+
it('should show detected ideas when user is teacher', () => {
37+
spyOn(userService, 'isTeacher').and.returnValue(true);
38+
fixture.detectChanges();
39+
expect(component['showDetectedIdeas']).toBe(true);
40+
});
41+
42+
it('should show detected ideas when user is not a teacher but there is additional settings', () => {
43+
spyOn(userService, 'isTeacher').and.returnValue(false);
44+
component.additionalSettings = { showDetectedIdeas: true };
45+
fixture.detectChanges();
46+
expect(component['showDetectedIdeas']).toBe(true);
47+
});
3648
});
3749
});

src/assets/wise5/components/dialogGuidance/dialog-guidance-show-work/dialog-guidance-show-work.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import { UserService } from '../../../../../app/services/user.service';
2323
[computerAvatar]="computerAvatar"
2424
[cRaterRubric]="cRaterRubric"
2525
[responses]="componentState.studentData.responses"
26-
[showDetectedIdeas]="isTeacher"
26+
[showDetectedIdeas]="showDetectedIdeas"
2727
/>
2828
</mat-card>
2929
`
3030
})
3131
export class DialogGuidanceShowWorkComponent extends ComponentShowWorkDirective {
3232
protected computerAvatar: ComputerAvatar;
3333
protected cRaterRubric: CRaterRubric;
34-
protected isTeacher: boolean = false;
34+
protected showDetectedIdeas: boolean = false;
3535

3636
constructor(
3737
private computerAvatarService: ComputerAvatarService,
@@ -44,7 +44,8 @@ export class DialogGuidanceShowWorkComponent extends ComponentShowWorkDirective
4444
}
4545

4646
ngOnInit(): void {
47-
this.isTeacher = this.userService.isTeacher();
47+
this.showDetectedIdeas =
48+
this.userService.isTeacher() || this.additionalSettings?.showDetectedIdeas;
4849
this.computerAvatar = this.computerAvatarService.getAvatar(
4950
this.componentState.studentData.computerAvatarId
5051
);

src/assets/wise5/components/openResponse/open-response-show-work/open-response-show-work.component.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,21 @@ describe('OpenResponseShowWorkComponent', () => {
9696
expect(component['showDetectedIdeas']).toBe(true);
9797
});
9898

99-
it('should not show detected ideas when user is not a teacher', () => {
99+
it('should not show detected ideas when user is not a teacher and there is no additional settings', () => {
100100
spyOn(annotationService, 'getAnnotationsByStudentWorkId').and.returnValue([]);
101101
spyOn(userService, 'isTeacher').and.returnValue(false);
102102
fixture.detectChanges();
103-
expect(component['showDetectedIdeas']).toBe(false);
103+
expect(component['showDetectedIdeas']).toBe(undefined);
104+
});
105+
106+
it('should show detected ideas when user is not a teacher but there is additional settings', () => {
107+
spyOn(annotationService, 'getAnnotationsByStudentWorkId').and.returnValue([
108+
mockCRaterAnnotation
109+
] as any);
110+
spyOn(userService, 'isTeacher').and.returnValue(false);
111+
component.additionalSettings = { showDetectedIdeas: true };
112+
fixture.detectChanges();
113+
expect(component['showDetectedIdeas']).toBe(true);
104114
});
105115
});
106116
});

src/assets/wise5/components/openResponse/open-response-show-work/open-response-show-work.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ export class OpenResponseShowWorkComponent extends ComponentShowWorkDirective {
4242
this.annotations = this.annotationService.getAnnotationsByStudentWorkId(
4343
this.componentState.id
4444
);
45-
this.cRaterAnnotation = this.annotations.find((annotation) => annotation.type === 'autoScore' && annotation.data.ideas);
45+
this.cRaterAnnotation = this.annotations.find(
46+
(annotation) => annotation.type === 'autoScore' && annotation.data.ideas
47+
);
4648
}
4749
this.showDetectedIdeas =
48-
this.userService.isTeacher() &&
50+
(this.userService.isTeacher() || this.additionalSettings?.showDetectedIdeas) &&
4951
this.cRaterRubric?.ideas.length &&
5052
this.cRaterAnnotation != null;
5153
this.processAttachments();

src/assets/wise5/components/showMyWork/show-my-work-student/show-my-work-student.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[componentContent]="showWorkComponentContent"
1010
[componentId]="showWorkComponentId"
1111
[nodeId]="showWorkNodeId"
12+
[additionalSettings]="componentContent.additionalSettings"
1213
/>
1314
}
1415
</mat-card-content>

src/assets/wise5/components/showWork/show-work-student/show-work-student.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ComponentShowWorkDirective } from '../../component-show-work.directive'
1616
template: '<div #component></div>'
1717
})
1818
export class ShowWorkStudentComponent {
19+
@Input() additionalSettings: any;
1920
@Input() componentContent: any;
2021
@Input() componentId: string;
2122
@ViewChild('component') private componentElementRef: ElementRef;
@@ -49,6 +50,7 @@ export class ShowWorkStudentComponent {
4950
environmentInjector: this.injector
5051
});
5152
Object.assign(this.componentRef.instance, {
53+
additionalSettings: this.additionalSettings,
5254
componentId: this.componentId,
5355
componentState: this.studentWork,
5456
isDisabled: true,

0 commit comments

Comments
 (0)