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

refactor(WorkgroupItemComponent): Convert workgroup to standalone #2016

Merged
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
3 changes: 2 additions & 1 deletion src/app/teacher/grading-common.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import { ComponentStateInfoComponent } from '../../assets/wise5/common/component
StatusIconComponent,
StudentTeacherCommonModule,
WorkgroupInfoComponent,
WorkgroupItemComponent,
WorkgroupComponentGradingComponent,
WorkgroupNodeScoreComponent,
WorkgroupNodeStatusComponent
],
declarations: [WorkgroupItemComponent, WorkgroupSelectAutocompleteComponent],
declarations: [WorkgroupSelectAutocompleteComponent],
exports: [
ComponentGradingComponent,
ComponentStateInfoComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,35 @@
</div>
</div>
</button>
<mat-list-item *ngIf="expanded && !disabled" class="grading__item-container">
<div class="grading__item" style="width: 100%">
<ng-container *ngFor="let component of components; let i = index">
<div
*ngIf="componentIdToIsVisible[component.id]"
id="component_{{ component.id }}_{{ workgroupId }}"
class="component component--grading"
>
<div [hidden]="!isComponentVisible(component.id)">
<h3 class="accent-1 gray-lightest-bg component__header">
{{ i + 1 + '. ' + getComponentTypeLabel(component.type) }}&nbsp;
<component-new-work-badge
[componentId]="component.id"
[workgroupId]="workgroupId"
[nodeId]="nodeId"
/>
</h3>
<workgroup-component-grading
class="component--grading__response__content"
[componentId]="component.id"
[workgroupId]="workgroupId"
[nodeId]="nodeId"
/>
</div>
</div>
</ng-container>
</div>
</mat-list-item>
@if (expanded && !disabled) {
<mat-list-item class="grading__item-container">
<div class="grading__item" style="width: 100%">
@for (component of components; track component.id; let i = $index) {
@if (componentIdToIsVisible[component.id]) {
<div
id="component_{{ component.id }}_{{ workgroupId }}"
class="component component--grading"
>
<div [hidden]="!isComponentVisible(component.id)">
<h3 class="accent-1 gray-lightest-bg component__header">
{{ i + 1 + '. ' + getComponentTypeLabel(component.type) }}&nbsp;
<component-new-work-badge
[componentId]="component.id"
[workgroupId]="workgroupId"
[nodeId]="nodeId"
/>
</h3>
<workgroup-component-grading
class="component--grading__response__content"
[componentId]="component.id"
[workgroupId]="workgroupId"
[nodeId]="nodeId"
/>
</div>
</div>
}
}
</div>
</mat-list-item>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ClassroomMonitorTestingModule } from '../../../classroom-monitor-testing.module';
import { WorkgroupItemComponent } from './workgroup-item.component';
import { TeacherProjectService } from '../../../../services/teacherProjectService';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentTypeServiceModule } from '../../../../services/componentTypeService.module';

let component: WorkgroupItemComponent;
let fixture: ComponentFixture<WorkgroupItemComponent>;
let getComponentsSpy: jasmine.Spy;
let teacherProjectService: TeacherProjectService;

describe('WorkgroupItemComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [WorkgroupItemComponent],
imports: [ClassroomMonitorTestingModule, ComponentTypeServiceModule],
providers: [TeacherProjectService],
schemas: [NO_ERRORS_SCHEMA]
imports: [WorkgroupItemComponent, ClassroomMonitorTestingModule, ComponentTypeServiceModule],
providers: [TeacherProjectService]
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,51 @@ import { Component, EventEmitter, Input, Output, SimpleChanges } from '@angular/
import { ComponentTypeService } from '../../../../services/componentTypeService';
import { TeacherProjectService } from '../../../../services/teacherProjectService';
import { calculateComponentVisibility } from '../../shared/grading-helpers/grading-helpers';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatListModule } from '@angular/material/list';
import { FlexLayoutModule } from '@angular/flex-layout';
import { WorkgroupInfoComponent } from '../workgroupInfo/workgroup-info.component';
import { WorkgroupNodeStatusComponent } from '../../../../../../app/classroom-monitor/workgroup-node-status/workgroup-node-status.component';
import { WorkgroupNodeScoreComponent } from '../../shared/workgroupNodeScore/workgroup-node-score.component';
import { ComponentNewWorkBadgeComponent } from '../../../../../../app/classroom-monitor/component-new-work-badge/component-new-work-badge.component';
import { WorkgroupComponentGradingComponent } from '../../workgroup-component-grading/workgroup-component-grading.component';

