@@ -7,5 +7,9 @@ import { Component } from '@angular/core'; | |||||
styleUrls: ['./app.component.scss'] | styleUrls: ['./app.component.scss'] | ||||
}) | }) | ||||
export class AppComponent { | export class AppComponent { | ||||
constructor() { | |||||
if (!localStorage.demoType) { | |||||
localStorage.demoType = 'Teacher'; | |||||
} | |||||
} | |||||
} | } |
@@ -1,14 +1,10 @@ | |||||
import { Injectable } from '@angular/core'; | import { Injectable } from '@angular/core'; | ||||
import { Observable, Observer } from 'rxjs'; | |||||
import * as moment from 'moment'; | import * as moment from 'moment'; | ||||
@Injectable({ | @Injectable({ | ||||
providedIn: 'root' | providedIn: 'root' | ||||
}) | }) | ||||
export class DemoService { | export class DemoService { | ||||
demoType: Observable<string>; | |||||
demoTypeObserver: Observer<string>; | |||||
courseData = [{ | courseData = [{ | ||||
classLevel: '10', | classLevel: '10', | ||||
courses: [{ | courses: [{ | ||||
@@ -328,9 +324,5 @@ export class DemoService { | |||||
}]; | }]; | ||||
constructor() { | constructor() { | ||||
this.demoType = Observable.create((observer: Observer<string>) => { | |||||
this.demoTypeObserver = observer; | |||||
this.demoTypeObserver.next('Teacher'); | |||||
}); | |||||
} | } | ||||
} | } |
@@ -19,7 +19,6 @@ export class CourseDetailsComponent implements OnInit { | |||||
selectedTopic: number; | selectedTopic: number; | ||||
classLevel: string; | classLevel: string; | ||||
demoTypeSubscriber: Subscription; | |||||
demoType: string; | demoType: string; | ||||
chapterList = []; | chapterList = []; | ||||
@@ -38,19 +37,11 @@ export class CourseDetailsComponent implements OnInit { | |||||
courseId = params['courseId']; | courseId = params['courseId']; | ||||
}); | }); | ||||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||||
this.demoType = type; | |||||
let courseData = this.demoService.courseData; | |||||
let course = courseData.find((courseClass) => courseClass.classLevel === classLevel).courses.find((course) => course.id === courseId); | |||||
this.heading = course.name; | |||||
this.chapterList = course.chapterList; | |||||
console.log(this.chapterList); | |||||
}); | |||||
this.demoType = localStorage.demoType; | |||||
let courseData = this.demoService.courseData; | |||||
let course = courseData.find((courseClass) => courseClass.classLevel === classLevel).courses.find((course) => course.id === courseId); | |||||
this.heading = course.name; | |||||
this.chapterList = course.chapterList; | |||||
} | } | ||||
ngOnDestroy() { | ngOnDestroy() { | ||||
@@ -1,6 +1,5 @@ | |||||
import { Component, OnInit } from '@angular/core'; | import { Component, OnInit } from '@angular/core'; | ||||
import { DemoService } from '../../services/demo.service'; | import { DemoService } from '../../services/demo.service'; | ||||
import { Subscription } from 'rxjs'; | |||||
import { Router } from '@angular/router'; | import { Router } from '@angular/router'; | ||||
@Component({ | @Component({ | ||||
@@ -9,7 +8,6 @@ import { Router } from '@angular/router'; | |||||
styleUrls: ['./courses.component.scss'] | styleUrls: ['./courses.component.scss'] | ||||
}) | }) | ||||
export class CoursesComponent implements OnInit { | export class CoursesComponent implements OnInit { | ||||
demoTypeSubscriber: Subscription; | |||||
demoType: string; | demoType: string; | ||||
classCourseList = []; | classCourseList = []; | ||||
@@ -19,17 +17,15 @@ export class CoursesComponent implements OnInit { | |||||
) { } | ) { } | ||||
ngOnInit(): void { | ngOnInit(): void { | ||||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||||
this.demoType = type; | |||||
if (type === 'Student') { | |||||
this.classCourseList = this.demoService.courseData; | |||||
this.classCourseList = this.classCourseList.filter((courseClass) => { | |||||
return courseClass.level === '10'; | |||||
}) | |||||
} else { | |||||
this.classCourseList = this.demoService.courseData; | |||||
} | |||||
}); | |||||
this.demoType = localStorage.demoType; | |||||
if (this.demoType === 'Student') { | |||||
this.classCourseList = this.demoService.courseData; | |||||
this.classCourseList = this.classCourseList.filter((courseClass) => { | |||||
return courseClass.classLevel === '10'; | |||||
}); | |||||
} else { | |||||
this.classCourseList = this.demoService.courseData; | |||||
} | |||||
} | } | ||||
goToCourse(classLevel: string, courseId: string) { | goToCourse(classLevel: string, courseId: string) { | ||||
@@ -1,7 +1,6 @@ | |||||
import { Component, OnInit } from '@angular/core'; | import { Component, OnInit } from '@angular/core'; | ||||
import { ScrollEvent } from 'ngx-scroll-event'; | import { ScrollEvent } from 'ngx-scroll-event'; | ||||
import { DemoService } from '../../services/demo.service'; | import { DemoService } from '../../services/demo.service'; | ||||
import { Subscription } from 'rxjs'; | |||||
@Component({ | @Component({ | ||||
selector: 'app-home', | selector: 'app-home', | ||||
@@ -13,7 +12,6 @@ export class HomeComponent implements OnInit { | |||||
showClassDetails: boolean; | showClassDetails: boolean; | ||||
selectedSegment: string = 'transcript'; | selectedSegment: string = 'transcript'; | ||||
showVideo: boolean = false; | showVideo: boolean = false; | ||||
demoTypeSubscriber: Subscription; | |||||
demoType: string; | demoType: string; | ||||
classList = []; | classList = []; | ||||
@@ -29,17 +27,15 @@ export class HomeComponent implements OnInit { | |||||
this.showClassDetails = false; | this.showClassDetails = false; | ||||
} | } | ||||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||||
this.demoType = type; | |||||
if (type === 'Student') { | |||||
this.classList = this.demoService.studentClassList; | |||||
this.showVideo = true; | |||||
} | |||||
this.demoType = localStorage.demoType; | |||||
if (this.demoType === 'Student') { | |||||
this.classList = this.demoService.studentClassList; | |||||
this.showVideo = true; | |||||
} | |||||
if (type === 'Teacher') { | |||||
this.classList = this.demoService.teacherClassList; | |||||
} | |||||
}); | |||||
if (this.demoType === 'Teacher') { | |||||
this.classList = this.demoService.teacherClassList; | |||||
} | |||||
} | } | ||||
public handleScroll(event: ScrollEvent) { | public handleScroll(event: ScrollEvent) { | ||||
@@ -58,8 +54,4 @@ export class HomeComponent implements OnInit { | |||||
} | } | ||||
} | } | ||||
ngOnDestroy() { | |||||
this.demoTypeSubscriber.unsubscribe(); | |||||
} | |||||
} | } |
@@ -12,8 +12,8 @@ | |||||
<figure> | <figure> | ||||
<img src="https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg"> | <img src="https://pbs.twimg.com/profile_images/3478244961/01ebfc40ecc194a2abc81e82ab877af4.jpeg"> | ||||
</figure> | </figure> | ||||
<h5> Dwayne The Rock </h5> | |||||
<p> 3000 XP </p> | |||||
<h5> {{ demoType }} </h5> | |||||
<p *ngIf="demoType === 'Student'"> 3000 XP </p> | |||||
</div> | </div> | ||||
</section> | </section> | ||||
@@ -139,7 +139,10 @@ | |||||
<button class="logout-button"> Logout </button> | <button class="logout-button"> Logout </button> | ||||
<button class="logout-button teacher-mode"> Login as Teacher </button> | |||||
<button class="logout-button teacher-mode" *ngIf="demoType === 'Student'" | |||||
(click)="changeLogin('Teacher')"> Login as Teacher </button> | |||||
<button class="logout-button teacher-mode" *ngIf="demoType === 'Teacher'" | |||||
(click)="changeLogin('Student')"> Login as Student </button> | |||||
</section> | </section> | ||||
</div> | </div> |
@@ -1,4 +1,5 @@ | |||||
import { Component, OnInit } from '@angular/core'; | import { Component, OnInit } from '@angular/core'; | ||||
import { Router } from '@angular/router'; | |||||
@Component({ | @Component({ | ||||
selector: 'app-more', | selector: 'app-more', | ||||
@@ -6,12 +7,25 @@ import { Component, OnInit } from '@angular/core'; | |||||
styleUrls: ['./more.component.scss'] | styleUrls: ['./more.component.scss'] | ||||
}) | }) | ||||
export class MoreComponent implements OnInit { | export class MoreComponent implements OnInit { | ||||
selectedSegment: string = 'badges'; | |||||
profileDetails: boolean = false; | |||||
selectedSegment: string = 'badges'; | |||||
profileDetails: boolean = false; | |||||
demoType: string; | |||||
constructor() { } | |||||
constructor( | |||||
private router: Router | |||||
) { } | |||||
ngOnInit(): void { | |||||
ngOnInit(): void { | |||||
this.demoType = localStorage.demoType; | |||||
} | } | ||||
ngOnDestroy() { | |||||
} | |||||
changeLogin(type: string) { | |||||
localStorage.demoType = type; | |||||
this.router.navigate(['welcome']); | |||||
} | |||||
} | } |
@@ -1,6 +1,5 @@ | |||||
import { Component, OnInit } from '@angular/core'; | import { Component, OnInit } from '@angular/core'; | ||||
import { DemoService } from '../services/demo.service'; | import { DemoService } from '../services/demo.service'; | ||||
import { Subscription } from 'rxjs'; | |||||
@Component({ | @Component({ | ||||
selector: 'app-welcome', | selector: 'app-welcome', | ||||
@@ -8,30 +7,26 @@ import { Subscription } from 'rxjs'; | |||||
styleUrls: ['./welcome.component.scss'] | styleUrls: ['./welcome.component.scss'] | ||||
}) | }) | ||||
export class WelcomeComponent implements OnInit { | export class WelcomeComponent implements OnInit { | ||||
demoTypeSubscriber: Subscription; | |||||
demoType: string; | |||||
classList = []; | classList = []; | ||||
demoType: string; | |||||
constructor( | constructor( | ||||
private demoService: DemoService | private demoService: DemoService | ||||
) { } | ) { } | ||||
ngOnInit(): void { | ngOnInit(): void { | ||||
this.demoTypeSubscriber = this.demoService.demoType.subscribe((type) => { | |||||
this.demoType = type; | |||||
if (type === 'Student') { | |||||
this.classList = this.demoService.studentClassList; | |||||
} | |||||
this.demoType = localStorage.demoType; | |||||
if (this.demoType === 'Student') { | |||||
this.classList = this.demoService.studentClassList; | |||||
} | |||||
if (type === 'Teacher') { | |||||
this.classList = this.demoService.teacherClassList; | |||||
} | |||||
}); | |||||
if (this.demoType === 'Teacher') { | |||||
this.classList = this.demoService.teacherClassList; | |||||
} | |||||
} | } | ||||
ngOnDestroy() { | ngOnDestroy() { | ||||
this.demoTypeSubscriber.unsubscribe(); | |||||
} | } | ||||
} | } |