Fun tech quiz questions directly in your terminal

Introduction

Quizzes are a great way to test your knowledge on a specific topic. So I decided to create a tool called the Quiz API!

Quiz API is a simple HTTP REST API for technical quizzes including a wide variety of topics like: Linux, …


This content originally appeared on DEV Community and was authored by Bobby Iliev

3um936quha6qp3q3o18y.png

Introduction

Quizzes are a great way to test your knowledge on a specific topic. So I decided to create a tool called the Quiz API!

Quiz API is a simple HTTP REST API for technical quizzes including a wide variety of topics like: Linux, DevOps, Programming (PHP, JS, Python and etc.), Docker,
Kubernetes and lots more!

It is free for developers and I've just released a beta version and started adding some cool questions!

As the Quiz API returns the output in a JSON format, I created a bash script that allows you to answer questions whenever you feel like directly via your terminal!

QuizAPI Demo

Prerequisites

In order to be able to use the Quiz API bash script you need to have the following:

  • An API Key for the Quiz API, you can get it totally for free here

  • Access to a bash terminal

Download the Quiz bash script

In order to download the bash script which would allow you to consume the QuizAPI and take questions directly via your terminal, you just need to run this command here:

wget https://quizapi.io/quiz.sh

Make sure to check the script before running it! This bash script is also available on git and you can check it's contents here:

https://github.com/QuizApi/QuizAPI-BASH/blob/master/quiz.sh

Any pull requests with improvements are more than welcome!

Install jq

The jq command-line tool is is a lightweight and flexible command-line JSON processor. It is great for parsing JSON output in your terminal and it is required by the Quiz API bash script.

If you try to run the script without having jq installed you will get the following message:

The jq command is required! Please install it and then try again

If you don't have jq already installed, you can do that by running one of the following commands depending on your OS:

Linux

  • Ubuntu/Debian:
sudo apt-get install jq

Or if you are running the latest Ubuntu version you might have to install it with snap:

sudo snap install jq
  • Fedora:
sudo dnf install jq
  • openSUSE:
sudo zypper install jq
  • Arch:
sudo pacman -S jq

Mac:

  • Homebrew:
brew install jq
  • MacPort
port install jq

If you are on a different system, follow the steps from the official documentation here:

https://stedolan.github.io/jq/download/

Usage

Once you have your API Key and jq installed you can execute the script by running the following commands:

  • Make the script executable:
chmod +x quiz.sh
  • Execute the script:
./quiz.sh

As we did not specify the API key, you will get the following output

Usage: quiz.sh -a API_KEY [-c Category] [-d Difficulty] [-t Tags]

In order for the script to work, we need to pass our API key as an argument. One of the ways to do that is to define our API key as an environment variable:

export API_KEY=your_api_key_here

Note: change the your_api_key_here with your actual Quiz API key!

Then run the following:

./quiz.sh -a ${API_KEY}

The script will make a curl request to the Quiz API and it would pars the output for you in a nice interactive cli multiple choice quiz like this:

 "How to dump pod logs (stdout) in Kubernetes?"
  1 ) "kubectl log my-pod"
  2 ) "kubectl pod logs my-pod"
  3 ) "kubectl logs my-pod"
  4 ) "kubectl pods logs my-pod"
Check an option (again to uncheck, ENTER when done):

You will be able to select 1 or multiple answers and then press enter:

"How to dump pod logs (stdout) in Kubernetes?"
  1 ) "kubectl log my-pod"
  2 ) "kubectl pod logs my-pod"
  3+) "kubectl logs my-pod"
  4 ) "kubectl pods logs my-pod"
"kubectl logs my-pod" was checked
Check an option (again to uncheck, ENTER when done):

Selected was:  "kubectl logs my-pod"
Correct: is:  "kubectl logs my-pod"
Correct Answer!

Available arguments

The script allows you to specify different parameters so that you could get the questions that you want.

The available arguments are:

  • -c - get questions only for a specific category
  • -d - get questions only for a specific difficulty (Easy, Medium and Hard)
  • -t - get questions for a specific topic/tag, this lets you combine multiple topics

For example, if you wanted to get easy Docker questions only, you could run:

./quiz.sh -a ${API_KEY} -d hard -t docker

Contributions

We have added about 1000 questions for the beta version! But we are planning to add a lot more than that in the future.

As the Quiz API is free for developers, any contributions would be greatly appreciated. If you are feeling adventurous, you could do so via this link here:

https://quizapi.io/contribute

If you notice a wrong question feel free to report it as well:

https://quizapi.io/contact

Conclusion

Quizzes can be a fun way to test and improve your knowledge, with the Quiz API you are going to be able to do so via your terminal at any time!

For more information make sure to check out the official documentation here:

https://quizapi.io/docs/1.0/overview

Also, feel free to reach out and say hi on twitter:

https://twitter.com/bobbyiliev_


This content originally appeared on DEV Community and was authored by Bobby Iliev


Print Share Comment Cite Upload Translate Updates
APA

Bobby Iliev | Sciencx (2021-05-26T06:55:11+00:00) Fun tech quiz questions directly in your terminal. Retrieved from https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/

MLA
" » Fun tech quiz questions directly in your terminal." Bobby Iliev | Sciencx - Wednesday May 26, 2021, https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/
HARVARD
Bobby Iliev | Sciencx Wednesday May 26, 2021 » Fun tech quiz questions directly in your terminal., viewed ,<https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/>
VANCOUVER
Bobby Iliev | Sciencx - » Fun tech quiz questions directly in your terminal. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/
CHICAGO
" » Fun tech quiz questions directly in your terminal." Bobby Iliev | Sciencx - Accessed . https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/
IEEE
" » Fun tech quiz questions directly in your terminal." Bobby Iliev | Sciencx [Online]. Available: https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/. [Accessed: ]
rf:citation
» Fun tech quiz questions directly in your terminal | Bobby Iliev | Sciencx | https://www.scien.cx/2021/05/26/fun-tech-quiz-questions-directly-in-your-terminal/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.