adding a quiz for this curriculum

This commit is contained in:
Jen Looper 2022-02-11 17:40:24 -05:00
parent de5287eb38
commit 1164583fb7
28 changed files with 29872 additions and 1 deletions

View File

@ -24,7 +24,7 @@ Similar to Readme's, please translate the assignments as well.
2. Add your language code to the dropdown in the quiz-app's App.vue file.
3. Edit the quiz-app's [translations index.js file](https://github.com/microsoft/ML-For-Beginners/blob/main/quiz-app/src/assets/translations/index.js) to add your language.
3. Edit the quiz-app's [translations index.js file](https://github.com/microsoft/AI-For-Beginners/blob/main/quiz-app/src/assets/translations/index.js) to add your language.
4. Finally, edit ALL the quiz links in your translated README.md files to point directly to your translated quiz: https://https://jolly-sea-0a877260f.azurestaticapps.net/quiz/1 becomes https://jolly-sea-0a877260f.azurestaticapps.net/quiz/1?loc=id

3
docs/_sidebar.md Normal file
View File

@ -0,0 +1,3 @@
- Introduction
- [Defining Data Science](../1-Introduction/01-defining-data-science/README.md)

9
docsifytopdf.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = {
contents: ['docs/_sidebar.md'], // array of "table of contents" files path
pathToPublic: 'pdf/readme.pdf', // path where pdf will stored
pdfOptions: {
margin: { top: '100px', bottom: '100px' }
}, // reference: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions
removeTemp: true, // remove generated .md and .html or not
emulateMedia: 'print', // mediaType, emulating by puppeteer for rendering pdf, 'print' by default (reference: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageemulatemediamediatype)
};

23
for-teachers.md Normal file
View File

@ -0,0 +1,23 @@
## For Educators
Would you like to use this curriculum in your classroom? Please feel free!
In fact, you can use it within GitHub itself by using GitHub Classroom.
To do that, fork this repo. You are going to need to create a repo for each lesson, so you're going to need to extract each folder into a separate repo. That way, [GitHub Classroom](https://classroom.github.com/classrooms) can pick up each lesson separately.
These [full instructions](https://github.blog/2020-03-18-set-up-your-digital-classroom-with-github-classroom/) will give you an idea how to set up your classroom.
## Using the repo as is
If you would like to use this repo as it currently stands, without using GitHub Classroom, that can be done as well. You would need to communicate with your students which lesson to work through together.
In an online format (Zoom, Teams, or other) you might form breakout rooms for the quizzes, and mentor students to help them get ready to learn. Then invite students to for the quizzes and submit their answers as 'issues' at a certain time. You might do the same with assignments, if you want students to work collaboratively out in the open.
If you prefer a more private format, ask your students to fork the curriculum, lesson by lesson, to their own GitHub repos as private repos, and give you access. Then they can complete quizzes and assignments privately and submit them to you via issues on your classroom repo.
There are many ways to make this work in an online classroom format. Please let us know what works best for you!
## Please give us your thoughts!
We want to make this curriculum work for you and your students. Please give us feedback in the discussion boards!

27
index.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AI for Beginners</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="icon" type="image/png" href="images/favicon.png">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'AI for Beginners',
repo: 'https://github.com/Microsoft/AI-For-Beginners',
relativePath: true
}
</script>
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
</body>
</html>

2205
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

29
package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "ds-for-beginners",
"version": "1.0.0",
"description": "AI for Beginners - A Curriculum",
"main": "index.js",
"scripts": {
"convert": "node_modules/.bin/docsify-to-pdf"
},
"repository": {
"type": "git",
"url": "git+https://github.com/microsoft/AI-For-Beginners.git"
},
"keywords": [
"machine",
"learning",
"ml",
"ai",
"curriculum"
],
"author": "Jen Looper and team",
"license": "MIT",
"bugs": {
"url": "https://github.com/microsoft/AI-For-Beginners/issues"
},
"homepage": "https://github.com/microsoft/AI-For-Beginners#readme",
"devDependencies": {
"docsify-to-pdf": "0.0.5"
}
}

