Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random quiz #4

Merged
merged 1 commit into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
127 changes: 127 additions & 0 deletions src/views/tutorial/randomTutorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import React from 'react';
import TutorialHeader from './tutorialHeader'

export default class RandomQuiz extends React.Component {
constructor(props) {
super(props);
this.state = {
lists: [],
identifier: 1,
};
}

componentDidMount() {
fetch("https://opentdb.com/api.php?amount=10&category=19&type=boolean")
.then(response => response.json())
.then(data => this.setState({ lists: data.results }));
}

render() {
let { lists, identifier } = this.state;
lists.forEach(function(list){
list.identifier = identifier++
});
console.log(lists);

return (
<>
<TutorialHeader />
<ul>
<div className="">
<h1>Random Trivia Test</h1>
<h2>Take the quick quiz</h2>
</div>
<div>
{lists.map(list => <ul key={list.id}>
<div className='questionList'>
<span className='identifier' >{list.identifier}. </span>
<div dangerouslySetInnerHTML={{ __html: list.question }} />
</div>
<p>{list.incorrect_answers + ',' + list.correct_answer}</p>
</ul>)
}
</div>
</ul>
</>
);
}
};


// import React, { useState, useEffect } from 'react';
// import { Link } from 'react-router-dom';
// import { makeStyles } from '@material-ui/core/styles';
// import GridList from '@material-ui/core/GridList';
// import GridListTile from '@material-ui/core/GridListTile';
// import GridListTileBar from '@material-ui/core/GridListTileBar';
// import './vendor.scss';
// import axios from 'axios';
// import Loader from 'react-loader-spinner';

// const useStyles = makeStyles(theme => ({
// root: {
// display: 'flex',
// flexWrap: 'wrap',
// justifyContent: 'space-around',
// overflow: 'hidden',
// backgroundColor: theme.palette.background.paper,
// },
// gridList: {
// flexWrap: 'nowrap',
// // Promote the list into his own layer on Chrome. This cost memory but helps keeping high FPS.
// transform: 'translateZ(0)',
// },
// title: {
// color: theme.palette.primary.light,
// },
// titleBar: {
// background:
// 'linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.3) 70%, rgba(0,0,0,0) 100%)',
// },
// }));

// function VendorList() {
// const classes = useStyles();
// const [data, setData] = useState({ vendorlists: [], loading: true });
// useEffect(() => {
// const fetchData = async () => {
// const result = await axios(
// 'https://service-mart-api.herokuapp.com/api/vendors',
// );
// setData(result.data);
// };
// fetchData();
// }, []);

// if (data.loading) {
// return <Loader
// className='loader'
// type="Puff"
// color="#00BFFF"
// height={80}
// width={80}
// timeout={10000}
// />;
// }

// return (
// <div className={classes.root}>
// <GridList className={classes.gridList} cols={2.5}>
// {data.vendorlists.filter(vendorlist => vendorlist.id <= 5).map(vendorlist => (
// <GridListTile key={vendorlist.id}>
// <img className='image' src={'https://res.cloudinary.com/dendekky/image/upload/v1578347606/serv-mart/serv-mart/blackmakeupartist_nm1uil.jpg'}/>
// <Link to={`/vendorlist/${vendorlist.id}`} className='link'>
// <GridListTileBar
// title={vendorlist.agency_name}
// classes={{
// root: classes.titleBar,
// title: classes.title,
// }}
// /></Link>
// </GridListTile>
// ))}
// </GridList>
// </div>
// );
// }
// export default VendorList;
10 changes: 10 additions & 0 deletions src/views/tutorial/tutorial.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@
// opacity: 0.5;
}
};

.questionList {
display: flex;
flex-direction: row;
.identifier {
margin-right: 5px;
}
}


2 changes: 1 addition & 1 deletion src/views/tutorial/tutorialHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TutorialHeader = () => {
</Tooltip>
}>
<NavDropdown title="TESTS" id="basic-nav-dropdown">
<NavDropdown.Item href="#action/3.1">Random Fun Quiz</NavDropdown.Item>
<NavDropdown.Item href="/randomtests">Random Fun Quiz</NavDropdown.Item>
<NavDropdown.Item href="#action/3.2">Zenith Quiz</NavDropdown.Item>
</NavDropdown>
</OverlayTrigger>
Expand Down