Skip to content

Commit 3e6e78b

Browse files
feat(GradeByStep): Sync class responses with summary (#2269)
Only show first component when the page is first rendered, and synchronize component displayed between summary and class responses.
1 parent c2eecca commit 3e6e78b

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/filter-components/filter-components.component.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function onlyOneComponent() {
3535
type: 'MultipleChoice'
3636
} as ComponentContent
3737
];
38+
component.selectedComponents = component.components;
39+
component.ngOnChanges();
3840
fixture.detectChanges();
3941
select = await loader.getHarness(MatSelectHarness);
4042
});
@@ -57,6 +59,7 @@ function moreThanOneComponent() {
5759
type: 'OpenResponse'
5860
} as ComponentContent
5961
];
62+
component.selectedComponents = [component.components[0]];
6063
component.ngOnChanges();
6164
fixture.detectChanges();
6265
select = await loader.getHarness(MatSelectHarness);
@@ -66,14 +69,18 @@ function moreThanOneComponent() {
6669
const options = await select.getOptions();
6770
expect(options.length).toBe(2);
6871
expect(await options[0].isSelected()).toBe(true);
69-
expect(await options[1].isSelected()).toBe(true);
72+
expect(await options[1].isSelected()).toBe(false);
7073
});
7174
it('clicking on an option should emit selected components', async () => {
7275
const spy = spyOn(component.componentsChange, 'emit').and.callThrough();
7376
await select.open();
7477
const options = await select.getOptions();
75-
await options[0].click();
78+
await options[1].click();
7679
expect(spy).toHaveBeenCalledWith([
80+
{
81+
id: 'c1',
82+
type: 'MultipleChoice'
83+
} as ComponentContent,
7784
{
7885
id: 'c2',
7986
type: 'OpenResponse'

src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/filter-components/filter-components.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ export class FilterComponentsComponent {
1919
@Output() componentsChange: EventEmitter<ComponentContent[]> = new EventEmitter<
2020
ComponentContent[]
2121
>();
22-
protected selectedComponents: ComponentContent[];
22+
@Input() selectedComponents: ComponentContent[];
2323
protected selectedText: string;
2424

2525
constructor(private componentTypeService: ComponentTypeService) {}
2626

2727
ngOnChanges(): void {
28-
this.selectedComponents = this.components;
2928
this.updateSelectedText();
3029
}
3130

src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/node-grading/node-grading.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h3 class="mat-body-1" i18n>Question Summaries</h3>
3737
<div class="mat-elevation-z1 app-background mt-4 mb-2">
3838
<mat-tab-group
3939
[selectedIndex]="selectedComponent.value"
40-
(selectedIndexChange)="selectedComponent.setValue($event)"
40+
(selectedIndexChange)="selectSummary($event)"
4141
mat-stretch-tabs="false"
4242
animationDuration="0"
4343
>
@@ -56,6 +56,7 @@ <h3 class="mat-body-1" i18n>Question Summaries</h3>
5656
<h3 class="mat-body-1" i18n>Class Responses</h3>
5757
<filter-components
5858
[components]="components"
59+
[selectedComponents]="visibleComponents"
5960
(componentsChange)="setVisibleComponents($event)"
6061
/>
6162
</div>

src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/node-grading/node-grading.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class NodeGradingComponent implements OnInit, OnDestroy, OnChanges {
103103
component['displayIndex'] = index + 1;
104104
return component;
105105
});
106-
this.visibleComponents = this.components;
106+
this.visibleComponents = [this.components[0]];
107107
this.numRubrics = this.node.getNumRubrics();
108108
this.setPeriod();
109109
}
@@ -144,4 +144,9 @@ export class NodeGradingComponent implements OnInit, OnDestroy, OnChanges {
144144
event.preventDefault();
145145
this.summariesVisible = !this.summariesVisible;
146146
}
147+
148+
protected selectSummary(componentIndex: number): void {
149+
this.selectedComponent.setValue(componentIndex);
150+
this.visibleComponents = [this.components[componentIndex]];
151+
}
147152
}

src/messages.xlf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14629,7 +14629,7 @@ The branches will be removed but the steps will remain in the unit.</source>
1462914629
<source>Showing <x id="PH" equiv-text="this.selectedComponents.length"/>/<x id="PH_1" equiv-text="this.components.length"/> questions</source>
1463014630
<context-group purpose="location">
1463114631
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/filter-components/filter-components.component.ts</context>
14632-
<context context-type="linenumber">33</context>
14632+
<context context-type="linenumber">32</context>
1463314633
</context-group>
1463414634
</trans-unit>
1463514635
<trans-unit id="214737279674024315" datatype="html">

0 commit comments

Comments
 (0)