BIN
pdf/readme.pdf Normal file

Binary file not shown.

1
quiz-app/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

21
quiz-app/LICENSE Normal file
View File

@ -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.

46
quiz-app/README.md Normal file
View File

@ -0,0 +1,46 @@
# Quizzes
These quizzes are the pre- and post-lecture quizzes for the data science curriculum at https://aka.ms/datascience-beginners
## Adding a translated quiz set
Add a quiz translation by creating matching quiz structures in the `assets/translations` folders. The canonical quizzes are in `assets/translations/en`. The quizzes are broken into several groupings. Make sure to align the numbering with the proper quiz section. There are 40 quizzes total in this curriculum, with the count starting at 0.
After editing the translations, edit the index.js file in the translation folder to import all the files following the conventions in `en`.
Edit the `index.js` file in `assets/translations` to import the new translated files.
Then, edit the dropdown in `App.vue` in this app to add your language. Match the localized abbreviation to the folder name for your language.
Finally, edit all the quiz links in the translated lessons, if they exist, to include this localization as a query parameter: `?loc=fr` for example.
## 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

5
quiz-app/babel.config.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

26553
quiz-app/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

44
quiz-app/package.json Normal file
View File

@ -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"
]
}

BIN
quiz-app/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -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>

View File

@ -0,0 +1,8 @@
{
"routes": [
{
"route": "/*",
"serve": "/index.html"
}
]
}

145
quiz-app/src/App.vue Normal file
View File

@ -0,0 +1,145 @@
<template>
<div>
<nav>
<ul>
<li>
<router-link class="navlink" to="/">Home</router-link>
</li>
<li>
<label for="locale">locale</label>
</li>
<li>
<select v-model="locale">
<option>en</option>
<option>es</option>
</select>
</li>
<li class="title">{{ questions[locale][0].title }}</li>
</ul>
</nav>
<div id="app">
<router-view>
<Quiz />
</router-view>
</div>
</div>
</template>
<script>
import Quiz from "@/components/Quiz.vue";
import messages from "@/assets/translations";
export default {
name: "App",
computed: {
questions() {
return messages;
},
},
i18n: { messages },
components: {
Quiz,
},
data() {
return {
locale: "",
};
},
watch: {
locale(val) {
this.$root.$i18n.locale = val;
},
},
created() {
this.route = this.$route.params.id;
if (this.$route.query.loc) {
this.locale = this.$route.query.loc;
} else {
this.locale = "en";
}
},
};
</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;
}
ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: left;
}
.title {
color:white;
font-weight: bold;
font-size: x-large;
float: right;
}
.link {
display: list-item;
}
h1,
h2,
h3,
.message {
text-align: center;
}
.error {
color: red;
}
.complete {
color: green;
}
.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>

View File

