Web Development COMP2101
- Subject Code :
COMP2101
Assessment 3 Web development Marking guide
Assessment criteria / grading rubric
CRITERIA |
A: Excellent (>80%) |
B: Very good (7079%) |
C: Good (6069%) |
D: Acceptable (5059%) |
N: Unacceptable (<50> |
Create a navigation bar to link pages (10 marks) |
Create a navigation bar with links pointing to at least 6 webpages (810 marks) |
Create a navigation bar with links pointing to 45 webpages (7 marks) |
Create a navigation bar with links pointing to 23 webpages (6 marks) |
Create a navigation bar with links pointing to 1 webpage (5 marks) |
No navigation bar (<5> |
Implement functionalities of the website (70 marks) |
Implement at least 12 functionalities (5670 marks) |
Implement at least 911 functionalities (4955 marks) |
Implement at least 68 functionalities (4248 marks) |
Implement 35 functionalities (3541 marks) |
Implement less than 3 functionalities (<35> |
Design the layout and styling of the website (20 marks) |
Very good use of spacing, symmetry, font and colours Consistent page layout (1620 marks) |
Good use of spacing, symmetry, font and colours Consistent page layout (1415 marks) |
Appropriate use of spacing, symmetry, font and colours Consistent page layout (1213 marks) |
Appropriate use spacing, symmetry, font and colours Inconsistent page layout (1011 marks) |
Improper spacing, symmetry, font and colours Inconsistent page layout (<10> |
IFU Web Assignment - Appendix
Relative URLs
A relative URL is a URL that is determined based on the path of the current page. Examples of a relative URL:
Examples of an absolute URL This type of URL is NOT allowed on this assignment.
'http://webprog.cs.latrobe.edu.au/12345678/IIT/Lab08/ViewCart.php'>View Cart
That last one is not even a valid URL
A URL that starts with a slash is called a root relative URL. This type of URL is NOT allowed on this assignment.
NOTE: you are allowed to use an absolute URL if you are linking to the brands website.
The reason this is so important is because we will not be marking your assignment from your home directory, instead we run the assignments from a special UNIX account.
Remember that Windows is not cases sensitive, but UNIX is. Please ensure your URLs are the correct case. This may cause problems if you develop your website on Windows and then copy it to UNIX.
Old HTML tags
There are a number of HTML tags and attributes that have been deprecated, which means your website must not use them because they are outdated and have been replaced by CSS.
You can always check if the tag or attribute you want to use is outdated by checking the w3schools website. List of deprecated tags and attributes:
http://www.tutorialspoint.com/html/html_deprecated_tags.htm
Here is a list of new tags in HTML5http://www.w3schools.com/htmL/html5_new_elements.asp
CSS Tricks
Animations.
You can do animations entirely using CSS3.http://www.w3schools.com/css/css3_animations.asp
Take a look at this:http://jsfiddle.net/nys5qzkd/5/
Imagine if we had something like this on the homepage, but instead of photos we had products that the user could click on. It would look very nice on your webprog.
Note: because CSS animations are so new, some browsers need to have special browser specific CSS. Most browsers will accept animation and @keyframes
But Chrome, Safari and Opera need to have -webkit-animation and @-webkit-keyframes
You should also investigateCSS Transitions.
Box sizing
When you specify a width in CSS, it does not include the margins and borders.
So a div with a width of 200px and a margin of 10px ends up taking 220px of space. This can cause all kinds of issues when using percentages.
To solve this issue you can use thebox-sizingCSS property.
Other Notes
If you're concerned that other students may try to copy your assignment (remember that your site is open to the public internet) what you can do is place an empty file named index.html in your public_webprog/IIT/ directory
Then rename you Lab08 directory to something that only you know. So now the only way to access your assignment is if you know the URL.
Detecting if the user already has a product in their cart. [NEW!]
Some of you may have noticed then when the user clicks on the 'Add To Cart' button nothing happens. But something is happening, it's just too fast to see!
When you click the 'Add To Cart' button the user gets redirected to AddToCart.php which adds the product to the ShoppingCart cookie. AddToCart.php then redirects the user back to ViewProduct.php instantly.
This happens so fast that it appears that nothing happened, so we need to provide the user some feedback! What we can do is make it so that the 'Add To Cart' button disappears if the product is already in the users cart.
This also prevents the same product being added multiple times by mistake (people might double click the button) There is a few ways to do this but this might be a good opportunity to use a user defined function.
Let's create a function called Does Cart Contain Product() which takes one parameter: the Product ID to look for. Our function will return true if the cart contains the specified product and false if it does not.
Step 1
Open functions.php and add a new function definition to the bottom of the file like so:
{
}
Notice that our function takes one variable as the input, this is known as the parameter (or argument)
Step 2
Inside out function we need to check if the user even has a shopping cart. If the user does not have a shopping cart, return false.
Inside our new function place this code:
if(isset($_COOKIE['ShoppingCart']))
{
cart
}
else
{
//user has no shopping cart.
}
Step 3
Ok so now we need to see if the users shopping cart contains the ProductID.
I have provided a handy function called stringContains(), which takes two parameters: a $haystack and a $needle. stringContains() will return true if it finds the needle in the haystack and returns false is it cannot be found.
We can use this function because the shopping cart cookie is a string! Inside the IF statement from step 2 (where the TODO is) place this code:
i
{
}
else
{
}
Step 4
Congratulations you have implemented you first PHP function!
Now we need to put it to good use. Open your ViewProduct.php and place this code inside the file.
// if the user has this item in their shopping cart
if(DoesCartContainProduct($ProductID))
{
}
else
{
echo "<form action = 'AddToCart.php?ProductID=$ProductID' method = 'POST'>";
//TODO echo the submit button here.
}
Common Errors
This happens if you include functions.php twice in the same file.
To fix this just remove the lower include.
Here we try to output $y before it was given a value.
PHP reads the file from top to bottom, so we need to make sure that $y has a value before we try to readthevalue. To fix this rearrange the file to define it before it gets used. Likeso:
This happens if you are selecting a column that is not part of that table.
Session ID is not in the movies table, we may need to do a join to the sessions table if we want to get sessionIDs
This can happen if you have a stray comma before the word FROM in your SQL. Can also happened if you have unclosed brackets just before the word FROM.
This usually happens because we never selected the plot in our SQL.
Remember that you can always check what is in a variable using var_dump()This can also occur if you did not put commas between your column names.Another possibility is this:
Notice that we are using $row2 instead of $row.
Make sure the $row variables names are correct.
Syntax errors can also be caused by having your keywords in the wrong order. LIMIT statements must goafterINNER JOIN statements. See the SQL lecture slides.
This often happens if you have the wrong quotes (or no quotes) around strings.
When in PHP try to get all strings to appear grey like so:
See the assignment appendix
This happens if you have a bindValue() with no matching question mark in the SQL. or if you have more bindValue statements than you do question marks.
Check that every question mark has a corresponding bindValue() with the correct number.
This happens when you try to bind a text variable to a number
Offsets must be integers. "Cheese" is not a number, so having an offset of "Cheese" makes nosense.
Check that your bindValue statements are correct.
This can happen if you are missing a closing curly bracket on your if statements. Check that every opening bracket "{" has a corresponding closing bracket "}"
This happens if you did not set proper permissions to the database directory AND the database files.
My reviews are displaying strange but I have no error messages.
This is usually caused by malformed HTML (forgetting to close tags) Run the page through the validator (see end of Lab 7)
IFU Web Assignment File Details.
This file describes the details of the PHP files that your online shop system will use.
You have also been provided with a diagram showing how the user will be directed around the different pages.
The red arrows represent POST requests and blue arrows represent GET requests. The files marked in green will be visible on the navigation bar.
The files marked in orange are special technical files that the user never sees.These files do not contain any HTML. Instead they perform a special task and depending in that task they redirect the user to another page.
Orange files should always be accessed by POST requests only because they modify the state of the website. The files marked in blue will be accessed using GET requests, and also require URL parameters.
The blue and green files should have the navigation bar visible at all times.
Unless there is a system error.
I recommend completing the orange files last.
If you have not already done so, please login to phpLiteAdmin and have a look at the data in all the tables this will help you get a better idea of what data you have to work with.
Message Cookies
Sometimes we want to display a message to the user but we dont want to display it on the current page.
Let's consider EmptyCart.php, this file has one task, empty the users shopping cart (deleting a cookie) When EmptyCart.php has completed its task with no errors it will redirect the user back to ViewCart.php
But we should always provide the user some feedback saying that the operation was successful. So we should display a message like "Your cart has been emptied"
The issue here is if we just echo a message on the page and then redirect the user, the user will have no time to read the message!
What we really need to do is display the message on ViewCart.php.
Problem: How can EmptyCart.php display a message on ViewCart.php?
Solution: Cookies.
What EmptyCart.php can do is set a cookie that contains the message we want to display, then redirect the user to ViewCart.php.
ViewCart.php then looks to see if there is a message cookie and if so display it on the page then deletes the cookie.
In this situation we would consider EmptyCart.php to be the message sender and ViewCart.php to be the message receiver.
There are a number of pages that use Message Cookies,these have already been implemented for you. Using the functions getCookieMessage() and setCookieMessage() (located in functions.php).
You must style the cookie messages so that they are noticed by the user (Error messages should be red for example) Although not all the cookie message are errors so make sure you style them appropriately.
I would recommend using a
or
for this, and maybe have a CSS class called errorMessage or something.
NOTE: getCookieMessage() will return an empty string if there was no messages. getCookieMessage() will also perform htmlspecialchars() on the messages so you can safely echo it to the page.
ProductList.php
Allows a customer to browse the items that our website has for sale.
This page will also provide a search functionality that allows potential customers to search the database for products they are interested in.
The output is limited to 10 items per page. The user should have a hyperlink to get to the next page and a hyperlink to get to the previous page.
The products should be sorted by popularity (that is, how many orders does each product appear in).
SQL Statements Required:
- One SQL SELECT statement to select the relevant
ViewProduct.php
Shows the details of a given product including a picture, description and price. The ProductID will be provided by a URL parameter.
Also shows the details of the brand, including a brand logo and a hyperlink to the brands website.
This page will also provide a button that says 'Add to Cart'. When the user clicks this button they will be taken to AddToCart.php which will then add the product to the users shopping cart. AddToCart.php will then send them back to this page.
Check to see if the user has this product in their shopping cart, if so dont display the 'Add to Cart' button.
SQL Statements Required:
- One SQL SELECT statement to select the given product.
CustomerList.php
Allows the business owners to view all the customers in the database.
For every customer in the database list ALL their details including CustomerID, name, address etc. This data should be displayed using a