source: Sources/frontend/src/app/add-question/add-question.component.ts@ 8423429

Last change on this file since 8423429 was 8423429, checked in by AngelNasev <angel.nasev@…>, 17 months ago

Add backend and frontend projects

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[8423429]1import {Component} from '@angular/core';
2import {QuestionInterface} from "../QuestionInterface";
3import {CourseInterface} from "../courseInterface";
4import {ActiveUserInterface} from "../ActiveUserInterface";
5import {LoginService} from "../login.service";
6import {ActivatedRoute, Router} from "@angular/router";
7import {AddQuestionService} from "../add-question.service";
8import {CategoryInterface} from "../categoryInterface";
9import {CategoryService} from "../category.service";
10
11
12@Component({
13 selector: 'app-add-question',
14 templateUrl: './add-question.component.html',
15 styleUrls: ['./add-question.component.css']
16})
17export class AddQuestionComponent {
18 title: string | undefined;
19 content: string | undefined;
20 courseId: number | undefined;
21 question: QuestionInterface | undefined;
22 course: CourseInterface | undefined;
23 activeUser: ActiveUserInterface | undefined;
24 categories : CategoryInterface[] =[]
25 dropdownList = [];
26 selectedItems = [];
27 dropdownSettings = {};
28
29 constructor(private addQuestionService: AddQuestionService,
30 private categoryService: CategoryService,
31 private loginService: LoginService,
32 private route: ActivatedRoute,
33 private router: Router) {
34 }
35
36 ngOnInit(): void {
37 this.courseId = Number(this.route.snapshot.paramMap.get('id'));
38 this.activeUser = this.loginService.activeUser;
39 this.categoryService.getAllCategories().subscribe(response => this.categories=response);
40 this.dropdownSettings = {
41 singleSelection: false,
42 idField: 'id',
43 textField: 'name',
44 selectAllText: 'Select All',
45 unSelectAllText: 'UnSelect All',
46 itemsShowLimit: 6,
47 allowSearchFilter: false
48 };
49 if (!this.activeUser) {
50 this.router.navigate(['/'])
51 }
52 }
53
54 submit() {
55 this.addQuestionService.add(this.title!!, this.content!!, this.activeUser!!.username, this.courseId!!,this.selectedItems!!.map(cat => cat.id))
56 }
57}
Note: See TracBrowser for help on using the repository browser.