Skip to content
Snippets Groups Projects
lecturer-create-omp-view.component.ts 2.26 KiB
Newer Older
import {Component, OnDestroy, OnInit} from '@angular/core';
import {LecturerInfoService} from 'src/app/services/lecturer-info.service';
import {LecturerDataService} from 'src/app/services/lecturer-data.service';
import {LecturerViewService} from 'src/app/services/lecturer-view.service';
import {Router} from '@angular/router';
import {QuestionDao} from 'src/app/dao/question.dao';
import {OmpClassDao} from 'src/app/dao/omp-class.dao';

@Component({
  selector: 'app-lecturer-create-omp-view',
  templateUrl: './lecturer-create-omp-view.component.html',
  styleUrls: ['./lecturer-create-omp-view.component.css']
})
export class LecturerCreateOmpViewComponent implements OnInit, OnDestroy {

  public isTemplate: Boolean;
  public questions: QuestionDao[];
  public classes: OmpClassDao[];
  public name: String;
  public topic: String;
  public currentClass: OmpClassDao;
  constructor(private lecturerInfoService: LecturerInfoService,
              private lecturerDataService: LecturerDataService,
              private lecturerViewService: LecturerViewService,
              private router: Router) {
  }

  ngOnInit(): void {
    this.questions = [];
    this.classes = [];
    this.initialiseForms();
    this.questions = [];
    this.classes = [];
  private getClasses(): void {
    this.lecturerInfoService.getLecturerClasses(this.lecturerDataService.lecturerId)
      .subscribe((data: OmpClassDao[]) => data.forEach(e => {
        this.classes.push(e);
        this.currentClass = this.classes[0];
      }));
  }
  private initialiseForms(): void {
    this.name = 'Enter a name for this one-minute paper!';
    this.topic = 'Enter a topic for this one-minute paper';
    this.isTemplate = this.lecturerDataService.isTemplate;
    this.getClasses();
      // TODO - if (template) then define template array list
    this.isAnonymous = false;
    this.addQuestion();
  }

  public createPaper(): void {

  }

  public createTemplate(): void {

  }

  public flipIsAnonymous(): void {
    this.isAnonymous = !this.isAnonymous;
  }

  public addQuestion(): void {
    this.questions.push(new QuestionDao('', '', 'Enter your question text!'));
  public removeQuestion(index: number): void {
    this.questions.splice(index, 1);