on question complete, ping /completed-challenges
parent
6de5ad682e
commit
e88b5a81c4
|
@ -9,7 +9,8 @@ import {
|
||||||
Panel,
|
Panel,
|
||||||
Row
|
Row
|
||||||
} from 'react-bootstrap';
|
} from 'react-bootstrap';
|
||||||
import { ajax$ } from '../../../../utils/ajax$.js';
|
|
||||||
|
import { postJSON$ } from '../../../../utils/ajax-stream.js';
|
||||||
|
|
||||||
const debug = debugFactory('freecc:hikes');
|
const debug = debugFactory('freecc:hikes');
|
||||||
const ANSWER_THRESHOLD = 200;
|
const ANSWER_THRESHOLD = 200;
|
||||||
|
@ -146,12 +147,8 @@ export default React.createClass({
|
||||||
const { dashedName, number } = this.props.params;
|
const { dashedName, number } = this.props.params;
|
||||||
const { id, name, difficulty, tests } = currentHike;
|
const { id, name, difficulty, tests } = currentHike;
|
||||||
const nextQuestionIndex = +number;
|
const nextQuestionIndex = +number;
|
||||||
const ajaxOptions = {
|
|
||||||
url: '/completed-challenge',
|
postJSON$('/completed-challenge', { id, name }).subscribeOnCompleted(() => {
|
||||||
method: 'POST',
|
|
||||||
body: { id, name }
|
|
||||||
};
|
|
||||||
ajax$(ajaxOptions).subscribeOnCompleted(() => {
|
|
||||||
if (tests[nextQuestionIndex]) {
|
if (tests[nextQuestionIndex]) {
|
||||||
return this.transitionTo(
|
return this.transitionTo(
|
||||||
`/hikes/${ dashedName }/questions/${ nextQuestionIndex + 1 }`
|
`/hikes/${ dashedName }/questions/${ nextQuestionIndex + 1 }`
|
||||||
|
|
Loading…
Reference in New Issue