├── .gitignore
├── README.md
├── assignments
├── assignment-1.md
├── assignment-2.md
├── assignment-3.md
├── assignment-4.md
├── assignment-5-client.js
├── assignment-5.md
├── images
│ ├── Box1_$10.png
│ ├── Box2_$5.png
│ ├── Clothes1_$20.png
│ ├── Clothes2_$30.png
│ ├── Jeans_$50.png
│ ├── KeyboardCombo_$40.png
│ ├── Keyboard_$20.png
│ ├── Mice_$20.png
│ ├── PC1_$350.png
│ ├── PC2_$400.png
│ ├── PC3_$300.png
│ └── Tent_$100.png
├── layout.png
└── product.png
├── server-boilerplate
├── README.md
├── StoreDB.js
├── index.js
├── initdb.mongo
├── package.json
└── public
│ └── index.html
└── tutorials
└── git-setup.md
/.gitignore:
--------------------------------------------------------------------------------
1 | CMakeCache.txt
2 | CMakeFiles
3 | CMakeScripts
4 | Testing
5 | Makefile
6 | cmake_install.cmake
7 | install_manifest.txt
8 | compile_commands.json
9 | CTestTestfile.cmake
10 | **/node_modules/**
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # University of British Columbia - CPEN 400A (Winter 2019)
2 | This repo contains the tutorials and necessary materials needed for assignments.
3 |
4 | [Git Tutorial](tutorials/git-setup.md)
5 |
6 | 1. [Assignment-1](assignments/assignment-1.md)
7 | 2. [Assignment-2](assignments/assignment-2.md)
8 | 3. [Assignment-3](assignments/assignment-3.md)
9 | 4. [Assignment-4](assignments/assignment-4.md)
10 | 4. [Assignment-5](assignments/assignment-5.md)
11 |
12 |
--------------------------------------------------------------------------------
/assignments/assignment-1.md:
--------------------------------------------------------------------------------
1 | [<< Back to Main](../README.md)
2 |
3 | # Overview
4 |
5 | You are hired as a web developer for UBC bookstore to develop a website to sell their products online. As a part of your job you are going to build an online store where you can list different items that can be sold online. Students can register on the website, browse all the available products, check out availability, read product description and purchase any of the listed items.
6 |
7 |
8 | # Assignment 1
9 |
10 | For the first part of this project, you will need to build the homepage for the online store. Below is a wireframe of how the web page should look:
11 |
12 | 
13 |
14 | You are free to choose colours and fonts of your own choice.
15 |
16 | **For this assignment, you will be using HTML and CSS to define the layout of a web page and apply styles to different DOM elements. There is no JavaScript required for this assignment, so you will be penalized if you use JavaScript for this assignment.**
17 |
18 |
19 | ## Directory Structure
20 |
21 | To help you get started, you will need to structure your project like the following. **Submission instructions are given in the end of this document.**
22 |
23 | ```
24 | /css/
25 | /js/
26 | /images/
27 | /index.html
28 | ```
29 |
30 | * Root folder (all html files go in this folder)
31 | * css
32 | * (all stylesheets go in this folder)
33 | * js
34 | * (all JavaScript files go in this folder)
35 | * images
36 | * (all images go in this folder)
37 | * index.html (this should be the entry point to your website)
38 |
39 |
40 | ## Tasks
41 |
42 | 1. [HTML] Create the html layout that will be required to generate the web page provided in the screenshot. Your homepage should include the following elements:
43 |
44 | * Header (div id=header)
45 | * Logo (img id=logo)
46 | * Welcome Banner (img id=banner)
47 | * Main Content (div id=content)
48 | * Navigation Menu (ul id=menu)
49 | * Menu Item 1 (li class=menuItem)
50 | * Menu Item 2 (li class=menuItem)
51 | * Menu Item 3 (li class=menuItem)
52 | * Product List (ul id=productList)
53 | * Product 1 (li class=product)
54 | * Product 2 (li class=product)
55 | * Product n (li class=product)
56 | * Footer (div id=footer)
57 |
58 | * **You can find and download all the product images that you will be displaying on the home page [HERE](./images/). The product name and price are indicated in the file name.**
59 |
60 | 2. [CSS] Create a CSS stylesheet to add relevant styles that would help you design the layout for the web page. A few things to keep in mind:
61 | * The width of the content within the website should be 1000px.
62 | * The content should be centered within the web page.
63 |
64 | 3. [CSS] You need to add some interactivity to the website using pure css (no javascript is required for these tasks, so *please do not use JavaScript*)
65 | * A) When you hover over any of the items in the navigation menu, the **text and background color should be changed**. As soon as you move the mouse pointer away, the color should be restored back to the original color.
66 | * B) When you hover over any of the product, the **background color around the product should change, and the price should become visible on top of the product image**. As soon as you take the mouse pointer away, the price should disappear and the background should revert to its original color.
67 |
68 |
69 | ## Testing
70 |
71 | **To test your code, insert the following script tags in the head tag of your page**
72 | ```
73 |
74 |
75 | ```
76 | You will see a red button on the top-right corner of your web page. Click it to test your code.
77 |
78 | * Note that you do not need to setup any server to host the webpage you are creating. Simply open the html pape with any browser, the webpage will be displayed.
79 |
80 | * The marks and feedback you get from the test script is for your debugging purposes. **Those marks are not used for grading.**
81 |
82 |
83 | ## Marking
84 |
85 | There are 3 tasks for this assignment:
86 | * Task 1: 2 Points
87 | * Task 2: 2 Points
88 | * Task 3:
89 | * A: 3 Points
90 | * B: 3 Points
91 |
92 |
93 | ## Submission instructions:
94 |
95 | * For each assignment, create a branch called `assignment-{number}` (case-sensitive, note the hyphen), for ex: `assignment-1`, `assignment-2`, * etc.
96 | * The TAs use a script to automate the checkout process, so it is **important that the branch name follows the format**
97 | * You can create as many branches as you want, but we will only mark the branch that follows this naming format
98 | * Make sure you push your changes to that branch before midnight (11:59 PM) on the date of the assignment deadline - late submissions will not be accepted.
99 | * We will be downloading the code on the midnight of the due date, any changes to code after that point will not be considered for marking.
100 |
101 | * For a step-by-step walk-through of the submission procedure, go [here](../tutorials/git-setup.md)
102 |
103 |
104 | ### Deadline:
105 |
106 | These deadlines will be strictly enforced; we won't be looking at any commits done after this time-stamp.
107 |
108 | * L1A, L1B, and L1C - Monday, September 23, 2019 23:59:59 PST
109 |
110 | Feel free to create the branch *assignment-N* from the beginning and make incremental commits. Doing it this way you would still have partially completed work even if you accidentally forget to push the final commit on the day of the deadline. We will `checkout` the most recent commit time-stamped before the deadline. For this Assignment 1, the branch should be called `assignment-1`.
111 |
--------------------------------------------------------------------------------
/assignments/assignment-2.md:
--------------------------------------------------------------------------------
1 | [<< Back to Main](../README.md)
2 |
3 | # Assignment 2
4 |
5 | This assignment builds on the work you have done for [Assignment 1](./assignment-1.md).
6 |
7 | For this assignment you will be implementing the "Shopping Cart" functionality. Here is a high-level overview of what you will be doing:
8 |
9 | * Create a "Store" object to keep track of the application's state
10 | * Create "Add to Cart", "Remove from Cart" buttons
11 | * Create a "Show Cart" button to see the items in the cart
12 | * Create a timer to track user inactivity
13 |
14 |
15 | ## Directory Structure
16 |
17 | Same as assignment 1, except this time it will include a JavaScript file that describes your application.
18 |
19 | ```
20 | /css/
21 | /js/
22 | /app.js
23 | /images/
24 | /index.html
25 | ```
26 |
27 | In the above example `app.js` will have all your JavaScript code. You should include this in your `index.html` as a `
74 |
75 | ```
76 | You will see a red button on the top-right corner of your web page. Click it to test your code.
77 | Watch out for the alert messages which tell you any missing components/functionalities. You are responsible for ensuring that all the functionalities above are implemented correctly - the tests are only there to help you. We reserve the right to test your code with other test cases than the above.
78 |
79 | * The feedback you get from the test script is for your debugging purpose only; **they are not used directly for grading.**
80 |
81 |
82 | ## Marking
83 |
84 | There are 7 tasks for this assignment (Total 15 Points):
85 | * Task 1: 2 Points
86 | * Task 2: 1 Point
87 | * Task 3: 1 Point
88 | * Task 4:
89 | * A: 1 Point
90 | * B: 1 Point
91 | * Task 5:
92 | * A: 2 Point
93 | * B: 2 Point
94 | * Task 6: 2 Points
95 | * Task 7: 3 Points
96 |
97 |
98 | ## Submission instructions:
99 |
100 | * Create a branch called `assignment-2`.
101 | * Update the code to reflect the changes for this assignment.
102 | * Make sure you commit and push your changes before the due date - late submissions will not be accepted.
103 |
104 |
105 | ### Deadlines:
106 |
107 | These deadlines will be strictly enforced; we won't be looking at any commits done after this time-stamp.
108 |
109 | * L1A, L1B and L1C - Monday, October 7, 2019 23:59:59 PST
110 |
--------------------------------------------------------------------------------
/assignments/assignment-3.md:
--------------------------------------------------------------------------------
1 | [<< Back to Main](../README.md)
2 |
3 | # Assignment 3
4 |
5 | This assignment builds on the work you have done for [Assignment 2](./assignment-2.md).
6 |
7 | In this assignment you will be focusing on making your application more dynamic. Here is a high-level overview of what you will be doing:
8 |
9 | * Dynamically generate the product list
10 | * Dynamically generate the shopping cart modal
11 |
12 |
13 | ## Tasks
14 |
15 | Before you begin, you can set the inactivity timeout to 30 minutes or longer so that the alerts don't keep popping up.
16 |
17 | 1. (5 Points) [JS] Define and implement the following functions.
18 | * A) `renderProduct(container, storeInstance, itemName)`
19 | * The first argument `container` is a DOM element *(not a CSS selector string)*
20 | * The second argument `storeInstance` is an instance of `Store`.
21 | * The third argument `itemName` is the name of a product (e.g. `"Box1"`)
22 | * The function should generate a single product box (DOM element) corresponding to `itemName`, then **replace the contents of `container` with this new DOM element**.
23 | * Conditionally generate "Add to Cart" and "Remove from Cart" buttons:
24 | * If the quantity of an item in stock is zero, "Add to Cart" button should not be generated.
25 | * If the quantity of an item in cart is zero, "Remove from Cart" button should not be generated.
26 | * Make sure that the click handlers on the buttons are working correctly.
27 |
28 | * B) `renderProductList(container, storeInstance)`
29 | * The first argument `container` is a DOM element *(not a CSS selector string)*
30 | * The second argument `storeInstance` is an instance of `Store`.
31 | * The function should generate the product list (DOM element), which so far you had hard-coded in the HTML, and then **replace the contents of `container` with this new DOM element.**
32 | * Use the `renderProduct` function you created in Task 1A to generate the individual product boxes.
33 | * On the element **that you pass to `renderProduct`** as the first argument, assign the id `product-` where `` is the name of each product (e.g. `"Box1"`). *You will need this id later.*
34 |
35 | 2. (1 Point) [JS+HTML] Remove the hard-coded product list (i.e. #productList) from `index.html` and in its place put a placeholder `
` with id `productView`. Then invoke `renderProductList` function with the appropriate arguments to populate this `
` element.
36 |
37 | 3. (2 Points) [JS] If you have completed Task 1 and 2, the product list should now render when you load the page. However, when you add an item to the cart, the "Remove from Cart" button does not show because we are not updating the HTML when our cart object is modified. In this task, you will use a *callback function* to set up a mechanism to re-render the view whenever the application's state is updated.
38 | * Add a new property `onUpdate` in the `Store` constructor function and initialize it to `null`
39 | * The `onUpdate` property will later be assigned a function that takes a single argument. In `addItemToCart` and `removeItemFromCart` methods, call `this.onUpdate` function whenever cart or stock is updated, passing in `itemName` as the argument.
40 | * After the `store` object is instantiated, assign to its `onUpdate` property a function with the signature `function(itemName)`.
41 | * The first argument `itemName` is the name of a product (e.g. `"Box1"`)
42 | * This function should call `renderProduct` function with the appropriate arguments. (Hint: use the ids you assigned in Task 1.B)
43 | * If Tasks 1 ~ 3 are done correctly, the product list should now be updated dynamically.
44 |
45 | 4. (4 Points) [JS] You will be upgrading the "show cart" functionality to display a modal window instead of an alert. First, define and implement the function with signature `renderCart(container, storeInstance)`:
46 | * The first argument `container` is a DOM element *(not a CSS selector string)*
47 | * The second argument `storeInstance` is an instance of `Store`.
48 | * The function should generate a table (does not need to be specifically a `
` element, we just mean "tabular representation") displaying the contents of the cart including the quantity of each item and the total price, and then **replace the contents of `container` with this new DOM element.**
49 | * The table should also have "+" and "-" `