All Projects → fabiandev → Angular Quiz App

fabiandev / Angular Quiz App

Licence: mit
A music quiz in Angular 2+ using the Spotify API.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Angular Quiz App

Rails new
A thoughtfully designed template for building modern Rails apps. Get started in minutes instead of hours 🔥🚀
Stars: ✭ 151 (-16.11%)
Mutual labels:  heroku
Express Webpack React Redux Typescript Boilerplate
🎉 A full-stack boilerplate that using express with webpack, react and typescirpt!
Stars: ✭ 156 (-13.33%)
Mutual labels:  heroku
Php Getting Started
Getting Started with PHP on Heroku
Stars: ✭ 170 (-5.56%)
Mutual labels:  heroku
Amiiboapi
A RESTful API for amiibo.
Stars: ✭ 153 (-15%)
Mutual labels:  heroku
Bovespastockratings
Crawler for Fundamental analysis platform for BOVESPA stocks, generating a score for each share according to the selected criteria on the indicators.
Stars: ✭ 154 (-14.44%)
Mutual labels:  heroku
Tune
A streamlined Spotify client and browser with a focus on performance and integrations.
Stars: ✭ 166 (-7.78%)
Mutual labels:  spotify-api
Discord Musicbot
Very simple discord music bot with the discord.js with Song Name playing. It can able to play music with the song name
Stars: ✭ 148 (-17.78%)
Mutual labels:  heroku
Giraffql
Interactive GraphQL exploration tool built with React - still working on the website
Stars: ✭ 176 (-2.22%)
Mutual labels:  heroku
Linebottemplate
A simple Golang LINE bot Template and tutorial how to setup on Heroku for LINE bot API
Stars: ✭ 156 (-13.33%)
Mutual labels:  heroku
Dokku Cli
Makes your Dokku even more Heroku
Stars: ✭ 170 (-5.56%)
Mutual labels:  heroku
Ng Demo
🦴 Bare Bones Angular 10 and Angular CLI Tutorial
Stars: ✭ 154 (-14.44%)
Mutual labels:  heroku
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines.
Stars: ✭ 1,856 (+931.11%)
Mutual labels:  heroku
Portfolio Generator
HoxNox - Portfolios Made Easy, Generate portfolios in 3 easy steps
Stars: ✭ 166 (-7.78%)
Mutual labels:  heroku
Ritabot
Real-Time Interchangeable Translating Assistant, an open-source free translation Bot for Discord.
Stars: ✭ 146 (-18.89%)
Mutual labels:  heroku
Spotify Now Playing
Spotify now playing information and control popup for macOS menu bar
Stars: ✭ 171 (-5%)
Mutual labels:  spotify-api
Jhipster6 Demo
JHipster 6 Demo! 🎉
Stars: ✭ 150 (-16.67%)
Mutual labels:  heroku
Heroku Node Proxy
一键在Heroku上部署node-unblocker Web代理,简单易用且免费
Stars: ✭ 160 (-11.11%)
Mutual labels:  heroku
Next Postgres Sequelize
React 16.8.4 + NextJS 8.0.3 + Emotion + Sequelize 5/Postgres + Passport Local Auth + Google App Engine or Heroku Deployment
Stars: ✭ 176 (-2.22%)
Mutual labels:  heroku
Crud App Vuejs Django
This is simple crud app and searchFilter made using vuejs and django. Used to explain the tutorial present on https://medium.com/@shubhambansal_89125/crud-app-using-vue-js-and-django-516edf4e4217 https://medium.com/@shubhambansal_89125/searchfilter-using-django-and-vue-js-215af82e12cd
Stars: ✭ 174 (-3.33%)
Mutual labels:  heroku
Coverify
🎧 Design fresh album cover for your Spotify playlists
Stars: ✭ 167 (-7.22%)
Mutual labels:  spotify-api

Angular Music Quiz

Quickstart

$ git clone https://github.com/fabiandev/angular-quiz-app.git
$ cd angular-quiz-app
$ npm install
$ npm start

