diff --git a/src/app/teacher/component-grading.module.ts b/src/app/teacher/component-grading.module.ts
index 15962cc937c..668280a57d8 100644
--- a/src/app/teacher/component-grading.module.ts
+++ b/src/app/teacher/component-grading.module.ts
@@ -13,6 +13,7 @@ import { MatchGradingModule } from '../../assets/wise5/components/match/match-gr
import { MultipleChoiceGradingModule } from '../../assets/wise5/components/multipleChoice/multiple-choice-grading/multiple-choice-grading.module';
import { OpenResponseGradingModule } from '../../assets/wise5/components/openResponse/open-response-grading/open-response-grading.module';
import { PeerChatGradingModule } from '../../assets/wise5/components/peerChat/peer-chat-grading/peer-chat-grading.module';
+import { ShowGroupWorkGradingModule } from '../../assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.module';
import { TableGradingModule } from '../../assets/wise5/components/table/table-grading/table-grading.module';
@NgModule({
@@ -31,6 +32,7 @@ import { TableGradingModule } from '../../assets/wise5/components/table/table-gr
MultipleChoiceGradingModule,
OpenResponseGradingModule,
PeerChatGradingModule,
+ ShowGroupWorkGradingModule,
TableGradingModule
],
exports: [
@@ -48,6 +50,7 @@ import { TableGradingModule } from '../../assets/wise5/components/table/table-gr
MultipleChoiceGradingModule,
OpenResponseGradingModule,
PeerChatGradingModule,
+ ShowGroupWorkGradingModule,
TableGradingModule
]
})
diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/workgroup-component-grading/workgroup-component-grading.component.html b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/workgroup-component-grading/workgroup-component-grading.component.html
index dc404c818ac..bd1923bf4d5 100644
--- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/workgroup-component-grading/workgroup-component-grading.component.html
+++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/workgroup-component-grading/workgroup-component-grading.component.html
@@ -102,9 +102,15 @@
>
+
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.html b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.html
new file mode 100644
index 00000000000..104debf087d
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.html
@@ -0,0 +1,35 @@
+
+
+ You have not been paired with a classmate yet. Please check back later.
+
+
+
+
+
+
+ account_circle
+
+ {{ workgroupInfos[member.id].displayNames }}
+
+
+
+ (Waiting for response...)
+
+
+
+
+
+
+
+
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.scss b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.scss
new file mode 100644
index 00000000000..9a7b05482ac
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.scss
@@ -0,0 +1,13 @@
+@import 'style/abstracts/variables';
+
+.mat-card {
+ margin: 4px;
+ padding: 8px;
+}
+
+.mat-card-content {
+ margin-top: 8px;
+ padding: 8px;
+ border-radius: $button-border-radius;
+ overflow: auto;
+}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.spec.ts b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.spec.ts
new file mode 100644
index 00000000000..75736f79e93
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.spec.ts
@@ -0,0 +1,195 @@
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { MatDialog } from '@angular/material/dialog';
+import { of } from 'rxjs';
+import { PeerGrouping } from '../../../../../app/domain/peerGrouping';
+import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
+import { AnnotationService } from '../../../services/annotationService';
+import { ConfigService } from '../../../services/configService';
+import { NodeService } from '../../../services/nodeService';
+import { NotebookService } from '../../../services/notebookService';
+import { PeerGroupService } from '../../../services/peerGroupService';
+import { ProjectService } from '../../../services/projectService';
+import { PeerGroup } from '../../peerChat/PeerGroup';
+import { PeerGroupMember } from '../../peerChat/PeerGroupMember';
+import { ShowGroupWorkDisplayComponent } from './show-group-work-display.component';
+
+class MockService {}
+
+class MockNotebookService {
+ notebookUpdated$: any = of({});
+
+ isNotebookEnabled() {
+ return false;
+ }
+}
+
+class MockConfigService {
+ getPeriodId() {
+ return periodId;
+ }
+ getRunId() {
+ return 1;
+ }
+ isAuthoring() {
+ return false;
+ }
+ isPreview() {
+ return false;
+ }
+ isSignedInUserATeacher() {
+ return false;
+ }
+ getWorkgroupId() {
+ return workgroupId;
+ }
+ getAvatarColorForWorkgroupId(workgroupId: any) {
+ return '#000000';
+ }
+ getUsernamesStringByWorkgroupId(workgroupId: number) {
+ return `Student ${workgroupId}`;
+ }
+}
+
+let component: ShowGroupWorkDisplayComponent;
+let componentState1;
+let componentState2;
+let componentState3;
+let fixture: ComponentFixture
;
+const periodId = 100;
+const peerGroup = new PeerGroup(
+ 1,
+ [new PeerGroupMember(1, 1), new PeerGroupMember(2, 1), new PeerGroupMember(3, 1)],
+ new PeerGrouping()
+);
+let studentWork;
+const workgroupId: number = 1000;
+
+describe('ShowGroupWorkDisplayComponent', () => {
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule, StudentTeacherCommonServicesModule],
+ declarations: [ShowGroupWorkDisplayComponent],
+ providers: [
+ AnnotationService,
+ { provide: ConfigService, useClass: MockConfigService },
+ { provide: MatDialog, useClass: MockService },
+ { provide: NodeService, useClass: MockService },
+ { provide: NotebookService, useClass: MockNotebookService },
+ { provide: PeerGroupService, useClass: PeerGroupService }
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ }).compileComponents();
+
+ fixture = TestBed.createComponent(ShowGroupWorkDisplayComponent);
+ componentState1 = createComponentState(1);
+ componentState2 = createComponentState(2);
+ studentWork = [componentState1, componentState2];
+ component = fixture.componentInstance;
+ component.componentContent = {
+ id: 'abc',
+ prompt: '',
+ showSaveButton: true,
+ showSubmitButton: true,
+ isShowMyWork: true,
+ layout: 'row',
+ type: 'ShowGroupWork'
+ };
+ spyOn(TestBed.inject(ProjectService), 'injectAssetPaths').and.returnValue({
+ type: 'OpenResponse'
+ });
+ component.peerGroup = peerGroup;
+ component.setWorkgroupInfos();
+ fixture.detectChanges();
+ });
+
+ setStudentWorkFromGroupMembers();
+ setLayout();
+ setWidths();
+ showGroupWorkInPreview();
+});
+
+function createComponentState(workgroupId: number): any {
+ return {
+ workgroupId: workgroupId
+ };
+}
+
+function setStudentWorkFromGroupMembers() {
+ describe('setStudentWorkFromGroupMembers', () => {
+ it('should add entry to workgroupIdToWork for each student work', () => {
+ component.setStudentWorkFromGroupMembers(studentWork);
+ expect(component.workgroupIdToWork.size).toEqual(2);
+ });
+ });
+}
+
+function setLayout() {
+ describe('setLayout', () => {
+ it('should set row layout for narrow component type', () => {
+ component.setStudentWorkFromGroupMembers(studentWork);
+ component.setLayout();
+ expect(component.flexLayout).toBe('row wrap');
+ });
+
+ it('should set column layout', () => {
+ component.componentContent.layout = 'column';
+ component.setStudentWorkFromGroupMembers(studentWork);
+ component.setLayout();
+ expect(component.flexLayout).toBe('column');
+ });
+ });
+}
+
+function setWidths() {
+ describe('setWidths()', () => {
+ it('should set widths for narrow component type including my work', () => {
+ component.setStudentWorkFromGroupMembers(studentWork);
+ component.setWidths();
+ expect(component.widthMd).toEqual(50);
+ expect(component.widthLg).toEqual(33.33);
+ });
+
+ it('should set widths for narrow component type not including my work', () => {
+ component.componentContent.isShowMyWork = false;
+ spyOn(TestBed.inject(ConfigService), 'getWorkgroupId').and.returnValue(1);
+ component.setStudentWorkFromGroupMembers(studentWork);
+ component.setWidths();
+ expect(component.widthMd).toEqual(50);
+ expect(component.widthLg).toEqual(33.33);
+ });
+
+ it('should set widths for narrow component type and more than 2 group members', () => {
+ componentState3 = createComponentState(3);
+ studentWork = [componentState1, componentState2, componentState3];
+ component.setStudentWorkFromGroupMembers(studentWork);
+ component.setWidths();
+ expect(component.widthMd).toEqual(50);
+ expect(component.widthLg).toEqual(33.33);
+ });
+ });
+}
+
+function showGroupWorkInPreview() {
+ describe('ngOnInit()', () => {
+ it('should show group work in preview', () => {
+ spyOn(TestBed.inject(ConfigService), 'isPreview').and.returnValue(true);
+ spyOn(TestBed.inject(ConfigService), 'getWorkgroupId').and.returnValue(workgroupId);
+ spyOn(TestBed.inject(ConfigService), 'getPeriodId').and.returnValue(periodId);
+ spyOn(TestBed.inject(PeerGroupService), 'retrievePeerGroup').and.returnValue(of(peerGroup));
+ const latestComponentState = {
+ id: 100,
+ studentData: {
+ response: 'Hello'
+ },
+ workgroupId: workgroupId
+ };
+ spyOn(TestBed.inject(PeerGroupService), 'retrieveStudentWork').and.returnValue(
+ of([latestComponentState])
+ );
+ component.ngOnInit();
+ expect(component.workgroupIdToWork.get(workgroupId)).toEqual(latestComponentState);
+ });
+ });
+}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.ts b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.ts
new file mode 100644
index 00000000000..55ab5dc54e2
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.ts
@@ -0,0 +1,122 @@
+import { Component, Input, OnInit } from '@angular/core';
+import { ConfigService } from '../../../services/configService';
+import { PeerGroupService } from '../../../services/peerGroupService';
+import { ProjectService } from '../../../services/projectService';
+import { PeerGroup } from '../../peerChat/PeerGroup';
+
+@Component({
+ selector: 'show-group-work-display',
+ templateUrl: './show-group-work-display.component.html',
+ styleUrls: ['./show-group-work-display.component.scss']
+})
+export class ShowGroupWorkDisplayComponent implements OnInit {
+ @Input() componentContent: any;
+ @Input() componentId: string;
+ flexLayout: string = 'column';
+ isPeerGroupRetrieved: boolean = false;
+ narrowComponentTypes: string[] = ['MultipleChoice', 'OpenResponse'];
+ @Input() nodeId: string;
+ peerGroup: PeerGroup;
+ showWorkComponentContent: any;
+ widthLg: number = 100;
+ widthMd: number = 100;
+ @Input() workgroupId: number;
+ workgroupIdToWork = new Map();
+ workgroupInfos: any = {};
+
+ constructor(
+ private configService: ConfigService,
+ private peerGroupService: PeerGroupService,
+ private projectService: ProjectService
+ ) {}
+
+ ngOnInit(): void {
+ this.retrieveStudentWorkForPeerGroup();
+ this.setShowWorkComponentContent();
+ }
+
+ private retrieveStudentWorkForPeerGroup(): void {
+ this.peerGroupService
+ .retrievePeerGroup(this.componentContent.peerGroupingTag, this.workgroupId)
+ .subscribe((peerGroup: PeerGroup) => {
+ if (peerGroup != null) {
+ this.peerGroup = this.componentContent.isShowMyWork
+ ? peerGroup
+ : this.removeMyWorkgroup(peerGroup);
+ this.setWorkgroupInfos();
+ this.peerGroupService
+ .retrieveStudentWork(
+ peerGroup,
+ this.nodeId,
+ this.componentId,
+ this.componentContent.showWorkNodeId,
+ this.componentContent.showWorkComponentId
+ )
+ .subscribe((studentWorkFromGroupMembers: any[]) => {
+ this.setStudentWorkFromGroupMembers(studentWorkFromGroupMembers);
+ this.setLayout();
+ });
+ }
+ this.isPeerGroupRetrieved = true;
+ });
+ }
+
+ setStudentWorkFromGroupMembers(studentWorkFromGroupMembers: any[]): void {
+ studentWorkFromGroupMembers.forEach((work) => {
+ this.workgroupIdToWork.set(work.workgroupId, work);
+ });
+ }
+
+ private setShowWorkComponentContent(): void {
+ this.showWorkComponentContent = this.projectService.injectAssetPaths(
+ this.projectService.getComponent(
+ this.componentContent.showWorkNodeId,
+ this.componentContent.showWorkComponentId
+ )
+ );
+ }
+
+ private removeMyWorkgroup(peerGroup: PeerGroup): PeerGroup {
+ const myWorkgroupId = this.configService.getWorkgroupId();
+ peerGroup.members = peerGroup.members.filter((workgroup) => {
+ return workgroup.id !== myWorkgroupId;
+ });
+ return peerGroup;
+ }
+
+ setWorkgroupInfos(): void {
+ this.workgroupInfos = {};
+ for (const member of this.peerGroup.members) {
+ this.setWorkgroupInfo(member.id);
+ }
+ }
+
+ private setWorkgroupInfo(workgroupId: number): void {
+ this.workgroupInfos[workgroupId] = {
+ avatarColor: this.configService.getAvatarColorForWorkgroupId(workgroupId),
+ displayNames: this.configService.getUsernamesStringByWorkgroupId(workgroupId)
+ };
+ }
+
+ setLayout(): void {
+ if (this.componentContent.layout === 'row') {
+ this.flexLayout = 'row wrap';
+ this.setWidths();
+ }
+ }
+
+ setWidths(): void {
+ const numWorkgroups = this.peerGroup.members.length;
+ if (numWorkgroups > 1) {
+ this.widthMd = 50;
+ this.widthLg = 50;
+ }
+ if (numWorkgroups > 2 && this.isNarrow()) {
+ this.widthLg = 33.33;
+ }
+ }
+
+ private isNarrow(): boolean {
+ return this.narrowComponentTypes.includes(this.showWorkComponentContent.type);
+ }
+}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.module.ts b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.module.ts
new file mode 100644
index 00000000000..37c312cb76d
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.module.ts
@@ -0,0 +1,14 @@
+import { CommonModule } from '@angular/common';
+import { NgModule } from '@angular/core';
+import { FlexLayoutModule } from '@angular/flex-layout';
+import { MatCardModule } from '@angular/material/card';
+import { MatIconModule } from '@angular/material/icon';
+import { ShowWorkStudentModule } from '../../showWork/show-work-student/show-work-student.module';
+import { ShowGroupWorkDisplayComponent } from './show-group-work-display.component';
+
+@NgModule({
+ declarations: [ShowGroupWorkDisplayComponent],
+ imports: [CommonModule, FlexLayoutModule, MatCardModule, MatIconModule, ShowWorkStudentModule],
+ exports: [ShowGroupWorkDisplayComponent]
+})
+export class ShowGroupWorkDisplayModule {}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.html b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.html
new file mode 100644
index 00000000000..792b3b43d18
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.html
@@ -0,0 +1,6 @@
+
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.scss b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.scss
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.spec.ts b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.spec.ts
new file mode 100644
index 00000000000..79653dd6a3f
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.spec.ts
@@ -0,0 +1,25 @@
+import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { MatDialogModule } from '@angular/material/dialog';
+import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
+import { ShowGroupWorkGradingComponent } from './show-group-work-grading.component';
+
+describe('ShowGroupWorkGradingComponent', () => {
+ let component: ShowGroupWorkGradingComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule, MatDialogModule, StudentTeacherCommonServicesModule],
+ declarations: [ShowGroupWorkGradingComponent]
+ }).compileComponents();
+
+ fixture = TestBed.createComponent(ShowGroupWorkGradingComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.ts b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.ts
new file mode 100644
index 00000000000..2cd7e3205e0
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.component.ts
@@ -0,0 +1,11 @@
+import { Component, Input } from '@angular/core';
+import { ComponentShowWorkDirective } from '../../component-show-work.directive';
+
+@Component({
+ selector: 'show-group-work-grading',
+ templateUrl: './show-group-work-grading.component.html',
+ styleUrls: ['./show-group-work-grading.component.scss']
+})
+export class ShowGroupWorkGradingComponent extends ComponentShowWorkDirective {
+ @Input() workgroupId: number;
+}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.module.ts b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.module.ts
new file mode 100644
index 00000000000..c8b4937dc88
--- /dev/null
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-grading/show-group-work-grading.module.ts
@@ -0,0 +1,10 @@
+import { NgModule } from '@angular/core';
+import { ShowGroupWorkDisplayModule } from '../show-group-work-display/show-group-work-display.module';
+import { ShowGroupWorkGradingComponent } from './show-group-work-grading.component';
+
+@NgModule({
+ declarations: [ShowGroupWorkGradingComponent],
+ imports: [ShowGroupWorkDisplayModule],
+ exports: [ShowGroupWorkGradingComponent]
+})
+export class ShowGroupWorkGradingModule {}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.html b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.html
index 419e46ef3b7..8b00210a84c 100644
--- a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.html
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.html
@@ -1,36 +1,7 @@
-
-
- You have not been paired with a classmate yet. Please check back later.
-
-
-
-
-
-
- account_circle
-
- {{ workgroupInfos[member.id].displayNames }}
-
-
-
- (Waiting for response...)
-
-
-
-
-
-
-
-
+
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.spec.ts b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.spec.ts
index e42c2b85a67..4faf1b5eec1 100644
--- a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.spec.ts
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.spec.ts
@@ -1,203 +1,24 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { MatDialog } from '@angular/material/dialog';
-import { of } from 'rxjs';
-import { PeerGrouping } from '../../../../../app/domain/peerGrouping';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
-import { Component } from '../../../common/Component';
-import { AnnotationService } from '../../../services/annotationService';
-import { ConfigService } from '../../../services/configService';
-import { NodeService } from '../../../services/nodeService';
-import { NotebookService } from '../../../services/notebookService';
-import { PeerGroupService } from '../../../services/peerGroupService';
-import { ProjectService } from '../../../services/projectService';
-import { StudentDataService } from '../../../services/studentDataService';
-import { StudentPeerGroupService } from '../../../services/studentPeerGroupService';
-import { PeerGroup } from '../../peerChat/PeerGroup';
-import { PeerGroupMember } from '../../peerChat/PeerGroupMember';
import { ShowGroupWorkStudentComponent } from './show-group-work-student.component';
-class MockService {}
-
-class MockNotebookService {
- notebookUpdated$: any = of({});
-
- isNotebookEnabled() {
- return false;
- }
-}
-
-class MockConfigService {
- getPeriodId() {
- return periodId;
- }
- getRunId() {
- return 1;
- }
- isAuthoring() {
- return false;
- }
- isPreview() {
- return false;
- }
- isSignedInUserATeacher() {
- return false;
- }
- getWorkgroupId() {
- return workgroupId;
- }
- getAvatarColorForWorkgroupId(workgroupId: any) {
- return '#000000';
- }
- getUsernamesStringByWorkgroupId(workgroupId: number) {
- return `Student ${workgroupId}`;
- }
-}
-
let component: ShowGroupWorkStudentComponent;
-let componentState1;
-let componentState2;
-let componentState3;
let fixture: ComponentFixture;
-const periodId = 100;
-const peerGroup = new PeerGroup(
- 1,
- [new PeerGroupMember(1, 1), new PeerGroupMember(2, 1), new PeerGroupMember(3, 1)],
- new PeerGrouping()
-);
-let studentWork;
-const workgroupId: number = 1000;
describe('ShowGroupWorkStudentComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HttpClientTestingModule, StudentTeacherCommonServicesModule],
declarations: [ShowGroupWorkStudentComponent],
- providers: [
- AnnotationService,
- { provide: ConfigService, useClass: MockConfigService },
- { provide: MatDialog, useClass: MockService },
- { provide: NodeService, useClass: MockService },
- { provide: NotebookService, useClass: MockNotebookService },
- { provide: PeerGroupService, useClass: StudentPeerGroupService }
- ],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ShowGroupWorkStudentComponent);
- componentState1 = createComponentState(1);
- componentState2 = createComponentState(2);
- studentWork = [componentState1, componentState2];
component = fixture.componentInstance;
- const componentContent = {
- id: 'abc',
- prompt: '',
- showSaveButton: true,
- showSubmitButton: true,
- isShowMyWork: true,
- layout: 'row',
- type: 'ShowGroupWork'
- };
- component.component = new Component(componentContent, null);
- spyOn(TestBed.inject(ProjectService), 'injectAssetPaths').and.returnValue({
- type: 'OpenResponse'
- });
- component.peerGroup = peerGroup;
- component.setWorkgroupInfos();
- spyOn(component, 'subscribeToSubscriptions').and.callFake(() => {});
fixture.detectChanges();
});
-
- setStudentWorkFromGroupMembers();
- setLayout();
- setWidths();
- showGroupWorkInPreview();
});
-
-function createComponentState(workgroupId: number): any {
- return {
- workgroupId: workgroupId
- };
-}
-
-function setStudentWorkFromGroupMembers() {
- describe('setStudentWorkFromGroupMembers', () => {
- it('should add entry to workgroupIdToWork for each student work', () => {
- component.setStudentWorkFromGroupMembers(studentWork);
- expect(component.workgroupIdToWork.size).toEqual(2);
- });
- });
-}
-
-function setLayout() {
- describe('setLayout', () => {
- it('should set row layout for narrow component type', () => {
- component.setStudentWorkFromGroupMembers(studentWork);
- component.setLayout();
- expect(component.flexLayout).toBe('row wrap');
- });
-
- it('should set column layout', () => {
- component.componentContent.layout = 'column';
- component.setStudentWorkFromGroupMembers(studentWork);
- component.setLayout();
- expect(component.flexLayout).toBe('column');
- });
- });
-}
-
-function setWidths() {
- describe('setWidths()', () => {
- it('should set widths for narrow component type including my work', () => {
- component.setStudentWorkFromGroupMembers(studentWork);
- component.setWidths();
- expect(component.widthMd).toEqual(50);
- expect(component.widthLg).toEqual(33.33);
- });
-
- it('should set widths for narrow component type not including my work', () => {
- component.componentContent.isShowMyWork = false;
- spyOn(TestBed.inject(ConfigService), 'getWorkgroupId').and.returnValue(1);
- component.setStudentWorkFromGroupMembers(studentWork);
- component.setWidths();
- expect(component.widthMd).toEqual(50);
- expect(component.widthLg).toEqual(33.33);
- });
-
- it('should set widths for narrow component type and more than 2 group members', () => {
- componentState3 = createComponentState(3);
- studentWork = [componentState1, componentState2, componentState3];
- component.setStudentWorkFromGroupMembers(studentWork);
- component.setWidths();
- expect(component.widthMd).toEqual(50);
- expect(component.widthLg).toEqual(33.33);
- });
- });
-}
-
-function showGroupWorkInPreview() {
- describe('ngOnInit()', () => {
- it('should show group work in preview', () => {
- spyOn(TestBed.inject(ConfigService), 'isPreview').and.returnValue(true);
- spyOn(TestBed.inject(ConfigService), 'getWorkgroupId').and.returnValue(workgroupId);
- spyOn(TestBed.inject(ConfigService), 'getPeriodId').and.returnValue(periodId);
- spyOn(TestBed.inject(PeerGroupService), 'retrievePeerGroup').and.returnValue(of(peerGroup));
- const latestComponentState = {
- id: 100,
- studentData: {
- response: 'Hello'
- },
- workgroupId: workgroupId
- };
- spyOn(
- TestBed.inject(StudentDataService),
- 'getLatestComponentStateByNodeIdAndComponentId'
- ).and.returnValue(latestComponentState);
- component.ngOnInit();
- expect(component.workgroupIdToWork.get(workgroupId)).toEqual(latestComponentState);
- });
- });
-}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.ts b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.ts
index b9adb629ba6..bc2c8e0cfb7 100644
--- a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.ts
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.ts
@@ -1,145 +1,9 @@
import { Component } from '@angular/core';
-import { MatDialog } from '@angular/material/dialog';
-import { AnnotationService } from '../../../services/annotationService';
-import { ConfigService } from '../../../services/configService';
-import { NodeService } from '../../../services/nodeService';
-import { NotebookService } from '../../../services/notebookService';
-import { PeerGroupService } from '../../../services/peerGroupService';
-import { ProjectService } from '../../../services/projectService';
-import { StudentAssetService } from '../../../services/studentAssetService';
-import { StudentDataService } from '../../../services/studentDataService';
import { ComponentStudent } from '../../component-student.component';
-import { ComponentService } from '../../componentService';
-import { PeerGroup } from '../../peerChat/PeerGroup';
@Component({
selector: 'show-group-work-student',
templateUrl: './show-group-work-student.component.html',
styleUrls: ['./show-group-work-student.component.scss']
})
-export class ShowGroupWorkStudentComponent extends ComponentStudent {
- flexLayout: string = 'column';
- isPeerGroupRetrieved: boolean = false;
- narrowComponentTypes: string[] = ['MultipleChoice', 'OpenResponse'];
- peerGroup: PeerGroup;
- showWorkComponentContent: any;
- widthLg: number = 100;
- widthMd: number = 100;
- workgroupIdToWork = new Map();
- workgroupInfos: any = {};
-
- constructor(
- protected annotationService: AnnotationService,
- protected componentService: ComponentService,
- protected configService: ConfigService,
- protected dialog: MatDialog,
- protected nodeService: NodeService,
- protected notebookService: NotebookService,
- protected peerGroupService: PeerGroupService,
- protected projectService: ProjectService,
- protected studentAssetService: StudentAssetService,
- protected studentDataService: StudentDataService
- ) {
- super(
- annotationService,
- componentService,
- configService,
- dialog,
- nodeService,
- notebookService,
- studentAssetService,
- studentDataService
- );
- }
-
- ngOnInit(): void {
- super.ngOnInit();
- this.retrieveStudentWorkForPeerGroup();
- this.setShowWorkComponentContent();
- }
-
- private retrieveStudentWorkForPeerGroup(): void {
- this.peerGroupService
- .retrievePeerGroup(this.componentContent.peerGroupingTag, this.workgroupId)
- .subscribe((peerGroup: PeerGroup) => {
- if (peerGroup != null) {
- this.peerGroup = this.componentContent.isShowMyWork
- ? peerGroup
- : this.removeMyWorkgroup(peerGroup);
- this.setWorkgroupInfos();
- this.peerGroupService
- .retrieveStudentWork(
- peerGroup,
- this.nodeId,
- this.componentId,
- this.componentContent.showWorkNodeId,
- this.componentContent.showWorkComponentId
- )
- .subscribe((studentWorkFromGroupMembers: any[]) => {
- this.setStudentWorkFromGroupMembers(studentWorkFromGroupMembers);
- this.setLayout();
- });
- }
- this.isPeerGroupRetrieved = true;
- });
- }
-
- setStudentWorkFromGroupMembers(studentWorkFromGroupMembers: any[]): void {
- studentWorkFromGroupMembers.forEach((work) => {
- this.workgroupIdToWork.set(work.workgroupId, work);
- });
- }
-
- private setShowWorkComponentContent(): void {
- this.showWorkComponentContent = this.projectService.injectAssetPaths(
- this.projectService.getComponent(
- this.componentContent.showWorkNodeId,
- this.componentContent.showWorkComponentId
- )
- );
- }
-
- private removeMyWorkgroup(peerGroup: PeerGroup): PeerGroup {
- const myWorkgroupId = this.configService.getWorkgroupId();
- peerGroup.members = peerGroup.members.filter((workgroup) => {
- return workgroup.id !== myWorkgroupId;
- });
- return peerGroup;
- }
-
- setWorkgroupInfos(): void {
- this.workgroupInfos = {};
- for (const member of this.peerGroup.members) {
- this.setWorkgroupInfo(member.id);
- }
- }
-
- private setWorkgroupInfo(workgroupId: number): void {
- this.workgroupInfos[workgroupId] = {
- avatarColor: this.ConfigService.getAvatarColorForWorkgroupId(workgroupId),
- displayNames: this.ConfigService.getUsernamesStringByWorkgroupId(workgroupId)
- };
- }
-
- setLayout(): void {
- if (this.componentContent.layout === 'row') {
- this.flexLayout = 'row wrap';
- this.setWidths();
- }
- }
-
- setWidths(): void {
- const numWorkgroups = this.peerGroup.members.length;
- if (numWorkgroups > 1) {
- this.widthMd = 50;
- this.widthLg = 50;
- }
- if (numWorkgroups > 2 && this.isNarrow()) {
- this.widthLg = 33.33;
- }
- }
-
- isNarrow(): boolean {
- return this.narrowComponentTypes.includes(this.showWorkComponentContent.type);
- }
-}
+export class ShowGroupWorkStudentComponent extends ComponentStudent {}
diff --git a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.module.ts b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.module.ts
index 3f825bd7945..db9fc897221 100644
--- a/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.module.ts
+++ b/src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.module.ts
@@ -1,21 +1,11 @@
-import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
-import { FlexLayoutModule } from '@angular/flex-layout';
-import { MatCardModule } from '@angular/material/card';
-import { MatIconModule } from '@angular/material/icon';
import { StudentComponentModule } from '../../../../../app/student/student.component.module';
-import { ShowWorkStudentModule } from '../../showWork/show-work-student/show-work-student.module';
+import { ShowGroupWorkDisplayModule } from '../show-group-work-display/show-group-work-display.module';
import { ShowGroupWorkStudentComponent } from './show-group-work-student.component';
@NgModule({
declarations: [ShowGroupWorkStudentComponent],
- imports: [
- CommonModule,
- FlexLayoutModule,
- MatCardModule,
- MatIconModule,
- ShowWorkStudentModule,
- StudentComponentModule],
+ imports: [ShowGroupWorkDisplayModule, StudentComponentModule],
exports: [ShowGroupWorkStudentComponent]
})
-export class ShowGroupWorkStudentModule { }
+export class ShowGroupWorkStudentModule {}
diff --git a/src/assets/wise5/services/teacherPeerGroupService.ts b/src/assets/wise5/services/teacherPeerGroupService.ts
index 6aca322ba8a..2879435bfad 100644
--- a/src/assets/wise5/services/teacherPeerGroupService.ts
+++ b/src/assets/wise5/services/teacherPeerGroupService.ts
@@ -24,15 +24,40 @@ export class TeacherPeerGroupService extends PeerGroupService {
});
}
- retrievePeerGroup(): Observable {
- return of(this.getPreviewPeerGroup());
+ retrievePeerGroup(peerGroupingTag: string, workgroupId: number): Observable {
+ // When the teacher previews anything that retrieves Peer Group like Classroom Monitor Step Info
+ // or Authoring preview popup, the workgroupId will be null
+ if (this.configService.isClassroomMonitor() && workgroupId != null) {
+ return super.retrievePeerGroup(peerGroupingTag, workgroupId);
+ } else {
+ return of(this.getPreviewPeerGroup());
+ }
}
retrievePeerGroupWork(): Observable {
return of([]);
}
- retrieveStudentWork(): Observable {
- return of([]);
+ retrieveStudentWork(
+ peerGroup: PeerGroup,
+ nodeId: string,
+ componentId: string,
+ showWorkNodeId: string,
+ showWorkComponentId: string
+ ): Observable {
+ if (
+ this.configService.isClassroomMonitor() &&
+ peerGroup.id !== PeerGroupService.PREVIEW_PEER_GROUP_ID
+ ) {
+ return super.retrieveStudentWork(
+ peerGroup,
+ nodeId,
+ componentId,
+ showWorkNodeId,
+ showWorkComponentId
+ );
+ } else {
+ return of([]);
+ }
}
}
diff --git a/src/messages.xlf b/src/messages.xlf
index 9e10fe7ee4e..5d9a3e71ccc 100644
--- a/src/messages.xlf
+++ b/src/messages.xlf
@@ -11390,14 +11390,14 @@ Are you sure you want to proceed?
src/assets/wise5/classroomMonitor/classroomMonitorComponents/workgroup-component-grading/workgroup-component-grading.component.html
- 110,112
+ 116,118
src/assets/wise5/classroomMonitor/classroomMonitorComponents/workgroup-component-grading/workgroup-component-grading.component.html
- 120
+ 126
@@ -17307,15 +17307,15 @@ If this problem continues, let your teacher know and move on to the next activit
- src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.html
- 3,5
+ src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.html
+ 2,4
- src/assets/wise5/components/showGroupWork/show-group-work-student/show-group-work-student.component.html
- 22,24
+ src/assets/wise5/components/showGroupWork/show-group-work-display/show-group-work-display.component.html
+ 21,23