@ -0,0 +1,453 @@
[
{
"title": "AI for Beginners: Quizzes",
"complete": "Congratulations, you completed the quiz!",
"error": "Sorry, try again",
"quizzes": [
{
"id": 0,
"title": "Defining Data Science - Pre Quiz",
"quiz": [
{
"questionText": "Why is the word _Science_ in Data Science?",
"answerOptions": [
{
"answerText": "It uses scientific methods to analyze data",
"isCorrect": "true"
},
{
"answerText": "Only people with academic degrees can understand it",
"isCorrect": "false"
},
{
"answerText": "To make is sound cool",
"isCorrect": "false"
}
]
},
{
"questionText": "Learning Data Science is only useful for developers",
"answerOptions": [
{
"answerText": "True",
"isCorrect": "false"
},
{
"answerText": "False",
"isCorrect": "true"
}
]
},
{
"questionText": "What do we need to demonstrate that basketball players are taller than average people?",
"answerOptions": [
{
"answerText": "Collect some data",
"isCorrect": "false"
},
{
"answerText": "Know some probability and statistics",
"isCorrect": "false"
},
{
"answerText": "All of the above",
"isCorrect": "true"
}
]
}
]
},
{
"id": 1,
"title": "Defining Data Science: Post-Quiz",
"quiz": [
{
"questionText": "Which areas are closely related to data science?",
"answerOptions": [
{
"answerText": "Artificial Intelligence",
"isCorrect": "false"
},
{
"answerText": "Machine Learning",
"isCorrect": "false"
},
{
"answerText": "All of the above",
"isCorrect": "true"
}
]
},
{
"questionText": "Which of the following is an example of non-structured data?",
"answerOptions": [
{
"answerText": "List of students in class",
"isCorrect": "false"
},
{
"answerText": "Collection of student essays",
"isCorrect": "true"
},
{
"answerText": "Graph of friends of social network users",
"isCorrect": "false"
}
]
},
{
"questionText": "What is the main goal of data science?",
"answerOptions": [
{
"answerText": "to collect data",
"isCorrect": "false"
},
{
"answerText": "to process data",
"isCorrect": "false"
},
{
"answerText": "to be able to make decisions based on data",
"isCorrect": "true"
}
]
}
]
},
{
"id": 2,
"title": "Ethics - Pre-Quiz",
"quiz": [
{
"questionText": "What is a consideration of ethics in Data Science?",
"answerOptions": [
{
"answerText": "Data collection",
"isCorrect": "false"
},
{
"answerText": "Algorithm Design",
"isCorrect": "false"
},
{
"answerText": "All the above",
"isCorrect": "true"
}
]
},
{
"questionText": "Which of the following are a part of ethical challenges?",
"answerOptions": [
{
"answerText": "Transparency",
"isCorrect": "false"
},
{
"answerText": "Data privacy",
"isCorrect": "true"
},
{
"answerText": "Reliability and safety",
"isCorrect": "false"
}
]
},
{
"questionText": "Data ethics also includes AI and machine learning algorithms ",
"answerOptions": [
{
"answerText": "True",
"isCorrect": "true"
},
{
"answerText": "False, they are separate",
"isCorrect": "false"
}
]
}
]
},
{
"id": 3,
"title": "Ethics - Post-Quiz",
"quiz": [
{
"questionText": "What is the main difference between ethics and applied ethics?",
"answerOptions": [
{
"answerText": "Applied ethics is a specific type of ethics",
"isCorrect": "false"
},
{
"answerText": "Applied ethics is not a real term",
"isCorrect": "false"
},
{
"answerText": "Applied ethics is the process of finding and correcting ethical issues",
"isCorrect": "true"
}
]
},
{
"questionText": "What is the difference between ethics regulation vs ethics principles",
"answerOptions": [
{
"answerText": "Ethics regulation focuses on regular ethics",
"isCorrect": "false"
},
{
"answerText": "There is no difference",
"isCorrect": "false"
},
{
"answerText": "Ethics principles do not relate to a particular law, while regulations do",
"isCorrect": "true"
}
]
},
{
"questionText": "Which of these are real ethical principles and practices that can be applied?",
"answerOptions": [
{
"answerText": "Collection bias",
"isCorrect": "false"
},
{
"answerText": "Compliance with ethics regulations",
"isCorrect": "false"
},
{
"answerText": "both of the above",
"isCorrect": "true"
}
]
}
]
},
{
"id": 4,
"title": "Defining Data - Pre-Quiz",
"quiz": [
{
"questionText": "Which of these could be quantitative data?",
"answerOptions": [
{
"answerText": "Photos of dogs",
"isCorrect": "false"
},
{
"answerText": "Hotel reviews",
"isCorrect": "false"
},
{
"answerText": "Students marks or grades",
"isCorrect": "true"
}
]
},
{
"questionText": "Which of these could be qualitative data?",
"answerOptions": [
{
"answerText": "List of employees' salaries",
"isCorrect": "false"
},
{
"answerText": "Hotel reviews",
"isCorrect": "true"
},
{
"answerText": "Students' marks or grades",
"isCorrect": "false"
}
]
},
{
"questionText": "What is the main goal of classifying data?",
"answerOptions": [
{
"answerText": "To store the data correctly",
"isCorrect": "false"
},
{
"answerText": "To give the data a proper name",
"isCorrect": "false"
},
{
"answerText": "To know which method is best to organize it for readability and analysis",
"isCorrect": "true"
}
]
}
]
},
{
"id": 5,
"title": "Defining Data - Post-Quiz",
"quiz": [
{
"questionText": "The teacher is reviewing students number of correct answers, what type of data is that?",
"answerOptions": [
{
"answerText": "Qualitative Data",
"isCorrect": "false"
},
{
"answerText": "Quantitative Data",
"isCorrect": "true"
},
{
"answerText": "All the above",
"isCorrect": "false"
}
]
},
{
"questionText": "A company is collecting surveys from their customers to improve their products. What type of data source is this?",
"answerOptions": [
{
"answerText": "Primary",
"isCorrect": "true"
},
{
"answerText": "Secondary",
"isCorrect": "false"
},
{
"answerText": "Tertiary",
"isCorrect": "false"
}
]
},
{
"questionText": "A student is collecting data using queries. What data source could that be?",
"answerOptions": [
{
"answerText": "Local Files",
"isCorrect": "false"
},
{
"answerText": "API",
"isCorrect": "false"
},
{
"answerText": "Database",
"isCorrect": "true"
}
]
}
]
},
{
"id": 6,
"title": "Statistics and Probability - Pre-Quiz",
"quiz": [
{
"questionText": "Why statistics and probability are important for data science?",
"answerOptions": [
{
"answerText": "Because you cannot operate on data without knowing math",
"isCorrect": "false"
},
{
"answerText": "Because data science is a science and has strong formal foundation",
"isCorrect": "true"
},
{
"answerText": "Because we want to keep uneducated people from doing data science",
"isCorrect": "false"
}
]
},
{
"questionText": "Can you get heads 10 times in a row when throwing a coin?",
"answerOptions": [
{
"answerText": "yes",
"isCorrect": "true"
},
{
"answerText": "no",
"isCorrect": "false"
}
]
},
{
"questionText": "When you throw a dice, what is the probability of getting an even number?",
"answerOptions": [
{
"answerText": "1/2",
"isCorrect": "true"
},
{
"answerText": "1/3",
"isCorrect": "false"
},
{
"answerText": "impossible to tell",
"isCorrect": "false"
}
]
}
]
},
{
"id": 7,
"title": "Statistics and Probability - Post-Quiz",
"quiz": [
{
"questionText": "We want to prove that basketball players are taller than average people. We have collected heights of 20 people from both groups. What do we need to do?",
"answerOptions": [
{
"answerText": "compare means",
"isCorrect": "false"
},
{
"answerText": "collect more data, 20 is not enough!",
"isCorrect": "false"
},
{
"answerText": "use t-test",
"isCorrect": "true"
}
]
},
{
"questionText": "How can we demonstrate that income of a person is dependent on the level of education?",
"answerOptions": [
{
"answerText": "compute correlation coefficient",
"isCorrect": "true"
},
{
"answerText": "divide into educated and non-educated cohorts and compute means",
"isCorrect": "false"
},
{
"answerText": "use t-test",
"isCorrect": "false"
}
]
},
{
"questionText": "We throw the dice 100 times and compute the average value. What would be the distribution of the result?",
"answerOptions": [
{
"answerText": "uniform",
"isCorrect": "false"
},
{
"answerText": "normal",
"isCorrect": "true"
},
{
"answerText": "none of the above",
"isCorrect": "false"
}
]
}
]
}
]
}
]

