1- import { Component , Input , ViewEncapsulation } from '@angular/core' ;
1+ import { Component , inject , Input , ViewEncapsulation } from '@angular/core' ;
22import { MatIcon } from '@angular/material/icon' ;
33import { TeacherSummaryDisplayComponent } from '../teacher-summary-display.component' ;
44import { firstValueFrom } from 'rxjs' ;
55import { ComponentState } from '../../../../../app/domain/componentState' ;
66import { MatExpansionModule } from '@angular/material/expansion' ;
7+ import { MatDialog } from '@angular/material/dialog' ;
8+ import { IdeaSummaryDialogComponent } from '../idea-summary-dialog/idea-summary-dialog.component' ;
9+ import { getAvatarColorForWorkgroupId } from '../../../common/workgroup/workgroup' ;
710
811interface IdeaCategory {
912 id : string ;
@@ -15,6 +18,7 @@ interface IdeaCategory {
1518interface Response {
1619 text : string ;
1720 timestamp : number ;
21+ usernames : string ;
1822}
1923
2024@Component ( {
@@ -25,12 +29,21 @@ interface Response {
2529 templateUrl : './idea-summary.component.html'
2630} )
2731export class IdeaSummaryComponent extends TeacherSummaryDisplayComponent {
32+ private dialog = inject ( MatDialog ) ;
33+
2834 @Input ( ) componentId : string ;
2935 @Input ( ) idea : IdeaCategory ;
3036 @Input ( ) nodeId : string ;
3137
3238 protected expanded : boolean = false ;
3339 protected responses : Response [ ] = [ ] ;
40+ protected sampleResponses : Response [ ] = [ ] ;
41+ private workgroups : any [ ] = [ ] ;
42+
43+ ngOnInit ( ) : void {
44+ super . ngOnInit ( ) ;
45+ this . workgroups = this . configService . getClassmateUserInfos ( ) ;
46+ }
3447
3548 protected renderDisplay ( ) : void {
3649 super . renderDisplay ( ) ;
@@ -52,9 +65,7 @@ export class IdeaSummaryComponent extends TeacherSummaryDisplayComponent {
5265 } else if ( component . type === 'OpenResponse' ) {
5366 this . responses = this . getORResponsesWithIdea ( states , this . idea . id ) ;
5467 }
55- if ( this . responses . length > 2 ) {
56- this . responses = this . responses . slice ( 0 , 2 ) ; // only show 2 responses max
57- }
68+ this . sampleResponses = this . responses . slice ( 0 , 2 ) ; // only show 2 responses max
5869 }
5970
6071 private getDGResponsesWithIdea ( states : ComponentState [ ] , ideaId : string ) : Response [ ] {
@@ -66,7 +77,10 @@ export class IdeaSummaryComponent extends TeacherSummaryDisplayComponent {
6677 if ( response ?. ideas ?. some ( ( idea ) => idea . detected && idea . name === ideaId ) ) {
6778 // computer responses contain ideas detected, but we want the actual student response
6879 // which is before the computer response
69- responsesWithIdea . push ( responses [ index - 1 ] ) ;
80+ const studentResponse = responses [ index - 1 ] ;
81+ studentResponse . usernames = this . getDisplayNames ( state . workgroupId ) ;
82+ studentResponse . avatarColor = getAvatarColorForWorkgroupId ( state . workgroupId ) ;
83+ responsesWithIdea . push ( studentResponse ) ;
7084 workgroupsProcessed . push ( state . workgroupId ) ;
7185 }
7286 } ) ;
@@ -84,7 +98,23 @@ export class IdeaSummaryComponent extends TeacherSummaryDisplayComponent {
8498 . filter ( ( state ) => annotations . some ( ( annotation ) => annotation . studentWorkId === state . id ) )
8599 . map ( ( state ) => ( {
86100 text : state . studentData . response ,
87- timestamp : state . clientSaveTime
101+ timestamp : state . clientSaveTime ,
102+ usernames : this . getDisplayNames ( state . workgroupId ) ,
103+ avatarColor : getAvatarColorForWorkgroupId ( state . workgroupId )
88104 } ) ) ;
89105 }
106+
107+ private getDisplayNames ( workgroupId : number ) : string {
108+ return this . workgroups . find ( ( workgroup ) => workgroup . workgroupId === workgroupId ) . displayNames ;
109+ }
110+
111+ protected showAllResponses ( ) : void {
112+ this . dialog . open ( IdeaSummaryDialogComponent , {
113+ data : {
114+ idea : this . idea ,
115+ responses : this . responses
116+ } ,
117+ panelClass : [ 'app-styles' , 'dialog-lg' ]
118+ } ) ;
119+ }
90120}
0 commit comments