<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Billy</id>
	<title>CSE330 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Billy"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/Billy"/>
	<updated>2026-11-15T18:17:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Mean_Stack&amp;diff=1847</id>
		<title>Mean Stack</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Mean_Stack&amp;diff=1847"/>
		<updated>2014-11-17T18:22:38Z</updated>

		<summary type="html">&lt;p&gt;Billy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
This module introduces MEAN, a fullstack web framework that uses '''M'''ongoDB, '''E'''xpress, '''A'''ngularJS and '''N'''ode.js. &amp;lt;br/&amp;gt;&lt;br /&gt;
You have already learned (some things) about Node.js. In this module, you will be introduced to other three new technologies. Don’t frown yet, the goal of this module is to expose you to the concept of web frameworks and prepare you for the creative project. You are not required to be an expert in all of these technologies, however, it’s important to understand the basics of each and how they work together.&lt;br /&gt;
Follow along the tutorials and complete exercises to learn how things work, and you will be ready to create your own web applications using the MEAN stack very soon!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting MEAN]]&lt;br /&gt;
* [[Git]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Tutorials ===&lt;br /&gt;
&lt;br /&gt;
Make sure you go through tutorials for both MongoDB and AngularJS, and understand how Express works.&lt;br /&gt;
&lt;br /&gt;
=== Install MEAN ===&lt;br /&gt;
&lt;br /&gt;
The individual and group assignments for this module only require AngularJS and completing the tutorial [https://docs.angularjs.org/tutorial here]. We provide installation instructions for the entire MEAN stack using MEAN.IO as a reference. You do not need to install the MEAN stack for this module (but it is recommended to really understand all of pieces involved). &lt;br /&gt;
&lt;br /&gt;
To install MEAN on your machine, initialize an app and type grunt in your terminal to start the server (make sure your mongoDB server is connected and running).&lt;br /&gt;
Open up the app in your browser (localhost:3000), and understand what the default app does.&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
* Extended the AngularJS tutorial with additional features.&lt;br /&gt;
&lt;br /&gt;
In the group portion of this module, you will extended the AngularJS tutorial with two additional features.  The first is a side-by-side comparison page displaying two products.  In the second, you will provide four additional sorting methods for displaying devices on the main product page.  &lt;br /&gt;
&lt;br /&gt;
In the side-by-side comparison page, a user will be able to select two devices and view all of their features in a table.  This table will consist of three columns.  The first column simply lists all of the features of either device (battery, camera, connectivity, hardware, etc ) .  The second and third columns will display the information associated with that category for a particular pair of devices, allowing a user to easily compare the same feature across different devices. &lt;br /&gt;
&lt;br /&gt;
The second feature is simply allowing users to sort the devices on additional metrics (in addition to Alphabetical and Newest).  Select four different attributes that you want to include to the drop down list on the main page. For example, I may want to sort by by weight or size of battery.  &lt;br /&gt;
&lt;br /&gt;
For each feature, create a separate Git branch.  Name the first branch SideBySide and the second branch AdditionalSorting.  After you complete a feature, merge the branch back to the master branch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- * Make an e-commerce site using the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To start, come up with use cases for your site. Think about what products the site is selling, what the user can do, and how information is stored etc.&lt;br /&gt;
&lt;br /&gt;
You may start with the default MEAN.io app and build on top of it. This way you don't have to implement user authentication. You can also create a MEAN package and start from there. &amp;lt;br/&amp;gt;&lt;br /&gt;
You may use phone models provided by the Angular Phone Catalog app as your products. Review the MongoDB section on how to import JSON data into MongoDB.&lt;br /&gt;
&lt;br /&gt;
 ==== Tips on Installing MEAN ====&lt;br /&gt;
&lt;br /&gt;
 Review the &amp;quot;Getting MEAN&amp;quot; section to understand the file system so you know how components work with each other.&lt;br /&gt;
 Keep in mind that you don't have to understand what every line of code does. Whenever in doubt, refer to the default app.&lt;br /&gt;
&lt;br /&gt;
You will be making changes on both the server side (the /server directory of your app) and the client side (in the /public directory)&lt;br /&gt;
#* Server Side:&lt;br /&gt;
Model: add model files to the /server/models folder. There are Mongoose files that define the objects, they are referenced by the controllers.&lt;br /&gt;
View: nothing to change&lt;br /&gt;
Controller: add controller file(s) for your models (/server/controllers), they are referenced by the routing file&lt;br /&gt;
Routing: add a js file in /server/routes folder that responds to client side requests (same format as the one in the default app) &lt;br /&gt;
#* Client Side&lt;br /&gt;
Model: nothing to change&lt;br /&gt;
View: (/public/views directory) views are .html files. Each view that requires data from the server side should be tied to a controller, inside the controller, you can specify methods to update/save/delete objects in the DB,  the view and routing section gives an example&lt;br /&gt;
Controller: add controller files to /public/controllers. Easy once you go through the AngularJS tutorial. You may need to add multiple services in the /public/services directory (tutorial part 11, and the default MEAN app) to use data received from the back end and persist data across views (look up ngCookie, $cookieStore or the HTML 5 localStorage solution).&lt;br /&gt;
Routing: /public/routes directory of your app. Add entries for all views you will use, and specify their urls and templates (stored in /public/views). --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total where 18/50 are extra credit points. To complete this module you must do either the Side-By-Side comparison feature or the Additional Sorting feature. You will receive the points according to the rubric below, and any points over 32/50 will be extra credit.&lt;br /&gt;
&lt;br /&gt;
# '''Completed AngularJS Tutorial (6 Points)'''&lt;br /&gt;
# '''Completed Side-By-Side comparison feature (18 points)'''&lt;br /&gt;
#* Users can select two different devices and view all of their attributes in a table format.&lt;br /&gt;
#* If information for a particular category is not available on one device, display &amp;quot;Not available&amp;quot; in the table&lt;br /&gt;
# '''Completed Additional Sorting feature (8 points)'''&lt;br /&gt;
#* Users can sort devices based on four different attributes and the attribute values are displayed on the main device list page.  (2 points per attribute).&lt;br /&gt;
# '''Git Repo (8 points)'''&lt;br /&gt;
#* Two branches are created, one for each feature (4 points).&lt;br /&gt;
#* Both branches are merged back to the master branch (4 points).&lt;br /&gt;
# '''Creative Portion (10 Points)'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Billy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=1792</id>
		<title>Module 4</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=1792"/>
		<updated>2014-10-01T02:41:03Z</updated>

		<summary type="html">&lt;p&gt;Billy: /* Output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 4, you will learn the fundamentals of Python, a popular scripting language, and Regular Expressions, which give you power in text processing.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 4.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Learn Python and Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Up to this point in CSE 330, you have used only one programming language: PHP.  In Module 4, you will learn a new language: Python.  Before starting this assignment, you should look over the [[Python|online textbook article about Python]].  Additionally, you may find it helpful to look over the [[Regular Expressions|online textbook article about Regular Expressions]].&lt;br /&gt;
&lt;br /&gt;
=== Write some Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Please write regular expressions that do each the following:&lt;br /&gt;
&lt;br /&gt;
# Match an input string that contains at least one occurrence of the string &amp;quot;hello world&amp;quot;&lt;br /&gt;
# Find all words in an input string that contain a triple vowel&lt;br /&gt;
# Match an input string that is entirely a flight code, of the format AA####, where '''AA''' is a two-letter uppercase airline code, and '''####''' is a three- or four-digit flight number&lt;br /&gt;
&lt;br /&gt;
Save your regexes to a text file.  The TA will test them in regexpal on Demo Day.&lt;br /&gt;
&lt;br /&gt;
=== Baseball Stats Counter ===&lt;br /&gt;
&lt;br /&gt;
The St. Louis Cardinals are the most legendary baseball team in the national league.  In this exercise, you will be creating a Python script that reads box scores from a file and computes the Cardinals' players' batting averages in a particular season.&lt;br /&gt;
&lt;br /&gt;
==== Tips and Instructions ====&lt;br /&gt;
&lt;br /&gt;
* You should write a Python script file to solve this problem.&lt;br /&gt;
* You should use a regular expression to parse players' names, at-bats, hits, and runs from the input file.&lt;br /&gt;
* You may want to create a class to hold and compute information about each player.&lt;br /&gt;
* Your file should take one command-line argument: the path to an input file.  If no path is given, your program should print a usage message.&lt;br /&gt;
&lt;br /&gt;
==== Input ====&lt;br /&gt;
&lt;br /&gt;
Sample input files may be found here: http://classes.engineering.wustl.edu/cse330/content/cardinals/&lt;br /&gt;
&lt;br /&gt;
The top of the file contains a citation, and what follows is an entire season of Cardinals Baseball box scores.  Each game starts with a title; for example:&lt;br /&gt;
&lt;br /&gt;
 === St.Louis Cardinals vs. Chicago Cubs, 1940-04-19 ===&lt;br /&gt;
&lt;br /&gt;
What follows are the performance of each player in that game.  The format of each line is as follows:&lt;br /&gt;
&lt;br /&gt;
 XXX batted # times with # hits and # runs&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name (you may assume that the name is unique), and each '''#''' are integers representing the number of &amp;quot;at bats&amp;quot;, the number of &amp;quot;hits&amp;quot;, and the number of &amp;quot;runs&amp;quot;, respectively.&lt;br /&gt;
&lt;br /&gt;
==== Output ====&lt;br /&gt;
&lt;br /&gt;
Your script needs to output all players' batting average across the season.  A player's batting average is that player's total hits divided by that player's total at-bats throughout the entire season.  For example, Johnny Hopp was at bat 149 times in 1940, and he had 41 hits, so his batting average was 0.275.&lt;br /&gt;
&lt;br /&gt;
Each line in the output should have the format:&lt;br /&gt;
&lt;br /&gt;
 XXX: #.###&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name, and '''#.###''' is the player's batting average, '''rounded''' (not truncated) to three decimal places.&lt;br /&gt;
&lt;br /&gt;
The players should be sorted by batting average, with the highest batting average on top.  If two players have the exact same batting average (before rounding occurs), the order between those two players is unimportant.&lt;br /&gt;
&lt;br /&gt;
For example, the correct output for the 1940 season is:&lt;br /&gt;
&amp;lt;!-- Jimmy Brown was 0.280 and Ira Hutchinson was 0.125 --&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Pepper Martin: 0.316&lt;br /&gt;
Walker Cooper: 0.316&lt;br /&gt;
Johnny Mize: 0.314&lt;br /&gt;
Ernie Koy: 0.310&lt;br /&gt;
Enos Slaughter: 0.306&lt;br /&gt;
Joe Medwick: 0.304&lt;br /&gt;
Terry Moore: 0.304&lt;br /&gt;
Joe Orengo: 0.286&lt;br /&gt;
Jimmy Brown: 0.280&lt;br /&gt;
Marty Marion: 0.279&lt;br /&gt;
Don Gutteridge: 0.276&lt;br /&gt;
Johnny Hopp: 0.275&lt;br /&gt;
Creepy Crespi: 0.273&lt;br /&gt;
Mickey Owen: 0.265&lt;br /&gt;
Bill DeLancey: 0.250&lt;br /&gt;
Don Padgett: 0.242&lt;br /&gt;
Stu Martin: 0.238&lt;br /&gt;
Eddie Lake: 0.222&lt;br /&gt;
Hal Epps: 0.214&lt;br /&gt;
Lon Warneke: 0.209&lt;br /&gt;
Harry Walker: 0.185&lt;br /&gt;
Max Lanier: 0.179&lt;br /&gt;
Bill McGee: 0.178&lt;br /&gt;
Carl Doyle: 0.174&lt;br /&gt;
Mort Cooper: 0.157&lt;br /&gt;
Clyde Shoun: 0.145&lt;br /&gt;
Carden Gillenwater: 0.130&lt;br /&gt;
Bob Bowman: 0.067&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Regular Expressions (15 Points):'''&lt;br /&gt;
#* Regular Expression 1 Correct (5 points)&lt;br /&gt;
#* Regular Expression 2 Correct (5 points)&lt;br /&gt;
#* Regular Expression 3 Correct (5 points)&lt;br /&gt;
# '''Baseball Stats Counter (35 Points):'''&lt;br /&gt;
#* Solution is written entirely in Python, except with permission from the instructor (8 points)&lt;br /&gt;
#* Correct usage of a regular expression to parse each line of the input file (8 points)&lt;br /&gt;
#* Script prints a usage message if a command line argument is not present (4 points)&lt;br /&gt;
#* Output is correct for the 1940 test case (15 points)&lt;br /&gt;
#*: ''This includes sorting and rounding.''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 4]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Billy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=1791</id>
		<title>Module 4</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=1791"/>
		<updated>2014-10-01T02:40:36Z</updated>

		<summary type="html">&lt;p&gt;Billy: /* Output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 4, you will learn the fundamentals of Python, a popular scripting language, and Regular Expressions, which give you power in text processing.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 4.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Learn Python and Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Up to this point in CSE 330, you have used only one programming language: PHP.  In Module 4, you will learn a new language: Python.  Before starting this assignment, you should look over the [[Python|online textbook article about Python]].  Additionally, you may find it helpful to look over the [[Regular Expressions|online textbook article about Regular Expressions]].&lt;br /&gt;
&lt;br /&gt;
=== Write some Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Please write regular expressions that do each the following:&lt;br /&gt;
&lt;br /&gt;
# Match an input string that contains at least one occurrence of the string &amp;quot;hello world&amp;quot;&lt;br /&gt;
# Find all words in an input string that contain a triple vowel&lt;br /&gt;
# Match an input string that is entirely a flight code, of the format AA####, where '''AA''' is a two-letter uppercase airline code, and '''####''' is a three- or four-digit flight number&lt;br /&gt;
&lt;br /&gt;
Save your regexes to a text file.  The TA will test them in regexpal on Demo Day.&lt;br /&gt;
&lt;br /&gt;
=== Baseball Stats Counter ===&lt;br /&gt;
&lt;br /&gt;
The St. Louis Cardinals are the most legendary baseball team in the national league.  In this exercise, you will be creating a Python script that reads box scores from a file and computes the Cardinals' players' batting averages in a particular season.&lt;br /&gt;
&lt;br /&gt;
==== Tips and Instructions ====&lt;br /&gt;
&lt;br /&gt;
* You should write a Python script file to solve this problem.&lt;br /&gt;
* You should use a regular expression to parse players' names, at-bats, hits, and runs from the input file.&lt;br /&gt;
* You may want to create a class to hold and compute information about each player.&lt;br /&gt;
* Your file should take one command-line argument: the path to an input file.  If no path is given, your program should print a usage message.&lt;br /&gt;
&lt;br /&gt;
==== Input ====&lt;br /&gt;
&lt;br /&gt;
Sample input files may be found here: http://classes.engineering.wustl.edu/cse330/content/cardinals/&lt;br /&gt;
&lt;br /&gt;
The top of the file contains a citation, and what follows is an entire season of Cardinals Baseball box scores.  Each game starts with a title; for example:&lt;br /&gt;
&lt;br /&gt;
 === St.Louis Cardinals vs. Chicago Cubs, 1940-04-19 ===&lt;br /&gt;
&lt;br /&gt;
What follows are the performance of each player in that game.  The format of each line is as follows:&lt;br /&gt;
&lt;br /&gt;
 XXX batted # times with # hits and # runs&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name (you may assume that the name is unique), and each '''#''' are integers representing the number of &amp;quot;at bats&amp;quot;, the number of &amp;quot;hits&amp;quot;, and the number of &amp;quot;runs&amp;quot;, respectively.&lt;br /&gt;
&lt;br /&gt;
==== Output ====&lt;br /&gt;
&lt;br /&gt;
Your script needs to output all players' batting average across the season.  A player's batting average is that player's total hits divided by that player's total at-bats throughout the entire season.  For example, Johnny Hopp was at bat 149 times in 1940, and he had 41 hits, so his batting average was 0.270.&lt;br /&gt;
&lt;br /&gt;
Each line in the output should have the format:&lt;br /&gt;
&lt;br /&gt;
 XXX: #.###&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name, and '''#.###''' is the player's batting average, '''rounded''' (not truncated) to three decimal places.&lt;br /&gt;
&lt;br /&gt;
The players should be sorted by batting average, with the highest batting average on top.  If two players have the exact same batting average (before rounding occurs), the order between those two players is unimportant.&lt;br /&gt;
&lt;br /&gt;
For example, the correct output for the 1940 season is:&lt;br /&gt;
&amp;lt;!-- Jimmy Brown was 0.280 and Ira Hutchinson was 0.125 --&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Pepper Martin: 0.316&lt;br /&gt;
Walker Cooper: 0.316&lt;br /&gt;
Johnny Mize: 0.314&lt;br /&gt;
Ernie Koy: 0.310&lt;br /&gt;
Enos Slaughter: 0.306&lt;br /&gt;
Joe Medwick: 0.304&lt;br /&gt;
Terry Moore: 0.304&lt;br /&gt;
Joe Orengo: 0.286&lt;br /&gt;
Jimmy Brown: 0.280&lt;br /&gt;
Marty Marion: 0.279&lt;br /&gt;
Don Gutteridge: 0.276&lt;br /&gt;
Johnny Hopp: 0.275&lt;br /&gt;
Creepy Crespi: 0.273&lt;br /&gt;
Mickey Owen: 0.265&lt;br /&gt;
Bill DeLancey: 0.250&lt;br /&gt;
Don Padgett: 0.242&lt;br /&gt;
Stu Martin: 0.238&lt;br /&gt;
Eddie Lake: 0.222&lt;br /&gt;
Hal Epps: 0.214&lt;br /&gt;
Lon Warneke: 0.209&lt;br /&gt;
Harry Walker: 0.185&lt;br /&gt;
Max Lanier: 0.179&lt;br /&gt;
Bill McGee: 0.178&lt;br /&gt;
Carl Doyle: 0.174&lt;br /&gt;
Mort Cooper: 0.157&lt;br /&gt;
Clyde Shoun: 0.145&lt;br /&gt;
Carden Gillenwater: 0.130&lt;br /&gt;
Bob Bowman: 0.067&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
# '''Regular Expressions (15 Points):'''&lt;br /&gt;
#* Regular Expression 1 Correct (5 points)&lt;br /&gt;
#* Regular Expression 2 Correct (5 points)&lt;br /&gt;
#* Regular Expression 3 Correct (5 points)&lt;br /&gt;
# '''Baseball Stats Counter (35 Points):'''&lt;br /&gt;
#* Solution is written entirely in Python, except with permission from the instructor (8 points)&lt;br /&gt;
#* Correct usage of a regular expression to parse each line of the input file (8 points)&lt;br /&gt;
#* Script prints a usage message if a command line argument is not present (4 points)&lt;br /&gt;
#* Output is correct for the 1940 test case (15 points)&lt;br /&gt;
#*: ''This includes sorting and rounding.''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 4]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Billy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=1780</id>
		<title>Module 3</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=1780"/>
		<updated>2014-09-17T04:54:44Z</updated>

		<summary type="html">&lt;p&gt;Billy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 3, you will learn about MySQL, a web application database.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 3.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction to MySQL]]&lt;br /&gt;
* [[MySQL Schema and State]]&lt;br /&gt;
* [[PHP and MySQL]]&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
You will create a simple grades database containing four tables.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' The individual assignment is to be done by writing queries by hand.  (You can use phpMyAdmin to run the queries, but '''do not let phpMyAdmin write your queries for you!''')  Writing your own queries gives you a greater understanding of the underlying mechanisms and databases in general.  Additionally, having SQL knowledge and experience is a very marketable trait.&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL and phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Before you start, '''you need to install MySQL''' on your EC2 instance.  You may also install phpMyAdmin, a web frontend to MySQL, if you choose to do so.&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[Introduction to MySQL]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up a Database ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[Introduction to MySQL]]&lt;br /&gt;
&lt;br /&gt;
# Create a database named '''wustl''' &lt;br /&gt;
# Create a user named '''wustl_inst''' and give them the password '''wustl_pass'''&lt;br /&gt;
&lt;br /&gt;
=== Create Tables ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
When creating tables, keep the following items in mind:&lt;br /&gt;
&lt;br /&gt;
* You should create all tables such that they use the InnoDB storage engine, since we wish to make use of its support of foreign keys. In other database engines, foreign key constraints are not enforced.  (If you mess up, you can use ALTER TABLE to change the storage engine.)&lt;br /&gt;
* Where it is appropriate, you should take advantage of the ability to define fields NOT NULL so that you do not inadvertently insert incomplete data for a row.&lt;br /&gt;
&lt;br /&gt;
Create the following tables:&lt;br /&gt;
&lt;br /&gt;
# Create a table named '''students''' with the following fields:&lt;br /&gt;
#* '''id''' of an appropriately-sized unsigned integer type (we will never need to process more than a million students)&lt;br /&gt;
#* '''first_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''last_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''email_address''' of type '''VARCHAR(50)'''&lt;br /&gt;
#: The primary key should be on the '''id''' field.&lt;br /&gt;
# Create a table named '''departments''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM''' (e.g. &amp;quot;L&amp;quot; for ArtSci and &amp;quot;E&amp;quot; for Engineering).  The options are as follows:&lt;br /&gt;
#*: 'L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M'&lt;br /&gt;
#* '''dept_id''' of an appropriately-sized unsigned integer type (in the foreseeable future there will never be more than 200 departments in a school)&lt;br /&gt;
#* '''abbreviation''' of type '''VARCHAR(9)''' (e.g. CSE, ChemE, etc)&lt;br /&gt;
#* '''dept_name''' of type '''VARCHAR(200)''' (e.g. Computer Science and Engineering)&lt;br /&gt;
#: The primary key should be on two fields: '''school_code''' and '''dept_id'''&lt;br /&gt;
#: '''Note:''' Why not just use the department ID for the primary key? The ID numbers are sometimes reused across schools. For instance, department 33 in The College of Arts and Sciences is Psychology while department 33 in The School of Engineering and Applied Sciences is Energy, Environmental and Chemical Engineering. Thus we must also include the school code to differentiate them  such that the record for  E33 is distinct from that of L33.&lt;br /&gt;
# Create a table named '''courses''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: This should have the same letters in the same order as the '''school_code''' '''ENUM''' field in the '''departments''' table.&lt;br /&gt;
#* '''dept_id''' of the same size of integer as in the '''departments''' table&lt;br /&gt;
#* '''course_code''' of type '''CHAR(5)''' (this will hold course codes; e.g., '330S', '131', '2960')&lt;br /&gt;
#* '''name''' of type '''VARCHAR(150)'''&lt;br /&gt;
#: The appropriate fields in this table should make a foreign key reference to the corresponding fields in '''department'''.&lt;br /&gt;
#: In addition, it is up to you to determine the field(s) for the primary key.&lt;br /&gt;
#: '''Note:''' If you are unsure which fields to make the foreign keys and feel the need to beg your friends or the TAs to give you the answer, bang your head on your desk whilst repeating &amp;quot;I WILL EXERCISE REASON AND COMMON SENSE AND I WILL CURTAIL MY DESIRE TO BLINDLY FOLLOW DIRECTIONS&amp;quot;&lt;br /&gt;
#: ''Disclaimer: don't actually bang your head on your desk, the resulting head trauma may in fact make it harder for you to determine which fields should have associated foreign keys.''&lt;br /&gt;
# Create a table named '''grades''' with the following fields:&lt;br /&gt;
#* '''pk_grade_ID''' of an appropriately-sized unsigned integer type (should be larger than the one you chose for the '''students''' table)&lt;br /&gt;
#*: You should declare this field to be '''auto_increment''' and make it the primary key.&lt;br /&gt;
#*: This is called a ''surrogate key'' as opposed to a ''natural key'' because it doesn't arise &amp;quot;naturally&amp;quot; from the data; that is to say that it is not derived from application data. The use of surrogate keys vs. natural keys is a polemic issue amongst database designers.  For a decently unbiased take on the issue, see this page: http://www.agiledata.org/essays/keys.html#Comparison&lt;br /&gt;
#*: '''Food for thought:''' Aside from simply exposing you to the concept, can you think of any reasons why a surrogate key might be preferable for this table?  Alternatively, what attributes, if any, could you use as a natural key, and what might be the drawbacks of doing so?&lt;br /&gt;
#* '''student_id''' of the same integer (unsigned) type that you chose in the '''students''' table&lt;br /&gt;
#* '''grade''' of type '''decimal(5,2)'''&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: Can you guess what entries to use for the enum?&lt;br /&gt;
#* '''dept_id''' of the same integer type that you've used for this field in other tables&lt;br /&gt;
#* '''course_code''' of the same type you chose for the course code in the '''courses''' table&lt;br /&gt;
#: The '''grades''' table should have foreign keys to both the '''students''' table and the '''courses''' table.&lt;br /&gt;
&lt;br /&gt;
=== Populate Tables ===&lt;br /&gt;
&lt;br /&gt;
Now, populate the tables by downloading the text files given below and loading them into the appropriate tables.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not insert all the values manually; instead, use the MySQL's ability to load in data from text files.&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
The files containing the data are:&lt;br /&gt;
* students: http://classes.engineering.wustl.edu/cse330/content/students_data.txt&lt;br /&gt;
* courses: http://classes.engineering.wustl.edu/cse330/content/courses.txt&lt;br /&gt;
* departments: http://classes.engineering.wustl.edu/cse330/content/departments_data.txt&lt;br /&gt;
* grades: http://classes.engineering.wustl.edu/cse330/content/grades_data.txt&lt;br /&gt;
&lt;br /&gt;
=== Insert More Data ===&lt;br /&gt;
&lt;br /&gt;
Insert the following data into the tables that you have created and populated:&lt;br /&gt;
&lt;br /&gt;
# Insert an entry for CSE 330&lt;br /&gt;
#: ''If you don't know CSE's department code, how can you find out using the tables in the database?''&lt;br /&gt;
# Insert the grades given for the students named below.  You may choose to make the entries for whichever classes you like, with the one condition that all of the students must have a grade for CSE 330 (who wouldn't want to take that class: I hear the professor and TAs are amazing!)&lt;br /&gt;
#* '''Ben Harper'''&lt;br /&gt;
#** E-mail: '''bharper@ffym.com'''&lt;br /&gt;
#** Student ID: '''88'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 35.5 (CSE 330 grade)&lt;br /&gt;
#*** 0&lt;br /&gt;
#*** 95&lt;br /&gt;
#* '''Matt Freeman'''&lt;br /&gt;
#** E-mail: '''mfreeman@kickinbassist.net'''&lt;br /&gt;
#** Student ID: '''202'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 100 (CSE 330 grade)&lt;br /&gt;
#*** 90.5&lt;br /&gt;
#*** 94.8&lt;br /&gt;
#* '''Marc Roberge'''&lt;br /&gt;
#** E-mail: '''mroberge@ofarevolution.us'''&lt;br /&gt;
#** Student ID: '''115'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 75 (CSE 330 grade)&lt;br /&gt;
#*** 37&lt;br /&gt;
#*** 45.5&lt;br /&gt;
#: You may choose any 3 classes you'd like for them to be enrolled in, with at least one class, &amp;quot;CSE 330S&amp;quot;, in which they are all enrolled.&lt;br /&gt;
&lt;br /&gt;
=== Querying Your Database ===&lt;br /&gt;
&lt;br /&gt;
Now that you have a fully-functional, populated database, let's do some queries on it!&lt;br /&gt;
&lt;br /&gt;
Please take a screenshot of running the following '''select''' queries and show them to a TA (be sure to include your query command and the response:&lt;br /&gt;
&lt;br /&gt;
# Select the entire grades table.&lt;br /&gt;
# Select all fields describing the courses offered in the school of arts and sciences (school code L).&lt;br /&gt;
# The names, student IDs, and grades of the students who are in CSE330.&lt;br /&gt;
#: '''Note:''' This query should involve joins.  You don't need to use any aggregation functions.&lt;br /&gt;
# The names, e-mails, and average grades of any student with an average below 50 so that the dean can send them an email notification that they are now on academic probation.&lt;br /&gt;
#: ''You should be able to do this in only one query, without making any temporary tables.  You will need to use aggregation functions and the '''having''' keyword.''&lt;br /&gt;
# An individual report card for Jack Johnson, consisting of his student ID, e-mail address, and average grade.&lt;br /&gt;
#: ''Again, you should be able to do this in just one query, using the correct combination of aggregation functions and joins.''&lt;br /&gt;
#: '''Note:''' Your query must look for students with the name Jack Johnson instead of hard-coding the student ID.&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs on this project.  You may work with the same partner from Module 2, or change to someone else.&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your subversion repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple News Web Site ===&lt;br /&gt;
&lt;br /&gt;
'''Examples:'''&lt;br /&gt;
* http://digg.com/&lt;br /&gt;
* http://slashdot.org/&lt;br /&gt;
&lt;br /&gt;
You should use '''PHP''' unless you get permission to use another web technology from the instructor.  You may also use phpMyAdmin to help set up databases.&lt;br /&gt;
&lt;br /&gt;
You may find this wiki article helpful: [[PHP and MySQL]]&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Users can register for accounts and then log in to the website.&lt;br /&gt;
* Accounts should have both a username and a ''secure'' password.  '''NEVER store plaintext passwords in a database!'''&lt;br /&gt;
*: For more information on password security, refer to [[Web Application Security, Part 2#Password Security|the Web Application Security guide]].&lt;br /&gt;
* Registered users can submit story commentary and links to those stories.&lt;br /&gt;
*: You do not have to make a distinction between the two types of stories, although if you want to, you could do something with this for the creative portion of your project.&lt;br /&gt;
* Registered users can comment on any story.&lt;br /&gt;
* Unregistered users can only view stories and comments.&lt;br /&gt;
* Registered users can edit and delete their stories and comments.&lt;br /&gt;
* All data must be kept in a MySQL database (user information, stories, comments, and categories).&lt;br /&gt;
* Creative Portion&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
No application is finished until much thought is put into web security and best practice.  Throughout this course, we heavily emphasize the dogma of [http://coderesponsibly.org/ responsible] coding.&lt;br /&gt;
&lt;br /&gt;
Read this week's Web Application Security guide: [[Web Application Security, Part 2]].  In particular, your project needs to:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to be secure from SQL injection attacks'''. If you are using prepared queries, you should already be safe on this front.&lt;br /&gt;
* '''Your passwords need to be securely salted''' to prevent rainbow table attacks.&lt;br /&gt;
* '''You should pass tokens in forms''' to prevent CSRF attacks.&lt;br /&gt;
* '''You should check all preconditions on the server side''' to prevent Abuse of Functionality attacks.&lt;br /&gt;
&lt;br /&gt;
You shouldn't forget the practices you learned last week:&lt;br /&gt;
&lt;br /&gt;
* '''Your page should validate''' with no errors through the W3C validator.&lt;br /&gt;
* '''Filter Input and Escape Output''', but not the other way around.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
# '''MySQL Queries (25 Points):'''&lt;br /&gt;
#* A MySQL server is running on your instance (2 points)&lt;br /&gt;
#* Tables fields, including data types, are correct (4 points)&lt;br /&gt;
#* Foreign keys are correct (4 points)&lt;br /&gt;
#* The output of each of the five queries is correct (3 points each)&lt;br /&gt;
# '''News Site (60 Points):'''&lt;br /&gt;
#* '''''User Management (20 Points):'''''&lt;br /&gt;
#** A session is created when a user logs in (3 points)&lt;br /&gt;
#** New users can register (3 points)&lt;br /&gt;
#** Passwords are hashed using salted one-way encryption (3 points)&lt;br /&gt;
#** Users can log out (3 points)&lt;br /&gt;
#** A user can edit and delete his/her own stories and comments but cannot edit or delete the stories or comments of another user (8 points)&lt;br /&gt;
#* '''''Story and Comment Management (20 Points):'''''&lt;br /&gt;
#** Relational database is configured with correct data types and foreign keys (4 points)&lt;br /&gt;
#** Stories can be posted (3 points)&lt;br /&gt;
#** A link can be associated with each story using a separate database field (3 points)&lt;br /&gt;
#** Comments can be posted in association with a story (4 points)&lt;br /&gt;
#** Stories can be edited and deleted (3 points)&lt;br /&gt;
#** Comments can be edited and deleted (3 points)&lt;br /&gt;
#**: ''Note: Although there are only 6 points allocated for editing/deleting in this section, there are 8 more points at stake in the User Management section that cannot be earned unless editing/deleting is implemented.  Implementing editing but not deleting, or vice-versa, will result in earning half the points.''&lt;br /&gt;
#* '''''Best Practices (15 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** Site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (2 points)&lt;br /&gt;
#** CSRF tokens are passed when creating, editing, and deleting comments and stories (5 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a creative.txt file in your group repo with the following:'''''&lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to your running ec2 instance&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Billy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Amazon_Web_Services&amp;diff=1776</id>
		<title>Amazon Web Services</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Amazon_Web_Services&amp;diff=1776"/>
		<updated>2014-09-03T04:17:17Z</updated>

		<summary type="html">&lt;p&gt;Billy: /* Creating and Configuring your EC2 Instance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Amazon Web Services provides a method to publish web sites on virtual machines in the &amp;quot;cloud.&amp;quot;  In CSE330, you will be using an EC2 instance to host your web site.&lt;br /&gt;
&lt;br /&gt;
Before reading this guide, you should be familiar with Linux and the various distributions of Linux.  Fore more information, refer to [[Linux#Linux Distributions|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
== Creating and Configuring your EC2 Instance ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Follow these steps to get to the AWS Management Console:&lt;br /&gt;
&lt;br /&gt;
# Create an AWS account: http://aws.amazon.com/&lt;br /&gt;
# Sign up for the EC2 Web Service: http://aws.amazon.com/ec2/&lt;br /&gt;
# Log in to the AWS Management Console&lt;br /&gt;
&lt;br /&gt;
To create your new virtual machine, click '''Launch Instance'''.  Do the following to configure your instance:&lt;br /&gt;
&lt;br /&gt;
# Use the Classic Wizard.&lt;br /&gt;
# Now choose what distribution of Linux you would like to use.  For more information on distributions, refer to [[Linux#Linux Distributions|the Linux guide]].  The following are both good choices, and throughout the wiki, the instructions are equally comprehensive for both.  This semester, we will be teaching this class using Ubuntu, but you are free to use either one.&lt;br /&gt;
#* Ubuntu Server 14.04 LTS (based on Debian)&lt;br /&gt;
#* Amazon Linux AMI (based on RHEL)&lt;br /&gt;
# The default instance variables are all fine.  Click Continue until you get to the &amp;quot;Create Key Pair&amp;quot; screen.&lt;br /&gt;
# Create a new Key Pair.  Enter some name for it, and then click &amp;quot;Create &amp;amp; Download your Key Pair&amp;quot;.  '''Save your key somewhere secure.'''  In addition to using it to authenticate for this instance, you will be able to use the same key for additional instances.&lt;br /&gt;
# Create a new Security Group and connect it to your server.  The security groups you create determine whether a port is open or blocked for your server.&lt;br /&gt;
#* You need to open the SSH port on your server.  To do this, select &amp;quot;SSH&amp;quot; from the drop-down box, and then click &amp;quot;Add Rule.&amp;quot;&lt;br /&gt;
#: We will be opening more ports by modifying the security group at a later time.  Click Continue.&lt;br /&gt;
# You are now ready to launch your virtual server!  Click Launch.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Starting and Stopping your EC2 Instance ==&lt;br /&gt;
&lt;br /&gt;
You can start and stop your instance by right-clicking on the instance.  The options are down in the &amp;quot;Instance Lifecycle&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
=== Amazon EC2 Gives You One Free Micro Instance ===&lt;br /&gt;
&lt;br /&gt;
It is free to keep '''''one''''' micro instance running at all times.  Keeping your instance running around the clock will make your life easier, because then you won't need to always change your hostname in your SSH clients.&lt;br /&gt;
&lt;br /&gt;
For additional Micro instances, or for larger instances, you will be charged hourly for their use.  One non-free Micro instance costs about $14/month; a Small instance costs about $43/month.&lt;br /&gt;
&lt;br /&gt;
=== Terminate vs Stop ===&lt;br /&gt;
&lt;br /&gt;
Never &amp;quot;terminate&amp;quot; your instance, as this PERMANENTLY DELETES the instance! Any time you are done using the instance you should instead &amp;quot;stop&amp;quot; the instance and then when you are ready to resume work you should &amp;quot;start&amp;quot; the instance.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Frequently committing your work to your repository is a safety net in case something horrible happens to your instance.&lt;br /&gt;
&lt;br /&gt;
== Enabling Web Access to your EC2 Instance ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
Once you have configured [[Apache]] (which you will do later in this Module), you will need to open up your EC2 instance to web traffic.  (By default amazon blocks all traffic to our instance.)&lt;br /&gt;
&lt;br /&gt;
Go to the Security Groups under Network &amp;amp; Security on the EC2 webpage. Select your security group, click on the Inbound Tab. Add a new Custom TCP rule with a Port range of 80.  Leave the Source at 0.0.0.0/0 (for all traffic). Click Add Rule, and then click Apply Rule Change.&lt;br /&gt;
&lt;br /&gt;
To make sure things are working, create a file, like '''hello.txt''', in your web server root.  Give it some content (might I suggest &amp;quot;Hello, world!&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
* In the Amazon AMI, the web server root is at /var/www/html&lt;br /&gt;
* In Ubuntu 12.04 LTS, the web server root is at /var/www&lt;br /&gt;
&lt;br /&gt;
For more information on editing files on the command line, refer to [[Linux#File Editors|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
You should now be able to visit your server load up the file using your web browser!  Example Link: http://ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com/hello.txt&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Billy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=HTML_Forms&amp;diff=1775</id>
		<title>HTML Forms</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=HTML_Forms&amp;diff=1775"/>
		<updated>2014-09-02T02:22:24Z</updated>

		<summary type="html">&lt;p&gt;Billy: /* Code Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The contents of a web page often changes depending on how you requested that page.  For example, when you perform a web search, the contents of the search list changes depending on your query.  This is done by way of HTTP request variables (aout which you will learn more in Module 2).&lt;br /&gt;
&lt;br /&gt;
The most fundamental way to make a web page sent HTTP request variables to another page is by using HTML Forms.  This article describes this process and how to implement it in your code.&lt;br /&gt;
&lt;br /&gt;
== HTTP Request Variables ==&lt;br /&gt;
&lt;br /&gt;
Visit your favorite search engine, and search for &amp;quot;QUERY&amp;quot;.  Now, look at your address bar.  Can you find your query &amp;quot;QUERY&amp;quot; somewhere in the URL?&lt;br /&gt;
&lt;br /&gt;
Your search engine probably used an HTTP Request Variable to send your desired query to the search page.  Here is how it might have worked:&lt;br /&gt;
&lt;br /&gt;
[[File:HTMLForm.png]]&lt;br /&gt;
&lt;br /&gt;
You can see that we didn't just go to example.com/search; we also incorporated the search query into the '''query string''' of the URL, where query stream &lt;br /&gt;
&lt;br /&gt;
=== Code Example ===&lt;br /&gt;
&lt;br /&gt;
The syntax for making a form in HTML is relatively straightforward.  The HTML for the above example could be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://example.com/search&amp;quot; method=&amp;quot;GET&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;label&amp;gt;Search Query: &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;q&amp;quot; /&amp;gt;&amp;lt;/label&amp;gt;&lt;br /&gt;
	&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Search&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;label&amp;gt;''' tag above allows text to &amp;quot;label&amp;quot; an input field.  When anything in the label is clicked, the input field will become focussed.&lt;br /&gt;
&lt;br /&gt;
== HTTP Request Methods ==&lt;br /&gt;
&lt;br /&gt;
In the above example, we used the GET method for transferring variables from our form to our destination page.  There are two widely supported options for transferring the variables:&lt;br /&gt;
&lt;br /&gt;
# '''GET''' transfers the variables in the URL.&lt;br /&gt;
# '''POST''' transfers the variables as an HTTP header.&lt;br /&gt;
&lt;br /&gt;
What does &amp;quot;as an HTTP header&amp;quot; mean?&lt;br /&gt;
&lt;br /&gt;
=== HTTP Headers ===&lt;br /&gt;
&lt;br /&gt;
Whenever you request a page on the http:// protocol, your browser sends a ''request header''.  Your browser responds with a ''response header'' followed by the content of your page.  You never see the request or response headers unless you have tools that let you see them.&lt;br /&gt;
&lt;br /&gt;
To let you have an idea, here are the request and response headers when I visit http://www.w3.org/ in Firefox:&lt;br /&gt;
&lt;br /&gt;
'''Request Headers:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
GET / HTTP/1.1&lt;br /&gt;
Host: www.w3.org&lt;br /&gt;
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:19.0) Gecko/20100101 Firefox/19.0&lt;br /&gt;
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&lt;br /&gt;
Accept-Language: en-US,en;q=0.5&lt;br /&gt;
Accept-Encoding: gzip, deflate&lt;br /&gt;
Connection: keep-alive&lt;br /&gt;
If-Modified-Since: Sat, 16 Mar 2013 09:16:37 GMT&lt;br /&gt;
If-None-Match: &amp;quot;8c8c-4d80736774740;89-3f26bd17a2f00&amp;quot;&lt;br /&gt;
Cache-Control: max-age=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Response Headers:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
HTTP/1.1 200 OK&lt;br /&gt;
Date: Sat, 16 Mar 2013 19:42:55 GMT&lt;br /&gt;
Server: Apache/2&lt;br /&gt;
Content-Location: Home.html&lt;br /&gt;
Vary: negotiate,accept&lt;br /&gt;
TCN: choice&lt;br /&gt;
Last-Modified: Sat, 16 Mar 2013 09:16:37 GMT&lt;br /&gt;
Etag: &amp;quot;8cc6-4d80736774740;89-3f26bd17a2f00&amp;quot;&lt;br /&gt;
Accept-Ranges: bytes&lt;br /&gt;
Content-Length: 36038&lt;br /&gt;
Cache-Control: max-age=600&lt;br /&gt;
Expires: Sat, 16 Mar 2013 19:52:55 GMT&lt;br /&gt;
P3P: policyref=&amp;quot;http://www.w3.org/2001/05/P3P/p3p.xml&amp;quot;&lt;br /&gt;
Connection: close&lt;br /&gt;
Content-Type: text/html; charset=utf-8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see that in the request header, information is sent about what browser and operating system I'm using (my ''user agent''), what language I prefer (in my case, ''en-US''), and the like.  If you have cookies for a site, they get transfered via a request header.  In the response header, we can see that the request was successful (HTTP code 200), that I am receiving an HTML document with the UTF-8 charset (in ''Content-Type''), and other various information.  All of these headers are standard; you can implement less-common headers as well.&lt;br /&gt;
&lt;br /&gt;
=== When to use GET vs. POST ===&lt;br /&gt;
&lt;br /&gt;
Here are some rules of thumb to help you decide whether to use GET or POST for a certain form.&lt;br /&gt;
&lt;br /&gt;
* If you would like the user of your application to be able to ''bookmark the destination page'' for later use (e.g. search results), you need to use '''GET''', because the bookmark will contain the entire URL, including the request variables.&lt;br /&gt;
* If you are transmitting ''sensitive information'' like passwords, you should use '''POST''', because POST variables will not appear in a user's browsing history, but GET variables will.&lt;br /&gt;
* If the data you are transmitting is large (over about 200 bytes), you need to use '''POST''', since some browsers will truncate the URL string after 256 characters.&lt;br /&gt;
* If the destination page takes the information from the form and modifies something in a database, it is best practice to use '''POST'''.&lt;br /&gt;
&lt;br /&gt;
=== Technicalities ===&lt;br /&gt;
&lt;br /&gt;
Although it is safe to think about POST variables as being transmitted as a header, this is technically not the case.  In reality, POST variables are sent in the request body.  The server knows to read the POST variables from the request body because of a '''application/x-www-form-urlencoded''' request content type header.&lt;br /&gt;
&lt;br /&gt;
Additionally, there has been a recent resurgence in so-called [[wikipedia:CRUD|CRUD]]; that is, additional HTTP request types beyond GET and POST: PUT, DELETE, OPTIONS, etc.  CRUD request types are beyond the scope of this course, but it is worth the time reading up on their meaning if you find yourself working with a RESTful web framework like Ruby on Rails.&lt;br /&gt;
&lt;br /&gt;
== Input Types ==&lt;br /&gt;
&lt;br /&gt;
In the example above, we used just two input types: a '''text''' field and a '''submit''' button.  In reality, there are over 20 different types.  Some of the more common types include:&lt;br /&gt;
&lt;br /&gt;
* '''hidden:''' allows for a variable to be passed as part of a form without requiring that the user input any data.&lt;br /&gt;
* '''password:''' allows for text to be hidden while typed.&lt;br /&gt;
* '''number:''' like a text box, but forces the content to be numerical.&lt;br /&gt;
** ''Note:'' You can set the '''step''', '''min''', and '''max''' attributes on your '''number''' input to change the precision of the number accepted.  For example, the following input field would accept only integers between 0 and 100 inclusive:&lt;br /&gt;
**: &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&amp;lt;input type=&amp;quot;number&amp;quot; name=&amp;quot;percentage&amp;quot; step=&amp;quot;1&amp;quot; min=&amp;quot;0&amp;quot; max=&amp;quot;100&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
* '''checkbox:''' a yes-or-no checkbox.&lt;br /&gt;
* '''radio:''' a multiple-choice question.  Use multiple input fields, all with the same ''name'' but different ''value''.&lt;br /&gt;
* '''file:''' allows for file uploads.  (We will deal with this more in module 2.)&lt;br /&gt;
&lt;br /&gt;
For a complete list, see [http://www.w3.org/TR/html5/forms.html#the-input-element section 4.10.7 of the HTML5 spec].&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;/div&gt;</summary>
		<author><name>Billy</name></author>
		
	</entry>
</feed>