View File

@ -0,0 +1,10 @@
import en0 from "./group-1.json";
const quiz = {
0: en0[0],
};
export default quiz;

View File

@ -0,0 +1,62 @@
[
{
"title": "Data Science pour Débutants: Quizzes",
"complete": "Felicitations, you completed the quiz!",
"error": "Oups, try again",
"quizzes": [
{
"id": 0,
"title": "Premier quiz",
"quiz": [
{
"questionText": "premier question",
"answerOptions": [
{
"answerText": "True",
"isCorrect": "true"
},
{
"answerText": "False",
"isCorrect": "false"
}
]
},
{
"questionText": "deuxieme question",
"answerOptions": [
{
"answerText": "classical ML was invented first",
"isCorrect": "false"
},
{
"answerText": "the use of neural networks",
"isCorrect": "true"
},
{
"answerText": "deep learning is used in robots",
"isCorrect": "false"
}
]
},
{
"questionText": "troisieme question",
"answerOptions": [
{
"answerText": "to automate the solving of multi-dimensional problems",
"isCorrect": "false"
},
{
"answerText": "to customize a shopping experience based on the type of customer",
"isCorrect": "false"
},
{
"answerText": "both of the above",
"isCorrect": "true"
}
]
}
]
}
]
}
]

View File

@ -0,0 +1,9 @@
import fr0 from "./group-1.json";
//import fr1 from "./group-2.json";
const quiz = {
0: fr0[0],
//1: fr1[0],
};
export default quiz;

