import { Component, OnInit } from '@angular/core';
import { QuestService } from '../../_services/quest.service';

@Component( {
  selector: 'app-leaderboard',
  templateUrl: './leaderboard.component.html',
} )
export class LeaderboardComponent implements OnInit {

  results: Array<any>;

  constructor( private questService: QuestService ) {
  }

  ngOnInit() {
    this.results = [];
    this.questService.getLeaderboard( ( res: Response ) => {
      if (res.ok) {
            points: result.totalPoints,
            time: new Date( result.totalElapsedTime ).toISOString().substr( 11, 8 )
          } )
          ;
        } )
      }
    } )
  }

}
        let results = res.json()[ 'data' ];
        results.map( result => {
          this.results.push( {
            place: results.indexOf( result ) + 1,
            fullName: result._student.lastName + ' ' + result._student.firstName,