<commit_before>var React = require('react-native');
var NavBar = require('./../../shared/navbar');
var Button = require('./../../shared/button');

var {
  View,
  Text,
} = React;

// class ToggleButton extends React.Component {
//   constructor(props)
//   submitAnswer(answer) {
//     // send socket with answer
//     this.socket.emit('studentConnect', {
//       userId: this.state.userId,

//     })
//       this.props.navigator.pop();
//     // go to previous page
//   }
//   render() {
//     return (
//       <TouchableHighlight underlayColor='#FF0000' style={styles.button} onPress={this.submitAnswer.bind(this, this.props.label)}>
//         <Text>{this.props.label}</Text>
//       </TouchableHighlight>
//     )
//   }
// }

class MultiChoice extends React.Component {
  constructor (props){
    super(props);
    this.state = {
      pollInfo: this.props.route.pollInfo,
      userId: this.props.route.userId,
      socket: this.props.route.socket
    };
  }  

  submitAnswer(answer) {
    console.log('Student',this.state.userId,'answered',answer,'to poll',this.state.pollInfo.pollId);
    // send socket with answer
    this.state.socket.emit('studentResponse', {
      userId: this.state.userId,
      answer: answer,
      pollId: this.state.pollInfo.pollId
    })
    this.props.navigator.pop();<commit_msg>Add socket listener for poll close<commit_after>var React = require('react-native');
var NavBar = require('./../../shared/navbar');
var Button = require('./../../shared/button');

var {
  View,
  Text,
} = React;

class MultiChoice extends React.Component {
  constructor (props){
    super(props);
    this.socket = this.props.route.socket;
    this.userId = this.props.route.userId;
    this.pollInfo = this.props.route.pollInfo;

    this.socket.on('closePoll', function(data) {
      this.props.navigator.pop();
    });
  }  

  submitAnswer(answer) {
    console.log('Student',this.userId,'answered',answer,'to poll',this.pollInfo.pollId);
    // send socket with answer
    this.socket.emit('studentResponse', {
      userId: this.userId,
      answer: answer,
      pollId: this.pollInfo.pollId
    })
    this.props.navigator.pop();
{'fraction_non_alphanumeric': 0.1695852534562212, 'fraction_numerical': 0.0018433179723502304, 'mean_word_length': 2.8021015761821366, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2765575', 'n_tokens_mistral': 683, 'n_tokens_neox': 676, 'n_words': 117}