Skip to content

Commit

Permalink
Styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Olyathecute committed Apr 11, 2022
1 parent 2f65a61 commit ec9a46a
Show file tree
Hide file tree
Showing 26 changed files with 388 additions and 369 deletions.
72 changes: 8 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,14 @@
# Getting Started with Create React App
# Quiz with API data

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## How to start

## Available Scripts
1. npm i
2. node index.js

In the project directory, you can run:
- Base local url: http://localhost:7777

### `npm start`
3. npm start

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
---

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
## Demonstration
112 changes: 58 additions & 54 deletions api/apiDoc.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,79 @@
# Basic local Quiz Api

Edit quizData to create your own quizzes

## how to run
1. npm i

1. npm i
2. node index.js

## Base local url: http://localhost:7777

<br>

# API description

**All Quizzes**
----
Returns json data about all available quizzes.
## **All Quizzes**

Returns json data about all available quizzes.

* **URL**
- **URL**

/all

* **Method:**
- **Method:**

`GET`

- **Success Response:**

* **Success Response:**

* **Code:** 200 <br />
**Content:**
- **Code:** 200 <br />
**Content:**
```js
[
{
"id": 1,
"name": "Квиз пример",
"description": "какое-то описание квиза",
"picture": "ссылка куда-нибудь",
"name": "Quiz example",
"description": "quiz description",
"picture": "something href or img",
"questionsCount": 3
},
...
]
```

**Start quiz**
----
Returns first quiz question.

* **URL**
**Start quiz**

---

Returns first quiz question.

- **URL**

/start/:id

* **Method:**
- **Method:**

`GET`

* **URL Params**

**Required:**

`id=[integer]` - quiz id want you want to start
- **URL Params**

**Required:**

`id=[integer]` - quiz id want you want to start

* **Success Response:**
- **Success Response:**

* **Code:** 200 <br />
**Content:**
- **Code:** 200 <br />
**Content:**
```js
{
"type": "chooseOne", // also chooseMany and match are available
"text": "Пример вопроса с 1 вариантом ответа",
"text": "Example question with 1 answer",
"choices": [
"1",
"false",
"fdsa",
"false1",
"false2",
"false3",
"right choice"
],
"value": 1,
Expand All @@ -78,45 +82,45 @@ Edit quizData to create your own quizzes
// if true one mistake will result in 0 score
}
```

* **Error Response:**

* **Code:** 404 NOT FOUND <br />
- **Error Response:**

- **Code:** 404 NOT FOUND <br />

**Answer a question**
----
return a score of an answer and the next question if such exists
## **Answer a question**

* **URL**
return a score of an answer and the next question if such exists

- **URL**

/answer

* **Method:**
- **Method:**

`POST`

* **Body Params**
- **Body Params**

**Required:**
* quizId
* questionId
* answer - string for chooseOne, array of srtings for chooseMany, object for match

* **Success Response:**
- quizId
- questionId
- answer - string for chooseOne, array of srtings for chooseMany, object for match

- **Success Response:**

* **Code:** 200 <br />
**Content:**
- **Code:** 200 <br />
**Content:**
```js
{
"score": 0, // calculated score for sent answer
"next": { // next question, null if there is none
"type": "match",
"text": "Пример вопроса сопоставления",
"text": "Example match question",
"choiceLeft": [ // this should be key in answer object
"1",
"2",
"3"
"first",
"second",
"third"
],
"choiceRight": [ // this should be value in answer object
"r1",
Expand All @@ -129,8 +133,8 @@ Edit quizData to create your own quizzes
}
}
```

* **Error Response:**

* **Code:** 400 BAD REQUEST <br />
* **Message:** some message with error description
- **Error Response:**

- **Code:** 400 BAD REQUEST <br />
- **Message:** some message with error description
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const getScore = (question, answer) => {
switch (question.type) {
case 'chooseOne': {
if (typeof answer !== 'string') throw new Error('answer should be a string for chooseOne')

return question.answer === answer ? question.value : 0
}
case 'chooseMany': {
Expand All @@ -70,7 +71,6 @@ const getScore = (question, answer) => {
for (let [left, right] of Object.entries(answer)) {
if (question.answer[left] === right) score += oneValue
else if (question.strict) return 0
else score -= oneValue
}
return score <= 0 || (question.strict && score !== question.value) ? 0 : score
}
Expand Down
Loading

0 comments on commit ec9a46a

Please sign in to comment.