<commit_before>import React, { Component } from 'react';
import Plates from './Plates.js'
import Answers from './Answers.js'
import Results from './Results.js'
import Bar from './Bar.js'

function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
};

class Quiz extends Component {
  constructor(props) {
    super(props);

    // here we're generating all the styles and numbers that will
    // be part of the test.
    // TODO(aazevedo): make sure we cover all the styles at least once
    this.questions = [];
    for (let i = 0; i < props.numberOfQuestions; ++i) {
      if(i === 0){
        this.questions.push(
          {testType: 5, number: getRandomInt(1, 9)});
      }else{
        this.questions.push(
          {testType: getRandomInt(0, 7), number: getRandomInt(1, 9)});
      }
    }

    this.state = {
      answers: [],
      progress: 0.059 //=100%/17
    };
    this.onAnswerClicked = this.onAnswerClicked.bind(this);
  }

  onAnswerClicked(answer) {
    this.state.answers.push(answer);
    this.setState({ answers: this.state.answers, progress: this.state.progress + 0.059 });
  }

  computeResults() {
    let numCorrect = 0;
    this.questions.forEach((question, i) => {
      numCorrect += question.number == this.state.answers[i] ? 1 : 0;
    });
    return numCorrect;
  }

  render() {
    // console.log(currentQuestion + " " + this.state.answers)
    let currentQuestion = this.state.answers.length;
    if(currentQuestion == 1 && this.computeResults() == 0){
      currentQuestion = 17;
    }
    if(currentQuestion >= this.questions.length){
      return(
        <Results numCorrect={this.computeResults()} numberOfQuestions={this.questions.length}/>
        );
    }
    const question = this.questions[currentQuestion];<commit_msg>Change progress bar percentage to start from 0%.<commit_after>import React, { Component } from 'react';
import Plates from './Plates.js'
import Answers from './Answers.js'
import Results from './Results.js'
import Bar from './Bar.js'

function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);
  return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
};

class Quiz extends Component {
  constructor(props) {
    super(props);

    // here we're generating all the styles and numbers that will
    // be part of the test.
    // TODO(aazevedo): make sure we cover all the styles at least once
    this.questions = [];
    for (let i = 0; i < props.numberOfQuestions; ++i) {
      if(i === 0){
        this.questions.push(
          {testType: 5, number: getRandomInt(1, 9)});
      }else{
        this.questions.push(
          {testType: getRandomInt(0, 7), number: getRandomInt(1, 9)});
      }
    }

    this.state = {
      answers: [],
      progress: 0
    };
    this.onAnswerClicked = this.onAnswerClicked.bind(this);
  }

  onAnswerClicked(answer) {
    this.state.answers.push(answer);
    this.setState({ answers: this.state.answers, progress: this.state.progress + 0.059 }); //=100%/17
  }

  computeResults() {
    let numCorrect = 0;
    this.questions.forEach((question, i) => {
      numCorrect += question.number == this.state.answers[i] ? 1 : 0;
    });
    return numCorrect;
  }

  render() {
    // console.log(currentQuestion + " " + this.state.answers)
    let currentQuestion = this.state.answers.length;
    if(currentQuestion == 1 && this.computeResults() == 0){
      currentQuestion = 17;
    }
    if(currentQuestion >= this.questions.length){
      return(
        <Results numCorrect={this.computeResults()} numberOfQuestions={this.questions.length}/>
        );
    }
    const question = this.questions[currentQuestion];
{'fraction_non_alphanumeric': 0.14367666232073012, 'fraction_numerical': 0.014602346805736636, 'mean_word_length': 2.859154929577465, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3182364', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1182, 'n_words': 300}