@Component({
imports: [
CommonModule,
MatButtonModule,
MatListModule,
FlexLayoutModule,
WorkgroupInfoComponent,
WorkgroupNodeStatusComponent,
WorkgroupNodeScoreComponent,
ComponentNewWorkBadgeComponent,
WorkgroupComponentGradingComponent
],
selector: 'workgroup-item',
templateUrl: 'workgroup-item.component.html',
styleUrls: ['workgroup-item.component.scss']
standalone: true,
styleUrl: 'workgroup-item.component.scss',
templateUrl: 'workgroup-item.component.html'
})
export class WorkgroupItemComponent {
componentIdToHasWork: { [componentId: string]: boolean } = {};
componentIdToIsVisible: { [componentId: string]: boolean } = {};
components: any[] = [];
disabled: boolean;
private componentIdToHasWork: { [componentId: string]: boolean } = {};
protected componentIdToIsVisible: { [componentId: string]: boolean } = {};
protected components: any[] = [];
protected disabled: boolean;
@Input() expanded: boolean;
hasAlert: boolean;
hasNewAlert: boolean;
protected hasAlert: boolean;
protected hasNewAlert: boolean;
@Input() hiddenComponents: string[] = [];
@Input() maxScore: number;
nodeHasWork: boolean;
private nodeHasWork: boolean;
@Input() nodeId: string;
@Output() onUpdateExpand: EventEmitter<any> = new EventEmitter();
score: any;
protected score: any;
@Input() showScore: boolean;
status: any;
statusClass: string;
statusText: string = '';
private status: any;
protected statusClass: string;
protected statusText: string = '';
@Input() workgroupId: number;
@Input() workgroupData: any;

Expand All @@ -39,7 +60,7 @@ export class WorkgroupItemComponent {
this.updateStatus();
}

updateNode(): void {
private updateNode(): void {
this.nodeHasWork = this.projectService.nodeHasWork(this.nodeId);
this.components = this.projectService.getComponents(this.nodeId);
this.componentIdToHasWork = this.projectService.calculateComponentIdToHasWork(this.components);
Expand Down Expand Up @@ -69,11 +90,11 @@ export class WorkgroupItemComponent {
}
}

isComponentVisible(componentId: string): boolean {
protected isComponentVisible(componentId: string): boolean {
return !this.hiddenComponents.includes(componentId);
}

getComponentTypeLabel(componentType): string {
protected getComponentTypeLabel(componentType): string {
return this.componentTypeService.getComponentTypeLabel(componentType);
}

Expand Down Expand Up @@ -109,10 +130,9 @@ export class WorkgroupItemComponent {
this.disabled = this.status === -1;
}

toggleExpand(): void {
protected toggleExpand(): void {
if (this.showScore) {
let expand = !this.expanded;
this.onUpdateExpand.emit({ workgroupId: this.workgroupId, value: expand });
this.onUpdateExpand.emit({ workgroupId: this.workgroupId, value: !this.expanded });
}
}
}
12 changes: 6 additions & 6 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -14102,7 +14102,7 @@ The branches will be removed but the steps will remain in the unit.</source>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroup-item/workgroup-item.component.ts</context>
<context context-type="linenumber">84</context>
<context context-type="linenumber">105</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/step-item/step-item.component.ts</context>
Expand All @@ -14117,7 +14117,7 @@ The branches will be removed but the steps will remain in the unit.</source>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroup-item/workgroup-item.component.ts</context>
<context context-type="linenumber">89</context>
<context context-type="linenumber">110</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/step-item/step-item.component.ts</context>
Expand All @@ -14132,7 +14132,7 @@ The branches will be removed but the steps will remain in the unit.</source>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroup-item/workgroup-item.component.ts</context>
<context context-type="linenumber">96</context>
<context context-type="linenumber">117</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/step-item/step-item.component.ts</context>
Expand All @@ -14154,7 +14154,7 @@ The branches will be removed but the steps will remain in the unit.</source>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroup-item/workgroup-item.component.ts</context>
<context context-type="linenumber">101</context>
<context context-type="linenumber">122</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/step-item/step-item.component.ts</context>
Expand Down Expand Up @@ -14246,7 +14246,7 @@ The branches will be removed but the steps will remain in the unit.</source>
<source>Visited</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroup-item/workgroup-item.component.ts</context>
<context context-type="linenumber">91</context>
<context context-type="linenumber">112</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/step-item/step-item.component.ts</context>
Expand All @@ -14257,7 +14257,7 @@ The branches will be removed but the steps will remain in the unit.</source>
<source>Not Visited</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/workgroup-item/workgroup-item.component.ts</context>
<context context-type="linenumber">103</context>
<context context-type="linenumber">124</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/classroomMonitor/classroomMonitorComponents/studentGrading/step-item/step-item.component.ts</context>
Expand Down
Loading