CIS 371 |
CSS and HTML |
Winter 2020 |
Based on an assignment originally developed by Prof. Engelsma.
GitHub Classroom URL: classroom.github.com/a/txkne0og
Objective
The objective of this assignment is to provide students with practice writing HTML and CSS.
Part 1: CSS
Craft CSS code for the following scenarios. You must craft your CSS by hand – do not use any third party CSS or JavaScript libraries in your solutions.
Avoid duplicating CSS rules when possible. I suggest adding the CSS to the head of each .html
file in the git repo. Feel free to suggest an alternative.
Please complete this assignment individually.
- Problem 1
-
HTML Source:
Problem 1 Example 1
Curabitur blandit tempus porttitor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Maecenas faucibus mollis interdum. Aenean lacinia bibendum nulla sed consectetur. Maecenas sed diam eget risus varius blandit sit amet non magna. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
Mad Tertulous
Specifications:
- h1 is centered with text color purple.
- The element marked with id=”signature” is right justified italics.
- First character in the paragraph is the Georgia font family and 40px in size.
- Problem 2
-
HTML Source:
Problem 2 I am top left
I am bottom left
I am top right
I am bottom right
Centered
Specifications:
- left justified text has a left margin of 5px.
- Right justified text has a right margin of 5px.
- Top/bottom margin is default.
- Size of the box is 100px X 100px, with background color
#00FF00
. - Be sure the center of box stays in the center when the screen is resized. (The center of the box should be centered, not the top, left corner.)
calc
for compute the location.
HTML Source:
Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur.
Nullam id dolor id nibh ultricies vehicula ut id elit. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam quis risus eget urna mollis ornare vel eu leo. Maecenas sed diam eget risus varius blandit sit amet non magna. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Donec ullamcorper nulla non metus auctor fringilla.
Maecenas faucibus mollis interdum. Nullam id dolor id nibh ultricies vehicula ut id elit. Donec ullamcorper nulla non metus auctor fringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
Specifications:
- paragraph text is displayed in default font.
- Quote box measures 200px X 100px.
- The font size of the quoted text is 120% larger than the default font-size.
- The font style of the quoted text is italic.
- The precise appearance of the page will depend on the width of the window. The important feature is that the paragraph text wraps around the quote text.
HTML Source:
Specifications:
- The boxes should begin to stack up vertically when the width of the view is reduced (i.e., when you reduce the width of your browser window.)
- If your browser window won't narrow enough to stack the boxes, you can make them a bit wider.
- This page need only work for browsers. It doesn't have to be "responsive" and work for mobile.
- Use shades of red, yellow, green for the box background and border. Colors do not need to match the example above exactly.
- The boxes are 300px wide.
- Padding, margins and borders are all set to 10px.
- Text should be centered in the containing box.
- Avoid duplicating lines of CSS. Place settings that apply to all three boxes in their own CSS ruleset.
HTML Source:
Specifications:
- normal, unvisited links are red with no underline.
- Visited links are grey with no underline.
- If you hover over a link it turns red with an underline.
- When you click a link it flashes momentarily a blue color with no underline.
Part 2: Quixx Board
Implement the board for the "pencil game" Quixx.
- Make your game look as much like the sample below as possible.
- Focus on designing your CSS to avoid duplication when possible.
- Make the width of each number box the same. (In other words, a box containing "2" should not be narrower than a box containing "12".)
- Limit your use of absolute and relative positioning. (You will need to use them in a couple places.)
- The starter code includes
quixx.html
. The purpose of this starter file is so you don't have to type the HTML for each number box by hand. You may use this as a starting point if you like; or, you can create your ownhtml
file from scratch. - Your design does not need to be responsive. Feel free to hard-code widths and heights for this assignment.
- Your design does, however, need to appear correctly at different screen witdths and scale factors. That doesn't mean it has to look good on a mobile screen, but small adjustments to the scale and/or window size shouldn't mess up the image.
This assignment must be completed indivdually. You may not share code; but, you are encouraged to share high-level ideas with each other including:
- Which CSS properties you used
- Which selectors you used to avoid repetition
Expect Part 2 to take much longer than Part 1.
Hints:
- You can use Unicode character
🔒
for the lock. - You can use Unicode character
🎲
for the small die. - You can use Unicode character
✗
for the smallx
over the die. - Use
position: relative
to slide thex
over the die. - Use
position: abosolute
to draw the back border around the 12 and lock columns. - Using
var
andcalc
will make it easier to make adjustments. (Remember to put spaces around "+
" and "-
".)
Part 3: Quixx using a template
Use an HTML templating system to generate the Quixx board.
- You may use any templating system you like (PHP, Razor (C#), ERB (Ruby), EJS (JavaScript), Jinja (Python), etc.). The sample code on git hub contains examples of several of these templating systems.
- Your template should dynamically generate a board based on two parameters: the maximum value in each row, and the number of rows.
For example, the board below uses parameters of 21 and 6. (If you prefer, you may simply set two variables at the beginning of your code and change those values by hand to generate a differently configured board.)
- In order for the template to automatically adjust to the desired number of rows and values, your template will have a nested loop.
- The first
n/2
rows should count up, the lastn/2
rows should count down.
- In preparation for the next assignment, please add a unique id to each number box. The ids should look something like
row3-col6
- You may use the template to generate CSS as well. (You may need to do this to get the widths and placement correct.)
Part 4: Implement the game
GitHub classroom link: classroom.github.com/g/cIUHZHJO
.
Add JavaScript to your Qwixx board so that you can play the game. You can find the rules here: gamewright.com/pdfs/Rules/QwixxTM-RULES.pdf
Rules:
- You may work in teams of up to two. (I will give temmates access to your repository by hand. Just ask.)
- Your implementation must be client-side only. (Obviously, you will need a server to provide the page and JavaScript; but, once the page loads, you shouldn't talk to the server again.)
- Use plain JavaScript: Don't use React, Angular, Vue, etc.
- You may either (1) use a static HTML file with a fixed, standard-sized board, or (2) use your code from part 3 to load a dynamically-generated board.
- You will need to add dice to your Qwixx board: Two white dice, and one additional die for each color used.
- Your implementation must use Model-View-Controller design (i.e., separate Model, View, and Controller) classes. (If you have a different design in mind, feel free to ask.)
- All state should be stored in the mode
- Your view may not modify your model.
- You must provide unit tests for your Model and Controller classes.
- You may use as much or as little of the provided starter code as you like.
Ideas / Suggestons:
- Have the model recognize and track three phases: (1) Need to roll, (2) Need to use white dice (or pass), (3) Need to use colored die (or take -5).
- Add a click handler to each number box. When a number box is clicked, check to see if that box is elligible to be crossed out (e.g., no boxes to the left have been crossed out, and number in the box corresponds to dice.)
- Writing many short, helper methods makes testing easier.
Setting up Jest
To run your Qwixx 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. To set up Jest using Babel:
- Set up
npm
in your project: npm init -y - Install
Jest
: npm install --save-dev jest - Install
Babel
: npm install --save-dev babel-jest @babel/core @babel/preset-env - Configure Babel by creating a file named
babel.config.js
with the following content:module.exports = { presets: [ [ '@babel/preset-env', { targets: { node: 'current', }, }, ], ], };
- Edit the
"scripts"/"test"
property to equaljest
You can now run your Jest tests from the command line with npm test.
Note: If you choose to use the starter code from GitHub classroom, these steps have already been completed. You need only run npm install.)
Rubric
This assignment will be scored out of 60 points, with opportunities for extra credit.
Points | Requirements |
---|---|
30 | Basic functionality and minimal model testing |
10 | Correctly calculates score |
10 | Correctly enforces rules |
5 | Complete and thorough unit tests |
5+ | A "bonus" of your choice (make the game multi-player, make the game work with a dynamically chosen board size, etc.) |
Note: In order to receive a grade for this assignment, your submission must, a minimum:
- Allow users to roll the dice,
- Allow users to cross out a box based on the white dice,
- Allow users to cross out a box based on a colored die, and
- Contain unit tests for the model.
Submission
I will grade the parts of this assignment separately.
- When Part 1 is complete, commit to the
master
branch with a commit message that includes "[grade me 1]
" (the square brackets are important). - When Part 2 is complete, commit to the
master
branch with a commit message that includes "[grade me 2]
" (the square brackets are important). - When Part 3 is complete, commit to the
master
branch with a commit message that includes "[grade me 3]
" (the square brackets are important). - When part 4 is complete, commit to the
master
branch with a commit message that includes "[grade me 4]
" (the square brackets are important) and Schedule a demo with me.
Please fill out this survey from RIT when you have completed Part 4.
Updated Saturday, 4 April 2020, 4:41 PM