Coder Social home page Coder Social logo

04-web-apis-code-quiz's Introduction

04-Web-APIs-Code-Quiz

Description

The Code Quiz build and runs a quick multi-choice quiz to test knowledge of JavaScript APIs. The quiz will run for a maximum of 75 seconds. A 10 second time penalty is applied for incorrect answers.

The Quiz itself is quite straight forward and has 4 distinct phases:

  1. Provides a brief introduction to the quiz. The quiz is started by clicking the Start Button. High Scores can be viewed by clicking the View Highscores link at the top left of the page
  2. Loops through the quiz questions presenting a list of possible answers for each
  3. Asks the user to enter their initials and record their score
  4. Displays the list of scores, sorted from high to low after the user has entered their intials

The user can view the list of high scores at any time.

Thinking Process & Structure

I've used snippets of Javascript in websites I've built in the past but not really understood what was happening.

This Challenge was an opportunity to develop my knowledge of the Web APIs and the DOM by using JavaScript to build and run the entire quiz. It would be a chance to do more with JavaScript, explore its functionality and really see how it works.

The entire quiz, including the HTML, is built and constructed in Javascript. I had to do the analysis first to know what would be required and then build the layout in HTML. Once that was done I could work out how to implement the quiz in JavaScript.

The supplied GIF didn't show what happened when the Show HighScores link was clicked when a Quiz was running and what happened subsequently when the Go Back button was clicked. I handled that as if the history.back() method had been used.

Doing the Challenge this way took much more time than I expected and I had to solve some tricky issues. I encountered unexpected issues with eventListeners and timers that had to be debugged & resolved. I had to change my approach on several occasions to get round problems. I learnt a lot about the DOM, eventListeners, onclick events, timers functions and scope.

Note:

I wouldn't do this in a real project:

  1. code maintenance would be expensive
  2. too many opportinuties for error
  3. debugging is time consuming

It was a useful exercise and I think well worth the time.

Data

Quiz questions, prompts and answers are stored in an object in the separate quiz.js source file. This file also stores the timelengths - quiz duration, penalty time and message display time. This means the questions and durations could be modified easily.

High Scores are stored in local storage in an array named quizScores. Each item in the quizScores array contains the score and intials for each recorded score. The score and initials pairs are themselves 2 item arrays. The quizScores array is sorted by scores in the array items.

Web APIs Code Quiz Website Link

Click the link to visit the deployed website: Web APIs Quiz.

Site Structure

The Web APIs Quiz is a JavaScript app with 4 phases that run in a single webpage.

  1. Phase 1 - Introduction/Instructions
  2. Phase 2 - Multiple Choice Quesions (currently 5, limited by the dataset, not the application)
  3. Phase 3 - Score Recording
  4. Phase 4 - Displaying/Managing the High Scores

Navigation

Phase One - Introduction

Web API Quiz Introduction

Phase Two - Question 3

Web API Quiz Question 3

Phase Three - Score Recording

Web API Quiz Introduction

Phase Three - Erorr Message

Web API Quiz Error Message

Phase Four - Display HighScores

Web API Quiz Display HighScores

Phase Four - Local Storage - quizScores Array

Web API Quiz Display HighScores

Changelog

The development history is recorded in the Changelog.

Resources Used

  1. Bootcamp Materials - Lesson Material from Week 4
  2. Prior knowlege and experience
  3. Group tutorial sessions
  4. MDM Web Docs addEventListener Method
  5. MDM Web Docs removeEventListener Method
  6. MDM Web Docs AbortSignal
  7. MDM Web Docs setInterval() global function
  8. MDM Web Docs Element:prepend() method
  9. MDM Web Docs Array.prototype.sort()

04-web-apis-code-quiz's People

Contributors

dingogap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.