Skip to content

Commit

Permalink
Merge pull request #13 from bu-else/feature/start_tests
Browse files Browse the repository at this point in the history
Feature/start tests
  • Loading branch information
rebecca-jellinek authored Dec 20, 2017
2 parents 1f6152f + 5f2971e commit 4f7566a
Show file tree
Hide file tree
Showing 12 changed files with 2,441 additions and 600 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ A website and user system starter.

[![Build Status](https://travis-ci.org/jedireza/aqua.svg?branch=master)](https://travis-ci.org/jedireza/aqua)

## How To:

# CAT Platform

1. Clone git repo, master branch
2. Run a mongod instance
3. ’npm start’ to start device on local host + port number
4. Enable [cross-origin resource sharing](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?utm_source=gmail)
5. Sign up by creating an account
6. You will receive an email from our server
7. Click ’Start New’ to begin assessment
1. Main code in *client/pages/account/assessments/index.jsx*, uses API calls from *client/pages/account/testapi.jsx*
8. If you log out , and sign back in, click email to reset password
9. Update your information or reset your password directly when signed in.

# Based on the Aqua Framework
*description below*




## Features

Expand Down
6 changes: 6 additions & 0 deletions client/pages/account/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const NotFound = require('./not-found.jsx');
const React = require('react');
const ReactRouter = require('react-router-dom');
const Settings = require('./settings/index.jsx');
const Assess = require('./assessments/index.jsx');
const Pending = require('./pending/index.jsx');
const Results = require('./results/index.jsx');


const Route = ReactRouter.Route;
Expand All @@ -20,6 +23,9 @@ const App = (
<Switch>
<Route path="/account" exact component={Home} />
<Route path="/account/settings" exact component={Settings} />
<Route path="/assessments" exact component={Assess} />
<Route path="/pending" exact component={Pending} />
<Route path="/results" exact component={Results} />

<Route component={NotFound} />
</Switch>
Expand Down
67 changes: 67 additions & 0 deletions client/pages/account/assessments/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use strict';
const React = require('react');
const ReactHelmet = require('react-helmet');
//const Button = require('react-bootstrap/lib/Button');
const ButtonToolbar = require('react-bootstrap/lib/ButtonToolbar');
//const ButtonGroup = require('react-bootstrap/lib/ButtonGroup');
const DropdownButton = require('react-bootstrap/lib/DropdownButton');
const MenuItem = require('react-bootstrap/lib/MenuItem');
const Helmet = ReactHelmet.Helmet;
const TestAPI = require('../testapi');
const url = 'http://128.31.24.189:8001/api/survey/start/';
const fetch = require('fetch-api');
const axios = require('axios');

class AssessPage extends React.Component {

constructor(props) {
super(props);

}

render() {

const buttonsInstance = (
<ButtonToolbar>
<DropdownButton title="Dropdown" id="bg-nested-dropdown">
<MenuItem eventKey="1">Dr</MenuItem>
<MenuItem eventKey="2">Dropdown link</MenuItem>
</DropdownButton>
</ButtonToolbar>

);



return (
<section className="section-about container">
<Helmet>
<title>Start Assessment</title>
</Helmet>
<div className="row">
<div className="col-sm-6">
<h1 className="page-header">Take an assessment</h1>
<div>
<h4>Instructions</h4>
<li>Select List Forms to display available instruments.</li>
<li>Select an instrument and then click the 'Order Form' button to order the instrument.</li>
<li>Click the 'Administer Form' button to start the assessment.</li>
<li>Refresh page to try another instrument.</li>
<li>The 'Display Form' button will preview an instrument (display all items in the instrument).</li>
</div>
{/*<div className="buttonsInstance">{buttonsInstance}</div>*/}

{/*TestAPI component is a child of Index component*/}
<TestAPI/>

</div>

<hr />
</div>
</section>
);
}
}


module.exports = AssessPage;
4 changes: 2 additions & 2 deletions client/pages/account/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ class Navbar extends React.Component {
<li className={this.classForPath('/assessments')}>
<Link to="/assessments">Start New</Link>
</li>
<li className={this.classForPath('/pending')}>
<li className={this.classForPath('/account/pending')}>
<Link to="/pending">Pending Tests</Link>
</li>
<li className={this.classForPath('/results')}>
<li className={this.classForPath('/account/results')}>
<Link to="/results">Test Results</Link>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ReactHelmet = require('react-helmet');
const Helmet = ReactHelmet.Helmet;


class AssessPage extends React.Component {
class PendingPage extends React.Component {
render() {

return (
Expand Down Expand Up @@ -75,4 +75,4 @@ class AssessPage extends React.Component {
}


module.exports = AssessPage;
module.exports = PendingPage;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const ReactHelmet = require('react-helmet');
const Helmet = ReactHelmet.Helmet;


class AssessPage extends React.Component {
class ResultsPage extends React.Component {
render() {

return (
Expand Down Expand Up @@ -77,4 +77,4 @@ class AssessPage extends React.Component {
}


module.exports = AssessPage;
module.exports = ResultsPage;
145 changes: 145 additions & 0 deletions client/pages/account/testapi.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// require the module
const React = require('react');
const url = 'http://128.31.24.189:8001/api/survey/start/';
const axios = require('axios');
const _ = require('underscore');

class TestAPI extends React.Component {

constructor(props) {
super(props);
this.state = {
questions: [],
responses: [],
selectedOption: [],
score: 0
// surveyID: '',
// userID: ''
};
//React components using ES6 classes no longer autobind this to non React methods.
this.handleFormReset = this.handleFormReset.bind(this);
this.handleFormSubmit = this.handleFormSubmit.bind(this);
}

componentDidMount() {
// this is where you make the axios call

axios.get(url)
.then(({ data })=> {
console.log(data); // entire json array
this.setState(
{questions: data.questions}
);

_.map(this.state.questions, question => {
this.setState({responses: question.responseOptions });
});

_.map(this.state.responses, response => {
this.setState({selectedOption: response.value});
});


})
.catch(function(error) {
if (error.response) {
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
console.log(error.request);
} else {
console.log('Error', error.message);
}
console.log(error.config);
});

}

render () {

return (
<div className ="container1">
<div className="container2">
<form onSubmit={this.handleFormSubmit} onReset={this.handleFormReset}>
{this.renderQuestions()}
<button className="btn btn-default" type="submit">Submit Responses</button>
<button className="btn btn-default" type="reset">Reset Responses</button>
</form>

{/*{this.renderRadioButtons()}*/}

</div>
</div>
);

}

// handleOptionChange(changeEvent) {
// this.setState({
// selectedOption: changeEvent.target.value
// });
// }

handleFormSubmit(formSubmitEvent) {
formSubmitEvent.preventDefault();
console.log('You have selected to submit');
this.setState({
score: 100
});
console.log(this.state.score);
}

handleFormReset(formSubmitEvent) {
formSubmitEvent.preventDefault();
console.log('You have selected to reset');
this.setState({
selectedOption: []
});
console.log(this.state.selectedOption);
}


renderQuestions() {

console.log(this.state.questions);

console.log(this.state.responses); // the state of responses at a given time

return _.map(this.state.questions, question => {

var question_text= question.questionText;

//var question_id = question.tabindex;

return ( _.map(question.responseOptions, response => {

var response_text = response.displayText;
var response_id = response.id;

// currently returning the question multiple times
// how do i get it to show the question once, and then a list of responses for every question?
return (

<ul><label>{question_text}</label>
<ul key ={response_id}></ul>

{/*// <input type='radio' value ="response option">{response_text}</input>*/}
<ul>
<button type = "button"ç>{response_text}</button>
</ul>
</ul>

);
}));
}

);


}
}


module.exports = TestAPI;

8 changes: 2 additions & 6 deletions client/pages/main/app-universal.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';
const About = require('./about/index.jsx');

const Assess = require('./assessments/index.jsx');

const Contact = require('./contact/index.jsx');
const Footer = require('./footer.jsx');
const Home = require('./home/index.jsx');
Expand All @@ -10,10 +12,8 @@ const LoginLogout = require('./login/logout/index.jsx');
const LoginReset = require('./login/reset/index.jsx');
const Navbar = require('./navbar.jsx');
const NotFound = require('./not-found.jsx');
const Pending = require('./pending/index.jsx');
const React = require('react');
const ReactRouter = require('react-router-dom');
const Results = require('./results/index.jsx');
const RouteRedirect = require('../../components/route-redirect.jsx');
const Signup = require('./signup/index.jsx');

Expand All @@ -36,10 +36,6 @@ const AppUniversal = function () {
<Route path="/login/reset/:email/:key" component={LoginReset} />
<Route path="/login/logout" exact component={LoginLogout} />
<Route path="/signup" exact component={Signup} />
<Route path="/assessments" exact component={Assess} />
<Route path="/pending" exact component={Pending} />
<Route path="/results" exact component={Results} />

<RouteRedirect from="/moved" to="/" code={301} />

<Route component={NotFound} />
Expand Down
Loading

0 comments on commit 4f7566a

Please sign in to comment.