parent
606723ffb8
commit
d1c8bd879b
@ -0,0 +1 @@
|
||||
node_modules
|
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Arpan Adhikari
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -0,0 +1,33 @@
|
||||
# Quizzes
|
||||
|
||||
These quizzes are the pre- and post-lecture quizzes for the web development for beginners curriculum at https://aka.ms/webdev-beginners
|
||||
|
||||
## Project setup
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
|
||||
```
|
||||
npm run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
|
||||
```
|
||||
npm run lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
||||
|
||||
Credits: Thanks to the original version of this quiz app: https://github.com/arpan45/simple-quiz-vue
|
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "quizzes",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.5",
|
||||
"vue": "^2.6.11",
|
||||
"vue-i18n": "^8.22.2",
|
||||
"vue-router": "^3.4.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"plugin:vue/essential",
|
||||
"eslint:recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"parser": "babel-eslint"
|
||||
},
|
||||
"rules": {}
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"last 2 versions",
|
||||
"not dead"
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 17 KiB |
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"routes": [
|
||||
{
|
||||
"route": "/*",
|
||||
"serve": "/index.html"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<div>
|
||||
<nav>
|
||||
<router-link class="navlink" to="/">Home</router-link>
|
||||
<label for="locale">locale</label>
|
||||
<select v-model="locale">
|
||||
<option>en</option>
|
||||
<option>ko</option>
|
||||
<option>id</option>
|
||||
<option>hi</option>
|
||||
<option>it</option>
|
||||
</select>
|
||||
</nav>
|
||||
<div id="app">
|
||||
<h1>{{ $t("title") }}</h1>
|
||||
<router-view>
|
||||
<Quiz />
|
||||
</router-view>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Quiz from "@/components/Quiz.vue";
|
||||
import messages from "@/assets/translations";
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
i18n: { messages },
|
||||
components: {
|
||||
Quiz,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
locale: "en",
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
locale(val) {
|
||||
this.$root.$i18n.locale = val;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
if (this.$route.query.loc) {
|
||||
this.locale = this.$route.query.loc;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
html {
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
color: #252d4a;
|
||||
}
|
||||
nav {
|
||||
background-color: #252d4a;
|
||||
padding: 1em;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
nav a {
|
||||
color: white;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.link {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
.message {
|
||||
text-align: center;
|
||||
}
|
||||
.error {
|
||||
color: red;
|
||||
}
|
||||
.card {
|
||||
width: 60%;
|
||||
border: #252d4a solid;
|
||||
border-radius: 5px;
|
||||
margin: auto;
|
||||
padding: 1em;
|
||||
}
|
||||
.btn {
|
||||
min-width: 50%;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
margin-bottom: 5px;
|
||||
width: 50%;
|
||||
font-size: 16px;
|
||||
color: #ffffff;
|
||||
background-color: #252d4a;
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
}
|
||||
.ans-btn {
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
margin: 4px auto;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,515 @@
|
||||
[
|
||||
{
|
||||
"title": "IoT Development for Beginners: Quizzes",
|
||||
"complete": "Congratulations, you completed the quiz!",
|
||||
"error": "Sorry, try again",
|
||||
"quizzes": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Lesson 1 - Introduction to IoT: Pre-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "The I in IoT stands for:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Internet",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Iridium",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Ironing",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "What's the estimated number of IoT devices in use by the end of 2020?",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "30",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "30 million",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "30 billion",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Smartphones are IoT devices",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "Lesson 1 - Introduction to IoT: Post-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "IoT devices need to be connected to the Internet at all time",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "IoT devices are always secure",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "AI can be run on low powered IoT devices",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "Lesson 2 - Introduction to IoT devices: Pre-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "The T in IoT stands for:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Transistors",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Things",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Turkeys",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "IoT devices gather information from the world around them using:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Sensors",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Actuators",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Carrier pigeons",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "IoT devices draw more power than the average desktop or laptop computer",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Lesson 2 - Introduction to IoT devices: Post-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "The three steps in a CPU instruction cycle are:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Decode, Execute, Fetch",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Fetch, Decode, Execute",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Stop, Collaborate, Listen",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "What operating system do Raspberry Pis run?",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "They don't run an OS",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Windows 95",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Raspberry Pi OS",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "IoT devices typically run faster and have more memory than the average desktop or laptop computer",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Lesson 3 - Interact with the physical world with sensors and actuators: Pre-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "An LED is a sensor:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Sensors are used to:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Gather data from the physical world.",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Control the physical world.",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Only monitor temperature.",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Actuators are use to:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Gather data from the physical world.",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Control the physical world.",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "To calculate insurance risks.",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "Lesson 3 - Interact with the physical world with sensors and actuators: Post-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Digital sensors send data as:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Voltage ranges",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "High and low voltages only",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Emails",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "What digital signal is sent when a button is pressed?",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "0",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "1",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "You can control analog actuators from a digital device using pulse-width modulation",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Lesson 4 - Connect your device to the Internet: Pre-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "IoT devices always need to be connected to the Internet to work:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "IoT devices always communicate over HTTP, the same as web apps and other web APIs:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "IoT devices rely on the cloud for all their decision making:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Lesson 4 - Connect your device to the Internet: Post-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Data gathered from sensors and sent to the cloud is called:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Telemetry",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Commands",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Measurements",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "What should happen to a command if the IoT device is offline:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "It should always be resent when the device is back online",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "It should never be resent when the device is back online",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "It depends on the command, the device a the requirements of the IoT app",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "MQTT, or Message Queueing Telemetry Transport, has message queues:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "Lesson 5 - Predict plant growth: Pre-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Iot devices can be used to support agriculture",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Plant needs include: (pick the best answer)",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Carbon dioxide, water, nutrients",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Carbon dioxide, water, nutrients, light",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Carbon dioxide, water, nutrients, light, warmth",
|
||||
"isCorrect": "true"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Sensors are too expensive for farmers in developed nations to use:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "Lesson 5 - Predict plant growth: Post-Lecture Quiz",
|
||||
"quiz": [
|
||||
{
|
||||
"questionText": "Plant growth is dependant on temperature",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "True",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "False",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "The temperatures to consider for plant growth are:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "Minimum, maximum",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "Base, optimal, maximum",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "Maximum only",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"questionText": "Growing Degree Days are calculated using which formula:",
|
||||
"answerOptions": [
|
||||
{
|
||||
"answerText": "(day max + day min) - plant base",
|
||||
"isCorrect": "false"
|
||||
},
|
||||
{
|
||||
"answerText": "((day max + day min) / 2) - plant base",
|
||||
"isCorrect": "true"
|
||||
},
|
||||
{
|
||||
"answerText": "((day min + plant base) / 2)",
|
||||
"isCorrect": "false"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@ -0,0 +1,10 @@
|
||||
// index.js
|
||||
import en from './en.json';
|
||||
|
||||
//export const defaultLocale = 'en';
|
||||
|
||||
const messages = {
|
||||
en: en[0],
|
||||
};
|
||||
|
||||
export default messages;
|
@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div v-for="q in questions" :key="q.id">
|
||||
<div v-if="route == q.id">
|
||||
<h2>{{ q.title }}</h2>
|
||||
<hr />
|
||||
<h3 v-if="complete" class="message">{{ $t("complete") }}</h3>
|
||||
<div v-else>
|
||||
<h3 v-if="error" class="error">{{ $t("error") }}</h3>
|
||||
<h2>
|
||||
{{ q.quiz[currentQuestion].questionText }}
|
||||
</h2>
|
||||
<div>
|
||||
<button
|
||||
:key="index"
|
||||
v-for="(option, index) in q.quiz[currentQuestion].answerOptions"
|
||||
@click="handleAnswerClick(option.isCorrect)"
|
||||
class="btn ans-btn"
|
||||
>
|
||||
{{ option.answerText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import messages from "@/assets/translations";
|
||||
|
||||
export default {
|
||||
name: "Quiz",
|
||||
data() {
|
||||
return {
|
||||
currentQuestion: 0,
|
||||
complete: false,
|
||||
error: false,
|
||||
route: "",
|
||||
locale: "",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
questions() {
|
||||
return this.$t("quizzes");
|
||||
},
|
||||
},
|
||||
|
||||
i18n: { messages },
|
||||
methods: {
|
||||
handleAnswerClick(isCorrect) {
|
||||
this.error = false;
|
||||
let nextQuestion = this.currentQuestion + 1;
|
||||
if (isCorrect == "true") {
|
||||
//always 3 questions per quiz
|
||||
if (nextQuestion < 3) {
|
||||
this.currentQuestion = nextQuestion;
|
||||
} else {
|
||||
this.complete = true;
|
||||
}
|
||||
} else {
|
||||
this.error = true;
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.route = this.$route.params.id;
|
||||
this.locale = this.$route.query.loc;
|
||||
},
|
||||
};
|
||||
</script>
|
@ -0,0 +1,14 @@
|
||||
import Vue from 'vue';
|
||||
import App from './App.vue';
|
||||
Vue.config.productionTip = false;
|
||||
import router from './router';
|
||||
|
||||
import VueI18n from 'vue-i18n';
|
||||
Vue.use(VueI18n);
|
||||
|
||||
const i18n = new VueI18n({
|
||||
locale: 'en',
|
||||
fallbackLocale: 'en',
|
||||
});
|
||||
|
||||
new Vue({ i18n, router, render: (h) => h(App) }).$mount('#app');
|
@ -0,0 +1,34 @@
|
||||
import Vue from 'vue';
|
||||
import Router from 'vue-router';
|
||||
import Home from '@/views/Home.vue';
|
||||
import Quiz from '@/components/Quiz.vue';
|
||||
import NotFound from '@/views/NotFound.vue';
|
||||
Vue.use(Router);
|
||||
|
||||
const router = new Router({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: Home,
|
||||
},
|
||||
{
|
||||
path: '/quiz/:id',
|
||||
name: 'Quiz',
|
||||
component: Quiz,
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'NotFound',
|
||||
component: NotFound,
|
||||
meta: { title: 'Not Found' },
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
next();
|
||||
});
|
||||
export default router;
|
@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<div>
|
||||
<router-link
|
||||
v-for="q in questions"
|
||||
:key="q.id"
|
||||
:to="`quiz/${q.id}`"
|
||||
class="link"
|
||||
>
|
||||
{{ q.title }}
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import messages from "@/assets/translations";
|
||||
|
||||
export default {
|
||||
name: "Home",
|
||||
computed: {
|
||||
questions() {
|
||||
return this.$t("quizzes");
|
||||
},
|
||||
},
|
||||
i18n: { messages },
|
||||
};
|
||||
</script>
|
@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
<p>Sorry, wrong number!</p>
|
||||
</div>
|
||||
</template>
|
Loading…
Reference in new issue