<commit_before>
'use strict';

import React, { Component } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { Grid, Row, Col } from 'react-bootstrap';

import Modal from './Modal';
import Navbar from './Navbar';
import Statusbar from './Statusbar';
import Editor from './Editor';
import ChallengePanel from './ChallengePanel';

/**
 * Top-level component for the app. This is rendered in App.jsx.
 */
export default class ArcadeMode extends Component {

  constructor(props) {
    super(props);

    this.onClickRunTests = this.onClickRunTests.bind(this);
    this.onClickNextChallenge = this.onClickNextChallenge.bind(this);
    this.onClickStartChallenge = this.onClickStartChallenge.bind(this);
    this.onClickFinishSession = this.onClickFinishSession.bind(this);
    this.onCodeChange = this.onCodeChange.bind(this);
    this.onTimerMaxValueChange = this.onTimerMaxValueChange.bind(this);
    this.onClickSolve = this.onClickSolve.bind(this);
  }

  onCodeChange(newCode) {
    console.log('Emitting new code from <ArcadeMode>');
    this.props.onCodeChange(newCode);
  }

  onClickNextChallenge() {
    const startTime = new Date().getTime();
    this.props.nextChallenge(startTime);
  }

  onClickRunTests() {
    if (!this.props.isRunningTests) {
      this.props.runTests(this.props.code, this.props.currChallenge);
    }
  }

  onClickStartChallenge() {
    const startTime = new Date().getTime();
    this.props.startChallenge(startTime);
    if (this.props.mode === 'Arcade') {
      this.props.startTimer(this.props.timerMaxValue);
    }
  }

  onClickFinishSession() {
    if (!this.props.isTimerFinished) {
      this.props.stopTimer();
    }
    this.props.finishSession();
  }

  /* Inserts the solution for current challenge into the editor. */
  onClickSolve() {
    this.props.solveChallenge();
  }

  onTimerMaxValueChange(e) {
    const inputValue = e.target.value;
    this.props.onTimerMaxValueChange(inputValue);
  }

  processTestResults() {
    const results = this.props.testResults;
    let testsOk = true;
    if (results.size) {
      results.forEach(result => { testsOk = testsOk && result.pass; });
    }<commit_msg>add current time to stopTimer call<commit_after>
'use strict';

import React, { Component } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { Grid, Row, Col } from 'react-bootstrap';

import Modal from './Modal';
import Navbar from './Navbar';
import Statusbar from './Statusbar';
import Editor from './Editor';
import ChallengePanel from './ChallengePanel';

/**
 * Top-level component for the app. This is rendered in App.jsx.
 */
export default class ArcadeMode extends Component {

  constructor(props) {
    super(props);

    this.onClickRunTests = this.onClickRunTests.bind(this);
    this.onClickNextChallenge = this.onClickNextChallenge.bind(this);
    this.onClickStartChallenge = this.onClickStartChallenge.bind(this);
    this.onClickFinishSession = this.onClickFinishSession.bind(this);
    this.onCodeChange = this.onCodeChange.bind(this);
    this.onTimerMaxValueChange = this.onTimerMaxValueChange.bind(this);
    this.onClickSolve = this.onClickSolve.bind(this);
  }

  onCodeChange(newCode) {
    console.log('Emitting new code from <ArcadeMode>');
    this.props.onCodeChange(newCode);
  }

  onClickNextChallenge() {
    const startTime = new Date().getTime();
    this.props.nextChallenge(startTime);
  }

  onClickRunTests() {
    if (!this.props.isRunningTests) {
      this.props.runTests(this.props.code, this.props.currChallenge);
    }
  }

  onClickStartChallenge() {
    const startTime = new Date().getTime();
    this.props.startChallenge(startTime);
    if (this.props.mode === 'Arcade') {
      this.props.startTimer(this.props.timerMaxValue);
    }
  }

  onClickFinishSession() {
    const timeNow = new Date().getTime();
    this.props.stopTimer(timeNow);
    this.props.finishSession();
  }

  /* Inserts the solution for current challenge into the editor. */
  onClickSolve() {
    this.props.solveChallenge();
  }

  onTimerMaxValueChange(e) {
    const inputValue = e.target.value;
    this.props.onTimerMaxValueChange(inputValue);
  }

  processTestResults() {
    const results = this.props.testResults;
    let testsOk = true;
    if (results.size) {
      results.forEach(result => { testsOk = testsOk && result.pass; });
    }
{'fraction_non_alphanumeric': 0.12743998205070675, 'fraction_numerical': 0.0, 'mean_word_length': 3.8562091503267975, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4769729', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1381, 'n_words': 279}