Tip: You can use yarn instead of npm.

Live Example

See this project in action:

https://fabiandev.io/angular-quiz-app/

Credits

This app uses:

Documentation

CLI

Dependencies

We use npm or yarn and jspm (currently [email protected]) to install dependencies.
For simplicity gulp and jspm can be installed globally, by using the -g flag.

$ npm install -g gulp [email protected]

Make sure that you have Node.js installed, npm comes with it. You can check with node --version. For faster npm dependency installs, use yarn.

To install development dependencies, used e.g. in gulp tasks use:

$ npm install --save-dev module-name

or yarn add module-name --dev

To install application dependencies, used on the server side use:

$ npm install --save module-name

or yarn add module-name

To install client side dependencies, use jspm:

$ jspm install modulename && npm run update-paths

The execution of update-paths is required to have all jspm package also mapped in compilerOptions.paths of tsconfig.json.

jspm also supports install npm:modulename and install github:user/repo

Typings

Typings are used to tell the TypeScript compiler about definitions. You can install them via npm just like this:

$ npm install @types/core-js

Building

Production Build

The production build should be used to compile the app for deployment. It will do it's best to keep the target files as small as possible.

$ gulp build

Development Build

A development build performs similar tasks as a production build, but makes debugging a lot easier.

$ gulp dev-build

Watch Changes

During development make use of the watch task, which does not need to compile the entire app on each change. The application will be transpiled on demand in the browser.

$ gulp watch

You may also execute gulp watch-build to perform those actions only once.

Local Server

Before starting the server copy .env.example in /server and name it .env, get Spotify API keys and fill them in.

NEVER PASTE YOUR KEYS IN THE EXAMPLE FILE OR ANYWHERE ELSE!

To start the sever type:

$ npm start

or yarn start

The server will be started with the dist directory as root, and a built version of the app will be used. Make sure to run gulp build or gul dev-build first.

To start a development server type:

$ npm start dev

or yarn start dev

The server will be started on the very top level of the application code. All files (including dependencies) are transpiled on-demand in the browser. While developing, make sure gulp watch is running, to pick up index.html and less-files changes.

Deployment

This app supports deployment on Heroku:

$ git push heroku master

Just make sure to set the correct Node and npm environment variables:

NODE_ENV=production
NPM_CONFIG_PRODUCTION=false

The npm production flag must be set to false that we can build the app on Heroku after pushing the repository.

And of course you have to add SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET as environment variables.

Optionally you may also add NEW_RELIC_LICENSE_KEY to enable monitoring by New Relic. If you do not provide a license key, New Relic simply won't be enabled.

Tip: If you deploy to Heroku, you can add the New Relic Add-on for free.

Configuration

This section covers how to configure the build tasks, the server and the application itself.

Build Configuration - config.js

You can set some configuration for TypeScript in tsconfig.json and in tslint.json. All other configuration can be found in config.js.

Please take a closer look at the config.js file comment's on the configuration properties for more detailed explanations.

config.src

Type: String

The folder, where the source files can be found, e.g. ./src (no trailing slash!).

config.dist

Type: String

The folder, where the built app will go to. Again, do not use a trailing slash.

dist is short for distribution.

config.watch

Type: String|Array<String>

Define which files should or shouldn't be watched, when using gulp watch. You can use the globbing pattern here.

config.jspm

Type: Object

This configuration holds the command, that will be executed later via gulp when building the application. You can type jspm in the command line to see all available options.

jspm internally uses the SystemJS builder.

config.less

Type: Object

Configure the less gulp task, to create CSS files from LESS files.

config.tslint

Type: Object

Define a globbing pattern, which TypeScript files to lint for errors.

config.index

Type: String

Define the index file for the application.

config.assets

Type: Object

Files to copy without further processing.

config.copy

Type: Array<Object>

Files to copy into a desired location, but only preserve the path from the set base.

Server Configuration - server/index.js

You can set environment variables in server/.env (not included in this repo). Copy server/.env.example and rename it to .env.