View File

@ -0,0 +1,8 @@
import englishQuizzes from './en/';
import frenchQuizzes from './fr/';
const messages = {
en: englishQuizzes,
fr: frenchQuizzes,
};
export default messages;

View File

@ -0,0 +1,89 @@
<template>
<div class="card">
<div v-for="q in questions[currLocale]" :key="q.quizzes[0].id">
<div v-for="quiz in q.quizzes" :key="quiz.id">
<div v-if="route == quiz.id">
<div>
<h3 v-if="complete" class="message complete">{{ q.complete }}</h3>
<div v-else>
<h3 v-if="error" class="error">{{ q.error }}</h3>
</div>
<h1>{{quiz.title}}</h1>
<h2>
{{ quiz.quiz[currentQuestion].questionText }}
</h2>
<div>
<button
:key="index"
v-for="(option, index) in quiz.quiz[currentQuestion]
.answerOptions"
@click="handleAnswerClick(option.isCorrect)"
class="btn ans-btn"
>
{{ option.answerText }}
</button>
</div>
</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 messages;
},
currLocale() {
return this.$root.$i18n.locale;
}
},
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;
if (this.$route.query.loc) {
this.locale = this.$route.query.loc;
} else {
this.locale = "en";
}
},
};
</script>

14
quiz-app/src/main.js Normal file
View File

@ -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');

View File

@ -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;

View File

@ -0,0 +1,51 @@
<template>
<div>
<div v-for="q in questions[currLocale]" :key="q.id">
<router-link
v-for="quiz in q.quizzes"
:key="quiz.id"
:to="`quiz/${quiz.id}`"
class="link"
>
{{ quiz.title }}
</router-link>
</div>
</div>
</template>
<script>
import messages from "@/assets/translations";
export default {
name: "Home",
data() {
return {
locale: "",
};
},
computed: {
questions() {
return messages;
},
currLocale() {
return this.$root.$i18n.locale;
}
},
i18n: { messages },
watch: {
locale(val) {
this.$root.$i18n.locale = val;
},
},
created() {
this.route = this.$route.params.id;
if (this.$route.query.loc) {
this.locale = this.$route.query.loc;
} else {
this.locale = "en";
}
},
};
</script>

View File

@ -0,0 +1,5 @@
<template>
<div>
<p>Sorry, wrong number!</p>
</div>
</template>