Skip to main content

CIS 371

CSS and HTML

Winter 2023

GitHub Classroom URL: https://classroom.github.com/a/RyMm8wnk

Objective

The objective of this series of assignments is to provide students with practice writing HTML and CSS.

Part 1: Static Wordle Board

Implement the Wordle board shown below in HTML and CSS.

(If you prefer, you can skip directly to Part 2 and complete them together as one assignment.)

Wordle board

For the most part, you are free to style the board however you like. It need not match the example below exactly. However,

This assignment must be completed individually. You may not share code; but, you are encouraged to share high-level ideas with each other including:


Part 2: Wordle using a template

Use an HTML templating system to generate the Wordle board.

6x8 Wordle board

Scaffolding

If you decide to use ejs as your templating system, I have set up an ExpressJS server that will (1) render the .ejs file for you, and (2) process the query string, and (3) pass the relevant parameters to the template. (You are not required to use this setup. You may also change my setup as you see fit.)

If you choose to use the provided server, do the following:

  1. Run npm install to install express, ejs, and Jest locally.
  2. Place your .ejs file in the view directory and give it a name that begins with with "wordle".

The Express server will pass query string parameters maxAttempts and guesses to your template as local variables. If you named your template file wordle_part2.ejs, you could test it by

  1. Running node index.js from the command line.
  2. Pointing your web browser to http://localhost:3000/wordle_part2?maxAttempts=8&guesses=short,shots,farce,seven

(You can run/examine wordle_demo to see how the routing and parameters are handled.)


Part 3: Implement the game

Add JavaScript to your Wordle board so that you can play the game.

Rules:

As with Part 2, you may use the provided code as a starting point. The js directory contains the outline of a Model, View, and Controller for Wordle. These files demonstrate how to add listeners to the keys, and how the Controller can connect the Model and the View. This sample code also grabs the parameters for the game (maxAttempts and the answer) from the query string. (See js/Wordle.js.)

(If you prefer, you can skip directly to Part 4 and complete them together as one assignment.)


Part 4: Add unit tests

Add unit tests to your model and controller. (I suggest you use Jest; but, you may pick any test framework you like.)

Setting up Jest

To run your Wordle code directly in a browser, you will want to use the ES 6 module import syntax. This ES6 syntax is different from the CommonJS syntax used by Node, which causes problems when testing. To address the differing import syntax, we will use a package called Babel to transform the code into something that Node handles.

The starter code has Jest and Babel already set up. However, if you need to add it to your project:

  1. Set up npm in your project: npm init -y
  2. Install Jest: npm install --save-dev jest
  3. Install Babel: npm install --save-dev babel-jest @babel/core @babel/preset-env
  4. Configure Babel by creating a file named babel.config.js with the following content:
    module.exports = {
      presets: [
        [
          '@babel/preset-env',
          {
            targets: {
              node: 'current',
            },
          },
        ],
      ],
    };
    
  5. Edit the "scripts"/"test" property in package.json to equal jest

You can now run your Jest tests from the command line with npm test.

Submission

I will grade the parts of this assignment separately.


Updated Monday, 30 January 2023, 11:14 AM

W3c Validation