@@ -13,29 +13,41 @@ import { SessionService } from '../../services/sessionService';
1313import { StudentDataService } from '../../services/studentDataService' ;
1414import { VLEProjectService } from '../vleProjectService' ;
1515import { copy } from '../../common/object/object' ;
16+ import { CommonModule } from '@angular/common' ;
17+ import { FlexLayoutModule } from '@angular/flex-layout' ;
18+ import { ComponentComponent } from '../../components/component/component.component' ;
19+ import { MatButtonModule } from '@angular/material/button' ;
20+ import { ComponentStateInfoComponent } from '../../common/component-state-info/component-state-info.component' ;
21+ import { HelpIconComponent } from '../../themes/default/themeComponents/helpIcon/help-icon.component' ;
1622
1723@Component ( {
24+ imports : [
25+ CommonModule ,
26+ ComponentComponent ,
27+ ComponentStateInfoComponent ,
28+ FlexLayoutModule ,
29+ HelpIconComponent ,
30+ MatButtonModule
31+ ] ,
1832 selector : 'node' ,
19- templateUrl : './node.component.html' ,
20- styleUrls : [ './node.component.scss' ]
33+ standalone : true ,
34+ styleUrl : './node.component.scss' ,
35+ templateUrl : './node.component.html'
2136} )
2237export class NodeComponent implements OnInit {
23- autoSaveInterval : number = 60000 ; // in milliseconds;
24- autoSaveIntervalId : any ;
25- components : any [ ] ;
26- componentToVisible = { } ;
27- dirtyComponentIds : any = [ ] ;
28- dirtySubmitComponentIds : any = [ ] ;
29- isDisabled : boolean ;
38+ private autoSaveInterval : number = 60000 ; // in milliseconds;
39+ private autoSaveIntervalId : any ;
40+ protected components : any [ ] ;
41+ protected componentToVisible = { } ;
42+ protected dirtyComponentIds : any = [ ] ;
43+ protected dirtySubmitComponentIds : any = [ ] ;
44+ protected disabled : boolean ;
45+ protected latestComponentState : ComponentState ;
3046 @Input ( ) node : Node ;
31- nodeContent : any ;
32- nodeStatus : any ;
33- latestComponentState : ComponentState ;
34- showRubric : boolean ;
35- submit : boolean = false ;
36- subscriptions : Subscription = new Subscription ( ) ;
37- teacherWorkgroupId : number ;
38- workComponents : string [ ] = [
47+ protected nodeStatus : any ;
48+ protected showRubric : boolean ;
49+ private subscriptions : Subscription = new Subscription ( ) ;
50+ private workComponents : string [ ] = [
3951 'Animation' ,
4052 'AudioOscillator' ,
4153 'ConceptMap' ,
@@ -52,7 +64,7 @@ export class NodeComponent implements OnInit {
5264 'Summary' ,
5365 'Table'
5466 ] ;
55- workgroupId : number ;
67+ protected workgroupId : number ;
5668
5769 constructor (
5870 private componentService : ComponentService ,
@@ -72,8 +84,7 @@ export class NodeComponent implements OnInit {
7284
7385 ngOnInit ( ) : void {
7486 this . workgroupId = this . configService . getWorkgroupId ( ) ;
75- this . teacherWorkgroupId = this . configService . getTeacherWorkgroupId ( ) ;
76- this . isDisabled = ! this . configService . isRunActive ( ) ;
87+ this . disabled = ! this . configService . isRunActive ( ) ;
7788
7889 this . initializeNode ( ) ;
7990 this . startAutoSaveInterval ( ) ;
@@ -82,18 +93,15 @@ export class NodeComponent implements OnInit {
8293 this . subscriptions . add (
8394 this . studentDataService . componentSaveTriggered$ . subscribe ( ( { nodeId, componentId } ) => {
8495 if ( nodeId == this . node . id && this . node . hasComponent ( componentId ) ) {
85- const isAutoSave = false ;
86- this . createAndSaveComponentData ( isAutoSave , componentId ) ;
96+ this . createAndSaveComponentData ( false , componentId ) ;
8797 }
8898 } )
8999 ) ;
90100
91101 this . subscriptions . add (
92102 this . studentDataService . componentSubmitTriggered$ . subscribe ( ( { nodeId, componentId } ) => {
93103 if ( nodeId == this . node . id && this . node . hasComponent ( componentId ) ) {
94- const isAutoSave = false ;
95- const isSubmit = true ;
96- this . createAndSaveComponentData ( isAutoSave , componentId , isSubmit ) ;
104+ this . createAndSaveComponentData ( false , componentId , true ) ;
97105 }
98106 } )
99107 ) ;
@@ -155,9 +163,8 @@ export class NodeComponent implements OnInit {
155163 ) ;
156164 }
157165
158- initializeNode ( ) : void {
166+ private initializeNode ( ) : void {
159167 this . clearLatestComponentState ( ) ;
160- this . nodeContent = this . projectService . getNodeById ( this . node . id ) ;
161168 this . components = this . getComponents ( ) ;
162169 this . nodeStatus = this . nodeStatusService . getNodeStatusByNodeId ( this . node . id ) ;
163170 this . dirtyComponentIds = [ ] ;
@@ -178,7 +185,8 @@ export class NodeComponent implements OnInit {
178185 this . showRubric = this . node . rubric != null && this . node . rubric != '' ;
179186 }
180187
181- const script = this . nodeContent . script ;
188+ const nodeContent = this . projectService . getNodeById ( this . node . id ) ;
189+ const script = nodeContent . script ;
182190 if ( script != null ) {
183191 this . projectService . retrieveScript ( script ) . then ( ( script : string ) => {
184192 new Function ( script ) . call ( this ) ;
@@ -198,21 +206,18 @@ export class NodeComponent implements OnInit {
198206 this . subscriptions . unsubscribe ( ) ;
199207 }
200208
201- saveButtonClicked ( ) : void {
202- const isAutoSave = false ;
203- this . createAndSaveComponentData ( isAutoSave ) ;
209+ protected save ( ) : void {
210+ this . createAndSaveComponentData ( false ) ;
204211 }
205212
206- submitButtonClicked ( ) : void {
213+ protected submit ( ) : void {
207214 this . nodeService . broadcastNodeSubmitClicked ( { nodeId : this . node . id } ) ;
208- const isAutoSave = false ;
209- const isSubmit = true ;
210- this . createAndSaveComponentData ( isAutoSave , null , isSubmit ) ;
215+ this . createAndSaveComponentData ( false , null , true ) ;
211216 }
212217
213218 private getComponents ( ) : any [ ] {
214219 return this . node . components . map ( ( component ) => {
215- if ( this . isDisabled ) {
220+ if ( this . disabled ) {
216221 component . isDisabled = true ;
217222 }
218223 return component ;
@@ -226,8 +231,7 @@ export class NodeComponent implements OnInit {
226231 private startAutoSaveInterval ( ) : void {
227232 this . autoSaveIntervalId = setInterval ( ( ) => {
228233 if ( this . dirtyComponentIds . length ) {
229- const isAutoSave = true ;
230- this . createAndSaveComponentData ( isAutoSave ) ;
234+ this . createAndSaveComponentData ( true ) ;
231235 }
232236 } , this . autoSaveInterval ) ;
233237 }
@@ -247,7 +251,7 @@ export class NodeComponent implements OnInit {
247251 * that needs saving
248252 */
249253 private createAndSaveComponentData (
250- isAutoSave ,
254+ isAutoSave : boolean ,
251255 componentId = null ,
252256 isSubmit = null
253257 ) : Promise < any > {
@@ -256,7 +260,11 @@ export class NodeComponent implements OnInit {
256260 ) ;
257261 }
258262
259- private createComponentStatesResponseHandler ( isAutoSave , componentId = null , isSubmit = null ) {
263+ private createComponentStatesResponseHandler (
264+ isAutoSave : boolean ,
265+ componentId : string = null ,
266+ isSubmit : boolean = null
267+ ) {
260268 return ( componentStates ) => {
261269 const componentAnnotations = this . getAnnotationsFromComponentStates ( componentStates ) ;
262270 componentStates . forEach ( ( componentState : any ) => {
@@ -400,7 +408,7 @@ export class NodeComponent implements OnInit {
400408 ) : any {
401409 componentState . runId = this . configService . getRunId ( ) ;
402410 componentState . periodId = this . configService . getPeriodId ( ) ;
403- componentState . workgroupId = this . configService . getWorkgroupId ( ) ;
411+ componentState . workgroupId = this . workgroupId ;
404412 componentState . isAutoSave = isAutoSave === true ;
405413 componentState . isSubmit ??= isSubmit ;
406414 }
@@ -429,7 +437,7 @@ export class NodeComponent implements OnInit {
429437 }
430438 }
431439
432- getComponentStateByComponentId ( componentId : string ) : any {
440+ protected getComponentStateByComponentId ( componentId : string ) : any {
433441 return this . studentDataService . getLatestComponentStateByNodeIdAndComponentId (
434442 this . node . id ,
435443 componentId
@@ -444,7 +452,7 @@ export class NodeComponent implements OnInit {
444452 ) ;
445453 }
446454
447- saveComponentState ( $event : any ) : Promise < any > {
455+ protected saveComponentState ( $event : any ) : Promise < any > {
448456 return Promise . all ( [ $event . componentStatePromise ] ) . then (
449457 this . createComponentStatesResponseHandler ( true )
450458 ) ;
0 commit comments