diff --git a/common/app/routes/Hikes/components/Question.jsx b/common/app/routes/Hikes/components/Question.jsx
index 0172c9b2e8..30c04a281f 100644
--- a/common/app/routes/Hikes/components/Question.jsx
+++ b/common/app/routes/Hikes/components/Question.jsx
@@ -1,14 +1,15 @@
import React, { PropTypes } from 'react';
-import { Navigation } from 'react-router';
+import { Navigation, TransitionHook } from 'react-router';
import stampit from 'react-stampit';
import { contain } from 'thundercats-react';
+import debugFactory from 'debug';
import {
Button,
Col,
- Row,
- Panel
+ Modal,
+ Panel,
+ Row
} from 'react-bootstrap';
-import debugFactory from 'debug';
const debug = debugFactory('freecc:hikes');
@@ -41,6 +42,7 @@ export default contain(
}
},
stampit(React, {
+ state: { showInfo: false },
displayName: 'Question',
propTypes: {
@@ -50,24 +52,78 @@ export default contain(
tests: PropTypes.array
},
- onAnswer(answer, userAnswer, e) {
+ onAnswer(answer, userAnswer, info, e) {
if (e && e.preventDefault) {
e.preventDefault();
}
if (answer === userAnswer) {
debug('correct answer!');
- return this.onCorrectAnswer();
+ this.setState({ showInfo: true });
}
return debug('incorrect');
},
onCorrectAnswer() {
+ const { hikes, currentHike } = this.props;
const { dashedName, number } = this.props.params;
- const nextQ = +number + 1;
- this.transitionTo(`/hikes/${ dashedName }/questions/${ nextQ }`);
+ const { difficulty, tests } = currentHike;
+ const nextQuestionIndex = +number;
+ this.setState({ showInfo: false }, () => {
+ if (tests[nextQuestionIndex]) {
+ return this.transitionTo(
+ `/hikes/${ dashedName }/questions/${ nextQuestionIndex + 1 }`
+ );
+ }
+ // next questions does not exit
+ // find next hike
+ //
+ const nextHike = hikes
+ // hikes is in oder of difficulty, lets get reverse order
+ .reverse()
+ // now lets find the hike with the difficulty right above this one
+ .reduce((lowerHike, hike) => {
+ if (hike.difficulty > difficulty) {
+ return hike;
+ }
+ return lowerHike;
+ }, null);
+
+ if (nextHike) {
+ return this.transitionTo(`${ nextHike.dashedName }`);
+ }
+ debug('next Hike was not found');
+ });
+ },
+
+ routerWillLeave(/* nextState, router, cb[optional] */) {
+ // TODO(berks): do animated transitions here stuff here
+ },
+
+ renderInfo(showInfo, info) {
+ return (
+
+
+
+ { info || 'correct!' }
+
+
+
+
+
+
+ );
},
render() {
+ const { showInfo } = this.state;
const { tests } = this.props;
const { number = '1' } = this.props.params;
@@ -81,17 +137,18 @@ export default contain(
{ question }
+ { this.renderInfo(showInfo, info) }
@@ -99,5 +156,7 @@ export default contain(
);
}
- }).compose(Navigation)
+ })
+ .compose(Navigation)
+ .compose(TransitionHook)
);
diff --git a/gulpfile.js b/gulpfile.js
index 8569da9928..28cef3e44a 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -43,6 +43,7 @@ var paths = {
'node_modules/',
'client/'
],
+
publicJs: './public/js',
loopback: {