Skip to main content

A small quiz application

Project description

# NuQui extension
This is a little module to make chatbots able to ask questions. There is already a prototype that uses the NuQui module [you find it here](https://github.com/nuqui-chatbot/nuqui-nombot). It has over 200 Questions about food in German. You can easily change the sqlite database to add more questions or adapt them to your needs. (it will never ask the same questions twice).

The question will be related to the food that the user ate. If there are no meal entry it will ask a random question.

### Installation
The installation is quite easy. It is a pypi module so you can just install it via pip.
```
pip install nuqui
```

If you want to install it form source code you just have to clone the, move into the root directory and then run the following command:
```
pip install -r requirements.txt
python setup.py install
```

### Usage
Nuqui is quite easy to use and has just a few methods to invoke in your program.

First you need to import nuqui in the file you need it
```
import nuqui
```
#### USer Management
After the import we need to make a new user in the nuqui module so we have to call
```
nuqui.create_user(<user_id>, <name>)
```
If your bot or program has the possibility to delete a user you have can also delete the user in the nuqui module by calling
```
nuqui.delete_user(<user_id>)
```
This will delete the user and everyhting related to him.

#### add meals
Then we need to add a meal to the user. That is also pretty simple to do. Just call
```
nuqui.add_meal(<user_id>, <food_String>, <total_calories>)
```
The 'food_string' needs to have a certain format. Just use ingredents of the meal and then concatenate them together with a comma seperation. e.g. "wasser,apfel,salz". The total calories are an int that represents the total calories of the whole meal.

#### Get a Question
Now as you have some restriction in the database you can ask for a question. With
```
nuqui.get_predefined_question_dict_with_random_answers(<user_id>)
```
you get a question dictionary (JSON) with the following structure:
```
{
"question": questionstring,
"answer": an array with 4 answer options,
"value": the points you get for this question
}
```
Let your user answer with 4 options (!A, !B, !C, !D)

#### Evaluate your answer
Because you dont know what the right answer you need e evaluation.
```
nuqui.evaluat(<answer>, <user_id>)
```
This function need an answer (A sting that contains either !A, !B, !C or !D) and the user id. It will return you a Dictornary (JSON) in the following structur:

```
{
"success": boolean,
"right_answer": right_answer,
"achieved_points": points the question was worth,
"total_points": the total points of the user
}
```

### run tests
You can also test the module by running the tests in the tests folder. They are all based on the standart unit test python framework.
To run the tests just type
```
python tests/test_basic.py
```

### Future work
* delete question form the user after a certain time
* make the database more persistent


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nuqui-0.1.6.tar.gz (36.8 kB view details)

Uploaded Source

Built Distributions

nuqui-0.1.6-py3.4.egg (27.6 kB view details)

Uploaded Source

nuqui-0.1.6-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file nuqui-0.1.6.tar.gz.

File metadata

  • Download URL: nuqui-0.1.6.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nuqui-0.1.6.tar.gz
Algorithm Hash digest
SHA256 7452ce59e164e1945e7cadb838b2dc5c3739d5035a2b0fd9bdbd24b1e25f49cd
MD5 dd57146cddcdfba98fee1a6859d77f74
BLAKE2b-256 643f887155063cda96a63a8f6f530a62b5d8e18b6eb3434f43a3150edd828f19

See more details on using hashes here.

File details

Details for the file nuqui-0.1.6-py3.4.egg.

File metadata

  • Download URL: nuqui-0.1.6-py3.4.egg
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for nuqui-0.1.6-py3.4.egg
Algorithm Hash digest
SHA256 72597f426ee2a3a55aa2d93683343202e2a1f48a23a7c795f468e70c50f0631e
MD5 46ab46e0c37b9eaf5301397611b88561
BLAKE2b-256 1962820f899a5435860961dfcdcdb8b96c49e34af622f3082b4af1c3fa1d4ef8

See more details on using hashes here.

File details

Details for the file nuqui-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for nuqui-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2e6d9a326be5e8bcc516b0c063d8f7e64d34bcda29a1437b7c963075b48d9371
MD5 977866b7dc9d0d729acd5347820f810b
BLAKE2b-256 ebc06a98625f467448c159260cfe9e58ba737d561adf42f6c9c5aabe7a0c1ba3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page