Skip to content

Commit

Permalink
fjsdflk
Browse files Browse the repository at this point in the history
  • Loading branch information
carokun committed Aug 5, 2017
1 parent 11bb741 commit 411bb73
Show file tree
Hide file tree
Showing 3 changed files with 9,777 additions and 11 deletions.
23 changes: 20 additions & 3 deletions frontend/components/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Code extends React.Component {
this.setState({
code: newCode
});
this.props.newCode(newCode);
console.log(this.state.code);
}

Expand All @@ -50,10 +51,26 @@ class Code extends React.Component {
}, () => this.refs.editor.focus());
}

handleSubmit(code, language) {
runCode(code, language) {
console.log('here');
var self = this;
axios.post('http://localhost:3000/run_code', {
code: code,
language: language,
questionId: this.state.questionId
}).then(function(resp) {
console.log('self', self);
console.log('resp', resp);
self.props.makeMessage(resp);
})
.catch(err => {
console.log(err);
})
}

handleSubmit(code, language) {
console.log('here');
var self = this;
console.log('THIS.STATE', this.state);
axios.post('http://localhost:3000/run_code', {
code: code,
language: language,
Expand Down Expand Up @@ -98,7 +115,7 @@ class Code extends React.Component {
<option value="python">Python</option>
</select>
</div>
<button onClick={() => (this.handleSubmit(this.state.code, 'javascript'))} className="button is-primary">
<button onClick={() => (this.runCode(this.state.code, 'javascript'))} className="button is-primary">
<span className="icon">
<i className="fa fa-code"></i>
</span>
Expand Down
85 changes: 77 additions & 8 deletions frontend/components/Technical.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ class Technical extends React.Component {
recording: false,
minutes: 15,
seconds: 0,
interval: ''
interval: '',
code: ''
}
this.makeMessage = this.makeMessage.bind(this);
this.closeToast = this.closeToast.bind(this);
this.nextQuestion = this.nextQuestion.bind(this);
this.goToQuestions = this.goToQuestions.bind(this);
this.decrement = this.decrement.bind(this);
this.newCode = this.newCode.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -90,16 +92,84 @@ class Technical extends React.Component {
}
nextQuestion() {
// SEND THE RESPONSE
var minutes = this.state.minutes
var seconds = this.state.seconds
axios.post('http://localhost:3000/run_code', {
code: this.state.code,
language: 'javascript',
questionId: this.state.curQuestionID
}).then(function(resp) {
if (resp.data.success) {
axios.post('/tech/question1', {
minutes,
seconds,
correct: true
})
.then((resp)=> {
console.log(resp);
})
} else {
axios.post('/tech/question1', {
minutes,
seconds,
correct: false
})
.then((resp)=> {
console.log(resp);
})
}
})
.catch(err => {
console.log(err);
})
// KILL THE TIMER
this.setState({curQ: false, notLastQ: false, minutes: 30, seconds: 0})
// setTimeout(() => {
//
// }, 900000 * 2)

}
goToQuestions() {
// this.props.history.push("/question");
var minutes = this.state.minutes
var seconds = this.state.seconds

axios.post('http://localhost:3000/run_code', {
code: this.state.code,
language: 'javascript',
questionId: this.state.curQuestionID
}).then(function(resp) {
if (resp.data.success) {
axios.post('/tech/question2', {
minutes,
seconds,
correct: true
})
.then((resp)=> {
console.log(resp);
})
} else {
axios.post('/tech/question2', {
minutes,
seconds,
correct: false
})
.then((resp)=> {
console.log(resp);
})
}
})
.catch(err => {
console.log(err);
})

window.location = '/question';
}


newCode(newCode) {
this.setState({
code: newCode
});
console.log(this.state.code);
}

handleClick() {
if (!this.state.recording) {
captureUserMedia((stream) => {
Expand Down Expand Up @@ -151,7 +221,6 @@ class Technical extends React.Component {
this.setState({toast: false})
}
render() {
console.log(this.state);
return(
<div className="container is-fluid" onKeyPress={(e) => { console.log(e); }}>
<Navbar {...this.props}/>
Expand All @@ -167,7 +236,7 @@ class Technical extends React.Component {
<p className="subtitle is-4">Given a string, you need to reverse the
order of characters in each word within a sentence while still preserving whitespace and initial word order.</p>
</div>
<Code makeMessage={this.makeMessage} questionId="597dc6d1a2340df255b085aa"/>
<Code newCode={this.newCode} makeMessage={this.makeMessage} questionId="597dc6d1a2340df255b085aa"/>
</div>
:
<div>
Expand All @@ -177,7 +246,7 @@ class Technical extends React.Component {
by adding characters in front of it. Find and return the shortest palindrome you can find by performing
this transformation.</p>
</div>
<Code makeMessage={this.makeMessage} questionId="597dc6b7a2340df255b085a9"/>
<Code newCode={this.newCode} makeMessage={this.makeMessage} questionId="597dc6b7a2340df255b085a9"/>
</div>
}
<div style={{height: '30px', width: '100%'}}></div>
Expand Down
Loading

0 comments on commit 411bb73

Please sign in to comment.