<commit_before>import { Component, OnInit } 			from '@angular/core';
import { Router, ActivatedRoute, Params }	from '@angular/router';

import 'rxjs/add/operator/switchMap';

//import { DataService } from './data.service';
import { AssessmentsService } 			from './assessments.service';
//import { Course } 				from '../model/course';
//import { Group } 				from '../model/group';
//import { Assessment } from './model/assessment';
//import { Student } from './model/student';
//import { AssessmentStats } from './model/assessment-stats';
//import { Stats } from './model/stats';
import { BreadcrumbSelectorSelect } 		from '../utils/breadcrumb-selector.component';
import { BreadcrumbSelectorEvent } 		from '../utils/breadcrumb-selector.component';

@Component({
    moduleId: module.id,
    templateUrl: './assessment-selector.component.html',
    styleUrls: ['./assessment-selector.component.css'],
    providers: [ AssessmentsService ]
})
export class AssessmentSelectorComponent implements OnInit {
    selects: BreadcrumbSelectorSelect[] = [];
    selectedYear: string;
    selectedCourseId: string;
    selectedGroupId: string;
  
    checkedButtonId: string;  
	
    constructor(
	private assessmentsService: AssessmentsService,
	private route: ActivatedRoute,
	private router: Router
    ) {}

    ngOnInit() {
	/*let group_id = this.route.snapshot.params['group_id'];
	console.log('AssessmentSelector - group_id:' + group_id);*/
	this.route.params
	    .switchMap((params: Params) => {
		const year = params['year'];
		if (year != undefined) {
		    this.selectedYear = year;
		}
		else {
		    return this.assessmentsService.getGroupsSelectYear();
		}
	    });
	this.assessmentsService.getGroupsSelectYear()
	    .subscribe(select => this.selects.push(select));
    }

    onSelectorChanged(event: BreadcrumbSelectorEvent) {
	let value = event.select_value;
	switch(event.select_id) {
	    case 'year':
		this.selectedGroup = null;
		this.selectedCourse = null;
                
		while(this.selects.length > 1) {
		    this.selects.pop();
		}
		
		if (value == -1) {
		    this.selectedYear = null;
		}
 		else {
		    this.selectedYear = value;
		    this.assessmentsService.getGroupsSelectCourse(this.selectedYear)
			.subscribe(select => this.selects.push(select));
		}
		break;
	    case 'course':<commit_msg>Assessments modularization WIP.<commit_after>import { Component, OnInit } 			from '@angular/core';
import { Router, ActivatedRoute, Params }	from '@angular/router';

import 'rxjs/add/operator/switchMap';

//import { DataService } from './data.service';
import { AssessmentsService } 			from './assessments.service';
//import { Course } 				from '../model/course';
//import { Group } 				from '../model/group';
//import { Assessment } from './model/assessment';
//import { Student } from './model/student';
//import { AssessmentStats } from './model/assessment-stats';
//import { Stats } from './model/stats';
import { BreadcrumbSelectorSelect } 		from '../utils/breadcrumb-selector.component';
import { BreadcrumbSelectorEvent } 		from '../utils/breadcrumb-selector.component';

@Component({
    moduleId: module.id,
    templateUrl: './assessment-selector.component.html',
    styleUrls: ['./assessment-selector.component.css'],
    providers: [ AssessmentsService ]
})
export class AssessmentSelectorComponent implements OnInit {
    selects: BreadcrumbSelectorSelect[] = [];
    selectedYear: string = null;
    selectedCourseId: string = null;
    selectedGroupId: string = null;
  
    checkedButtonId: string;  
	
    constructor(
	private assessmentsService: AssessmentsService,
	private route: ActivatedRoute,
	private router: Router
    ) {}

    ngOnInit() {
	/*let group_id = this.route.snapshot.params['group_id'];
	console.log('AssessmentSelector - group_id:' + group_id);*/
	this.route.params
	    .switchMap((params: Params) => {
		const year = params['year'];
		const course_id = params['course_id'];
		const group_id = params['group_id'];
		let yearObservable = Observable.empty();
		let courseObservable = Observable.empty();
		let groupObservable =  Observable.empty();

		if (year == undefined || this.selectedYear == null) {
		    yearObservable = this.assessmentsService.getGroupsSelectYear();
		}
		else {
		    if (year != this.selectedYear) {
			this.selectedYear = year;
			courseObservable = this.assessmentsService.getGroupsSelectCourse(year);
		    }
		    else {
		  	if ((course_id != undefined && course_id != this.selectedCourseId) || group_id == undefined) {
			    this.selectedCourseId = course_id;
			    groupObservable = this.assessmentsService.getGroupsSelectGroup(year, course_id)
			} 
		    }
		}
	    }).subscribe(select => this.selects.push(select));
    }

    onSelectorChanged(event: BreadcrumbSelectorEvent) {
	let value = event.select_value;
	switch(event.select_id) {
	    case 'year':
		this.selectedGroup = null;
		this.selectedCourse = null;
                
		while(this.selects.length > 1) {
		    this.selects.pop();
		}
		
		if (value == -1) {
		    this.selectedYear = null;
		}
 		else {
		    this.selectedYear = value;
		    this.assessmentsService.getGroupsSelectCourse(this.selectedYear)
			.subscribe(select => this.selects.push(select));
		}
		break;
	    case 'course':
{'fraction_non_alphanumeric': 0.13785890853774482, 'fraction_numerical': 0.0007606008746910059, 'mean_word_length': 3.542314335060449, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931063', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1579, 'n_words': 318}