import { Component, OnInit, Input } from '@angular/core';

import { CourseData } from '../../../structures/course-data';

@Component({
  selector: 'app-instructor-evaluation-block',
  templateUrl: './instructor-evaluation-block.component.html',
  styleUrls: ['./instructor-evaluation-block.component.scss']
})
export class InstructorEvaluationBlockComponent implements OnInit {

  @Input() courses: CourseData[] = [];
  @Input() instructorId: number = 0;

  evaluatedAtCourses: CourseData[] = [];

  showList: boolean = false;

  constructor() { 
  }

  ngOnInit(): void {
    this.evaluatedAtCourses = this.courses.filter(course => {
      var found = course.instructors?.find(instructor => { return instructor.instructorId == this.instructorId; });
      if(found != undefined) {
        return found.evaluation != null;
      }
      return false;
    });
  }

}
