@@ -6,7 +6,7 @@ import { BrowserStorageService } from '@v3/app/services/storage.service';
66import { ActivityService , Task } from '@v3/services/activity.service' ;
77import { AssessmentService , Assessment , Submission , AssessmentReview } from '@v3/services/assessment.service' ;
88import { UtilsService } from '@v3/app/services/utils.service' ;
9- import { BehaviorSubject , firstValueFrom , Subject , Subscription } from 'rxjs' ;
9+ import { BehaviorSubject , filter , firstValueFrom , Subject , Subscription } from 'rxjs' ;
1010import { ReviewService } from '@v3/app/services/review.service' ;
1111import { AssessmentComponent } from '@v3/app/components/assessment/assessment.component' ;
1212import { debounceTime } from 'rxjs/operators' ;
@@ -87,17 +87,20 @@ export class AssessmentMobilePage implements OnInit, OnDestroy {
8787 } ) ;
8888 this . subscriptions . add ( paramsSub ) ;
8989
90- const assessmentSub = this . assessmentService . assessment$ . subscribe ( res => {
91- if ( ! res && this . assessmentDataLoaded ) {
92- this . goBack ( ) ;
93- return ;
94- }
90+ const assessmentSub = this . assessmentService . assessment$ .
91+ pipe (
92+ filter ( res => res && this . assessmentDataLoaded ) , // only proceed if assessment data is loaded
93+ ) . subscribe ( res => {
94+ if ( ! res ) {
95+ this . goBack ( ) ;
96+ return ;
97+ }
9598
96- if ( res ) {
97- this . assessment = res ;
98- this . utils . setPageTitle ( this . assessment ?. name ) ;
99- }
100- } ) ;
99+ if ( res ) {
100+ this . assessment = res ;
101+ this . utils . setPageTitle ( this . assessment ?. name ) ;
102+ }
103+ } ) ;
101104 this . subscriptions . add ( assessmentSub ) ;
102105
103106 const taskSub = this . activityService . currentTask$ . subscribe ( res => this . currentTask = res ) ;
@@ -169,10 +172,6 @@ export class AssessmentMobilePage implements OnInit, OnDestroy {
169172 console . error ( 'Asmt submission error:' , saved ) ;
170173 throw new Error ( "Error submitting assessment" ) ;
171174 }
172-
173- if ( this . assessment . pulseCheck === true && event . autoSave === false ) {
174- await this . assessmentService . pullFastFeedback ( ) ;
175- }
176175 } else if ( this . action === 'review' && submission . status === 'pending review' ) {
177176 const saved = await firstValueFrom ( this . assessmentService . submitReview (
178177 event . assessmentId ,
@@ -197,13 +196,13 @@ export class AssessmentMobilePage implements OnInit, OnDestroy {
197196 await this . assessmentService . pullFastFeedback ( ) ;
198197 }
199198
200- this . savingText$ . next ( $localize `Last saved ${ this . utils . getFormatedCurrentTime ( ) } ` ) ;
199+ this . savingText$ . next ( $localize `Last saved ${ this . utils . getFormatedCurrentTime ( ) } ` ) ;
201200 if ( ! event . autoSave ) {
202201 // show toast message
203202 if ( hasSubmission === true ) {
204203 this . notificationsService . assessmentSubmittedToast ( { isDuplicated : true } ) ;
205204 } else {
206- this . notificationsService . assessmentSubmittedToast ( { isReview : this . action === 'review' } ) ;
205+ this . notificationsService . assessmentSubmittedToast ( { isReview : this . action === 'review' } ) ;
207206 }
208207
209208 await this . assessmentService . fetchAssessment (
@@ -232,7 +231,7 @@ export class AssessmentMobilePage implements OnInit, OnDestroy {
232231 } catch ( err ) {
233232 this . btnDisabled$ . next ( false ) ;
234233 this . saving = false ;
235- this . notificationsService . assessmentSubmittedToast ( { isFail : true } ) ;
234+ this . notificationsService . assessmentSubmittedToast ( { isFail : true } ) ;
236235 }
237236 }
238237
@@ -246,7 +245,7 @@ export class AssessmentMobilePage implements OnInit, OnDestroy {
246245 return this . activityService . getActivity ( this . activityId , true , this . task , ( ) => {
247246 this . btnDisabled$ . next ( false ) ;
248247 } ) ;
249- } catch ( err ) {
248+ } catch ( err ) {
250249 this . btnDisabled$ . next ( false ) ;
251250 console . error ( err ) ;
252251 }
0 commit comments