Skip to content

Commit

Permalink
added a couch state
Browse files Browse the repository at this point in the history
  • Loading branch information
RheuX committed Dec 13, 2024
1 parent ec72e72 commit 30c4375
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app/courses/step-view-courses/courses-step-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export class CoursesStepViewComponent implements OnInit, OnDestroy {
combineLatest(
this.coursesService.courseUpdated$,
this.resourcesService.resourcesListener(this.parent),
this.stateService.getCouchState('exams', 'local')
this.stateService.getCouchState('exams', 'local'),
this.stateService.getCouchState('surveys', 'local')
).pipe(takeUntil(this.onDestroy$))
.subscribe(([ { course, progress = [] }, resources, exams ]: [ { course: any, progress: any }, any[], any[] ]) => {
this.initCourse(course, progress, resources.map((resource: any) => resource.doc), exams);
.subscribe(([ { course, progress = [] }, resources, exams, surveys ]: [ { course: any, progress: any }, any[], any[], any[] ]) => {
this.initCourse(course, progress, resources.map((resource: any) => resource.doc), exams, surveys);
if (this.countActivity) {
this.coursesService.courseActivity('visit', course, this.stepNum);
this.countActivity = false;
Expand Down Expand Up @@ -106,7 +107,7 @@ export class CoursesStepViewComponent implements OnInit, OnDestroy {
this.onDestroy$.complete();
}

initCourse(course, progress, resources, exams) {
initCourse(course, progress, resources, exams, surveys) {
// To be readable by non-technical people stepNum param will start at 1
this.stepDetail = course.steps[this.stepNum - 1];
this.initResources(resources);
Expand All @@ -129,7 +130,11 @@ export class CoursesStepViewComponent implements OnInit, OnDestroy {
}
if (this.stepDetail.survey) {
console.log('log: survey', this.stepDetail.survey);
// if (this.stepDetail.survey)
this.submissionsService.openSubmission({
parentId: this.stepDetail.surveys._id + '@' + course._id,
parent: surveys.find(survey => survey._id === this.stepDetail.surveys._id) || this.stepDetail.survey,
user: this.userService.get(),
type: 'survey' });
}
this.isLoading = false;
}
Expand Down

0 comments on commit 30c4375

Please sign in to comment.