Back to Home

Quiz app

These quizzes are the pre- and post-lecture quizzes for the data science curriculum at https://aka.ms/webdev-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.

Here’s the shape of a translation file:
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. For example, if your translation JSON is in ex.json, make ‘ex’ the localization key, then enter it as shown below to import it
index.js

Run the Quiz App locally

Prerequisites

  1. Create a repository from this template
  2. Clone your new repository, and navigate to the quiz-app
git clone https://github.com/your-github-organization/repo-name
cd repo-name/quiz-app
  1. Install the npm packages & dependencies
npm install

Build the app

  1. To build the solution, run:
npm run build

Start the App

  1. To run the solution, run:
npm run dev

[Optional] Linting

  1. To ensure the code is linted, run:
npm run lint

Deploy the Quiz-app to Azure

Prerequisites

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "quiz-app" # App source code path
api_location: ""API source code path optional
output_location: "dist" #Built app content directory - optional

- Post-Deployment: After deployment is complete, click on ‘Go to Deployment’ then ‘View app in browser’. Once your GitHub Action (workflow) is executed successfully, refresh the live page to view your application.

[
    {
        "title": "A title",
        "complete": "A complete button title",
        "error": "An error message upon selecting the wrong answer",
        "quizzes": [
            {
                "id": 1,
                "title": "Title",
                "quiz": [
                    {
                        "questionText": "The question asked",
                        "answerOptions": [
                            {
                                "answerText": "Option 1 title",
                                "isCorrect": true
                            },
                            {
                                "answerText": "Option 2 title",
                                "isCorrect": false
                            }
                        ]
                    }
                ]
            }
        ]
    }
]
Example:

Follow the lesson from Microsoft Web-Dev-For-Beginners course

Tags: web,development