Other options are set in server/config/app.js for a production server, or /server.config/app.dev.js for a development server.

Application Configuration

Note, that the index.html is not inside the src, but on the very top level of the application code.

The index.html is processed by gulp-preprocess.

For the dev server or a dev build, src/js/main.dev.ts will be used. For a production build, src/js/main.prod.ts is the entry point of the app.

Extending

It is possible to add questions and answers to this app, by performing a few steps discussed by examples below.

Answers

To add a custom answer yesno, create a directory yesno in src/js/components/quiz/answers, containing the following files:

  • answer-yesno.component.ts
  • answer-yesno.html
  • answer-yesno.css (optional)
  • index.ts
// answer-yesno.component.ts

import { Component } from '@angular/core';
import { GenericAnswer } from 'app/components';

import template from './answer-yesno.html';
import mainStyle from './answer-yesno.css';
import commonStyle from '../common.css';

@Component({
  selector: 'answer-yesno',
  template: template,
  styles: [
    commonStyle,
    mainStyle
  ]
})
export class AnswerYesNoComponent extends GenericAnswer {

  protected init(): void {
    
  }

}
<!-- answer-yesno.html -->

<div class="row answers">
  <div class="col l6 m12 s12">
    <input #checkYes id="answer{{question.id}}_yes" type="checkbox" (change)="answerChanged(checkYes.checked ? 'yes' : null)" [disabled]="!checkYes.checked && hasAnswer()">
    <label htmlFor="answer{{question.id}}_yes" class="grey-text text-darken-3">Yes</label>
  </div>
  <div class="col l6 m12 s12">
    <input #checkNo id="answer{{question.id}}_no" type="checkbox" (change)="answerChanged(checkNo.checked ? 'no' : null)" [disabled]="!checkNo.checked && hasAnswer()">
    <label htmlFor="answer{{question.id}}_no" class="grey-text text-darken-3">No</label>
  </div>
</div>
// index.ts
export * from './answer-yesno.component';

Finally add an export to src/js/components/quiz/answers/answers.ts:

export * from './yesno/index';

Questions

To add a new question type simple, define it in src/js/components/quiz/questions/types.ts:

export enum QuestionType {
  // ...
  Simple,
  // ...
}

Also create a directory simple in src/js/components/quiz/questions, containing the following files:

  • question-simple.component.ts
  • question-simple.html
  • question-simple.css (optional)
  • index.ts
// question-simple.component.ts

import { Component } from '@angular/core';
import { GenericQuestion, QuestionType } from 'app/components';

import template from './question-simple.html';
import mainStyle from './question-simple.css';
import commonStyle from '../common.css';

@Component({
  selector: 'question-simple',
  template: template,
  styles: [
    commonStyle,
    mainStyle
  ]
})
export class QuestionSimpleComponent extends GenericQuestion {

  public static type = QuestionType.Simple;

  public init(): void {
    this.setTitle('Do you like this quiz?');
    this.setCorrectAnswer('yes');
  }

}
<!-- question-simple.html -->

<div class="col s12 m8 offset-m2 l6 offset-l3">
  <div class="card-panel grey lighten-5 z-depth-1">
    <div class="row valign-wrapper">
      <div class="col s2">
        <i class="material-icons circle green white-text">sentiment_satisfied</i>
      </div>
      <div class="col s10 truncate">
        {{ question.title }}
      </div>
    </div>
  </div>
</div>

<!-- Using the previously created answer type -->
<answer-yesno [question]="question" (onAnswerChange)="answerChanged($event)">

<!-- It is possible to omit the following, but it gives you
the ability to add a custom icon, image, or anything else
to the status overview -->
<ng-template #statusTemplate>
  <i class="material-icons circle green white-text">sentiment_satisfied</i>
</ng-template>

// index.ts
export * from './question-simple.component';

Finally add an export to src/js/components/quiz/questions/questions.ts:

export * from './simple/index';

This is it

The application will automatically consider the added question and will use it randomly.

Try it! You can copy-paste the code above.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].