<?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=Jimmy</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=Jimmy"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/Jimmy"/>
	<updated>2026-11-15T18:16:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2148</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2148"/>
		<updated>2016-02-04T11:18:08Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Creating the Site */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&amp;quot;&amp;gt;          &lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 55 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by 1 PM on the due date (commit early and often). Failing to commit by 1 PM on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Sunday at 1:00 PM). You are allowed to demo your assignment at TA office hours. However, after Sunday at 1 PM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-10 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (50 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2129</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2129"/>
		<updated>2016-01-10T21:30:33Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&amp;quot;&amp;gt;          &lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 55 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo. Please import the four modified files to bitbucket''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (50 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2127</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2127"/>
		<updated>2015-12-03T00:10:15Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&amp;quot;&amp;gt;          &lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 55 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (50 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2126</id>
		<title>Module 5</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2126"/>
		<updated>2015-11-18T20:27:39Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 5, you will learn JavaScript, the dominant client-side web language.  JavaScript is the third and final programming language you will learn in CSE 330.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 5.&lt;br /&gt;
&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
&lt;br /&gt;
''This module takes students a while. It is strongly recommended that you start early and ask questions as they come up.''&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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
'''''IMPORTANT:'' Both of the individual assignments must be completed ''without'' using a JavaScript library like jQuery.'''  However, you may (and should) use jQuery for the group portion.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Calculator ===&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a calculator using PHP.  Now you will be making one using JavaScript.&lt;br /&gt;
&lt;br /&gt;
* The web page should have two input fields and a radio button group for the operation, with the 4 basic math operations represented (add, subtract, multiply, divide).&lt;br /&gt;
* JavaScript should monitor all three fields and display the current result whenever the user changes any value in any field, without refreshing the page.&lt;br /&gt;
*: '''Tip 1:''' Consider using either the ''change'' or the ''keyup'' event on the text fields, and either the ''change'' or the ''click'' event on the radio buttons.&lt;br /&gt;
*: '''Tip 2:''' Re-read [[JavaScript|the JavaScript guide]] if you need help figuring our how to bind callback functions to events, or how to determine which radio button is currently selected.  (There are examples for both of these!)&lt;br /&gt;
* The calculator should be completely self-contained; i.e., you should not be making any requests to any other server-side or client-side scripts or web pages after the initial page load.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' You can embed JavaScript code into an HTML document like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
// your code here&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If your code isn't working the way you expect, use a JavaScript error console.  In Chrome, for example, press Ctrl-Shift-I (or Cmd-Option-I) to open the WebKit inspector.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' It is best practice to fully separate the content, appearance, and behavior.  In previous modules, you may have lost points for using HTML tags that change the appearance of things &amp;lt;nowiki&amp;gt;(like &amp;lt;center&amp;gt; and &amp;lt;font&amp;gt;).&amp;lt;/nowiki&amp;gt;  In this module, make sure that you define your event listeners in JavaScript as in &amp;lt;code&amp;gt;document.getElementById(&amp;quot;xyz&amp;quot;).addEventListener(...)&amp;lt;/code&amp;gt; and '''''not''''' in the HTML like &amp;lt;code&amp;gt;&amp;lt;button onclick=&amp;quot;badExample();&amp;quot;&amp;gt;Bad Example&amp;lt;/button&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Weather Widget ===&lt;br /&gt;
&lt;br /&gt;
In this section, you will make a web page that displays the weather forecast using AJAX requests to a weather server.&lt;br /&gt;
&lt;br /&gt;
# Make an empty HTML document; name it '''weather.html'''&lt;br /&gt;
#: Refer to the [[HTML and CSS]] guide for the skeleton of an HTML document&lt;br /&gt;
# Define a function in JavaScript; call it '''fetchWeather()'''.  You may write your JavaScript in an embedded script in your head tag.&lt;br /&gt;
# Inside your '''fetchWeather()''' function, make an AJAX request to the weather server.&lt;br /&gt;
#: We have a server that outputs the current weather in JSON format.  The format is documented in the [[#JSON Structure]] section below.&lt;br /&gt;
#: '''URL:''' http://classes.engineering.wustl.edu/cse330/content/weather_json.php&lt;br /&gt;
#: We kindly thank Yahoo Weather for providing us with up-to-date weather information.&lt;br /&gt;
#* '''IMPORTANT:''' Under normal circumstances, AJAX requests ''cannot'' be performed cross-domain for security reasons.  We have set the &amp;lt;code&amp;gt;Access-Control-Allow-Origin&amp;lt;/code&amp;gt; header on our server to allow requests from your EC2 instances, or from localhost.  '''You will therefore need to upload your code to your EC2, or access it via localhost, in order for the AJAX requests to work.'''  This means that you cannot, for example, complete this part of the individual portion in JSFiddle.&lt;br /&gt;
# In your callback, process the JSON and use JavaScript to manipulate the HTML DOM to display the following information on your page:&lt;br /&gt;
#* Location&lt;br /&gt;
#** City, in a &amp;lt;nowiki&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;/nowiki&amp;gt; tag&lt;br /&gt;
#** State, not in any tag&lt;br /&gt;
#* Humidity&lt;br /&gt;
#* Current Temperature&lt;br /&gt;
#* Image for Tomorrow's Forecast (see [[#Weather Condition Images]] below for more information)&lt;br /&gt;
#* Image for the Day After Tomorrow's Forecast&lt;br /&gt;
# Finally, bind '''fetchWeather()''' to the DOMContentLoaded event so that your weather widget is automatically initialized when the page is loaded:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, fetchWeather, false);&amp;lt;/source&amp;gt;&lt;br /&gt;
# In addition, add a button that runs your ''fetchWeather'' function when clicked.  This should update your widget with the current weather conditions.&lt;br /&gt;
&lt;br /&gt;
Use the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;weather&amp;quot; id=&amp;quot;weatherWidget&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-loc&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-humidity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-temp&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-tomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-dayaftertomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the CSS file from here: http://classes.engineering.wustl.edu/cse330/content/weather.css&lt;br /&gt;
&lt;br /&gt;
When everything is working, the weather widget should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:WeatherWidget.png]]&lt;br /&gt;
&lt;br /&gt;
'''Important:''' The widget in this section needs to work in only Firefox and Chrome.  It does '''''not''''' need to work Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
===== JSON Structure =====&lt;br /&gt;
&lt;br /&gt;
The JSON from our server looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;updated&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;,&lt;br /&gt;
   &amp;quot;location&amp;quot;: {&lt;br /&gt;
      &amp;quot;city&amp;quot;: &amp;quot;St. Louis&amp;quot;,&lt;br /&gt;
      &amp;quot;state&amp;quot;: &amp;quot;MO&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;wind&amp;quot;: {&lt;br /&gt;
      &amp;quot;chill&amp;quot;: &amp;quot;62&amp;quot;,&lt;br /&gt;
      &amp;quot;direction&amp;quot;: &amp;quot;150&amp;quot;,&lt;br /&gt;
      &amp;quot;speed&amp;quot;: &amp;quot;3 mph&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;atmosphere&amp;quot;: {&lt;br /&gt;
      &amp;quot;humidity&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
      &amp;quot;visibility&amp;quot;: &amp;quot;10&amp;quot;,&lt;br /&gt;
      &amp;quot;pressure&amp;quot;: &amp;quot;30.12 in&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;current&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;28&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Mostly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;temp&amp;quot;: &amp;quot;62°F&amp;quot;,&lt;br /&gt;
      &amp;quot;date&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;tomorrow&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;29&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Clouds Early/Clearing Late&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;45°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;61°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;dayafter&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;30&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Partly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;53°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;65°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;credit&amp;quot;: &amp;quot;http://us.rd.yahoo.com/dailynews/rss/weather/St._Louis__MO/*http://weather.yahoo.com/forecast/USMO0170_f.html&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Weather Condition Images =====&lt;br /&gt;
&lt;br /&gt;
Each day's forecast has a code.  There are images associated with these codes.&lt;br /&gt;
&lt;br /&gt;
One place to get the images is from here: &amp;lt;nowiki&amp;gt;http://us.yimg.com/i/us/nws/weather/gr/&amp;lt;/nowiki&amp;gt;'''##'''&amp;lt;nowiki&amp;gt;ds.png&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the '''##''' with the forecast code.  For example, for code 32, the URL would be: http://us.yimg.com/i/us/nws/weather/gr/32ds.png&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
I forgot if I already mentioned this, but '''start early on this project!''' It will take longer than you think, I promise!&lt;br /&gt;
&lt;br /&gt;
You are encouraged to use the advanced version control practices you learned in Module 5 when completing this assignment.&lt;br /&gt;
&lt;br /&gt;
=== Calendar ===&lt;br /&gt;
&lt;br /&gt;
Build a simple calendar that allows users to add and remove events dynamically.&lt;br /&gt;
&lt;br /&gt;
You will use JavaScript to process user interactions at the web browser, without ever refreshing the browser after the initial web page load.  You may use a JavaScript library of your choice, including Ext JS.&lt;br /&gt;
&lt;br /&gt;
Your application should utilize AJAX to run server-side scripts that query your database to save and retrieve information, including user accounts and events.&lt;br /&gt;
&lt;br /&gt;
We have also written some functions to help you get started: [[JavaScript Calendar Library]]&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
* https://calendar.google.com/&lt;br /&gt;
* http://www.zoho.com/calendar/&lt;br /&gt;
&lt;br /&gt;
==== Server Side Language ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, you may use a database of your choice.  MySQL is probably the logical choice since you have been using it since Module 2, but if you're up for a challenge we encourage you to look at other database options like [[wikipedia:MongoDB|MongoDB]].&lt;br /&gt;
&lt;br /&gt;
''* While it is fine to use the provided example for reference, copying it in its entirety is a violation of Academic Integrity and will result in a 0 for the group portion of this module.  Don't plagiarize.''&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Support a month-by-month view of the calendar.&lt;br /&gt;
*: Show one month at a time, with buttons to move forward or backward.&lt;br /&gt;
*: There should be no limit to how far forward or backward the user can go.&lt;br /&gt;
* Users can register and log in to the website.&lt;br /&gt;
*: You may leverage your MySQL project code and database from module 3 to get started.&lt;br /&gt;
* Unregistered users should see no events on the calendar.&lt;br /&gt;
* Registered users can add events.&lt;br /&gt;
*: All events should have a date and time, but do not need to have a duration.&lt;br /&gt;
*: You do ''not'' need to support recurring events (where you add an event that repeats, for example, every monday).&lt;br /&gt;
* Registered users see only events that they have added.&lt;br /&gt;
*: Your AJAX should not ask the server for events from a certain username.  Instead, your AJAX should ask the server for events, and the server should respond with the events for only the currently-logged-in user (from the session).  Can you think of why?&lt;br /&gt;
* Registered users can delete their events, but not the events of others.&lt;br /&gt;
*: Again, the server should delete events based on the username present in the session.  (If it deletes only based on an Event ID, an attacker could feed any arbitrary Event ID to your server, even if he/she didn't own that event.)&lt;br /&gt;
* All user and event data should be kept in a database.&lt;br /&gt;
* At no time should the main page need to be reloaded.&lt;br /&gt;
*: User registration, user authentication, event addition, and event deletion should all be handled by JavaScript and AJAX requests to your server.&lt;br /&gt;
* Your page needs to work in the versions of Firefox and Chrome installed on the lab computers.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Run your database schema by a TA before implementing it.&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to prevent XSS attacks.'''  Be careful when transmitting data over JSON that will be reflected in an event title!  (Note: JSON data should be sanitized on the client side, not the server side.)&lt;br /&gt;
* '''Perform precautionary measures to prevent session hijacking attacks.'''&lt;br /&gt;
*: You should specify your session cookie to be HTTP-Only.  However, for the means of this module, you need not test for user agent consistency.&lt;br /&gt;
* '''Optional:''' Validate your JavaScript code using [http://www.jshint.com/ JSHint] '''''or''''' [http://jslint.com/ JSLint] for up to 3 points of extra credit.&lt;br /&gt;
&lt;br /&gt;
You should continue the practices that you have learned in past weeks:&lt;br /&gt;
&lt;br /&gt;
* Pass tokens in forms to prevent CSRF attacks.&lt;br /&gt;
*: '''Hint:''' You will need to send your CSRF tokens in your AJAX requests.  Remember that AJAX still submits forms and runs server-side scripts, just like the vanilla forms you've been using in Modules 2 and 3.&lt;br /&gt;
* Use prepared queries to prevent SQL Injection attacks.&lt;br /&gt;
* If storing passwords in a database, always store them salted and encrypted.&lt;br /&gt;
* Your page should validate with no errors through the W3C validator.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module5-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share your repo with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''JavaScript Calculator (10 Points):'''&lt;br /&gt;
#* Calculator successfully adds, subtracts, multiplies, and divides numbers (3 points)&lt;br /&gt;
#* The result is automatically computed when a value in either field is changed (3 points)&lt;br /&gt;
#* Calculator is written entirely in pure, conventional JavaScript with no external libraries (4 points)*&lt;br /&gt;
#*: ''Note: be sure to fully separate content, appearance, and behavior.  This means that you should '''not''' use the event attributes on the HTML elements like onclick, onchange, and onkeyup.''&lt;br /&gt;
# '''Weather Widget (15 Points):'''&lt;br /&gt;
#* Widget performs an AJAX request to fetch the current weather (4 points)&lt;br /&gt;
#* The HTML template is filled with the correct information, including an image (4 points)&lt;br /&gt;
#* Button to reload the weather widget (2 points)&lt;br /&gt;
#* Widget is written entirely in pure, conventional JavaScript with no external libraries (5 points)*&lt;br /&gt;
# '''AJAX Calendar (60 Points):'''&lt;br /&gt;
#* '''''Calendar View (10 Points):'''''&lt;br /&gt;
#** The calendar is displayed as a table grid with days as the columns and weeks as the rows, one month at a time (5 points)&lt;br /&gt;
#** The user can view different months as far in the past or future as desired (5 points)&lt;br /&gt;
#* '''''User and Event Management (25 Points):'''''&lt;br /&gt;
#** Events can be added, modified, and deleted (5 points)&lt;br /&gt;
#** Events have a title, date, and time (2 points)&lt;br /&gt;
#** Users can log into the site, and they cannot view or manipulate events associated with other users (8 points)&lt;br /&gt;
#**: ''Don't fall into the Abuse of Functionality trap!  Check user credentials on the server side as well as on the client side.''&lt;br /&gt;
#** All actions are performed over AJAX, without ever needing to reload the page (10 points)&lt;br /&gt;
#* '''''Best Practices (20 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** If storing passwords, they are stored salted and encrypted; if using OpenID, you are storing the user's OpenID identifier in the database (2 points)&lt;br /&gt;
#** All AJAX requests that either contain sensitive information or modify something on the server are performed via POST, not GET (3 points)&lt;br /&gt;
#** Safe from XSS attacks; that is, all content is escaped on output (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** CSRF tokens are passed when editing or removing events (3 points)&lt;br /&gt;
#** Session cookie is HTTP-Only (3 points)&lt;br /&gt;
#** Page passes the W3C validator (2 points)&lt;br /&gt;
#** ''Extra Credit:'' Your code passes ''JSHint'' or ''JSLint'' (+3 bonus 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)'''&lt;br /&gt;
#* '''Additional Calendars Features (worth 15 points):''' Develop some additional features for the calendar, a few examples are provided below.&lt;br /&gt;
#**  Users can tag an event with a particular category and enable/disable those tags in the calendar view. (5 points)&lt;br /&gt;
#**  Users can share their calendar with additional users. (5 points)&lt;br /&gt;
#**  Users can create group events that display on multiple users calendars (5 points)&lt;br /&gt;
''* These points can be earned only if at least 3 other points have been earned in that category.  This is to prevent these points from being &amp;quot;free.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2125</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=2125"/>
		<updated>2015-11-18T20:26:43Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* 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;
=== 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 330S&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 330S (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 330S 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 330S 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 330S 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 CSE330S.&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 Git 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.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&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 links).&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&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, and they should be stored in a separate database field from the story (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, with proper commenting (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 homepage of the site&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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2124</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2124"/>
		<updated>2015-11-18T20:26:03Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands (5 points)&lt;br /&gt;
#* The time zone is correct on your instance (5 points)&lt;br /&gt;
#* The UserDir Apache module is working (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 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 the front page of your site&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;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2123</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2123"/>
		<updated>2015-11-18T01:21:23Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&amp;quot;&amp;gt;          &lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2121</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2121"/>
		<updated>2015-11-17T17:14:42Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js&amp;quot;&amp;gt;          &lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2120</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2120"/>
		<updated>2015-11-16T19:06:04Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2119</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2119"/>
		<updated>2015-11-16T17:57:57Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2118</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2118"/>
		<updated>2015-11-16T17:47:57Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2117</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2117"/>
		<updated>2015-11-16T17:46:07Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2116</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2116"/>
		<updated>2015-11-15T23:21:57Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2115</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2115"/>
		<updated>2015-11-15T21:21:06Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Individual Assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2090</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2090"/>
		<updated>2015-11-09T22:26:55Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2089</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2089"/>
		<updated>2015-11-09T22:26:33Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. type the following in your command file from the coffees directory:&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2088</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2088"/>
		<updated>2015-11-09T22:17:37Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2087</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2087"/>
		<updated>2015-11-09T17:53:42Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&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;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&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 75 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (5 points)&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* You can explain to the TA why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (10 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2041</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2041"/>
		<updated>2015-11-04T01:18:01Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&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;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&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 80 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (13 points)&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* You can explain to the TA why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (10 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2040</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2040"/>
		<updated>2015-11-01T06:10:50Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2039</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2039"/>
		<updated>2015-10-28T19:51:44Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Individual Assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2037</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2037"/>
		<updated>2015-10-09T19:33:29Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://docs.angularjs.org/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignment must be demoed by the Monday at 1:00 PM of the week after the assignment is due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Monday, you will receive a late penalty for the assignment solely based on when you demo.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2035</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=2035"/>
		<updated>2015-09-30T04:40:29Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* 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;
=== 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 330S&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 330S (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 330S 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 330S 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 330S 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 CSE330S.&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 Git 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.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&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 links).&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&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, and they should be stored in a separate database field from the story (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, with proper commenting (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 homepage of the site&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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2034</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2034"/>
		<updated>2015-09-30T04:40:01Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands (5 points)&lt;br /&gt;
#* The time zone is correct on your instance (5 points)&lt;br /&gt;
#* The UserDir Apache module is working (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 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 the front page of your site&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;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2033</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2033"/>
		<updated>2015-09-21T21:31:41Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&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;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&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 80 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).'''&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (13 points)&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* You can explain to the TA why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (10 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2032</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2032"/>
		<updated>2015-09-21T21:31:22Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&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;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&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 80 points total.&lt;br /&gt;
&lt;br /&gt;
Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (13 points)&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* You can explain to the TA why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (10 Points)'''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2031</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=2031"/>
		<updated>2015-09-21T19:46:09Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Requirements */&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;
=== 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 330S&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 330S (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 330S 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 330S 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 330S 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 CSE330S.&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 Git 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.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&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 links).&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&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, and they should be stored in a separate database field from the story (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, with proper commenting (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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2030</id>
		<title>Module 5</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2030"/>
		<updated>2015-09-21T18:17:20Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 5, you will learn JavaScript, the dominant client-side web language.  JavaScript is the third and final programming language you will learn in CSE 330.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 5.&lt;br /&gt;
&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
&lt;br /&gt;
''This module takes students a while. It is strongly recommended that you start early and ask questions as they come up.''&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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
'''''IMPORTANT:'' Both of the individual assignments must be completed ''without'' using a JavaScript library like jQuery.'''  However, you may (and should) use jQuery for the group portion.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Calculator ===&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a calculator using PHP.  Now you will be making one using JavaScript.&lt;br /&gt;
&lt;br /&gt;
* The web page should have two input fields and a radio button group for the operation, with the 4 basic math operations represented (add, subtract, multiply, divide).&lt;br /&gt;
* JavaScript should monitor all three fields and display the current result whenever the user changes any value in any field, without refreshing the page.&lt;br /&gt;
*: '''Tip 1:''' Consider using either the ''change'' or the ''keyup'' event on the text fields, and either the ''change'' or the ''click'' event on the radio buttons.&lt;br /&gt;
*: '''Tip 2:''' Re-read [[JavaScript|the JavaScript guide]] if you need help figuring our how to bind callback functions to events, or how to determine which radio button is currently selected.  (There are examples for both of these!)&lt;br /&gt;
* The calculator should be completely self-contained; i.e., you should not be making any requests to any other server-side or client-side scripts or web pages after the initial page load.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' You can embed JavaScript code into an HTML document like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
// your code here&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If your code isn't working the way you expect, use a JavaScript error console.  In Chrome, for example, press Ctrl-Shift-I (or Cmd-Option-I) to open the WebKit inspector.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' It is best practice to fully separate the content, appearance, and behavior.  In previous modules, you may have lost points for using HTML tags that change the appearance of things &amp;lt;nowiki&amp;gt;(like &amp;lt;center&amp;gt; and &amp;lt;font&amp;gt;).&amp;lt;/nowiki&amp;gt;  In this module, make sure that you define your event listeners in JavaScript as in &amp;lt;code&amp;gt;document.getElementById(&amp;quot;xyz&amp;quot;).addEventListener(...)&amp;lt;/code&amp;gt; and '''''not''''' in the HTML like &amp;lt;code&amp;gt;&amp;lt;button onclick=&amp;quot;badExample();&amp;quot;&amp;gt;Bad Example&amp;lt;/button&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Weather Widget ===&lt;br /&gt;
&lt;br /&gt;
In this section, you will make a web page that displays the weather forecast using AJAX requests to a weather server.&lt;br /&gt;
&lt;br /&gt;
# Make an empty HTML document; name it '''weather.html'''&lt;br /&gt;
#: Refer to the [[HTML and CSS]] guide for the skeleton of an HTML document&lt;br /&gt;
# Define a function in JavaScript; call it '''fetchWeather()'''.  You may write your JavaScript in an embedded script in your head tag.&lt;br /&gt;
# Inside your '''fetchWeather()''' function, make an AJAX request to the weather server.&lt;br /&gt;
#: We have a server that outputs the current weather in JSON format.  The format is documented in the [[#JSON Structure]] section below.&lt;br /&gt;
#: '''URL:''' http://classes.engineering.wustl.edu/cse330/content/weather_json.php&lt;br /&gt;
#: We kindly thank Yahoo Weather for providing us with up-to-date weather information.&lt;br /&gt;
#* '''IMPORTANT:''' Under normal circumstances, AJAX requests ''cannot'' be performed cross-domain for security reasons.  We have set the &amp;lt;code&amp;gt;Access-Control-Allow-Origin&amp;lt;/code&amp;gt; header on our server to allow requests from your EC2 instances, or from localhost.  '''You will therefore need to upload your code to your EC2, or access it via localhost, in order for the AJAX requests to work.'''  This means that you cannot, for example, complete this part of the individual portion in JSFiddle.&lt;br /&gt;
# In your callback, process the JSON and use JavaScript to manipulate the HTML DOM to display the following information on your page:&lt;br /&gt;
#* Location&lt;br /&gt;
#** City, in a &amp;lt;nowiki&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;/nowiki&amp;gt; tag&lt;br /&gt;
#** State, not in any tag&lt;br /&gt;
#* Humidity&lt;br /&gt;
#* Current Temperature&lt;br /&gt;
#* Image for Tomorrow's Forecast (see [[#Weather Condition Images]] below for more information)&lt;br /&gt;
#* Image for the Day After Tomorrow's Forecast&lt;br /&gt;
# Finally, bind '''fetchWeather()''' to the DOMContentLoaded event so that your weather widget is automatically initialized when the page is loaded:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, fetchWeather, false);&amp;lt;/source&amp;gt;&lt;br /&gt;
# In addition, add a button that runs your ''fetchWeather'' function when clicked.  This should update your widget with the current weather conditions.&lt;br /&gt;
&lt;br /&gt;
Use the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;weather&amp;quot; id=&amp;quot;weatherWidget&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-loc&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-humidity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-temp&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-tomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-dayaftertomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the CSS file from here: http://classes.engineering.wustl.edu/cse330/content/weather.css&lt;br /&gt;
&lt;br /&gt;
When everything is working, the weather widget should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:WeatherWidget.png]]&lt;br /&gt;
&lt;br /&gt;
'''Important:''' The widget in this section needs to work in only Firefox and Chrome.  It does '''''not''''' need to work Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
===== JSON Structure =====&lt;br /&gt;
&lt;br /&gt;
The JSON from our server looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;updated&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;,&lt;br /&gt;
   &amp;quot;location&amp;quot;: {&lt;br /&gt;
      &amp;quot;city&amp;quot;: &amp;quot;St. Louis&amp;quot;,&lt;br /&gt;
      &amp;quot;state&amp;quot;: &amp;quot;MO&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;wind&amp;quot;: {&lt;br /&gt;
      &amp;quot;chill&amp;quot;: &amp;quot;62&amp;quot;,&lt;br /&gt;
      &amp;quot;direction&amp;quot;: &amp;quot;150&amp;quot;,&lt;br /&gt;
      &amp;quot;speed&amp;quot;: &amp;quot;3 mph&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;atmosphere&amp;quot;: {&lt;br /&gt;
      &amp;quot;humidity&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
      &amp;quot;visibility&amp;quot;: &amp;quot;10&amp;quot;,&lt;br /&gt;
      &amp;quot;pressure&amp;quot;: &amp;quot;30.12 in&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;current&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;28&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Mostly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;temp&amp;quot;: &amp;quot;62°F&amp;quot;,&lt;br /&gt;
      &amp;quot;date&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;tomorrow&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;29&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Clouds Early/Clearing Late&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;45°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;61°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;dayafter&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;30&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Partly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;53°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;65°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;credit&amp;quot;: &amp;quot;http://us.rd.yahoo.com/dailynews/rss/weather/St._Louis__MO/*http://weather.yahoo.com/forecast/USMO0170_f.html&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Weather Condition Images =====&lt;br /&gt;
&lt;br /&gt;
Each day's forecast has a code.  There are images associated with these codes.&lt;br /&gt;
&lt;br /&gt;
One place to get the images is from here: &amp;lt;nowiki&amp;gt;http://us.yimg.com/i/us/nws/weather/gr/&amp;lt;/nowiki&amp;gt;'''##'''&amp;lt;nowiki&amp;gt;ds.png&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the '''##''' with the forecast code.  For example, for code 32, the URL would be: http://us.yimg.com/i/us/nws/weather/gr/32ds.png&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
I forgot if I already mentioned this, but '''start early on this project!''' It will take longer than you think, I promise!&lt;br /&gt;
&lt;br /&gt;
You are encouraged to use the advanced version control practices you learned in Module 5 when completing this assignment.&lt;br /&gt;
&lt;br /&gt;
=== Calendar ===&lt;br /&gt;
&lt;br /&gt;
Build a simple calendar that allows users to add and remove events dynamically.&lt;br /&gt;
&lt;br /&gt;
You will use JavaScript to process user interactions at the web browser, without ever refreshing the browser after the initial web page load.  You may use a JavaScript library of your choice, including Ext JS.&lt;br /&gt;
&lt;br /&gt;
Your application should utilize AJAX to run server-side scripts that query your database to save and retrieve information, including user accounts and events.&lt;br /&gt;
&lt;br /&gt;
We have also written some functions to help you get started: [[JavaScript Calendar Library]]&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
* https://calendar.google.com/&lt;br /&gt;
* http://www.zoho.com/calendar/&lt;br /&gt;
&lt;br /&gt;
==== Server Side Language ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, you may use a database of your choice.  MySQL is probably the logical choice since you have been using it since Module 2, but if you're up for a challenge we encourage you to look at other database options like [[wikipedia:MongoDB|MongoDB]].&lt;br /&gt;
&lt;br /&gt;
''* While it is fine to use the provided example for reference, copying it in its entirety is a violation of Academic Integrity and will result in a 0 for the group portion of this module.  Don't plagiarize.''&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Support a month-by-month view of the calendar.&lt;br /&gt;
*: Show one month at a time, with buttons to move forward or backward.&lt;br /&gt;
*: There should be no limit to how far forward or backward the user can go.&lt;br /&gt;
* Users can register and log in to the website.&lt;br /&gt;
*: You may leverage your MySQL project code and database from module 3 to get started.&lt;br /&gt;
*: You may alternatively use [[Web Application Security, Part 2#OpenID|OpenID]] for user authentication.  Note that you will still need a Users table in order associate calendar events with a certain OpenID.&lt;br /&gt;
* Unregistered users should see no events on the calendar.&lt;br /&gt;
* Registered users can add events.&lt;br /&gt;
*: All events should have a date and time, but do not need to have a duration.&lt;br /&gt;
*: You do ''not'' need to support recurring events (where you add an event that repeats, for example, every monday).&lt;br /&gt;
* Registered users see only events that they have added.&lt;br /&gt;
*: Your AJAX should not ask the server for events from a certain username.  Instead, your AJAX should ask the server for events, and the server should respond with the events for only the currently-logged-in user (from the session).  Can you think of why?&lt;br /&gt;
* Registered users can delete their events, but not the events of others.&lt;br /&gt;
*: Again, the server should delete events based on the username present in the session.  (If it deletes only based on an Event ID, an attacker could feed any arbitrary Event ID to your server, even if he/she didn't own that event.)&lt;br /&gt;
* All user and event data should be kept in a database.&lt;br /&gt;
* At no time should the main page need to be reloaded.&lt;br /&gt;
*: User registration, user authentication, event addition, and event deletion should all be handled by JavaScript and AJAX requests to your server.&lt;br /&gt;
* Your page needs to work in the versions of Firefox and Chrome installed on the lab computers.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Run your database schema by a TA before implementing it.&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to prevent XSS attacks.'''  Be careful when transmitting data over JSON that will be reflected in an event title!  (Note: JSON data should be sanitized on the client side, not the server side.)&lt;br /&gt;
* '''Perform precautionary measures to prevent session hijacking attacks.'''&lt;br /&gt;
*: You should specify your session cookie to be HTTP-Only.  However, for the means of this module, you need not test for user agent consistency.&lt;br /&gt;
* '''Optional:''' Validate your JavaScript code using [http://www.jshint.com/ JSHint] '''''or''''' [http://jslint.com/ JSLint] for up to 3 points of extra credit.&lt;br /&gt;
&lt;br /&gt;
You should continue the practices that you have learned in past weeks:&lt;br /&gt;
&lt;br /&gt;
* Pass tokens in forms to prevent CSRF attacks.&lt;br /&gt;
*: '''Hint:''' You will need to send your CSRF tokens in your AJAX requests.  Remember that AJAX still submits forms and runs server-side scripts, just like the vanilla forms you've been using in Modules 2 and 3.&lt;br /&gt;
* Use prepared queries to prevent SQL Injection attacks.&lt;br /&gt;
* If storing passwords in a database, always store them salted and encrypted.&lt;br /&gt;
* Your page should validate with no errors through the W3C validator.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module5-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''JavaScript Calculator (10 Points):'''&lt;br /&gt;
#* Calculator successfully adds, subtracts, multiplies, and divides numbers (3 points)&lt;br /&gt;
#* The result is automatically computed when a value in either field is changed (3 points)&lt;br /&gt;
#* Calculator is written entirely in pure, conventional JavaScript with no external libraries (4 points)*&lt;br /&gt;
#*: ''Note: be sure to fully separate content, appearance, and behavior.  This means that you should '''not''' use the event attributes on the HTML elements like onclick, onchange, and onkeyup.''&lt;br /&gt;
# '''Weather Widget (15 Points):'''&lt;br /&gt;
#* Widget performs an AJAX request to fetch the current weather (4 points)&lt;br /&gt;
#* The HTML template is filled with the correct information, including an image (4 points)&lt;br /&gt;
#* Button to reload the weather widget (2 points)&lt;br /&gt;
#* Widget is written entirely in pure, conventional JavaScript with no external libraries (5 points)*&lt;br /&gt;
# '''AJAX Calendar (60 Points):'''&lt;br /&gt;
#* '''''Calendar View (10 Points):'''''&lt;br /&gt;
#** The calendar is displayed as a table grid with days as the columns and weeks as the rows, one month at a time (5 points)&lt;br /&gt;
#** The user can view different months as far in the past or future as desired (5 points)&lt;br /&gt;
#* '''''User and Event Management (25 Points):'''''&lt;br /&gt;
#** Events can be added, modified, and deleted (5 points)&lt;br /&gt;
#** Events have a title, date, and time (2 points)&lt;br /&gt;
#** Users can log into the site, and they cannot view or manipulate events associated with other users (8 points)&lt;br /&gt;
#**: ''Don't fall into the Abuse of Functionality trap!  Check user credentials on the server side as well as on the client side.''&lt;br /&gt;
#** All actions are performed over AJAX, without ever needing to reload the page (10 points)&lt;br /&gt;
#* '''''Best Practices (20 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** If storing passwords, they are stored salted and encrypted; if using OpenID, you are storing the user's OpenID identifier in the database (2 points)&lt;br /&gt;
#** All AJAX requests that either contain sensitive information or modify something on the server are performed via POST, not GET (3 points)&lt;br /&gt;
#** Safe from XSS attacks; that is, all content is escaped on output (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** CSRF tokens are passed when editing or removing events (3 points)&lt;br /&gt;
#** Session cookie is HTTP-Only (3 points)&lt;br /&gt;
#** Page passes the W3C validator (2 points)&lt;br /&gt;
#** ''Extra Credit:'' Your code passes ''JSHint'' or ''JSLint'' (+3 bonus 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)'''&lt;br /&gt;
#* '''Additional Calendars Features (worth 15 points):''' Develop some additional features for the calendar, a few examples are provided below.&lt;br /&gt;
#**  Users can tag an event with a particular category and enable/disable those tags in the calendar view. (5 points)&lt;br /&gt;
#**  Users can share their calendar with additional users. (5 points)&lt;br /&gt;
#**  Users can create group events that display on multiple users calendars (5 points)&lt;br /&gt;
''* These points can be earned only if at least 3 other points have been earned in that category.  This is to prevent these points from being &amp;quot;free.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2029</id>
		<title>Module 5</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2029"/>
		<updated>2015-09-21T18:16:59Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 5, you will learn JavaScript, the dominant client-side web language.  JavaScript is the third and final programming language you will learn in CSE 330.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 5.&lt;br /&gt;
&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
&lt;br /&gt;
''This module takes students a while. It is strongly recommended that you start early and ask questions as they come up.''&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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
'''''IMPORTANT:'' Both of the individual assignments must be completed ''without'' using a JavaScript library like jQuery.'''  However, you may (and should) use jQuery for the group portion.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Calculator ===&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a calculator using PHP.  Now you will be making one using JavaScript.&lt;br /&gt;
&lt;br /&gt;
* The web page should have two input fields and a radio button group for the operation, with the 4 basic math operations represented (add, subtract, multiply, divide).&lt;br /&gt;
* JavaScript should monitor all three fields and display the current result whenever the user changes any value in any field, without refreshing the page.&lt;br /&gt;
*: '''Tip 1:''' Consider using either the ''change'' or the ''keyup'' event on the text fields, and either the ''change'' or the ''click'' event on the radio buttons.&lt;br /&gt;
*: '''Tip 2:''' Re-read [[JavaScript|the JavaScript guide]] if you need help figuring our how to bind callback functions to events, or how to determine which radio button is currently selected.  (There are examples for both of these!)&lt;br /&gt;
* The calculator should be completely self-contained; i.e., you should not be making any requests to any other server-side or client-side scripts or web pages after the initial page load.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' You can embed JavaScript code into an HTML document like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
// your code here&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If your code isn't working the way you expect, use a JavaScript error console.  In Chrome, for example, press Ctrl-Shift-I (or Cmd-Option-I) to open the WebKit inspector.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' It is best practice to fully separate the content, appearance, and behavior.  In previous modules, you may have lost points for using HTML tags that change the appearance of things &amp;lt;nowiki&amp;gt;(like &amp;lt;center&amp;gt; and &amp;lt;font&amp;gt;).&amp;lt;/nowiki&amp;gt;  In this module, make sure that you define your event listeners in JavaScript as in &amp;lt;code&amp;gt;document.getElementById(&amp;quot;xyz&amp;quot;).addEventListener(...)&amp;lt;/code&amp;gt; and '''''not''''' in the HTML like &amp;lt;code&amp;gt;&amp;lt;button onclick=&amp;quot;badExample();&amp;quot;&amp;gt;Bad Example&amp;lt;/button&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Weather Widget ===&lt;br /&gt;
&lt;br /&gt;
In this section, you will make a web page that displays the weather forecast using AJAX requests to a weather server.&lt;br /&gt;
&lt;br /&gt;
# Make an empty HTML document; name it '''weather.html'''&lt;br /&gt;
#: Refer to the [[HTML and CSS]] guide for the skeleton of an HTML document&lt;br /&gt;
# Define a function in JavaScript; call it '''fetchWeather()'''.  You may write your JavaScript in an embedded script in your head tag.&lt;br /&gt;
# Inside your '''fetchWeather()''' function, make an AJAX request to the weather server.&lt;br /&gt;
#: We have a server that outputs the current weather in JSON format.  The format is documented in the [[#JSON Structure]] section below.&lt;br /&gt;
#: '''URL:''' http://classes.engineering.wustl.edu/cse330/content/weather_json.php&lt;br /&gt;
#: We kindly thank Yahoo Weather for providing us with up-to-date weather information.&lt;br /&gt;
#* '''IMPORTANT:''' Under normal circumstances, AJAX requests ''cannot'' be performed cross-domain for security reasons.  We have set the &amp;lt;code&amp;gt;Access-Control-Allow-Origin&amp;lt;/code&amp;gt; header on our server to allow requests from your EC2 instances, or from localhost.  '''You will therefore need to upload your code to your EC2, or access it via localhost, in order for the AJAX requests to work.'''  This means that you cannot, for example, complete this part of the individual portion in JSFiddle.&lt;br /&gt;
# In your callback, process the JSON and use JavaScript to manipulate the HTML DOM to display the following information on your page:&lt;br /&gt;
#* Location&lt;br /&gt;
#** City, in a &amp;lt;nowiki&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;/nowiki&amp;gt; tag&lt;br /&gt;
#** State, not in any tag&lt;br /&gt;
#* Humidity&lt;br /&gt;
#* Current Temperature&lt;br /&gt;
#* Image for Tomorrow's Forecast (see [[#Weather Condition Images]] below for more information)&lt;br /&gt;
#* Image for the Day After Tomorrow's Forecast&lt;br /&gt;
# Finally, bind '''fetchWeather()''' to the DOMContentLoaded event so that your weather widget is automatically initialized when the page is loaded:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, fetchWeather, false);&amp;lt;/source&amp;gt;&lt;br /&gt;
# In addition, add a button that runs your ''fetchWeather'' function when clicked.  This should update your widget with the current weather conditions.&lt;br /&gt;
&lt;br /&gt;
Use the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;weather&amp;quot; id=&amp;quot;weatherWidget&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-loc&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-humidity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-temp&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-tomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-dayaftertomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the CSS file from here: http://classes.engineering.wustl.edu/cse330/content/weather.css&lt;br /&gt;
&lt;br /&gt;
When everything is working, the weather widget should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:WeatherWidget.png]]&lt;br /&gt;
&lt;br /&gt;
'''Important:''' The widget in this section needs to work in only Firefox and Chrome.  It does '''''not''''' need to work Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
===== JSON Structure =====&lt;br /&gt;
&lt;br /&gt;
The JSON from our server looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;updated&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;,&lt;br /&gt;
   &amp;quot;location&amp;quot;: {&lt;br /&gt;
      &amp;quot;city&amp;quot;: &amp;quot;St. Louis&amp;quot;,&lt;br /&gt;
      &amp;quot;state&amp;quot;: &amp;quot;MO&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;wind&amp;quot;: {&lt;br /&gt;
      &amp;quot;chill&amp;quot;: &amp;quot;62&amp;quot;,&lt;br /&gt;
      &amp;quot;direction&amp;quot;: &amp;quot;150&amp;quot;,&lt;br /&gt;
      &amp;quot;speed&amp;quot;: &amp;quot;3 mph&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;atmosphere&amp;quot;: {&lt;br /&gt;
      &amp;quot;humidity&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
      &amp;quot;visibility&amp;quot;: &amp;quot;10&amp;quot;,&lt;br /&gt;
      &amp;quot;pressure&amp;quot;: &amp;quot;30.12 in&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;current&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;28&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Mostly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;temp&amp;quot;: &amp;quot;62°F&amp;quot;,&lt;br /&gt;
      &amp;quot;date&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;tomorrow&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;29&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Clouds Early/Clearing Late&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;45°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;61°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;dayafter&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;30&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Partly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;53°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;65°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;credit&amp;quot;: &amp;quot;http://us.rd.yahoo.com/dailynews/rss/weather/St._Louis__MO/*http://weather.yahoo.com/forecast/USMO0170_f.html&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Weather Condition Images =====&lt;br /&gt;
&lt;br /&gt;
Each day's forecast has a code.  There are images associated with these codes.&lt;br /&gt;
&lt;br /&gt;
One place to get the images is from here: &amp;lt;nowiki&amp;gt;http://us.yimg.com/i/us/nws/weather/gr/&amp;lt;/nowiki&amp;gt;'''##'''&amp;lt;nowiki&amp;gt;ds.png&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the '''##''' with the forecast code.  For example, for code 32, the URL would be: http://us.yimg.com/i/us/nws/weather/gr/32ds.png&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
I forgot if I already mentioned this, but '''start early on this project!''' It will take longer than you think, I promise!&lt;br /&gt;
&lt;br /&gt;
You are encouraged to use the advanced version control practices you learned in Module 5 when completing this assignment.&lt;br /&gt;
&lt;br /&gt;
=== Calendar ===&lt;br /&gt;
&lt;br /&gt;
Build a simple calendar that allows users to add and remove events dynamically.&lt;br /&gt;
&lt;br /&gt;
You will use JavaScript to process user interactions at the web browser, without ever refreshing the browser after the initial web page load.  You may use a JavaScript library of your choice, including Ext JS.&lt;br /&gt;
&lt;br /&gt;
Your application should utilize AJAX to run server-side scripts that query your database to save and retrieve information, including user accounts and events.&lt;br /&gt;
&lt;br /&gt;
We have also written some functions to help you get started: [[JavaScript Calendar Library]]&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
* https://calendar.google.com/&lt;br /&gt;
* http://www.zoho.com/calendar/&lt;br /&gt;
&lt;br /&gt;
==== Server Side Language ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, you may use a database of your choice.  MySQL is probably the logical choice since you have been using it since Module 2, but if you're up for a challenge we encourage you to look at other database options like [[wikipedia:MongoDB|MongoDB]].&lt;br /&gt;
&lt;br /&gt;
''* While it is fine to use the provided example for reference, copying it in its entirety is a violation of Academic Integrity and will result in a 0 for the group portion of this module.  Don't plagiarize.''&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Support a month-by-month view of the calendar.&lt;br /&gt;
*: Show one month at a time, with buttons to move forward or backward.&lt;br /&gt;
*: There should be no limit to how far forward or backward the user can go.&lt;br /&gt;
* Users can register and log in to the website.&lt;br /&gt;
*: You may leverage your MySQL project code and database from module 3 to get started.&lt;br /&gt;
*: You may alternatively use [[Web Application Security, Part 2#OpenID|OpenID]] for user authentication.  Note that you will still need a Users table in order associate calendar events with a certain OpenID.&lt;br /&gt;
* Unregistered users should see no events on the calendar.&lt;br /&gt;
* Registered users can add events.&lt;br /&gt;
*: All events should have a date and time, but do not need to have a duration.&lt;br /&gt;
*: You do ''not'' need to support recurring events (where you add an event that repeats, for example, every monday).&lt;br /&gt;
* Registered users see only events that they have added.&lt;br /&gt;
*: Your AJAX should not ask the server for events from a certain username.  Instead, your AJAX should ask the server for events, and the server should respond with the events for only the currently-logged-in user (from the session).  Can you think of why?&lt;br /&gt;
* Registered users can delete their events, but not the events of others.&lt;br /&gt;
*: Again, the server should delete events based on the username present in the session.  (If it deletes only based on an Event ID, an attacker could feed any arbitrary Event ID to your server, even if he/she didn't own that event.)&lt;br /&gt;
* All user and event data should be kept in a database.&lt;br /&gt;
* At no time should the main page need to be reloaded.&lt;br /&gt;
*: User registration, user authentication, event addition, and event deletion should all be handled by JavaScript and AJAX requests to your server.&lt;br /&gt;
* Your page needs to work in the versions of Firefox and Chrome installed on the lab computers.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Run your database schema by a TA before implementing it.&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to prevent XSS attacks.'''  Be careful when transmitting data over JSON that will be reflected in an event title!  (Note: JSON data should be sanitized on the client side, not the server side.)&lt;br /&gt;
* '''Perform precautionary measures to prevent session hijacking attacks.'''&lt;br /&gt;
*: You should specify your session cookie to be HTTP-Only.  However, for the means of this module, you need not test for user agent consistency.&lt;br /&gt;
* '''Optional:''' Validate your JavaScript code using [http://www.jshint.com/ JSHint] '''''or''''' [http://jslint.com/ JSLint] for up to 3 points of extra credit.&lt;br /&gt;
&lt;br /&gt;
You should continue the practices that you have learned in past weeks:&lt;br /&gt;
&lt;br /&gt;
* Pass tokens in forms to prevent CSRF attacks.&lt;br /&gt;
*: '''Hint:''' You will need to send your CSRF tokens in your AJAX requests.  Remember that AJAX still submits forms and runs server-side scripts, just like the vanilla forms you've been using in Modules 2 and 3.&lt;br /&gt;
* Use prepared queries to prevent SQL Injection attacks.&lt;br /&gt;
* If storing passwords in a database, always store them salted and encrypted.&lt;br /&gt;
* Your page should validate with no errors through the W3C validator.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''JavaScript Calculator (10 Points):'''&lt;br /&gt;
#* Calculator successfully adds, subtracts, multiplies, and divides numbers (3 points)&lt;br /&gt;
#* The result is automatically computed when a value in either field is changed (3 points)&lt;br /&gt;
#* Calculator is written entirely in pure, conventional JavaScript with no external libraries (4 points)*&lt;br /&gt;
#*: ''Note: be sure to fully separate content, appearance, and behavior.  This means that you should '''not''' use the event attributes on the HTML elements like onclick, onchange, and onkeyup.''&lt;br /&gt;
# '''Weather Widget (15 Points):'''&lt;br /&gt;
#* Widget performs an AJAX request to fetch the current weather (4 points)&lt;br /&gt;
#* The HTML template is filled with the correct information, including an image (4 points)&lt;br /&gt;
#* Button to reload the weather widget (2 points)&lt;br /&gt;
#* Widget is written entirely in pure, conventional JavaScript with no external libraries (5 points)*&lt;br /&gt;
# '''AJAX Calendar (60 Points):'''&lt;br /&gt;
#* '''''Calendar View (10 Points):'''''&lt;br /&gt;
#** The calendar is displayed as a table grid with days as the columns and weeks as the rows, one month at a time (5 points)&lt;br /&gt;
#** The user can view different months as far in the past or future as desired (5 points)&lt;br /&gt;
#* '''''User and Event Management (25 Points):'''''&lt;br /&gt;
#** Events can be added, modified, and deleted (5 points)&lt;br /&gt;
#** Events have a title, date, and time (2 points)&lt;br /&gt;
#** Users can log into the site, and they cannot view or manipulate events associated with other users (8 points)&lt;br /&gt;
#**: ''Don't fall into the Abuse of Functionality trap!  Check user credentials on the server side as well as on the client side.''&lt;br /&gt;
#** All actions are performed over AJAX, without ever needing to reload the page (10 points)&lt;br /&gt;
#* '''''Best Practices (20 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** If storing passwords, they are stored salted and encrypted; if using OpenID, you are storing the user's OpenID identifier in the database (2 points)&lt;br /&gt;
#** All AJAX requests that either contain sensitive information or modify something on the server are performed via POST, not GET (3 points)&lt;br /&gt;
#** Safe from XSS attacks; that is, all content is escaped on output (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** CSRF tokens are passed when editing or removing events (3 points)&lt;br /&gt;
#** Session cookie is HTTP-Only (3 points)&lt;br /&gt;
#** Page passes the W3C validator (2 points)&lt;br /&gt;
#** ''Extra Credit:'' Your code passes ''JSHint'' or ''JSLint'' (+3 bonus 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)'''&lt;br /&gt;
#* '''Additional Calendars Features (worth 15 points):''' Develop some additional features for the calendar, a few examples are provided below.&lt;br /&gt;
#**  Users can tag an event with a particular category and enable/disable those tags in the calendar view. (5 points)&lt;br /&gt;
#**  Users can share their calendar with additional users. (5 points)&lt;br /&gt;
#**  Users can create group events that display on multiple users calendars (5 points)&lt;br /&gt;
''* These points can be earned only if at least 3 other points have been earned in that category.  This is to prevent these points from being &amp;quot;free.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2028</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=2028"/>
		<updated>2015-09-21T18:15:49Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&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 the string &amp;quot;hello world&amp;quot; in a sentence&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;
Examples:&lt;br /&gt;
   Regex 1:  Programmers will often write ''[[hello world]]'' as their first project with a programming language.&lt;br /&gt;
   Regex 2:  The ''[[gooey]]'' peanut butter and jelly sandwich was a ''[[beauty]]''.&lt;br /&gt;
   Regex 3:  ''[[AA312]]'' (should match)&lt;br /&gt;
             ''[[AA1298]]'' (should match)&lt;br /&gt;
             US31344 (should NOT match)&lt;br /&gt;
             NW314 and CO118 (should NOT match)&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;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upload your baseball code, a file with your Regular expressions, and screenshots of your python output onto bitbucket, and we will use the time-stamps to determine late-penalties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2027</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=2027"/>
		<updated>2015-09-21T18:15:36Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&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 the string &amp;quot;hello world&amp;quot; in a sentence&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;
Examples:&lt;br /&gt;
   Regex 1:  Programmers will often write ''[[hello world]]'' as their first project with a programming language.&lt;br /&gt;
   Regex 2:  The ''[[gooey]]'' peanut butter and jelly sandwich was a ''[[beauty]]''.&lt;br /&gt;
   Regex 3:  ''[[AA312]]'' (should match)&lt;br /&gt;
             ''[[AA1298]]'' (should match)&lt;br /&gt;
             US31344 (should NOT match)&lt;br /&gt;
             NW314 and CO118 (should NOT match)&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;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upload your baseball code, a file with your Regular expressions, and screenshots of your python output onto bitbucket, and we will use the time-stamps to determine late-penalties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2026</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=2026"/>
		<updated>2015-09-21T18:15:20Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&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 the string &amp;quot;hello world&amp;quot; in a sentence&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;
Examples:&lt;br /&gt;
   Regex 1:  Programmers will often write ''[[hello world]]'' as their first project with a programming language.&lt;br /&gt;
   Regex 2:  The ''[[gooey]]'' peanut butter and jelly sandwich was a ''[[beauty]]''.&lt;br /&gt;
   Regex 3:  ''[[AA312]]'' (should match)&lt;br /&gt;
             ''[[AA1298]]'' (should match)&lt;br /&gt;
             US31344 (should NOT match)&lt;br /&gt;
             NW314 and CO118 (should NOT match)&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;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upload your baseball code, a file with your Regular expressions, and screenshots of your python output onto bitbucket, and we will use the time-stamps to determine late-penalties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2025</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=2025"/>
		<updated>2015-09-21T17:57:22Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* 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;
=== 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 330S&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 330S (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 330S 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 330S 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 330S 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 CSE330S.&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 Git 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.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&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;
&lt;br /&gt;
'''Assignments must be demoed by the Friday at 1:00 PM of the week of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after Friday, you will receive a late penalty for the assignment (ie. if you demo on Saturday, you will be 5 days late, regardless of your timestamp).''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&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, and they should be stored in a separate database field from the story (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, with proper commenting (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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2024</id>
		<title>Introduction to MySQL</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Introduction_to_MySQL&amp;diff=2024"/>
		<updated>2015-09-21T16:58:01Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Installing phpMyAdmin from Download */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article is an introduction to MySQL, a database used in conjunction with web applications.&lt;br /&gt;
&lt;br /&gt;
== Why Use a Database? ==&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a web site that used flatfiles to keep track of usernames and uploaded file associations.  However, flatfiles are insecure, lack complex logic, and are impractical for a large-scale web application.  This is where databases come in.  Databases are designed from the ground up to be fast, efficient, and powerful storage solutions for any amount of data.&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using '''MySQL''', which is a popular, open-source ''relational database management system'' for web applications.&lt;br /&gt;
&lt;br /&gt;
== Database Structure ==&lt;br /&gt;
&lt;br /&gt;
A MySQL server consists of ''databases'', each of which contains ''tables''.  Tables, in turn, consist of one or more ''fields'' (like columns), and the data is stored in one or more ''entries'' (like rows).  A field in a table can be designated as an ''index''; that is, something that can be used to look up the information in the database.  The set of tables, fields, and indices in your database is called your ''schema''.&lt;br /&gt;
&lt;br /&gt;
MySQL uses the '''Structured Query Language (SQL)''' for manipulating data.&lt;br /&gt;
&lt;br /&gt;
=== Storage Engines ===&lt;br /&gt;
&lt;br /&gt;
MySQL is a database server, but under the hood, it actually uses a '''storage engine''' to retrieve the data.  Two storage engines that are popular in the MySQL community are '''InnoDB''' and '''MyISAM'''.  MyISAM is slightly faster than InnoDB, and it specializes in database schemas that involve predominantly ''SELECT'' and ''INSERT'' queries (which you will learn about later).  However, MyISAM lacks InnoDB's power in making relations between tables, and MyISAM also does not support InnoDB's database transactions.  [http://www.akadia.com/services/mysql_survival.html Click here for more information regarding the differences between MyISAM and InnoDB.]&lt;br /&gt;
&lt;br /&gt;
In CSE330, we will be using InnoDB for our primary MySQL storage engine because of its support for foreign key constraints.  However, in your personal applications down the road, feel free to use either InnoDB or MyISAM.&lt;br /&gt;
&lt;br /&gt;
== Installing and Configuring MySQL ==&lt;br /&gt;
&lt;br /&gt;
To use MySQL, you need the MySQL Server package.  Because we will be interacting with MySQL primarily from PHP scripts, we will also need the associated PHP libraries.&lt;br /&gt;
&lt;br /&gt;
* In '''apt (Debian)''', you need the packages '''mysql-server''' and '''mysql-client''' and '''php5-mysqlnd''' and '''php5-mcrypt'''&lt;br /&gt;
* In '''yum (RHEL)''', you need the packages '''mysql-server''' and '''php-mysqlnd''' and '''php-mcrypt''' and '''php-mbstring'''&lt;br /&gt;
&lt;br /&gt;
'''Important:''' We will be using the MySQLnd driver in this class.  Make sure that you install the '''php(5)-mysql''nd''''' rather than the '''php(5)-mysql''' package.&lt;br /&gt;
&lt;br /&gt;
If you need a refresher on how to install software packages in Linux, re-read [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
Remember to restart Apache after installing any packages relating to your web server!&lt;br /&gt;
&lt;br /&gt;
=== For RHEL Users: Additional Configurations ===&lt;br /&gt;
&lt;br /&gt;
Apt in Debian takes care of some basic MySQL configurations automatically during installation, but unfortunately Yum in RHEL does not.&lt;br /&gt;
&lt;br /&gt;
In RHEL, run these commands to start the server and the client automatically on startup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo /sbin/chkconfig --add mysqld&lt;br /&gt;
$ sudo /sbin/chkconfig mysqld on&lt;br /&gt;
$ sudo /sbin/service mysqld start&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In RHEL, run the following command to set the MySQL root user password:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysqladmin -u root password&lt;br /&gt;
New password: &lt;br /&gt;
Confirm new password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When it asks, type the new password, press Enter, and then type the new password again.  You cannot see what you are typing because a password is supposed to be secret.  If the shell displayed the password to you while you were typing it, it would be forever saved in ''~/.bash_history''!&lt;br /&gt;
&lt;br /&gt;
== Using MySQL from the Command Line ==&lt;br /&gt;
&lt;br /&gt;
To interface with MySQL from the command line, use the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command.  The syntax is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME&lt;br /&gt;
Welcome to the MySQL monitor. ...&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be prompted for the password associated with USERNAME.&lt;br /&gt;
&lt;br /&gt;
'''Debian Quirk:''' If you will be importing data into your database on this MySQL session, you should also pass the &amp;lt;code&amp;gt;--local-infile&amp;lt;/code&amp;gt; flag as a runtime argument to the &amp;lt;code&amp;gt;mysql&amp;lt;/code&amp;gt; command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mysql -u USERNAME -p DATABASENAME --local-infile&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Managing Databases ==&lt;br /&gt;
&lt;br /&gt;
To create a database on your MySQL server, simply run the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can delete a database using the query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
drop database DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you're at the MySQL prompt, use the following query to select a database to which to run select, insert, update, and delete queries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
use DATABASENAME;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MySQL User Management ==&lt;br /&gt;
&lt;br /&gt;
The first time you log into MySQL, you will need to use the root user, with the password that you specified earlier.  However, it is unwise to use the root user for everyday operations with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Creating a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user named USERNAME with the password PASSWORD, run the following query inside MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
create user 'USERNAME'@'localhost' identified by 'PASSWORD';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create USERNAME, but that user will not have privileges to access any databases.&lt;br /&gt;
&lt;br /&gt;
=== Granting Privileges ===&lt;br /&gt;
&lt;br /&gt;
MySQL provides the '''grant''' command to grant privileges to a user.  The syntax for assigning USERNAME some PRIVILEGES on a TABLE in a DATABASE is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant PRIVILEGES on DATABASE.TABLE to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to grant global privileges to a certain administrative user, run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant all on *.* to USERNAME@'localhost' with grant option;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ''with grant option'' enables this user to create other users and assign them permissions, like we are doing here.&lt;br /&gt;
&lt;br /&gt;
If you want to grant privileges to a certain user so that they can only manipulate data in a certain database (a wise idea for when you create a user to use in your PHP web application), run the query like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
grant select,insert,update,delete on DATABASE.* to USERNAME@'localhost';&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whenever you change privileges, you also need to run the query &amp;lt;code&amp;gt;flush privileges;&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;mysql&amp;quot;&amp;gt;&lt;br /&gt;
flush privileges;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== phpMyAdmin ==&lt;br /&gt;
&lt;br /&gt;
It is often cumbersome to SSH into your server every time you want to interact with your database.  A popular web-based window into your MySQL server is '''phpMyAdmin'''.&lt;br /&gt;
&lt;br /&gt;
=== Installing phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
You have two choices here: you can either download phpMyAdmin directly from the phpMyAdmin web site, or if you are using Debian, you can install it from the apt repository.&lt;br /&gt;
&lt;br /&gt;
==== Installing phpMyAdmin from Download ====&lt;br /&gt;
&lt;br /&gt;
If you are using RHEL, this is your best option to install phpMyAdmin.  If you are using Debian, it is easiest to install it directly from apt (see [[#Installing phpMyAdmin from Apt|the next section]]).&lt;br /&gt;
&lt;br /&gt;
Get the link to the latest '''*.tar.gz''' version of phpMyAdmin here: http://www.phpmyadmin.net/home_page/downloads.php&lt;br /&gt;
&lt;br /&gt;
Inside your server via SSH, download the file to your home directory using '''wget''', and then extract it using '''tar -xzvf''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd&lt;br /&gt;
$ wget 'https://files.phpmyadmin.net/phpMyAdmin/4.4.15/phpMyAdmin-4.4.15-all-languages.tar.gz'&lt;br /&gt;
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.&lt;br /&gt;
Saving to: “phpMyAdmin-3.5.2.2-english.tar.gz”&lt;br /&gt;
&lt;br /&gt;
100%[==================&amp;gt;] 2,972,789    910K/s   in 3.2s&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
$ tar -xzvf phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
...&lt;br /&gt;
$ ls&lt;br /&gt;
phpMyAdmin-3.5.2.2-english  phpMyAdmin-3.5.2.2-english.tar.gz&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, move the directory to your web server root, and set ownership of the directory to the Apache user (example commands below).&lt;br /&gt;
&lt;br /&gt;
* In RHEL, the Apache user is '''apache:apache''' (that is, the username '''apache''' in the group name '''apache''')&lt;br /&gt;
* In Debian, the Apache user is '''www-data:www-data'''&lt;br /&gt;
&lt;br /&gt;
As a refresher, the web server root is located at '''/var/www/html''' in RHEL and newer versions of Debian (Ubuntu 14.0) and at '''/var/www''' in older versions of Debian.&lt;br /&gt;
&lt;br /&gt;
For example, in RHEL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chown -R apache:apache phpMyAdmin-3.5.2.2-english&lt;br /&gt;
$ sudo mv phpMyAdmin-3.5.2.2-english /var/www/html/phpmyadmin&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a phpMyAdmin configuration file, which needs to be saved as '''config.inc.php'''.  The easiest way to do this is to copy the '''config.sample.inc.php''' file that is included with your download.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cd /var/www/html/phpmyadmin&lt;br /&gt;
$ sudo cp config.sample.inc.php config.inc.php&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, open config.inc.php in your favorite text editor (if you forgot how, refer to [[Linux#File Editors|the Linux guide]]), and edit the following line, putting in something random for &amp;quot;mySecretHere&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 $cfg['blowfish_secret'] = 'mySecretHere';&lt;br /&gt;
&lt;br /&gt;
Finally, restart Apache, and you're good to go.  phpMyAdmin will be accessible via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
==== Installing phpMyAdmin from Apt ====&lt;br /&gt;
&lt;br /&gt;
The package name in apt is '''phpmyadmin'''.  When it asks which server to automatically configure, press the spacebar to check &amp;quot;apache&amp;quot; and then press enter.  Keep the remaining options at their defaults.  You should now be able to access phpMyAdmin via http://ec2-blah-blah.compute-1.amazonaws.com/phpmyadmin/&lt;br /&gt;
&lt;br /&gt;
That was easy!&lt;br /&gt;
&lt;br /&gt;
===== Troubleshooting =====&lt;br /&gt;
&lt;br /&gt;
Older versions of the phpmyadmin package in apt required that you perform one additional step: let Apache know that phpMyAdmin was installed.  The new version does this automatically so long as you check the &amp;quot;apache&amp;quot; box in the first step of the instalation process.&lt;br /&gt;
&lt;br /&gt;
To manually hook up phpMyAdmin with Apache, run the following command to symlink ''phpmyadmin.conf'' into Apache's ''conf.d'' directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf&lt;br /&gt;
$ sudo apache2ctl restart  # restart Apache&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Using phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Once phpMyAdmin is installed, you will see a login screen.  Log in using a non-root username and password you set up in the previous section.  Once inside, you will see a GUI for interacting with your MySQL database.&lt;br /&gt;
&lt;br /&gt;
Even with the GUI, it is often easier to run queries manually, especially when doing operations like creating a table.  To run a query manually, click either the &amp;quot;SQL&amp;quot; tab or the little icon in the toolbar on the upper-left-hand side of the screen that looks like a database cluster (it's third from the left).&lt;br /&gt;
&lt;br /&gt;
== MySQL Schema and State ==&lt;br /&gt;
&lt;br /&gt;
Read the [[MySQL Schema and State]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
== Using MySQL in PHP ==&lt;br /&gt;
&lt;br /&gt;
Read the [[PHP and MySQL]] guide for more information.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2023</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=2023"/>
		<updated>2015-09-21T16:12:37Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Group Project */&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;
=== 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 330S&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 330S (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 330S 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 330S 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 330S 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 CSE330S.&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 Git 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.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&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, and they should be stored in a separate database field from the story (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, with proper commenting (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>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2022</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2022"/>
		<updated>2015-09-14T15:15:15Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands (5 points)&lt;br /&gt;
#* The time zone is correct on your instance (5 points)&lt;br /&gt;
#* The UserDir Apache module is working (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 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;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2021</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2021"/>
		<updated>2015-09-14T15:14:48Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;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 assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName1-LastName1-StudentID1-FirstName2-LastName2-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343-Jane-Doe-201243) &lt;br /&gt;
# OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands (5 points)&lt;br /&gt;
#* The time zone is correct on your instance (5 points)&lt;br /&gt;
#* The UserDir Apache module is working (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 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;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=PHP&amp;diff=2020</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=PHP&amp;diff=2020"/>
		<updated>2015-09-09T00:28:04Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Your First PHP Script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PHP is an open-source language used widely for writing server-side code for web servers.  PHP is a good starting point for web developers, as it is straightforward to learn and yet powerful at the same time.  Indeed, some of the internet's most popular web sites are written using PHP as their language of choice!  This article introduces the syntax of PHP and how to make a basis PHP web application.&lt;br /&gt;
&lt;br /&gt;
{{XKCD&lt;br /&gt;
|name=mac_pc&lt;br /&gt;
|id=934&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== What is PHP? ==&lt;br /&gt;
&lt;br /&gt;
PHP is a server-side scripting language widely used in web development.  PHP is what turns your web site from a static fileserver into a dynamic web application.&lt;br /&gt;
&lt;br /&gt;
By default, Apache only knows how to serve static HTML pages to the client.  You can write as many HTML pages as you want, which is fine for basic web sites.  But if you want to have users post to a forum, or process credit card transactions, or make your own online calendar, a server-side language like PHP is what you need.&lt;br /&gt;
&lt;br /&gt;
=== Document Generation Language ===&lt;br /&gt;
&lt;br /&gt;
If PHP's original core purpose had to be described in three words, it would be this: '''document generation language'''.  Unlike languages including Java, Ruby, Python, and Perl, which consist of classes in a strict program layout, PHP code is most often embedded inside a template document.  When the PHP interpreter runs, it &amp;quot;fills in the gaps&amp;quot; and generates a finished product document.&lt;br /&gt;
&lt;br /&gt;
This isn't to say that PHP can ''only'' be a document generating language, because this is certainly not true.  However, for the purposes of Module 2, it is safe to think of it this way when you are learning the concepts behind a web server.&lt;br /&gt;
&lt;br /&gt;
==== MIME Types ====&lt;br /&gt;
&lt;br /&gt;
By default, PHP generates HTML documents.  (Recall that an HTML document is simply a block of text consisting of markup conforming to the HTML standard.)&lt;br /&gt;
&lt;br /&gt;
However, PHP does not need to generate HTML documents.  It can also generate images, PDFs, or any other type of document.  Each of these document types has its own unique markup language.  The markup language used by a certain document is defined by its ''MIME Type''.&lt;br /&gt;
&lt;br /&gt;
The HTML MIME Type is '''text/html'''.  Other MIME Types include '''image/jpeg''', '''image/png''', and '''application/xml'''.&lt;br /&gt;
&lt;br /&gt;
To change the MIME Type of the document generated by PHP, use the statement:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
header(&amp;quot;Content-Type: image/jpeg&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since PHP generates HTML documents by default, you can think of there being an implicit &amp;lt;code&amp;gt;header(&amp;quot;Content-Type: text/html&amp;quot;);&amp;lt;/code&amp;gt; at the top of every PHP script.&lt;br /&gt;
&lt;br /&gt;
=== PHP and Apache ===&lt;br /&gt;
&lt;br /&gt;
When you request a PHP file over Apache, the file is ''not'' sent verbatim.  Instead, it is first sent through the PHP interpreter.  Here is an oversimplified schematic of the process:&lt;br /&gt;
&lt;br /&gt;
[[File:PHP-Apache_Flowchart.png]]&lt;br /&gt;
&lt;br /&gt;
In summary, here are some points to keep in mind.&lt;br /&gt;
&lt;br /&gt;
# A PHP file on your server is not an HTML document.  It is a PHP script.&lt;br /&gt;
# PHP generates documents.  By default, it generates HTML documents.&lt;br /&gt;
# PHP can generate other document types by changing the MIME Type in the Content-Type HTTP Header.&lt;br /&gt;
# Apache runs the PHP interpreter on your PHP script before transmitting it to the browser.  The content that is generated after the PHP interpreter runs is expected to match the MIME type: by default, an HTML document.&lt;br /&gt;
# The W3C Validator checks for valid markup in an HTML document.  Everywhere that PHP generates an HTML document, that HTML document should be valid.&lt;br /&gt;
&lt;br /&gt;
== Installing PHP ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
To install PHP, you need both the PHP interpreter and the Apache module that runs PHP code.  In yum, the package name is '''php'''; in Debian, the package name is '''php5'''.  (The Apache module that runs PHP is automatically installed with both of these packages.)&lt;br /&gt;
&lt;br /&gt;
Once you install the required packages, [[Web Server Configuration#Restarting Apache and Testing|restart Apache]] for the changes to take effect.&lt;br /&gt;
&lt;br /&gt;
=== Debian Quirk ===&lt;br /&gt;
&lt;br /&gt;
Starting in 2010, Debian-based systems restrict PHP scripts by default for the UserDir module.  If you are using a Debian-based server, edit the file ''/etc/apache2/mods-available/php5.conf''.  Find the section of code shown below and comment it out.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;apache&amp;quot;&amp;gt;&lt;br /&gt;
    #&amp;lt;IfModule mod_userdir.c&amp;gt;&lt;br /&gt;
    #    &amp;lt;Directory /home/*/public_html&amp;gt;&lt;br /&gt;
    #        php_admin_value engine Off&lt;br /&gt;
    #    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
    #&amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will of course need to restart Apache for the changes to take effect.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== PHP Configurations ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
The PHP configuration file is called ''php.ini''.  In RHEL, it is located at ''/etc/php.ini''; in Debian, it is located at ''/etc/php5/apache2/php.ini''.&lt;br /&gt;
&lt;br /&gt;
The configuration file is largely self-documenting as to what the different options mean.  There is one value in particular that we want to change for the purposes of CSE330.  Open php.ini in your favorite text editor, find the '''display_errors''' option, and set it to '''On''':&lt;br /&gt;
&lt;br /&gt;
 display_errors = On&lt;br /&gt;
&lt;br /&gt;
You will need to restart Apache for any php.ini changes to take effect.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' You can turn errors on or off for a certain PHP script by using the '''error_reporting()''' and/or '''ini_set()''' functions.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you tell PHP to log its errors, they will be stored in the Apache error log file, at ''/var/log/httpd/error_log'' in RHEL or ''/var/log/apache2/error.log'' in Debian.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Your First PHP Script ==&lt;br /&gt;
&lt;br /&gt;
By default, all files that have the *.php extension will be interpreted as containing PHP code.  &lt;br /&gt;
All files with PHP need to be saved as '.php'; not '.html'.&lt;br /&gt;
Here is the most basic PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save that code into a file named phpinfo.php, and save it in your web server directory.  Load it up in your browser like this: ''http://ec2-blah-blah.compute-1.amazonaws.com/phpinfo.php''&lt;br /&gt;
&lt;br /&gt;
If you see something like this, your PHP installation is working!&lt;br /&gt;
&lt;br /&gt;
[[Image:Php_info.png]]&lt;br /&gt;
&lt;br /&gt;
Look at the source code of that page.  Notice that even though there were only three lines of code in our PHP file, PHP filled it up with hundreds of lines of HTML!&lt;br /&gt;
&lt;br /&gt;
Your own PHP scripts will probably look something more like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
	&amp;lt;title&amp;gt;My First PHP Script&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo &amp;quot;\t&amp;lt;p&amp;gt;Hello World!&amp;lt;/p&amp;gt;\n&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code will send the following HTML to the browser:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
	&amp;lt;title&amp;gt;My First PHP Script&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;Hello World!&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here's the take-home message of this section.  To run PHP code, enclose it in &amp;lt;code&amp;gt;&amp;lt;?php  ?&amp;gt;&amp;lt;/code&amp;gt; tags; HTML code can be used in a PHP file (although not inside the PHP code block!); and just a few lines of code can generate an arbitrary amount of HTML.&lt;br /&gt;
&lt;br /&gt;
== PHP Language Components ==&lt;br /&gt;
&lt;br /&gt;
PHP is a programming language much like others you have learned: it has variables, arrays, functions, objects etc.  However, the syntax for PHP and the way PHP handles variables may be new to you.  This section gives an overview of PHP the language.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
All variables start with the currency '''$''' symbol.  The '''$''' is necessary for both setting and accessing.&lt;br /&gt;
&lt;br /&gt;
PHP is a weak-typed language; that is, you can set any type of value to a variable (string, array, number, etc), and PHP will accept it, even if that variable previously contained a different data type.  In some ways this is convenient, but in others it can lead to hard-to-detect bugs, so be careful.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$i = 5;  # Set the integer 5 to the variable $i&lt;br /&gt;
$msg = &amp;quot;Hello World&amp;quot;;  # Set the string Hello World to the variable $msg&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that all lines in PHP necessarily end with a semicolon.  If you forget a semicolon, the PHP will fail to parse!&lt;br /&gt;
&lt;br /&gt;
=== Strings ===&lt;br /&gt;
&lt;br /&gt;
Strings in PHP can be either single-quoted or double-quoted.  Single-quoted strings are always taken literally; double-quoted strings allow for additional elements.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$a = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
$b = &amp;quot;Banana&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$fruits_double = &amp;quot;$a\n$b&amp;quot;;   # $fruits_double now contains the string Apple (line break) Banana&lt;br /&gt;
$fruits_single = '$a\n$b';   # $fruits_single now contains the string $a\n$b&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to use special characters in a double-quoted strings, escape them using the backslash operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$a = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
$b = &amp;quot;Banana&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$fruits = &amp;quot;\$a\\n$b&amp;quot;;   # $fruits now contains the string $a\nBanana&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can concatenate multiple strings together using the concatenation operator, which in php is a period:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$c = &amp;quot;Cherry&amp;quot;;&lt;br /&gt;
$g = &amp;quot;Grapefruit&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$fruits = $c.&amp;quot;\n&amp;quot;.$g;   # $fruits contains the string Cherry (line break) Grapefruit&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
Declaring arrays is very simple in PHP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$fruits = array(&amp;quot;Apple&amp;quot;, &amp;quot;Banana&amp;quot;, &amp;quot;Cherry&amp;quot;, &amp;quot;Grapefruit&amp;quot;);   # $arr now contains an array with 4 items&lt;br /&gt;
&lt;br /&gt;
echo $fruits[1];   # displays Banana&lt;br /&gt;
&lt;br /&gt;
echo count($fruits);   # displays 4&lt;br /&gt;
&lt;br /&gt;
array_shift($fruits);   # remove the first element of the array&lt;br /&gt;
&lt;br /&gt;
echo $fruits[1];   # displays Cherry&lt;br /&gt;
&lt;br /&gt;
echo count($fruits);   # displays 3&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: '''echo''' outputs a string to the browser.  We will see more ways to output data [[#Outputting Data|later in this guide]].&lt;br /&gt;
&lt;br /&gt;
PHP also supports ''associative arrays''.  Associative arrays are arrays whose keys are strings rather than numbers; in some languages, they are called Dictionaries.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$fruits[&amp;quot;a&amp;quot;] = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
$fruits[&amp;quot;b&amp;quot;] = &amp;quot;Banana&amp;quot;;&lt;br /&gt;
$fruits[&amp;quot;c&amp;quot;] = &amp;quot;Cherry&amp;quot;;&lt;br /&gt;
$fruits[&amp;quot;g&amp;quot;] = &amp;quot;Grapefruit&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
echo $fruits[&amp;quot;b&amp;quot;];   # displays Cherry&lt;br /&gt;
&lt;br /&gt;
$keys = array_keys($fruits);   # get an array containing indexed values of the fruits' keys&lt;br /&gt;
&lt;br /&gt;
echo $keys[3];   # displays g&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conditional Statements ===&lt;br /&gt;
&lt;br /&gt;
Conditional statements work similarly to how they do in other languages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$grade = 85;&lt;br /&gt;
&lt;br /&gt;
if ($grade &amp;lt; 60) {&lt;br /&gt;
	echo &amp;quot;F&amp;quot;;&lt;br /&gt;
} elseif ($grade &amp;lt; 70) {&lt;br /&gt;
	echo &amp;quot;D&amp;quot;;&lt;br /&gt;
} elseif ($grade &amp;lt; 80) {&lt;br /&gt;
	echo &amp;quot;C&amp;quot;;&lt;br /&gt;
} elseif ($grade &amp;lt; 90) {&lt;br /&gt;
	echo &amp;quot;B&amp;quot;;&lt;br /&gt;
} else {&lt;br /&gt;
	echo &amp;quot;A&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP also supports switch statements, which are convenient for simplifying long if/elseid/else blocks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$food = &amp;quot;Apple&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
switch ($food) {&lt;br /&gt;
&lt;br /&gt;
case &amp;quot;Apple&amp;quot;:&lt;br /&gt;
case &amp;quot;Banana&amp;quot;:&lt;br /&gt;
case &amp;quot;Cherry&amp;quot;:&lt;br /&gt;
case &amp;quot;Grapefruit&amp;quot;:&lt;br /&gt;
	echo &amp;quot;You must like fruit!&amp;quot;;&lt;br /&gt;
	break;&lt;br /&gt;
case &amp;quot;Broccoli&amp;quot;:&lt;br /&gt;
case &amp;quot;Spinach&amp;quot;:&lt;br /&gt;
	echo &amp;quot;You must like vegetables!&amp;quot;;&lt;br /&gt;
	break;&lt;br /&gt;
default:&lt;br /&gt;
	echo &amp;quot;You don't like fruits or vegetables!&amp;quot;;&lt;br /&gt;
	break;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Loops ===&lt;br /&gt;
&lt;br /&gt;
PHP supports several different kinds of loops, including while, for, and foreach:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
$mystring = &amp;quot;&amp;quot;;&lt;br /&gt;
$i = 0;&lt;br /&gt;
while ($i &amp;lt; 5) {&lt;br /&gt;
	$mystring .= &amp;quot;Blah&amp;quot;;&lt;br /&gt;
	$i++;&lt;br /&gt;
}&lt;br /&gt;
echo $mystring;   # displays BlahBlahBlahBlahBlah&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$myarray = array(&amp;quot;Apple&amp;quot;, &amp;quot;Banana&amp;quot;, &amp;quot;Cherry&amp;quot;, &amp;quot;Grapefruit&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
# The following two loops are functionally equivalent.&lt;br /&gt;
&lt;br /&gt;
$mystring = &amp;quot;&amp;quot;;&lt;br /&gt;
for($i=0; $i&amp;lt;count($myarray); $i++){&lt;br /&gt;
	$mystring .= $i.&amp;quot;: &amp;quot;.$myarray[$i].&amp;quot;, &amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
echo $mystring;   # displays 0: Apple, 1: Banana, 2: Cherry, 3: Grapefruit&lt;br /&gt;
&lt;br /&gt;
$mystring = &amp;quot;&amp;quot;;&lt;br /&gt;
foreach($myarray as $key =&amp;gt; $value){&lt;br /&gt;
	$mystring .= $key.&amp;quot;: &amp;quot;.$value;&lt;br /&gt;
}&lt;br /&gt;
echo $mystring;   #displays 0: Apple, 1: Banana, 2: Cherry, 3: Grapefruit&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Functions ===&lt;br /&gt;
&lt;br /&gt;
Just like with all modern programming languages, you can define your own functions with PHP.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function add($x, $y){&lt;br /&gt;
	return $x + $y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
echo add(3, 5);   # displays 8&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A neat shortcut for PHP is that you can specify default parameter values directly in the argument list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function sayHello($name=&amp;quot;John Doe&amp;quot;){&lt;br /&gt;
	return &amp;quot;Hello, $name... how do you do?&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
echo sayHello(&amp;quot;Todd&amp;quot;);   # displays Hello, Todd... how do you do?&lt;br /&gt;
echo sayHello();   # displays Hello, John Doe... how do you do?&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Object-Oriented Programming ===&lt;br /&gt;
&lt;br /&gt;
PHP5 supports object-oriented programming, and many new libraries come as classes rather than simple functions.  Here is an example class definition:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
class Food {&lt;br /&gt;
	protected $name;&lt;br /&gt;
	&lt;br /&gt;
	function __construct($name){&lt;br /&gt;
		$this-&amp;gt;name = $name;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	static function getDefinition(){&lt;br /&gt;
		return &amp;quot;Food is nourishment for carbon-based lifeforms.&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	function formatName(){&lt;br /&gt;
		return &amp;quot;Gotta love to eat &amp;quot; . $this-&amp;gt;name;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class Fruit extends Food {&lt;br /&gt;
	function formatName(){&lt;br /&gt;
		return Food::formatName() . &amp;quot; (fruit)&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$fruit = new Fruit(&amp;quot;Cherry&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
echo $fruit-&amp;gt;formatName() . &amp;quot;\n&amp;quot;;   # displays: Gotta love to eat Cherry (fruit)&lt;br /&gt;
&lt;br /&gt;
echo Fruit::getDefinition() . &amp;quot;\n&amp;quot;;   # displays: Food is nourishment for carbon-based lifeforms.&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Things to notice:&lt;br /&gt;
&lt;br /&gt;
* All methods in a class must be preceded by the function keyword.&lt;br /&gt;
* Static methods require the '''static''' keyword&lt;br /&gt;
* Instance methods can refer to the current instance through the implicit variable '''$this'''&lt;br /&gt;
* To access properties and methods from an instance, use an arrow: '''$instance-&amp;gt;property'''&lt;br /&gt;
* To access static properties and methods from a class, use two colons: '''ClassName::StaticPropertyOrMethod'''&lt;br /&gt;
* Instances of classes are defined using the syntax '''$instance = new ClassName();''' like in Java&lt;br /&gt;
&lt;br /&gt;
== Outputting Data ==&lt;br /&gt;
&lt;br /&gt;
What's the point of a web language if we can't output data?  The most basic method for outputting data is using either the '''echo''' or '''print''' statement:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo &amp;quot;Hello World&amp;quot;;   # outputs Hello World to the browser&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You often find yourself wanting to print all information associated with a variable for debugging purposes.  PHP provides the handy '''var_dump''' function for that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
var_dump($myvar);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Content Type ===&lt;br /&gt;
&lt;br /&gt;
PHP is just a factory for generating documents.  We've so far seen it create HTML documents, but it can just as easily create images, PDFs, or any other type of interpreted file format.  Each of these files formats has a '''MIME Type''' associated with it.  To specify a MIME type for a page served over HTTP, the &amp;lt;code&amp;gt;Content-Type&amp;lt;/code&amp;gt; header must be set.&lt;br /&gt;
&lt;br /&gt;
This brings up an important point.  '''Every PHP document has an implicit &amp;lt;code&amp;gt;Content-Type: text/html&amp;lt;/code&amp;gt; header.'''  This means that by default, PHP will generate HTML documents.  '''The MIME type for a document can be changed using the header() function:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
header(&amp;quot;Content-Type: text/plain&amp;quot;);&lt;br /&gt;
echo time();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example creates a plain text file containing the current timestamp (number of seconds since January 1, 1970).&lt;br /&gt;
&lt;br /&gt;
For another application of the Content-Type header, see [[#Sending a File to the Browser]]&lt;br /&gt;
&lt;br /&gt;
=== sprintf() ===&lt;br /&gt;
&lt;br /&gt;
Code in PHP that outputs information can get very ugly.  Consider, for example, the following snippet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$medals = array(&lt;br /&gt;
	&amp;quot;United States&amp;quot; =&amp;gt; array(46, 29, 29),&lt;br /&gt;
	&amp;quot;China&amp;quot; =&amp;gt; array(38, 27, 23),&lt;br /&gt;
	&amp;quot;Russia&amp;quot; =&amp;gt; array(24, 26, 32)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Gold Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Silver Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Bronze Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
foreach($medals as $country =&amp;gt; $counts){&lt;br /&gt;
	echo &amp;quot;\t&amp;lt;tr&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($country).&amp;quot;&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($counts[0]).&amp;quot;&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($counts[1]).&amp;quot;&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;&amp;quot;.htmlentities($counts[2]).&amp;quot;&amp;lt;/td&amp;gt;\n\t&amp;lt;/tr&amp;gt;\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will generate the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Gold Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Silver Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Bronze Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;United States&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;46&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;29&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;29&amp;lt;/td&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;China&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;38&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;27&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;23&amp;lt;/td&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;Russia&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;24&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;26&amp;lt;/td&amp;gt;&lt;br /&gt;
		&amp;lt;td&amp;gt;32&amp;lt;/td&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It's not very clear, though, that this is what the PHP code is going to generate.  In particular, the ''echo'' line inside the ''foreach'' loop is 196 jumbled characters!&lt;br /&gt;
&lt;br /&gt;
'''sprintf()''' is a nifty PHP function (with roots in C) that allows us to clean up that code.  We get the same output as above if we use the following PHP instead:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$medals = array(&lt;br /&gt;
	&amp;quot;United States&amp;quot; =&amp;gt; array(46, 29, 29),&lt;br /&gt;
	&amp;quot;China&amp;quot; =&amp;gt; array(38, 27, 23),&lt;br /&gt;
	&amp;quot;Russia&amp;quot; =&amp;gt; array(24, 26, 32)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
	&amp;lt;tr&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Gold Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Silver Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
		&amp;lt;th&amp;gt;Bronze Medals&amp;lt;/th&amp;gt;&lt;br /&gt;
	&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
foreach($medals as $country =&amp;gt; $counts){&lt;br /&gt;
	echo sprintf(&amp;quot;\t&amp;lt;tr&amp;gt;\n\t\t&amp;lt;td&amp;gt;%s&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;%d&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;%d&amp;lt;/td&amp;gt;\n\t\t&amp;lt;td&amp;gt;%d&amp;lt;/td&amp;gt;\n\t&amp;lt;/tr&amp;gt;\n&amp;quot;,&lt;br /&gt;
		htmlentities($country),&lt;br /&gt;
		$counts[0],&lt;br /&gt;
		$counts[1],&lt;br /&gt;
		$counts[2]&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code is more straightforward and self-explanatory than the first example, and it is also easier to edit and maintain.&lt;br /&gt;
&lt;br /&gt;
Here's how '''sprintf()''' works.  The first argument is a ''format string''.  A format string can contain ''conversion specifications'' for additional data that will be inserted into the format string.  The most common conversion specifications are:&lt;br /&gt;
&lt;br /&gt;
* '''%s''' for a string&lt;br /&gt;
* '''%d''' for a signed integer&lt;br /&gt;
* '''%u''' for an unsigned integer&lt;br /&gt;
* '''%f''' for a floating-point number&lt;br /&gt;
** '''%.2f''' for a floating-point number with 2 decimal places&lt;br /&gt;
* '''%%''' for a literal percentage sign&lt;br /&gt;
&lt;br /&gt;
For more detail on sprintf formats, refer to [http://us.php.net/sprintf the PHP documentation].&lt;br /&gt;
&lt;br /&gt;
The remaining arguments are the data that are inserted into each of the conversion specifications.  In the example above, there are four conversion specifications ('''%s''', '''%d''', '''%d''', and '''%d'''), so '''sprintf()''' takes 4 additional arguments after the format string.&lt;br /&gt;
&lt;br /&gt;
Note that we still need to sanitize string output (using '''htmlentities()''' ) when we are using '''sprintf()'''.  However, since our format string specifies integers for the remaining three arguments, '''sprintf()''' will take care of type casting, so we no longer need to worry about sanitizing the integers.&lt;br /&gt;
&lt;br /&gt;
An additional tip: '''printf()''' is a shortcut for '''echo sprintf()'''.  That is, the following lines are functionally equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$n = 12345.678;&lt;br /&gt;
printf(&amp;quot;%.2f\n&amp;quot;, $n); // prints 12345.68&lt;br /&gt;
echo sprintf(&amp;quot;%.2f\n&amp;quot;, $n); // also prints 12345.68&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Passing Variables ==&lt;br /&gt;
&lt;br /&gt;
Input values can be passed to a script either through the URL request line or through data submitted by a form. Built in arrays $_GET['var'] and $_POST['var'] return the value of ''var'' depending on the access method. As we will see in the next section, values can also be passed through session variables. Finally, you can use cookies to store and retrieve values. &lt;br /&gt;
&lt;br /&gt;
Note that upon submitting a form, the page specified in the form tag's action attribute is loaded (with variables sent via post or get).&lt;br /&gt;
&lt;br /&gt;
=== GET: Passing Variables via URL ===&lt;br /&gt;
&lt;br /&gt;
If you want to pass values in a URL, the format is &amp;lt;nowiki&amp;gt;''http://example.com/yourphpfile.php?var1=value1&amp;amp;var2=value2.....''&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PHP saves URL variables in the associative array '''$_GET'''.&lt;br /&gt;
&lt;br /&gt;
For example, the following PHP document would print a hello message according to a name given in the URL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Hello World&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$name = $_GET['name'];&lt;br /&gt;
&lt;br /&gt;
printf(&amp;quot;&amp;lt;p&amp;gt;Hello, %s; how do you do?&amp;lt;/p&amp;gt;\n&amp;quot;,&lt;br /&gt;
	htmlentities($name)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you access the URL like this: ''greeting.php?name=Alice'', it will show ''Hello, Alice; how do you do?''&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Before we output the name, we pass it through '''htmlentities()''', which sanitizes it for output to the HTML document.  This is necessary because if we displayed the name verbatim from the URL, the name could be ''anything'': that includes malicious code that could be run on a victim's computer!  You will learn more about this type of cyberattack, called '''Cross-Site Scripting''', in Module 4.  For now, just know that whenever you display anything to the end user, you need to pass it through '''htmlentities()'''.&lt;br /&gt;
&lt;br /&gt;
=== POST: Passing Variables via Form ===&lt;br /&gt;
&lt;br /&gt;
Another method for passing variables from page to page is by sending it via POST variables.  Like with GET, POST variables are saved in an associative array, this time named '''$_POST'''.&lt;br /&gt;
&lt;br /&gt;
Consider the following form:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Hello World&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;info.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;firstnameinput&amp;quot;&amp;gt;First Name:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;firstname&amp;quot; id=&amp;quot;firstnameinput&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;lastnameinput&amp;quot;&amp;gt;Last Name:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;lastname&amp;quot; id=&amp;quot;lastnameinput&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;birthyearinput&amp;quot;&amp;gt;Birth Year:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;number&amp;quot; name=&amp;quot;birthyear&amp;quot; id=&amp;quot;birthyearinput&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;strong&amp;gt;Gender:&amp;lt;/strong&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;male&amp;quot; id=&amp;quot;maleinput&amp;quot; /&amp;gt; &amp;lt;label for=&amp;quot;maleinput&amp;quot;&amp;gt;Male&amp;lt;/label&amp;gt; &amp;amp;nbsp;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;female&amp;quot; id=&amp;quot;femaleinput&amp;quot; /&amp;gt; &amp;lt;label for=&amp;quot;femaleinput&amp;quot;&amp;gt;Female&amp;lt;/label&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Send&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;reset&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information on the HTML markup in the above example, refer to [[HTML and CSS|the HTML and CSS guide]].&lt;br /&gt;
&lt;br /&gt;
This submits a form with POST data to '''info.php'''.  Inside '''info.php''', the provided values will be available in the associative $_POST array under the keys ''firstname'', ''lastname'', ''birthyear'', and ''gender''.&lt;br /&gt;
&lt;br /&gt;
To display the submitted input on a target page, '''info.php''' could contain:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Person Information&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$first = $_POST['firstname'];&lt;br /&gt;
$last = $_POST['lastname'];&lt;br /&gt;
$birthyear = (int) $_POST['birthyear'];&lt;br /&gt;
$gender = $_POST['gender'];&lt;br /&gt;
$age = 2012 - $birthyear;&lt;br /&gt;
&lt;br /&gt;
printf(&amp;quot;&amp;lt;p&amp;gt;Hello, %s %s!  You were born in %d, so you are %d years old.  You are %s.&amp;lt;/p&amp;gt;\n&amp;quot;,&lt;br /&gt;
	htmlentities($first),&lt;br /&gt;
	htmlentities($last),&lt;br /&gt;
	$birthyear,&lt;br /&gt;
	$age,&lt;br /&gt;
	htmlentities($gender)&lt;br /&gt;
);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' It is ''very'' important that you always sanitize strings that you output to the browser using '''htmlentities()''' or a similar function.  If you don't, your site will be vulnerable to all sorts of malware.  For more information, refer to the [[Web Application Security, Part 1|Web Application Security]] guide.&lt;br /&gt;
&lt;br /&gt;
For further help with using HTML forms with PHP, we recommend [http://www.tizag.com/phpT/forms.php this tutorial].&lt;br /&gt;
&lt;br /&gt;
=== Self-Submitting Forms ===&lt;br /&gt;
&lt;br /&gt;
Oftentimes we don't want to pass form values to a different page, but rather to the same page as contains the form so that we can process the information and display output on that same page.  To do this, you can simply omit the '''action''' parameter from the form.  Alternatively, you can use a PHP environment variable like $_SERVER['PHP_SELF'].&lt;br /&gt;
&lt;br /&gt;
The following example simply takes the data input from a form and, via POST variables, echoes it back to the user as bold text on the same page:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Bold Printer&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&amp;gt;&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;name&amp;quot;&amp;gt;Name:&amp;lt;/label&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;name&amp;quot; id=&amp;quot;name&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Print in Bold&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
if(isset($_POST['name'])){&lt;br /&gt;
	printf(&amp;quot;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;%s&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;\n&amp;quot;,&lt;br /&gt;
		htmlentities($_POST['name'])&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sessions ==&lt;br /&gt;
&lt;br /&gt;
If you need to keep track of information associated with a user between page loads, you should use a ''session''.  Sessions are excellent for keeping track of the currently-logged-in user, for example.&lt;br /&gt;
&lt;br /&gt;
PHP makes session management dirt simple.  Whenever you need to use session variables, simply call '''session_start()'''.  Then, you may interact with the $_SESSION associative array, and PHP will take care of accessing and saving all session variables for you!&lt;br /&gt;
&lt;br /&gt;
For example, the following page will display a number, and then double that number on each page reload:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
 &lt;br /&gt;
$oldnum = (int) @$_SESSION['inc_num'];&lt;br /&gt;
if($oldnum&amp;lt;1) $oldnum=1;&lt;br /&gt;
$newnum = $oldnum*2;&lt;br /&gt;
 &lt;br /&gt;
echo $newnum;&lt;br /&gt;
$_SESSION['inc_num'] = $newnum;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sessions also work across different pages, as long as they are on the same web server.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' To log out a user, you can call '''session_destroy()''' after '''session_start()''' on the logout page.&lt;br /&gt;
&lt;br /&gt;
== Other PHP Tips ==&lt;br /&gt;
&lt;br /&gt;
=== Redirecting to a Different Page ===&lt;br /&gt;
&lt;br /&gt;
If you want to redirect the user to a different page, you need to send a '''Location''' header.  For example, a page containing only this code would redirect the user to the ''login.php'' file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
header(&amp;quot;Location: login.php&amp;quot;);&lt;br /&gt;
exit;   // we call exit here so that the script will stop executing before the connection is broken&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is often useful to perform redirects after you perform server-side operations.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' You should generally not leave a user sitting on a page that has POST data, because if they refresh the page, their POST data will be submitted again, causing your server to perform an action twice.  Rather, you should perform the operation, and then redirect them to another page that does not contain POST data in the header.&lt;br /&gt;
&lt;br /&gt;
=== Reading a File Line-by-Line ===&lt;br /&gt;
&lt;br /&gt;
If you want to read a file line-by-line, open a file handler using '''fopen()''', use '''fgets()''' to read lines until you've reached the end, and then close the file using '''fclose()'''.&lt;br /&gt;
&lt;br /&gt;
The following example reads '''file_with_lines.txt''' and outputs its content in an unordered list, where each list item is a line in the file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$h = fopen(&amp;quot;file_with_lines.txt&amp;quot;, &amp;quot;r&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
$linenum = 1;&lt;br /&gt;
echo &amp;quot;&amp;lt;ul&amp;gt;\n&amp;quot;;&lt;br /&gt;
while( !feof($h) ){&lt;br /&gt;
	printf(&amp;quot;\t&amp;lt;li&amp;gt;Line %d: %s&amp;lt;/li&amp;gt;\n&amp;quot;,&lt;br /&gt;
		$linenum++,&lt;br /&gt;
		fgets($h)&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
echo &amp;quot;&amp;lt;/ul&amp;gt;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
fclose($h);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Most files in Linux end with an empty line, so the very last iteration of the above loop will output an empty bullet point.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The function '''fgets()''' reads the contents of a line ''in addition to the line feed at the end of the line''.  If you want to compare a string to the line that was read by '''fgets()''', you need to pass the value returned by '''fgets()''' to a function like '''[http://php.net/trim trim()]'''.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you want to read an entire file, PHP provides the '''file_get_contents()''' function, which is basically a shortcut for '''fopen()''', '''fread()''', and '''fclose()'''.  ('''fread()''' is similar to '''fgets()''', except it reads the entire file instead of just one line.)&lt;br /&gt;
&lt;br /&gt;
=== Sending a File to the Browser ===&lt;br /&gt;
&lt;br /&gt;
Another useful function to know is the '''readfile''' function. It takes a file on the webserver's file system and sends it to the web browser. A simple example is given below, but note that you'll probably need to specify addition header fields in order to have the web browser download the file correctly.&lt;br /&gt;
&lt;br /&gt;
The following example loads a file associated with a certain username and displays it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
&lt;br /&gt;
$filename = $_GET['file'];&lt;br /&gt;
&lt;br /&gt;
// We need to make sure that the filename is in a valid format; if it's not, display an error and leave the script.&lt;br /&gt;
// To perform the check, we will use a regular expression.&lt;br /&gt;
if( !preg_match('/^[\w_\.\-]+$/', $filename) ){&lt;br /&gt;
	echo &amp;quot;Invalid filename&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Get the username and make sure that it is alphanumeric with limited other characters.&lt;br /&gt;
// You shouldn't allow usernames with unusual characters anyway, but it's always best to perform a sanity check&lt;br /&gt;
// since we will be concatenating the string to load files from the filesystem.&lt;br /&gt;
$username = $_SESSION['username'];&lt;br /&gt;
if( !preg_match('/^[\w_\-]+$/', $username) ){&lt;br /&gt;
	echo &amp;quot;Invalid username&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$full_path = sprintf(&amp;quot;/srv/uploads/%s/%s&amp;quot;, $username, $filename);&lt;br /&gt;
&lt;br /&gt;
// Now we need to get the MIME type (e.g., image/jpeg).  PHP provides a neat little interface to do this called finfo.&lt;br /&gt;
$finfo = new finfo(FILEINFO_MIME_TYPE);&lt;br /&gt;
$mime = $finfo-&amp;gt;file($full_path);&lt;br /&gt;
&lt;br /&gt;
// Finally, set the Content-Type header to the MIME type of the file, and display the file.&lt;br /&gt;
header(&amp;quot;Content-Type: &amp;quot;.$mime);&lt;br /&gt;
readfile($full_path);&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Uploading a File ===&lt;br /&gt;
&lt;br /&gt;
Uploading files is similar to submitting data in forms.  For starters, you need a form that submits to your uploading script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form enctype=&amp;quot;multipart/form-data&amp;quot; action=&amp;quot;uploader.php&amp;quot; method=&amp;quot;POST&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;MAX_FILE_SIZE&amp;quot; value=&amp;quot;20000000&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;label for=&amp;quot;uploadfile_input&amp;quot;&amp;gt;Choose a file to upload:&amp;lt;/label&amp;gt; &amp;lt;input name=&amp;quot;uploadedfile&amp;quot; type=&amp;quot;file&amp;quot; id=&amp;quot;uploadfile_input&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
	&amp;lt;p&amp;gt;&lt;br /&gt;
		&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Upload File&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that we need to specify &amp;lt;code&amp;gt;enctype=&amp;quot;multipart/form-data&amp;quot;&amp;lt;/code&amp;gt; on the form.  This is to enable files to be uploaded and recognized by PHP.&lt;br /&gt;
&lt;br /&gt;
PHP puts all files submitted with a form into the '''$_FILES''' superglobal array.  Each entry in the $_FILES array contains the following information:&lt;br /&gt;
&lt;br /&gt;
* '''$_FILES['uploadedfile']['name']''' is the original name of the file on the client's machine&lt;br /&gt;
* '''$_FILES['uploadedfile']['type']''' is the MIME type of the file according to the browser (don't take it for granted)&lt;br /&gt;
* '''$_FILES['uploadedfile']['size']''' is the size, in bytes, of the uploaded file&lt;br /&gt;
* '''$_FILES['uploadedfile']['tmp_name']''' is the temporary location on your filesystem where Apache saved the uploaded file&lt;br /&gt;
* '''$_FILES['uploadedfile']['error']''' is the error code associated with the file upload (if applicable)&lt;br /&gt;
&lt;br /&gt;
To upload the file submitted by the form above in a user's special folder, we could use the following PHP code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
session_start();&lt;br /&gt;
&lt;br /&gt;
// Get the filename and make sure it is valid&lt;br /&gt;
$filename = basename($_FILES['uploadedfile']['name']);&lt;br /&gt;
if( !preg_match('/^[\w_\.\-]+$/', $filename) ){&lt;br /&gt;
	echo &amp;quot;Invalid filename&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Get the username and make sure it is valid&lt;br /&gt;
$username = $_SESSION['username'];&lt;br /&gt;
if( !preg_match('/^[\w_\-]+$/', $username) ){&lt;br /&gt;
	echo &amp;quot;Invalid username&amp;quot;;&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$full_path = sprintf(&amp;quot;/srv/uploads/%s/%s&amp;quot;, $username, $filename);&lt;br /&gt;
&lt;br /&gt;
if( move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $full_path) ){&lt;br /&gt;
	header(&amp;quot;Location: upload_success.html&amp;quot;);&lt;br /&gt;
	exit;&lt;br /&gt;
}else{&lt;br /&gt;
	header(&amp;quot;Location: upload_failure.html&amp;quot;);&lt;br /&gt;
	exit;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' A lot of the code above is the same as the code in the file download example.  In your project, you should save the logic of generating the file path (in a function) in a third file that you include into the upload and download scripts.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' By default, PHP will not allow a file upload of more than 2 MB.  SitePoint has an excellent tutorial for how to increase this limit: http://www.sitepoint.com/upload-large-files-in-php/&lt;br /&gt;
&lt;br /&gt;
== PEAR ==&lt;br /&gt;
&lt;br /&gt;
The PHP Extension and Application Repository, or '''PEAR''', is a package manager that enables you to install classes and/or extensions to PHP.  In other words, it is a yum/apt for PHP.  You can think of PEAR as PHP's analog of ''gem'' in Ruby or ''pip'' in Python.&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
PEAR is available through both the yum and apt repositories under the package name '''php-pear'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo apt-get install php-pear  # in Debian&lt;br /&gt;
$ sudo yum install php-pear  # in RHEL&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Installing PHP Extensions ===&lt;br /&gt;
&lt;br /&gt;
Using PEAR to install PHP extensions is just as easy as yum, apt, gem, and pip.  Just run '''sudo pear install xxx'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo pear install Archive_Tar&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go here for a list of available packages in PEAR: http://pear.php.net/packages.php&lt;br /&gt;
&lt;br /&gt;
=== Using PHP Extensions ===&lt;br /&gt;
&lt;br /&gt;
To make use an extension installed in PEAR, you must '''include''' or '''require''' it into the PHP file of interest.  For example, if you wanted to use the Archive_Tar class from the above example in a PHP file, you would do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require &amp;quot;Archive/Tar.php&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// your code here&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By convention, the filepath you need to specify is the name of the PEAR package with underscores replaced with slashes and a .php extension at the end.  For example, the package ''Console_Getargs'' becomes &amp;lt;code&amp;gt;require &amp;quot;Console/Getargs.php&amp;quot;;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PECL ===&lt;br /&gt;
&lt;br /&gt;
The PHP Extension Community Library, or '''PECL''', is a repository for additional PHP extensions, the difference being that PECL extensions are written in compiled C code rather than PHP.&lt;br /&gt;
&lt;br /&gt;
PECL is installed automatically when you install PEAR from yum or apt-get.&lt;br /&gt;
&lt;br /&gt;
Installing an extension using PECL is almost identical to PEAR, except that you use '''pecl''' instead of '''pear''' on the command prompt:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo pecl install imagick&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You do not need to '''require''' or '''include''' PECL extensions since they are already compiled into PHP.&lt;br /&gt;
&lt;br /&gt;
== PHP Reference ==&lt;br /&gt;
&lt;br /&gt;
If you ever have a question about PHP, first check the well-written documentation.  To skip immediately to the documentation on any function, simply visit &amp;lt;nowiki&amp;gt;http://php.net/&amp;lt;/nowiki&amp;gt;'''functionname'''.  For example: http://php.net/var_dump&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=2018</id>
		<title>CSE 330 Online Textbook - Table of Contents</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=2018"/>
		<updated>2015-09-01T05:29:36Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:CSE330Banner.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&amp;lt;div style=&amp;quot;column-width: 300px; -moz-column-width: 300px; -webkit-column-width: 300px;&amp;quot;&amp;gt;&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=1&lt;br /&gt;
|subject=HTML and CSS Fundamentals&lt;br /&gt;
|links=&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=2&lt;br /&gt;
|subject=Linux, Apache, and PHP&lt;br /&gt;
|links=&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=3&lt;br /&gt;
|subject=SQL Databases&lt;br /&gt;
|links=&lt;br /&gt;
* [[Introduction to MySQL]] (installation)&lt;br /&gt;
* [[MySQL Schema and State]] (queries)&lt;br /&gt;
* [[PHP and MySQL]] (using MySQL from PHP)&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=4&lt;br /&gt;
|subject=Scripting for Rapid Prototyping&lt;br /&gt;
|links=&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=5&lt;br /&gt;
|subject=JavaScript and APIs&lt;br /&gt;
|links=&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=6&lt;br /&gt;
|subject=Real-Time Web Applications&lt;br /&gt;
|links=&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=7&lt;br /&gt;
|subject=Angular JS&lt;br /&gt;
|links=&lt;br /&gt;
* [[Preparations]]&lt;br /&gt;
* [[Getting MEAN]]&lt;br /&gt;
* [[Git]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=8&lt;br /&gt;
|subject=Creative Project&lt;br /&gt;
|links=&lt;br /&gt;
* [[Choosing a Platform]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=9&lt;br /&gt;
|subject=Web Frameworks&lt;br /&gt;
|links=&lt;br /&gt;
* [[Web Frameworks]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
Use this wiki as a starting place for your projects in CSE 330.  However, web development is a large field, so it is impossible for us to document everything you might need to know.  Here are some other places you should look when you need to find something:&lt;br /&gt;
&lt;br /&gt;
* [http://www.webplatform.org/ WebPlatform.org], a community-driven source containing documentation and tutorials for Web technologies&lt;br /&gt;
* [http://reference.sitepoint.com/html SitePoint], which has a reference page as well as quality articles and tutorials&lt;br /&gt;
* Also take a look at [http://designfestival.com/13-time-saving-tools-for-web-designers/ this list of productivity tools] for web development.&lt;br /&gt;
&lt;br /&gt;
If you can't find what you need in any of these places, try using your favorite search engine.  '''Be wary of sites that come up on search engines.'''  Many HTML reference sites document bad practices and dated techniques.  If you're unsure whether a reference site you find is legitimate, ask a TA.&lt;br /&gt;
&lt;br /&gt;
== Want to Learn More? ==&lt;br /&gt;
&lt;br /&gt;
The limited amount of time in CSE 330 means that we can cover only a subset of the wide range of possible topics in the field of rapid prototyping and web development.  Indeed, the exact topics covered in CSE 330 change from year to year.&lt;br /&gt;
&lt;br /&gt;
Feel free to browse some of the topics that have previously been covered in CSE 330: [[:Category:Former Content|CSE 330 Former Content]]&lt;br /&gt;
&lt;br /&gt;
You should also consider following blogs like [http://www.sitepoint.com/ SitePoint] to keep up-to-date on the latest developments in the field of web development.&lt;br /&gt;
&lt;br /&gt;
== Content License ==&lt;br /&gt;
&lt;br /&gt;
The content of this wiki is copyright (c) 2013, Washington University in St. Louis, Department of Computer Science.  All rights reserved.&lt;br /&gt;
&lt;br /&gt;
=== Modified BSD License ===&lt;br /&gt;
&lt;br /&gt;
Redistribution and use in source and binary forms, with or without modification, by a Third Party who has not completed and is not in the process of completing CSE 330, of the code examples or concepts on this wiki, are permitted, provided that the following conditions are met:&lt;br /&gt;
&lt;br /&gt;
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.&lt;br /&gt;
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
* Neither the name of the Washington University School of Engineering and Applied Science nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.&lt;br /&gt;
&lt;br /&gt;
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS TO ALL PARTIES &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
&lt;br /&gt;
=== What it Means ===&lt;br /&gt;
&lt;br /&gt;
If you are a student in CSE 330, you may use the code from this wiki freely in your projects without the need for attribution.  If you are not a student in CSE 330, you may use the code from this wiki freely in your projects with attribution.  Either way, the code examples are provided &amp;quot;as is&amp;quot;, without any warranty, and Washington University holds no liability for problems arising from the use of the content in this wiki.&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Linux&amp;diff=2017</id>
		<title>Linux</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Linux&amp;diff=2017"/>
		<updated>2015-09-01T04:55:33Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Linux Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[wikipedia:Linux|Linux]] is an [[wikipedia:Free and open-source software|open-source]] operating system based on [[wikipedia:UNIX|UNIX]].  Linux is highly versatile and is used in a wide range of applications.  [[wikipedia:Desktop Linux|Desktop Linux]] is Linux with a GUI (like Microsoft Windows or Mac OS X); Desktop Linux is popular in niche markets, and it is used widely in developing countries.&lt;br /&gt;
&lt;br /&gt;
Linux is the most widely used operating system for web servers.  In CSE330, we will be interacting with Linux from the command line.  This article covers the tools you need to make the best use of Linux.&lt;br /&gt;
&lt;br /&gt;
== Linux Distributions ==&lt;br /&gt;
&lt;br /&gt;
The open-source community is responsible for the development of many different [[wikipedia:Linux distributions|distributions]] of Linux.  Distributions, or ''distros'', are different &amp;quot;flavors&amp;quot; of the Linux operating system with different objectives.&lt;br /&gt;
&lt;br /&gt;
There are hundreds of distributions of Linux.  Three of the main banches are [[wikipedia:Debian|Debian]], [[wikipedia:SuSE|SuSE]] (based on [[wikipedia:Slackware|Slackware]]), and [[wikipedia:Red Hat Enterprise Linux|Red Hat Enterprise Linux (RHEL)]].&lt;br /&gt;
&lt;br /&gt;
The sections below discuss two of these branches and give recommendations of Linux distributions suitable for a web server.  The CSE330 wiki provides instructions for both Debian-based and RHEL-based Linux distributions, so the choice of which to use is up to you.&lt;br /&gt;
&lt;br /&gt;
=== Debian ===&lt;br /&gt;
&lt;br /&gt;
'''Debian''' was first introduced in 1993.  Debian has a passionate following, and its repositories contain more software packages than any other mainstream Linux distribution.  There are hundreds of derivatives of Debian.  Debian's most popular desktop derivative is '''[[wikipedia:Ubuntu|Ubuntu]]'''.&lt;br /&gt;
&lt;br /&gt;
Base Debian has a slow upgrade schedule, and because of this, it is an extremely stable operating system, making it well-suited for servers.  '''[[wikipedia:Ubuntu Server|Ubuntu Server]]''' is also an excellent choice for a Debian-based web server.&lt;br /&gt;
&lt;br /&gt;
=== Red Hat Enterprise Linux (RHEL) ===&lt;br /&gt;
&lt;br /&gt;
Red Hat Enterprise Linux, or '''RHEL''', was first introduced in 1994.  RHEL is known for being a good choice for enterprises that wish to use Linux as their primary OS.  RHEL has an abundance of administration tools.&lt;br /&gt;
&lt;br /&gt;
The Linux Lab in Lopata Hall uses '''[[wikipedia:Fedora Linux|Fedora Linux]]''', a desktop distribution based on RHEL.  '''[[wikipedia:CentOS|CentOS]]''' is a popular RHEL derivative that is widely used in web servers.  The '''[[wikipedia:Amazon Machine Image|Amazon EC2 Linux AMI]]''' is derived from CentOS, making it a distribution in the RHEL family.&lt;br /&gt;
&lt;br /&gt;
=== Special Note: Linux Kernel and Modules ===&lt;br /&gt;
{{XKCD&lt;br /&gt;
|id=619&lt;br /&gt;
|name=supported_features&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
What separates Linux from other Unix variants is its kernel. The kernel is the most important component of the operating system and is responsible for scheduling processes, providing access to the hardware devices, allocating memory to the programs, and so on.&lt;br /&gt;
&lt;br /&gt;
The Linux kernel uses both monolithic and modular approaches. A monolithic kernel is a single program that contains all the code so any addition to kernel (such as code to access a driver) requires recompiling the code. A monolithic kernel is usually a little faster and could have a smaller size since only the absolutely necessary code is there. The modular kernel, on the other hand, enables dynamic loading and unloading  of kernel code, called ''modules''. Typical modules include device drivers. Thanks to this modular approach, Linux seldom requires a reboot after installing a new device.&lt;br /&gt;
&lt;br /&gt;
== Bash ==&lt;br /&gt;
&lt;br /&gt;
In this course, you will be interacting with Linux primarily on the command line.  The most widespread ''command line language'' is '''Bash'''.  This is described in more detail in [[Bash|the Bash guide]].&lt;br /&gt;
&lt;br /&gt;
== Files and Permissions ==&lt;br /&gt;
&lt;br /&gt;
At the core of a Unix-based operating system is a directory structure with files and permissions.&lt;br /&gt;
&lt;br /&gt;
=== Filesystem Hierarchy ===&lt;br /&gt;
&lt;br /&gt;
The root directory of Linux contains a dozen or so subdirectories, each with a specific purpose:&lt;br /&gt;
&lt;br /&gt;
* '''/bin''' contains [[Bash#Running Programs|binaries]] used by all users&lt;br /&gt;
* '''/sbin''' contains system binaries typically used only by the system administrator&lt;br /&gt;
* '''/lib''' contains libraries for the binaries found in '''/bin''' and '''/sbin'''&lt;br /&gt;
* '''/etc''' contains configuration files&lt;br /&gt;
** '''/etc/yum.conf''' Configuration file for yum&lt;br /&gt;
** '''/etc/yum/yum.repos.d''' Directory containing .repo files for online repositories&lt;br /&gt;
** '''/etc/crontab''' System-wide crontab file&lt;br /&gt;
** '''/etc/fstab''' Information about default partitions to be mounted&lt;br /&gt;
** '''/etc/group''' List of groups in the system&lt;br /&gt;
** '''/etc/hosts''' List of IP addresses with their names&lt;br /&gt;
** '''/etc/inittab''' What to do at each run-level&lt;br /&gt;
** '''/etc/inetd.conf''' Configuration file for some internet services (replaced by xinetd.* in most systems)&lt;br /&gt;
** '''/etc/modules.conf''' Module information for the boot&lt;br /&gt;
** '''/etc/motd''' Message to be seen at the login prompt&lt;br /&gt;
** '''/etc/passwd''' User information&lt;br /&gt;
** '''/etc/profile''' System level initial file for sh and its derivatives&lt;br /&gt;
** '''/etc/shadow''' User passwords&lt;br /&gt;
* '''/dev''' contains device files&lt;br /&gt;
* '''/proc''' contains information on currently running processes&lt;br /&gt;
* '''/var''' contains files whose contents is expected to change&lt;br /&gt;
** '''/var/log''' contains system log files&lt;br /&gt;
*** '''/var/log/messages''' System/Kernel messages&lt;br /&gt;
*** '''/var/log/syslog''' System log (mostly for Daemons)&lt;br /&gt;
*** '''/var/log/wtmp'''' User access log (binary)&lt;br /&gt;
*** '''/var/log/dmesg''' Boot-up messages&lt;br /&gt;
*** '''/var/log/auth.log''' Authorization logs&lt;br /&gt;
** '''/var/lib''' contains packages and database files&lt;br /&gt;
** '''/var/spool''' contains print queues&lt;br /&gt;
* '''/tmp''' contains temporary files that are deleted at system reboot&lt;br /&gt;
* '''/usr''' contains user programs&lt;br /&gt;
** '''/usr/bin''' contains binaries for user programs&lt;br /&gt;
** '''/usr/sbin''' contains binaries for system administrators&lt;br /&gt;
** '''/usr/lib''' contains libraries for '''/usr/bin''' and '''/usr/sbin'''&lt;br /&gt;
** '''/usr/local''' contains programs that you install from source&lt;br /&gt;
* '''/home''' contains users' home directories&lt;br /&gt;
* '''/root''' is root's home directory&lt;br /&gt;
* '''/boot''' contains boot loader files (do not touch unless you know what you are doing!)&lt;br /&gt;
* '''/opt''' contains optional add-on applications&lt;br /&gt;
* '''/mnt''' is where system administrators can mount filesystems&lt;br /&gt;
* '''/media''' contains links to removable media devices (for example, CDs)&lt;br /&gt;
* '''/srv''' contains site-specific data which are served by the system&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information, see the Wikipedia article on the [[wikipedia:Filesystem Hierarchy Standard|Filesystem Hierarchy Standard]].&lt;br /&gt;
&lt;br /&gt;
=== File Permissions ===&lt;br /&gt;
&lt;br /&gt;
Every file in Linux has permissions that define which users can Read, Write, and Execute it.  Every file has an owner and a group.  The permissions for a file are set on three levels: User (owner), Group, and Other.&lt;br /&gt;
&lt;br /&gt;
==== Symbolic Notation ====&lt;br /&gt;
&lt;br /&gt;
When you view the permissions of a file in Linux, they will most often be displayed in ''symbolic notation''.  Symbolic notation consists of 10 characters: the first defines the file type, and then there are three characters each for User, Group, and Other permissions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;-r--r--r--&amp;lt;/code&amp;gt; is a normal file that is readable by all users but writable or executable by no one.&lt;br /&gt;
* &amp;lt;code&amp;gt;-rwxr-xr-x&amp;lt;/code&amp;gt; is a normal file that is readable and executable by everyone but only writable by User (the file's owner).  This is the most common permission set.&lt;br /&gt;
&lt;br /&gt;
==== Viewing File Permissions ====&lt;br /&gt;
&lt;br /&gt;
To view the permissions of all files in a certain directory, run the binary &amp;lt;code&amp;gt;ls -l&amp;lt;/code&amp;gt; in Bash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ls -l   # displays a list of all files in a directory with their permissions in symbolic notation&lt;br /&gt;
total 16&lt;br /&gt;
lrwxr-xr-x  1 sffc  wheel   6 Aug  9 09:13 link -&amp;gt; myfile.txt&lt;br /&gt;
-rwxr--r--  1 sffc  wheel  12 Aug  9 09:13 myfile.txt&lt;br /&gt;
$ ls -l myfile.txt   # displays the permissions of only myfile.txt&lt;br /&gt;
-rwxr--r--  1 sffc  wheel  12 Aug  9 09:13 myfile.txt&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setting File Permissions ====&lt;br /&gt;
&lt;br /&gt;
Linux comes with several useful binaries for setting file permissions.&lt;br /&gt;
&lt;br /&gt;
* '''chmod''' is used for setting permissions&lt;br /&gt;
* '''chown''' is used for setting a file's owner&lt;br /&gt;
* '''chgrp''' is used for setting a file's group&lt;br /&gt;
&lt;br /&gt;
Some examples are shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ chmod a+x myfile.txt   # turns on the Execute option for all users&lt;br /&gt;
$ chmod o-w myfile.txt   # turns off the Write option for Other users&lt;br /&gt;
$ chmod u+wx-r myfile.txt   # turns on the Write and Execute options for User (the file's owner) and also turns off the Read option for User&lt;br /&gt;
$ chown todd myfile.txt   # sets the owner of myfile.txt to the user todd.  Note: First comes the user, then comes the filename: not the other way around!&lt;br /&gt;
$ chgrp staff myfile.txt   # sets the group of myfile.txt to usergroup staff&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, see https://www.linux.com/learn/tutorials/760276-how-to-manage-file-and-folder-permissions-in-linux&lt;br /&gt;
&lt;br /&gt;
=== The . and .. Directories ===&lt;br /&gt;
&lt;br /&gt;
The '''.''' directory is a reference to the current directory.   The '''..''' directory brings you one level up in the filesystem.&lt;br /&gt;
&lt;br /&gt;
=== Symbolic Links ===&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Symbolic link|symbolic link]], or ''symlink'', is basically a link from one spot in the filesystem to another.  You can think of them like ''aliases'' in Mac OS X.  To create a a symlink, use the ''ln -s'' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ln -s /path/to/file.txt /path/to/link   # creates a symlink to file.txt at /path/to/link&lt;br /&gt;
&lt;br /&gt;
# Example:&lt;br /&gt;
$ ln -s /home/todd/instructions.doc /var/www/public_html/classes/instructions.doc   # creates a symlink in the web server to instructions.doc&lt;br /&gt;
$ vi /var/www/public_html/classes/instructions.doc   # changes to the symbolic link will be reflected in the original file&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== User Management ==&lt;br /&gt;
&lt;br /&gt;
=== Adding a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user, use the '''useradd''' command.  Then, set a password for that user using the '''passwd''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo useradd -r -m -c &amp;quot;My Full Name&amp;quot; myUserName&lt;br /&gt;
$ sudo passwd myUserName&lt;br /&gt;
Enter new UNIX password: &lt;br /&gt;
Retype new UNIX password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If Linux doesn't like your command, first check your syntax and then try it with single quotes around your full name and password instead of double quotes. If this works it is likely that you used some special characters in your password such as '!', which serves a special purpose in the shell. This is because Linux takes parameters enclosed in double quotes as one string, but still looks for special characters inside of the string and acts in accordance with their normal meaning. On the other hand, single quotes tell the shell to ignore any special characters within.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' If you are using Ubuntu Server, new users are created with /bin/sh as their default shell.  You want to use /bin/bash.  To change the shell for your user, run this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chsh -s /bin/bash myUserName   # changes shell for myUserName to /bin/bash&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding a User to the Sudoers List ===&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should never SSH into your server as the root user.  Instead, you should use a normal user to whom you give '''sudo''' privileges.  (For more detail on sudo, see [[Linux#SUDO|the Linux guide]].)&lt;br /&gt;
&lt;br /&gt;
To give a user sudo privileges, use the command '''visudo''', which opens up the SUDO configuration file in the system's default text editor.  (Never edit the file ''/etc/sudoers'' directly!)  SUDO users are specified using lines similar to&lt;br /&gt;
&lt;br /&gt;
 alice   ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
Add that line immediately below  the line defining '''root''':&lt;br /&gt;
&lt;br /&gt;
 root   ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
When you are finished, save and close the file.  For more information on editing files on the command line, refer to [[#File Editors|the section about File Editors in this guide]].&lt;br /&gt;
&lt;br /&gt;
In this case, '''alice''' will be able to run any command with SUDO privileges on the computer.   For more detail on SUDO configuration, see http://www.linuxhelp.net/guides/sudo/&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The visudo utility is especially useful because it not only locks the sudoers file against simultaneous edits, but it also checks the file for syntax errors when you quit. Therefore, it is always recommended that you use visudo to change the sudoers list rather than attempting to modify it directly.&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
In Linux, you can see your network information by typing '''ifconfig'''. This command shows the status information of each network interface, including the IP address you will need to remotely connect to your instance. The interface ''lo'' is the special loopback interface with IP address 127.0.0.1.  This refers to your local machine and any connection from your machine to your machine goes through this pseudo-interface.  Typical network interfaces include ''eth0'', ''eth1'',..., ''wlan0'', etc. Ethernet cards are represented with ''ethX''.  In the past, most wireless cards showed up as ''wlanX'', but it is also common now for them to be represented with ''ethX'' names. ''ifconfig'' also gives information such as hardware address (MAC), netmask, and broadcast addresses.&lt;br /&gt;
&lt;br /&gt;
You can start or stop networking by calling ''/etc/init.d/networking'' script. As with most ''/etc/init.d'' scripts, this script takes several options, such as ''start'', ''stop'', ''restart''.  Note even if you stop networking, you would still have your lo interface. You can look at the code of the script to find out what it actually does. You can also stop or start individual interfaces by using the '''ifup''' and '''ifdown''' commands.&lt;br /&gt;
&lt;br /&gt;
The network configuration files are stored in ''/etc/network''. ''/etc/network/interfaces'' contains the defaults for each interface. For xample, you could specify static IP, netmask, network, broadcast and default gateway for an interface here, but you should not need to edit this files in general.  These default options can be changed with the '''ifconfig''' command. The ''/etc/network/if-down.d'' and ''/etc/network/if-up.d'' directories contain the scripts that are going to be executed when an interface is turned on or off.  Of course, most modern Linux distributions have GUI tools for doing network configuration more easily, and you shouldn't need to change anything for the purposes of this course.&lt;br /&gt;
&lt;br /&gt;
== Synchronizing Date and Time ==&lt;br /&gt;
&lt;br /&gt;
In order to avoid setting your system's time manually at every daylight savings change, you can use a Network Time Server via the Network Time Protocol (NTP).&lt;br /&gt;
&lt;br /&gt;
The NTP Daemon comes pre-installed on EC2 AMI instances.  To install it on Debian, install the '''ntp''' package from apt.&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
=== Setting Timezone ===&lt;br /&gt;
&lt;br /&gt;
Your server is probably not set to the correct timezone by default.&lt;br /&gt;
&lt;br /&gt;
The timezone files are in the directory ''/usr/share/zoneinfo''. They are further organized within subdirectories grouped by region.  For instance, Rome's time zone file is stored within ''/usr/share/zoneinfo/Europe''.&lt;br /&gt;
&lt;br /&gt;
In order to set the time zone, simply copy the desired time zone file to our ''/etc'' directory as a new file named &amp;quot;localtime&amp;quot;.  For example, to set the the machine's system time to Rome's time zone, we would enter the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo cp /usr/share/zoneinfo/Europe/Rome /etc/localtime&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''ntp'' uses ''/etc/ntp.conf'' configuration file to find the ostnames of remote time servers.  The defaults here are probably fine.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installing Software ==&lt;br /&gt;
&lt;br /&gt;
The package management tool in Red Hat Enterprise Linux (and therefore also your Amazon EC2 instance) is '''rpm'''.  (In Debian, it is '''dpkg'''.)  If you have an ''rpm'' package, you can install it by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ rpm -i somepackage.rpm&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This requires that ''somepackage.rpm'' be in your current directory, which means you will have to download the file yourself (or create it). It requires you to manually install any dependencies the package has.&lt;br /&gt;
&lt;br /&gt;
=== Repository-Based Package Managers ===&lt;br /&gt;
&lt;br /&gt;
A better alternative is to use a repository-based package manager.  In RHEL, this is '''yum'''; in Debian, it is '''apt'''.&lt;br /&gt;
&lt;br /&gt;
Before you install new software, you need to ensure that your local list of available packages is up-to-date.  Run one of the following commands to perform this operation:&lt;br /&gt;
&lt;br /&gt;
* In RHEL: '''yum check-update'''&lt;br /&gt;
* In Debian: '''apt-get update'''&lt;br /&gt;
&lt;br /&gt;
After you have ensured that your package list is synced with the remote repository, you can start installing packages.  To install a package, use one of the following commands:&lt;br /&gt;
&lt;br /&gt;
* In RHEL: '''yum install package-name'''&lt;br /&gt;
* In Debian: '''apt-get install package-name'''&lt;br /&gt;
&lt;br /&gt;
If you get a permission denied error, try sudoing the command, like '''sudo apt-get install xxxx'''&lt;br /&gt;
&lt;br /&gt;
For example, this is how you would install ''lynx'', a command-line web browser, in your RHEL Linux distribution:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ lynx --version   # is lynx installed?&lt;br /&gt;
-bash: lynx: command not found&lt;br /&gt;
$ sudo yum check-update   # sync package lists with the remote repositories&lt;br /&gt;
$ sudo yum install lynx    # install the lynx package&lt;br /&gt;
Downloading Packages:&lt;br /&gt;
lynx-2.8.6-27.6.amzn1.i686.rpm        | 1.8 MB     00:00     &lt;br /&gt;
Running rpm_check_debug&lt;br /&gt;
Running Transaction Test&lt;br /&gt;
Transaction Test Succeeded&lt;br /&gt;
Running Transaction&lt;br /&gt;
  Installing : lynx-2.8.6-27.6.amzn1.i686             1/1 &lt;br /&gt;
&lt;br /&gt;
Installed:&lt;br /&gt;
  lynx.i686 0:2.8.6-27.6.amzn1                                                                                                                                                                                                                &lt;br /&gt;
&lt;br /&gt;
Complete!&lt;br /&gt;
$ lynx --version   # test again to see if we have lynx installed&lt;br /&gt;
Lynx Version 2.8.6rel.5 (09 May 2007)&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also search for available packages by name or by the name of a file that they install.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ yum search lynx   # search for packages whose name contains lynx&lt;br /&gt;
======= N/S Matched: lynx =======&lt;br /&gt;
lynx.i686 : A text-based Web browser&lt;br /&gt;
$ yum provides lynx   # search for packages that install a file or command named lynx&lt;br /&gt;
lynx-2.8.6-27.6.amzn1.i686 : A text-based Web browser&lt;br /&gt;
Repo        : installed&lt;br /&gt;
Matched from:&lt;br /&gt;
Other       : Provides-match: lynx&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The list of repositories that '''yum''' searches is located at &amp;lt;code&amp;gt;/etc/yum.conf&amp;lt;/code&amp;gt;.  The list of repositories that '''apt''' searches is located at &amp;lt;code&amp;gt;/etc/apt/sources.list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
=== Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
To save you some headaches later on, it is recommended that you install a few essential package bundles when you first create a new Linux instance.  These packages include things like Make and a C compiler.&lt;br /&gt;
&lt;br /&gt;
'''Debian:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo apt-get install build-essential&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RHEL:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo yum groupinstall &amp;quot;Development Tools&amp;quot;&lt;br /&gt;
$ sudo yum install kernel-devel kernel-headers&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Searching for Packages ===&lt;br /&gt;
&lt;br /&gt;
You can search for packages by name, command, and so on.  For example, to search for all packages relating to &amp;quot;lynx&amp;quot;, you could do:&lt;br /&gt;
&lt;br /&gt;
'''Debian:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ apt-cache search lynx&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RHEL:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ yum search lynx&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Command Reference ==&lt;br /&gt;
{{XKCD&lt;br /&gt;
|id=196&lt;br /&gt;
|name=command_line_fu&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Earlier, you saw that '''cat''' is a command that shows the contents of a file.  Below is a list of other useful commands in Linux.&lt;br /&gt;
&lt;br /&gt;
=== Navigation and File Management ===&lt;br /&gt;
&lt;br /&gt;
* '''ls''' List file(s) in current working directory&lt;br /&gt;
** '''ll''' Shortcut to '''ls -l'''.  List files with more details than '''ls'''.  Only available in certain distributions&lt;br /&gt;
* '''cd''' Change working directory.  Note: cd called without any arguments moves you to your home directory&lt;br /&gt;
* '''cp''' Copy a file&lt;br /&gt;
* '''mv''' Move or rename a file&lt;br /&gt;
* '''rm''' Remove a file&lt;br /&gt;
** '''rm -r''' Remove a directory and all files in it&lt;br /&gt;
* '''ln -s''' Create a symlink to a file&lt;br /&gt;
* '''mkdir''' Create a directory&lt;br /&gt;
* '''rmdir''' Remove a directory (directory must be empty; if it's not, use '''rm -r''')&lt;br /&gt;
* '''cat''' Display the contents of a file&lt;br /&gt;
* '''less''' Display the contents of a file, wait for the user at each page&lt;br /&gt;
* '''tail''' Display the last 20 lines of a file&lt;br /&gt;
** '''tail -f''' Display the last 20 lines of a file and then wait for changes, displaying them as they occur.  Useful for monitoring log files.&lt;br /&gt;
* '''chown''' Change the owner of a file&lt;br /&gt;
* '''chgrp''' Change the group of a file&lt;br /&gt;
* '''chmod''' Change the security permissions of a file&lt;br /&gt;
* '''grep''' Display the lines of a file matching a user specified string&lt;br /&gt;
* '''diff''' Display the difference between two files&lt;br /&gt;
&lt;br /&gt;
=== System Administration ===&lt;br /&gt;
&lt;br /&gt;
* '''df''' Display free diskspace&lt;br /&gt;
* '''du''' Display disk usage&lt;br /&gt;
* '''free''' Display memory usage information&lt;br /&gt;
* '''date''' Display current time and date&lt;br /&gt;
* '''top''' Display the CPU and Memory usages of current processes&lt;br /&gt;
* '''ps''' Display current processes&lt;br /&gt;
* '''kill''' Terminate a running process&lt;br /&gt;
* '''killall''' Terminate the running process matching user specified criterias&lt;br /&gt;
* '''ping hostname''' Ping a host&lt;br /&gt;
* '''host''' Get the IP address of a host&lt;br /&gt;
* '''passwd''' Change the user password&lt;br /&gt;
* '''su user''' Switch to the privileges of another user&lt;br /&gt;
* '''shutdown''' Power off the computer&lt;br /&gt;
* '''reboot''' Reboot the computer&lt;br /&gt;
* '''clear''' Clear the terminal&lt;br /&gt;
* '''ifconfig''' Display/Configure a network device&lt;br /&gt;
* '''file''' Show the file type&lt;br /&gt;
* '''lsmod''' Display loaded kernel modules&lt;br /&gt;
* '''insmod''' Install a kernel module&lt;br /&gt;
* '''modprobe''' Load a kernel module (also load the dependencies)&lt;br /&gt;
* '''adduser''' Add a new user&lt;br /&gt;
* '''exit''' Exit from a shell&lt;br /&gt;
* '''lpr''' Print a file&lt;br /&gt;
* '''head''' Display  lines at the beginning of a file&lt;br /&gt;
* '''tail''' Display lines at the end of a file&lt;br /&gt;
* '''pwd''' Display the name of the current working directory&lt;br /&gt;
* '''lsof''' Open files in the system&lt;br /&gt;
* '''netstat''' Statistics related to open sockets&lt;br /&gt;
&lt;br /&gt;
=== File Editors ===&lt;br /&gt;
{{XKCD&lt;br /&gt;
|name=real_programmers&lt;br /&gt;
|id=378&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
It is sometimes convenient to edit files using the command line.  Three widely-used command line text editors are '''vi''', '''emacs''', and '''nano'''.&lt;br /&gt;
&lt;br /&gt;
==== Vi ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using Vi, use the command '''vi'''.  You will see something like this:&lt;br /&gt;
&lt;br /&gt;
 .&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 &amp;quot;myfile.txt&amp;quot; [New File]&lt;br /&gt;
&lt;br /&gt;
To insert text into the file, press '''i''' once, then type away:&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 -- INSERT -- &lt;br /&gt;
&lt;br /&gt;
To leave insert mode, press ESC.&lt;br /&gt;
&lt;br /&gt;
To save your file, type the command ''':w''' and press Enter.&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 &amp;quot;myfile.txt&amp;quot; [New] 1L, 12C written&lt;br /&gt;
&lt;br /&gt;
To save and then close your file, type the command ''':wq'''.  (To close the file without saving, use the command ''':q!''')&lt;br /&gt;
&lt;br /&gt;
For more vi commands, see http://ss64.com/vi.html&lt;br /&gt;
&lt;br /&gt;
==== Emacs ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using emacs, use the command '''emacs'''.  You can start typing immediately:&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 -uuu:**-F1  myfile.txt     All L1     (Text)----------&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
To save a file, type '''C-x C-s''' (that means Control-X, then Control-S):&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 -uuu:---F1  myfile.txt     All L1     (Text)----------&lt;br /&gt;
 Wrote /home/todd/myfile.txt&lt;br /&gt;
&lt;br /&gt;
To quit emacs, type '''C-x C-c'''.  (It will ask you whether or not to save the file if you've made changes.)&lt;br /&gt;
&lt;br /&gt;
For more emacs commands, see http://souptonuts.sourceforge.net/chirico/emacs_ref.html&lt;br /&gt;
&lt;br /&gt;
==== Nano ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using nano, use the command '''nano'''.  You can start editing the file immediately:&lt;br /&gt;
&lt;br /&gt;
   GNU nano 2.0.6               File: myfile.txt                                      &lt;br /&gt;
 &lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ^G Get Help   ^O WriteOut   ^R Read File  ^Y Prev Page  ^K Cut Text   ^C Cur Pos&lt;br /&gt;
 ^X Exit       ^J Justify    ^W Where Is   ^V Next Page  ^U UnCut Text ^T To Spell&lt;br /&gt;
&lt;br /&gt;
Nano tells you the commands you need right there so you don't have to always keep looking them up like with Vi and Emacs.&lt;br /&gt;
&lt;br /&gt;
For more detail on Nano commands, see http://www.nano-editor.org/dist/v2.2/nano.html&lt;br /&gt;
&lt;br /&gt;
== Linux Resources ==&lt;br /&gt;
&lt;br /&gt;
[http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html  Linux System Administration Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.0/userguide-9.0/ch24.html Working with the Shell (SUSE Documentation)]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Linux_kernel Linux Kernel]&lt;br /&gt;
&lt;br /&gt;
[http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html VI Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://students.cec.wustl.edu/~jg18/guide/ Making the Transition to Linux: A Guide to the Linux Command Line Interface for Students]&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Linux&amp;diff=2016</id>
		<title>Linux</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Linux&amp;diff=2016"/>
		<updated>2015-09-01T04:54:43Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Setting File Permissions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[wikipedia:Linux|Linux]] is an [[wikipedia:Free and open-source software|open-source]] operating system based on [[wikipedia:UNIX|UNIX]].  Linux is highly versatile and is used in a wide range of applications.  [[wikipedia:Desktop Linux|Desktop Linux]] is Linux with a GUI (like Microsoft Windows or Mac OS X); Desktop Linux is popular in niche markets, and it is used widely in developing countries.&lt;br /&gt;
&lt;br /&gt;
Linux is the most widely used operating system for web servers.  In CSE330, we will be interacting with Linux from the command line.  This article covers the tools you need to make the best use of Linux.&lt;br /&gt;
&lt;br /&gt;
== Linux Distributions ==&lt;br /&gt;
&lt;br /&gt;
The open-source community is responsible for the development of many different [[wikipedia:Linux distributions|distributions]] of Linux.  Distributions, or ''distros'', are different &amp;quot;flavors&amp;quot; of the Linux operating system with different objectives.&lt;br /&gt;
&lt;br /&gt;
There are hundreds of distributions of Linux.  Three of the main banches are [[wikipedia:Debian|Debian]], [[wikipedia:SuSE|SuSE]] (based on [[wikipedia:Slackware|Slackware]]), and [[wikipedia:Red Hat Enterprise Linux|Red Hat Enterprise Linux (RHEL)]].&lt;br /&gt;
&lt;br /&gt;
The sections below discuss two of these branches and give recommendations of Linux distributions suitable for a web server.  The CSE330 wiki provides instructions for both Debian-based and RHEL-based Linux distributions, so the choice of which to use is up to you.&lt;br /&gt;
&lt;br /&gt;
=== Debian ===&lt;br /&gt;
&lt;br /&gt;
'''Debian''' was first introduced in 1993.  Debian has a passionate following, and its repositories contain more software packages than any other mainstream Linux distribution.  There are hundreds of derivatives of Debian.  Debian's most popular desktop derivative is '''[[wikipedia:Ubuntu|Ubuntu]]'''.&lt;br /&gt;
&lt;br /&gt;
Base Debian has a slow upgrade schedule, and because of this, it is an extremely stable operating system, making it well-suited for servers.  '''[[wikipedia:Ubuntu Server|Ubuntu Server]]''' is also an excellent choice for a Debian-based web server.&lt;br /&gt;
&lt;br /&gt;
=== Red Hat Enterprise Linux (RHEL) ===&lt;br /&gt;
&lt;br /&gt;
Red Hat Enterprise Linux, or '''RHEL''', was first introduced in 1994.  RHEL is known for being a good choice for enterprises that wish to use Linux as their primary OS.  RHEL has an abundance of administration tools.&lt;br /&gt;
&lt;br /&gt;
The Linux Lab in Lopata Hall uses '''[[wikipedia:Fedora Linux|Fedora Linux]]''', a desktop distribution based on RHEL.  '''[[wikipedia:CentOS|CentOS]]''' is a popular RHEL derivative that is widely used in web servers.  The '''[[wikipedia:Amazon Machine Image|Amazon EC2 Linux AMI]]''' is derived from CentOS, making it a distribution in the RHEL family.&lt;br /&gt;
&lt;br /&gt;
=== Special Note: Linux Kernel and Modules ===&lt;br /&gt;
{{XKCD&lt;br /&gt;
|id=619&lt;br /&gt;
|name=supported_features&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
What separates Linux from other Unix variants is its kernel. The kernel is the most important component of the operating system and is responsible for scheduling processes, providing access to the hardware devices, allocating memory to the programs, and so on.&lt;br /&gt;
&lt;br /&gt;
The Linux kernel uses both monolithic and modular approaches. A monolithic kernel is a single program that contains all the code so any addition to kernel (such as code to access a driver) requires recompiling the code. A monolithic kernel is usually a little faster and could have a smaller size since only the absolutely necessary code is there. The modular kernel, on the other hand, enables dynamic loading and unloading  of kernel code, called ''modules''. Typical modules include device drivers. Thanks to this modular approach, Linux seldom requires a reboot after installing a new device.&lt;br /&gt;
&lt;br /&gt;
== Bash ==&lt;br /&gt;
&lt;br /&gt;
In this course, you will be interacting with Linux primarily on the command line.  The most widespread ''command line language'' is '''Bash'''.  This is described in more detail in [[Bash|the Bash guide]].&lt;br /&gt;
&lt;br /&gt;
== Files and Permissions ==&lt;br /&gt;
&lt;br /&gt;
At the core of a Unix-based operating system is a directory structure with files and permissions.&lt;br /&gt;
&lt;br /&gt;
=== Filesystem Hierarchy ===&lt;br /&gt;
&lt;br /&gt;
The root directory of Linux contains a dozen or so subdirectories, each with a specific purpose:&lt;br /&gt;
&lt;br /&gt;
* '''/bin''' contains [[Bash#Running Programs|binaries]] used by all users&lt;br /&gt;
* '''/sbin''' contains system binaries typically used only by the system administrator&lt;br /&gt;
* '''/lib''' contains libraries for the binaries found in '''/bin''' and '''/sbin'''&lt;br /&gt;
* '''/etc''' contains configuration files&lt;br /&gt;
** '''/etc/yum.conf''' Configuration file for yum&lt;br /&gt;
** '''/etc/yum/yum.repos.d''' Directory containing .repo files for online repositories&lt;br /&gt;
** '''/etc/crontab''' System-wide crontab file&lt;br /&gt;
** '''/etc/fstab''' Information about default partitions to be mounted&lt;br /&gt;
** '''/etc/group''' List of groups in the system&lt;br /&gt;
** '''/etc/hosts''' List of IP addresses with their names&lt;br /&gt;
** '''/etc/inittab''' What to do at each run-level&lt;br /&gt;
** '''/etc/inetd.conf''' Configuration file for some internet services (replaced by xinetd.* in most systems)&lt;br /&gt;
** '''/etc/modules.conf''' Module information for the boot&lt;br /&gt;
** '''/etc/motd''' Message to be seen at the login prompt&lt;br /&gt;
** '''/etc/passwd''' User information&lt;br /&gt;
** '''/etc/profile''' System level initial file for sh and its derivatives&lt;br /&gt;
** '''/etc/shadow''' User passwords&lt;br /&gt;
* '''/dev''' contains device files&lt;br /&gt;
* '''/proc''' contains information on currently running processes&lt;br /&gt;
* '''/var''' contains files whose contents is expected to change&lt;br /&gt;
** '''/var/log''' contains system log files&lt;br /&gt;
*** '''/var/log/messages''' System/Kernel messages&lt;br /&gt;
*** '''/var/log/syslog''' System log (mostly for Daemons)&lt;br /&gt;
*** '''/var/log/wtmp'''' User access log (binary)&lt;br /&gt;
*** '''/var/log/dmesg''' Boot-up messages&lt;br /&gt;
*** '''/var/log/auth.log''' Authorization logs&lt;br /&gt;
** '''/var/lib''' contains packages and database files&lt;br /&gt;
** '''/var/spool''' contains print queues&lt;br /&gt;
* '''/tmp''' contains temporary files that are deleted at system reboot&lt;br /&gt;
* '''/usr''' contains user programs&lt;br /&gt;
** '''/usr/bin''' contains binaries for user programs&lt;br /&gt;
** '''/usr/sbin''' contains binaries for system administrators&lt;br /&gt;
** '''/usr/lib''' contains libraries for '''/usr/bin''' and '''/usr/sbin'''&lt;br /&gt;
** '''/usr/local''' contains programs that you install from source&lt;br /&gt;
* '''/home''' contains users' home directories&lt;br /&gt;
* '''/root''' is root's home directory&lt;br /&gt;
* '''/boot''' contains boot loader files (do not touch unless you know what you are doing!)&lt;br /&gt;
* '''/opt''' contains optional add-on applications&lt;br /&gt;
* '''/mnt''' is where system administrators can mount filesystems&lt;br /&gt;
* '''/media''' contains links to removable media devices (for example, CDs)&lt;br /&gt;
* '''/srv''' contains site-specific data which are served by the system&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information, see the Wikipedia article on the [[wikipedia:Filesystem Hierarchy Standard|Filesystem Hierarchy Standard]].&lt;br /&gt;
&lt;br /&gt;
=== File Permissions ===&lt;br /&gt;
&lt;br /&gt;
Every file in Linux has permissions that define which users can Read, Write, and Execute it.  Every file has an owner and a group.  The permissions for a file are set on three levels: User (owner), Group, and Other.&lt;br /&gt;
&lt;br /&gt;
==== Symbolic Notation ====&lt;br /&gt;
&lt;br /&gt;
When you view the permissions of a file in Linux, they will most often be displayed in ''symbolic notation''.  Symbolic notation consists of 10 characters: the first defines the file type, and then there are three characters each for User, Group, and Other permissions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;-r--r--r--&amp;lt;/code&amp;gt; is a normal file that is readable by all users but writable or executable by no one.&lt;br /&gt;
* &amp;lt;code&amp;gt;-rwxr-xr-x&amp;lt;/code&amp;gt; is a normal file that is readable and executable by everyone but only writable by User (the file's owner).  This is the most common permission set.&lt;br /&gt;
&lt;br /&gt;
==== Viewing File Permissions ====&lt;br /&gt;
&lt;br /&gt;
To view the permissions of all files in a certain directory, run the binary &amp;lt;code&amp;gt;ls -l&amp;lt;/code&amp;gt; in Bash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ls -l   # displays a list of all files in a directory with their permissions in symbolic notation&lt;br /&gt;
total 16&lt;br /&gt;
lrwxr-xr-x  1 sffc  wheel   6 Aug  9 09:13 link -&amp;gt; myfile.txt&lt;br /&gt;
-rwxr--r--  1 sffc  wheel  12 Aug  9 09:13 myfile.txt&lt;br /&gt;
$ ls -l myfile.txt   # displays the permissions of only myfile.txt&lt;br /&gt;
-rwxr--r--  1 sffc  wheel  12 Aug  9 09:13 myfile.txt&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setting File Permissions ====&lt;br /&gt;
&lt;br /&gt;
Linux comes with several useful binaries for setting file permissions.&lt;br /&gt;
&lt;br /&gt;
* '''chmod''' is used for setting permissions&lt;br /&gt;
* '''chown''' is used for setting a file's owner&lt;br /&gt;
* '''chgrp''' is used for setting a file's group&lt;br /&gt;
&lt;br /&gt;
Some examples are shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ chmod a+x myfile.txt   # turns on the Execute option for all users&lt;br /&gt;
$ chmod o-w myfile.txt   # turns off the Write option for Other users&lt;br /&gt;
$ chmod u+wx-r myfile.txt   # turns on the Write and Execute options for User (the file's owner) and also turns off the Read option for User&lt;br /&gt;
$ chown todd myfile.txt   # sets the owner of myfile.txt to the user todd.  Note: First comes the user, then comes the filename: not the other way around!&lt;br /&gt;
$ chgrp staff myfile.txt   # sets the group of myfile.txt to usergroup staff&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, see https://www.linux.com/learn/tutorials/760276-how-to-manage-file-and-folder-permissions-in-linux&lt;br /&gt;
&lt;br /&gt;
=== The . and .. Directories ===&lt;br /&gt;
&lt;br /&gt;
The '''.''' directory is a reference to the current directory.   The '''..''' directory brings you one level up in the filesystem.&lt;br /&gt;
&lt;br /&gt;
=== Symbolic Links ===&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Symbolic link|symbolic link]], or ''symlink'', is basically a link from one spot in the filesystem to another.  You can think of them like ''aliases'' in Mac OS X.  To create a a symlink, use the ''ln -s'' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ln -s /path/to/file.txt /path/to/link   # creates a symlink to file.txt at /path/to/link&lt;br /&gt;
&lt;br /&gt;
# Example:&lt;br /&gt;
$ ln -s /home/todd/instructions.doc /var/www/public_html/classes/instructions.doc   # creates a symlink in the web server to instructions.doc&lt;br /&gt;
$ vi /var/www/public_html/classes/instructions.doc   # changes to the symbolic link will be reflected in the original file&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== User Management ==&lt;br /&gt;
&lt;br /&gt;
=== Adding a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user, use the '''useradd''' command.  Then, set a password for that user using the '''passwd''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo useradd -r -m -c &amp;quot;My Full Name&amp;quot; myUserName&lt;br /&gt;
$ sudo passwd myUserName&lt;br /&gt;
Enter new UNIX password: &lt;br /&gt;
Retype new UNIX password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If Linux doesn't like your command, first check your syntax and then try it with single quotes around your full name and password instead of double quotes. If this works it is likely that you used some special characters in your password such as '!', which serves a special purpose in the shell. This is because Linux takes parameters enclosed in double quotes as one string, but still looks for special characters inside of the string and acts in accordance with their normal meaning. On the other hand, single quotes tell the shell to ignore any special characters within.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' If you are using Ubuntu Server, new users are created with /bin/sh as their default shell.  You want to use /bin/bash.  To change the shell for your user, run this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chsh -s /bin/bash myUserName   # changes shell for myUserName to /bin/bash&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding a User to the Sudoers List ===&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should never SSH into your server as the root user.  Instead, you should use a normal user to whom you give '''sudo''' privileges.  (For more detail on sudo, see [[Linux#SUDO|the Linux guide]].)&lt;br /&gt;
&lt;br /&gt;
To give a user sudo privileges, use the command '''visudo''', which opens up the SUDO configuration file in the system's default text editor.  (Never edit the file ''/etc/sudoers'' directly!)  SUDO users are specified using lines similar to&lt;br /&gt;
&lt;br /&gt;
 alice   ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
Add that line immediately below  the line defining '''root''':&lt;br /&gt;
&lt;br /&gt;
 root   ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
When you are finished, save and close the file.  For more information on editing files on the command line, refer to [[#File Editors|the section about File Editors in this guide]].&lt;br /&gt;
&lt;br /&gt;
In this case, '''alice''' will be able to run any command with SUDO privileges on the computer.   For more detail on SUDO configuration, see http://www.linuxhelp.net/guides/sudo/&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The visudo utility is especially useful because it not only locks the sudoers file against simultaneous edits, but it also checks the file for syntax errors when you quit. Therefore, it is always recommended that you use visudo to change the sudoers list rather than attempting to modify it directly.&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
In Linux, you can see your network information by typing '''ifconfig'''. This command shows the status information of each network interface, including the IP address you will need to remotely connect to your instance. The interface ''lo'' is the special loopback interface with IP address 127.0.0.1.  This refers to your local machine and any connection from your machine to your machine goes through this pseudo-interface.  Typical network interfaces include ''eth0'', ''eth1'',..., ''wlan0'', etc. Ethernet cards are represented with ''ethX''.  In the past, most wireless cards showed up as ''wlanX'', but it is also common now for them to be represented with ''ethX'' names. ''ifconfig'' also gives information such as hardware address (MAC), netmask, and broadcast addresses.&lt;br /&gt;
&lt;br /&gt;
You can start or stop networking by calling ''/etc/init.d/networking'' script. As with most ''/etc/init.d'' scripts, this script takes several options, such as ''start'', ''stop'', ''restart''.  Note even if you stop networking, you would still have your lo interface. You can look at the code of the script to find out what it actually does. You can also stop or start individual interfaces by using the '''ifup''' and '''ifdown''' commands.&lt;br /&gt;
&lt;br /&gt;
The network configuration files are stored in ''/etc/network''. ''/etc/network/interfaces'' contains the defaults for each interface. For xample, you could specify static IP, netmask, network, broadcast and default gateway for an interface here, but you should not need to edit this files in general.  These default options can be changed with the '''ifconfig''' command. The ''/etc/network/if-down.d'' and ''/etc/network/if-up.d'' directories contain the scripts that are going to be executed when an interface is turned on or off.  Of course, most modern Linux distributions have GUI tools for doing network configuration more easily, and you shouldn't need to change anything for the purposes of this course.&lt;br /&gt;
&lt;br /&gt;
== Synchronizing Date and Time ==&lt;br /&gt;
&lt;br /&gt;
In order to avoid setting your system's time manually at every daylight savings change, you can use a Network Time Server via the Network Time Protocol (NTP).&lt;br /&gt;
&lt;br /&gt;
The NTP Daemon comes pre-installed on EC2 AMI instances.  To install it on Debian, install the '''ntp''' package from apt.&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
=== Setting Timezone ===&lt;br /&gt;
&lt;br /&gt;
Your server is probably not set to the correct timezone by default.&lt;br /&gt;
&lt;br /&gt;
The timezone files are in the directory ''/usr/share/zoneinfo''. They are further organized within subdirectories grouped by region.  For instance, Rome's time zone file is stored within ''/usr/share/zoneinfo/Europe''.&lt;br /&gt;
&lt;br /&gt;
In order to set the time zone, simply copy the desired time zone file to our ''/etc'' directory as a new file named &amp;quot;localtime&amp;quot;.  For example, to set the the machine's system time to Rome's time zone, we would enter the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo cp /usr/share/zoneinfo/Europe/Rome /etc/localtime&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''ntp'' uses ''/etc/ntp.conf'' configuration file to find the ostnames of remote time servers.  The defaults here are probably fine.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installing Software ==&lt;br /&gt;
&lt;br /&gt;
The package management tool in Red Hat Enterprise Linux (and therefore also your Amazon EC2 instance) is '''rpm'''.  (In Debian, it is '''dpkg'''.)  If you have an ''rpm'' package, you can install it by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ rpm -i somepackage.rpm&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This requires that ''somepackage.rpm'' be in your current directory, which means you will have to download the file yourself (or create it). It requires you to manually install any dependencies the package has.&lt;br /&gt;
&lt;br /&gt;
=== Repository-Based Package Managers ===&lt;br /&gt;
&lt;br /&gt;
A better alternative is to use a repository-based package manager.  In RHEL, this is '''yum'''; in Debian, it is '''apt'''.&lt;br /&gt;
&lt;br /&gt;
Before you install new software, you need to ensure that your local list of available packages is up-to-date.  Run one of the following commands to perform this operation:&lt;br /&gt;
&lt;br /&gt;
* In RHEL: '''yum check-update'''&lt;br /&gt;
* In Debian: '''apt-get update'''&lt;br /&gt;
&lt;br /&gt;
After you have ensured that your package list is synced with the remote repository, you can start installing packages.  To install a package, use one of the following commands:&lt;br /&gt;
&lt;br /&gt;
* In RHEL: '''yum install package-name'''&lt;br /&gt;
* In Debian: '''apt-get install package-name'''&lt;br /&gt;
&lt;br /&gt;
If you get a permission denied error, try sudoing the command, like '''sudo apt-get install xxxx'''&lt;br /&gt;
&lt;br /&gt;
For example, this is how you would install ''lynx'', a command-line web browser, in your RHEL Linux distribution:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ lynx --version   # is lynx installed?&lt;br /&gt;
-bash: lynx: command not found&lt;br /&gt;
$ sudo yum check-update   # sync package lists with the remote repositories&lt;br /&gt;
$ sudo yum install lynx    # install the lynx package&lt;br /&gt;
Downloading Packages:&lt;br /&gt;
lynx-2.8.6-27.6.amzn1.i686.rpm        | 1.8 MB     00:00     &lt;br /&gt;
Running rpm_check_debug&lt;br /&gt;
Running Transaction Test&lt;br /&gt;
Transaction Test Succeeded&lt;br /&gt;
Running Transaction&lt;br /&gt;
  Installing : lynx-2.8.6-27.6.amzn1.i686             1/1 &lt;br /&gt;
&lt;br /&gt;
Installed:&lt;br /&gt;
  lynx.i686 0:2.8.6-27.6.amzn1                                                                                                                                                                                                                &lt;br /&gt;
&lt;br /&gt;
Complete!&lt;br /&gt;
$ lynx --version   # test again to see if we have lynx installed&lt;br /&gt;
Lynx Version 2.8.6rel.5 (09 May 2007)&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also search for available packages by name or by the name of a file that they install.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ yum search lynx   # search for packages whose name contains lynx&lt;br /&gt;
======= N/S Matched: lynx =======&lt;br /&gt;
lynx.i686 : A text-based Web browser&lt;br /&gt;
$ yum provides lynx   # search for packages that install a file or command named lynx&lt;br /&gt;
lynx-2.8.6-27.6.amzn1.i686 : A text-based Web browser&lt;br /&gt;
Repo        : installed&lt;br /&gt;
Matched from:&lt;br /&gt;
Other       : Provides-match: lynx&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The list of repositories that '''yum''' searches is located at &amp;lt;code&amp;gt;/etc/yum.conf&amp;lt;/code&amp;gt;.  The list of repositories that '''apt''' searches is located at &amp;lt;code&amp;gt;/etc/apt/sources.list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
=== Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
To save you some headaches later on, it is recommended that you install a few essential package bundles when you first create a new Linux instance.  These packages include things like Make and a C compiler.&lt;br /&gt;
&lt;br /&gt;
'''Debian:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo apt-get install build-essential&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RHEL:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo yum groupinstall &amp;quot;Development Tools&amp;quot;&lt;br /&gt;
$ sudo yum install kernel-devel kernel-headers&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Searching for Packages ===&lt;br /&gt;
&lt;br /&gt;
You can search for packages by name, command, and so on.  For example, to search for all packages relating to &amp;quot;lynx&amp;quot;, you could do:&lt;br /&gt;
&lt;br /&gt;
'''Debian:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ apt-cache search lynx&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RHEL:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ yum search lynx&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Command Reference ==&lt;br /&gt;
{{XKCD&lt;br /&gt;
|id=196&lt;br /&gt;
|name=command_line_fu&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Earlier, you saw that '''cat''' is a command that shows the contents of a file.  Below is a list of other useful commands in Linux.&lt;br /&gt;
&lt;br /&gt;
=== Navigation and File Management ===&lt;br /&gt;
&lt;br /&gt;
* '''ls''' List file(s) in current working directory&lt;br /&gt;
** '''ll''' Shortcut to '''ls -l'''.  List files with more details than '''ls'''.  Only available in certain distributions&lt;br /&gt;
* '''cd''' Change working directory.  Note: cd called without any arguments moves you to your home directory&lt;br /&gt;
* '''cp''' Copy a file&lt;br /&gt;
* '''mv''' Move or rename a file&lt;br /&gt;
* '''rm''' Remove a file&lt;br /&gt;
** '''rm -r''' Remove a directory and all files in it&lt;br /&gt;
* '''ln -s''' Create a symlink to a file&lt;br /&gt;
* '''mkdir''' Create a directory&lt;br /&gt;
* '''rmdir''' Remove a directory (directory must be empty; if it's not, use '''rm -r''')&lt;br /&gt;
* '''cat''' Display the contents of a file&lt;br /&gt;
* '''less''' Display the contents of a file, wait for the user at each page&lt;br /&gt;
* '''tail''' Display the last 20 lines of a file&lt;br /&gt;
** '''tail -f''' Display the last 20 lines of a file and then wait for changes, displaying them as they occur.  Useful for monitoring log files.&lt;br /&gt;
* '''chown''' Change the owner of a file&lt;br /&gt;
* '''chgrp''' Change the group of a file&lt;br /&gt;
* '''chmod''' Change the security permissions of a file&lt;br /&gt;
* '''grep''' Display the lines of a file matching a user specified string&lt;br /&gt;
* '''diff''' Display the difference between two files&lt;br /&gt;
&lt;br /&gt;
=== System Administration ===&lt;br /&gt;
&lt;br /&gt;
* '''df''' Display free diskspace&lt;br /&gt;
* '''du''' Display disk usage&lt;br /&gt;
* '''free''' Display memory usage information&lt;br /&gt;
* '''date''' Display current time and date&lt;br /&gt;
* '''top''' Display the CPU and Memory usages of current processes&lt;br /&gt;
* '''ps''' Display current processes&lt;br /&gt;
* '''kill''' Terminate a running process&lt;br /&gt;
* '''killall''' Terminate the running process matching user specified criterias&lt;br /&gt;
* '''ping hostname''' Ping a host&lt;br /&gt;
* '''host''' Get the IP address of a host&lt;br /&gt;
* '''passwd''' Change the user password&lt;br /&gt;
* '''su user''' Switch to the privileges of another user&lt;br /&gt;
* '''shutdown''' Power off the computer&lt;br /&gt;
* '''reboot''' Reboot the computer&lt;br /&gt;
* '''clear''' Clear the terminal&lt;br /&gt;
* '''ifconfig''' Display/Configure a network device&lt;br /&gt;
* '''file''' Show the file type&lt;br /&gt;
* '''lsmod''' Display loaded kernel modules&lt;br /&gt;
* '''insmod''' Install a kernel module&lt;br /&gt;
* '''modprobe''' Load a kernel module (also load the dependencies)&lt;br /&gt;
* '''adduser''' Add a new user&lt;br /&gt;
* '''exit''' Exit from a shell&lt;br /&gt;
* '''lpr''' Print a file&lt;br /&gt;
* '''head''' Display  lines at the beginning of a file&lt;br /&gt;
* '''tail''' Display lines at the end of a file&lt;br /&gt;
* '''pwd''' Display the name of the current working directory&lt;br /&gt;
* '''lsof''' Open files in the system&lt;br /&gt;
* '''netstat''' Statistics related to open sockets&lt;br /&gt;
&lt;br /&gt;
=== File Editors ===&lt;br /&gt;
{{XKCD&lt;br /&gt;
|name=real_programmers&lt;br /&gt;
|id=378&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
It is sometimes convenient to edit files using the command line.  Three widely-used command line text editors are '''vi''', '''emacs''', and '''nano'''.&lt;br /&gt;
&lt;br /&gt;
==== Vi ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using Vi, use the command '''vi'''.  You will see something like this:&lt;br /&gt;
&lt;br /&gt;
 .&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 &amp;quot;myfile.txt&amp;quot; [New File]&lt;br /&gt;
&lt;br /&gt;
To insert text into the file, press '''i''' once, then type away:&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 -- INSERT -- &lt;br /&gt;
&lt;br /&gt;
To leave insert mode, press ESC.&lt;br /&gt;
&lt;br /&gt;
To save your file, type the command ''':w''' and press Enter.&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 &amp;quot;myfile.txt&amp;quot; [New] 1L, 12C written&lt;br /&gt;
&lt;br /&gt;
To save and then close your file, type the command ''':wq'''.  (To close the file without saving, use the command ''':q!''')&lt;br /&gt;
&lt;br /&gt;
For more vi commands, see http://ss64.com/vi.html&lt;br /&gt;
&lt;br /&gt;
==== Emacs ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using emacs, use the command '''emacs'''.  You can start typing immediately:&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 -uuu:**-F1  myfile.txt     All L1     (Text)----------&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
To save a file, type '''C-x C-s''' (that means Control-X, then Control-S):&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 -uuu:---F1  myfile.txt     All L1     (Text)----------&lt;br /&gt;
 Wrote /home/todd/myfile.txt&lt;br /&gt;
&lt;br /&gt;
To quit emacs, type '''C-x C-c'''.  (It will ask you whether or not to save the file if you've made changes.)&lt;br /&gt;
&lt;br /&gt;
For more emacs commands, see http://souptonuts.sourceforge.net/chirico/emacs_ref.html&lt;br /&gt;
&lt;br /&gt;
==== Nano ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using nano, use the command '''nano'''.  You can start editing the file immediately:&lt;br /&gt;
&lt;br /&gt;
   GNU nano 2.0.6               File: myfile.txt                                      &lt;br /&gt;
 &lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ^G Get Help   ^O WriteOut   ^R Read File  ^Y Prev Page  ^K Cut Text   ^C Cur Pos&lt;br /&gt;
 ^X Exit       ^J Justify    ^W Where Is   ^V Next Page  ^U UnCut Text ^T To Spell&lt;br /&gt;
&lt;br /&gt;
Nano tells you the commands you need right there so you don't have to always keep looking them up like with Vi and Emacs.&lt;br /&gt;
&lt;br /&gt;
For more detail on Nano commands, see http://www.nano-editor.org/dist/v2.2/nano.html&lt;br /&gt;
&lt;br /&gt;
== Linux Resources ==&lt;br /&gt;
&lt;br /&gt;
[http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html  Linux System Administration Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.0/userguide-9.0/ch24.html Working with the Shell (SUSE Documentation)]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Linux_kernel Linux Kernel]&lt;br /&gt;
&lt;br /&gt;
[http://www.eng.hawaii.edu/Tutor/vi.html VI Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://students.cec.wustl.edu/~jg18/guide/ Making the Transition to Linux: A Guide to the Linux Command Line Interface for Students]&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Web_Frameworks&amp;diff=2015</id>
		<title>Web Frameworks</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Web_Frameworks&amp;diff=2015"/>
		<updated>2015-09-01T04:50:55Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Notable Sites using CakePHP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;So far in this class, you have been using PHP to run your web site.  You may have found that PHP can become burdensome when you are writing complex applications, and it can be hard to use for collaboration.&lt;br /&gt;
&lt;br /&gt;
Web Frameworks are an alternative method for writing web applications.  Web Frameworks are designed to make the experience for the developer more elegant and increase the possibilities for collaboration.&lt;br /&gt;
&lt;br /&gt;
There are ''hundreds'' of Web Frameworks out there.  We have chosen three of the more popular frameworks to write about in this article.  If you want to use a different framework, there is a section at the end telling you what to look out for.&lt;br /&gt;
&lt;br /&gt;
== Web Frameworks vs. Content Management Systems ==&lt;br /&gt;
&lt;br /&gt;
When talking about Web applications, you may hear the terms ''WordPress'', ''Drupal'', or ''Joomla''.  These are '''content management systems''', or CMSs.  A CMS is a pre-built &amp;quot;canned&amp;quot; web application that works with minimal configuration.  Most CMSs have user accounts, blogging, shopping carts, and other common idioms right out of the box.  The big weakness of a CMS is that it lacks fine tuning and customization.  CMSs are most appropriate for individuals who do not know how to program a web site.&lt;br /&gt;
&lt;br /&gt;
Web frameworks give you all the power you need to customize your web application.  Most major web sites are built using web frameworks; very few use a vanilla CMS.  You're a future computer scientist or engineer at an elite institution, and after this course you will have the background you need to build applications using a web framework instead of a CMS.&lt;br /&gt;
&lt;br /&gt;
[[File:CMS-vs-Framework.gif]]&lt;br /&gt;
&lt;br /&gt;
== Common Features of Web Frameworks ==&lt;br /&gt;
&lt;br /&gt;
=== Routing ===&lt;br /&gt;
&lt;br /&gt;
A '''key difference''' between PHP and web frameworks is in how routing occurs.&lt;br /&gt;
&lt;br /&gt;
In PHP, if you went to an address like http://www.example.com/welcome.php then Apache would run the script located at, for example, ''/var/www/html/welcome.php''.&lt;br /&gt;
&lt;br /&gt;
However, frameworks do ''not'' generally work the same way.  This is in part because of the MVC architecture.  Most frameworks use a ''router'' instead that routes arbitrary URLs to controllers.  Scripts are never &amp;quot;loaded&amp;quot; directly through Apache.&lt;br /&gt;
&lt;br /&gt;
Here is a sample router file from a Ruby on Rails web application so you can get an idea of how it works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
# Ruby on Rails Routing Example&lt;br /&gt;
MovieNews::Application.routes.draw do&lt;br /&gt;
  resource :session, only: [:new, :create, :destroy]&lt;br /&gt;
&lt;br /&gt;
  resources :users&lt;br /&gt;
&lt;br /&gt;
  resources :movies do&lt;br /&gt;
    resources :reviews&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  root to: &amp;quot;movies#index&amp;quot;&lt;br /&gt;
  get &amp;quot;released-movies&amp;quot; =&amp;gt; &amp;quot;movies#index&amp;quot;, as: &amp;quot;released_movies&amp;quot;&lt;br /&gt;
  get &amp;quot;signup&amp;quot; =&amp;gt; &amp;quot;users#new&amp;quot;, as: &amp;quot;signup&amp;quot;&lt;br /&gt;
  get &amp;quot;login&amp;quot; =&amp;gt; &amp;quot;sessions#new&amp;quot;, as: &amp;quot;login&amp;quot;&lt;br /&gt;
  get &amp;quot;logout&amp;quot; =&amp;gt; &amp;quot;sessions#destroy&amp;quot;, as: &amp;quot;logout&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Word of Caution:''' This means that you should not save your framework source code in a directory that Apache serves!  For example, if you put your Django site in ''/var/www/mydjango/'', people could navigate via their web browser to ''example.com/mydjango/'' and see all of your source code, including sensitive business logic and passwords!  '''Do not make this mistake.'''&lt;br /&gt;
&lt;br /&gt;
=== Less Code ===&lt;br /&gt;
&lt;br /&gt;
Frameworks are designed to separate your application logic from your HTML and CSS.  In fact, most web frameworks automatically generate all of the HTML and CSS that you need.  So, you could write a fully functional (albeit bland-looking) web site in a Web Framework without writing a singly line of HTML or CSS!&lt;br /&gt;
&lt;br /&gt;
=== Object-Relational Mapping ===&lt;br /&gt;
&lt;br /&gt;
Many Web Frameworks use an [[wikipedia:Object-Relational Mapping|object-relational mapping]] paradigm for communication with the database.  What this means is that instead of writing SQL queries, you call methods on objects instead.  For example, the following snippet of code in Ruby on Rails loads a certain user out of the database and changes their nickname:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
# Ruby on Rails ORM Example&lt;br /&gt;
u = User.find_by_username(&amp;quot;alice&amp;quot;)&lt;br /&gt;
u.update_attributes(&lt;br /&gt;
  nickname: &amp;quot;Ali&amp;quot;&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== MVC Architecture ===&lt;br /&gt;
&lt;br /&gt;
In PHP, your code probably ended up jumbled together in various disorganized places.  This is part of the reason why many Web Frameworks choose to use a Model-View-Controller architecture.&lt;br /&gt;
&lt;br /&gt;
You learned about the Model-View-Controller architecture in CSE 132.  If you need a review, [[wikipedia:Model–view–controller|read the article on Wikipedia]].&lt;br /&gt;
&lt;br /&gt;
A directory structure for an MVC framework might look like the following:&lt;br /&gt;
&lt;br /&gt;
* '''app''' (holds MVC components)&lt;br /&gt;
** '''models''' (contains models)&lt;br /&gt;
** '''controllers''' (contains controllers)&lt;br /&gt;
** '''views''' (contains views)&lt;br /&gt;
* '''config''' (holds global server configurations)&lt;br /&gt;
* '''lib''' (other assorted libraries)&lt;br /&gt;
&lt;br /&gt;
With an MVC architecture, a request to the server typically follows the following path:&lt;br /&gt;
&lt;br /&gt;
# The server routes the request to a certain controller.&lt;br /&gt;
# The controller interprets the request, loading requested information from the models.&lt;br /&gt;
# The controller passes the information from the models to a view.&lt;br /&gt;
# The final view is sent to the user.&lt;br /&gt;
&lt;br /&gt;
== Some Popular Web Frameworks ==&lt;br /&gt;
&lt;br /&gt;
=== Django ===&lt;br /&gt;
&lt;br /&gt;
'''Django''' is an open source web development framework that uses Python as its programming language.&lt;br /&gt;
&lt;br /&gt;
Django uses object-relational mapping for interacting with the database.  It also uses an MVC architecture; note that Django calls the Controller the ''view'' and the View the ''template''.&lt;br /&gt;
&lt;br /&gt;
Because of Python's large following outside of the realm of web development, there are more general-use libraries available for Python than there are for a language like Ruby.  As such, Django is great for sites that require complex server-side operations.&lt;br /&gt;
&lt;br /&gt;
We will be using Django as the standard web framework for Module 5.  We made this choice because of the fact that Django runs on Python.&lt;br /&gt;
&lt;br /&gt;
==== Django Resources ====&lt;br /&gt;
&lt;br /&gt;
* [https://www.djangoproject.com/ Official Web Site]&lt;br /&gt;
* [https://docs.djangoproject.com/en/1.4/ Django Documentation]&lt;br /&gt;
&lt;br /&gt;
==== Notable Sites using Django ====&lt;br /&gt;
&lt;br /&gt;
* [http://www.washingtontimes.com/ The Washington Times]&lt;br /&gt;
* [http://www.mozilla.org/ Mozilla]&lt;br /&gt;
* [http://www.pbs.org/ PBS]&lt;br /&gt;
* [http://instagram.com/ Instagram]&lt;br /&gt;
&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
&lt;br /&gt;
Ruby on Rails, or just '''Rails''', is an open source web development framework that uses [[wikipedia:Ruby (programming language)|Ruby]] as its programming language.  Ruby is similar in syntax to Python, and it was chosen for Rails because of its elegant syntax and adaptability.&lt;br /&gt;
&lt;br /&gt;
Rails uses ActiveRecord, an object-relational mapping library, to communicate with its database back-end.  Rails also employs an MVC architecture.&lt;br /&gt;
&lt;br /&gt;
One feature of Rails that differentiates it from other frameworks is its concept of ''database migrations''.  Whenever you need to change your database schema, Rails lets you do so by generating a ''migration''.  In tue future, if the change wasn't what you wanted, your solution is easy: just rollback the migration.&lt;br /&gt;
&lt;br /&gt;
Rails is great for web sites that follow a typical web design pattern: for example, blogs, e-commerce, and news sites.&lt;br /&gt;
&lt;br /&gt;
==== Ruby on Rails Resources ====&lt;br /&gt;
&lt;br /&gt;
* [http://rubyonrails.org/ Official Web Site]&lt;br /&gt;
* [http://guides.rubyonrails.org/ Guides and Tutorials]&lt;br /&gt;
* [http://api.rubyonrails.org/ Rails Documentation]&lt;br /&gt;
* [http://railscasts.com/ Rails Screencasts]&lt;br /&gt;
* [http://www.ruby-lang.org/en/documentation/quickstart/ Ruby Tutorial]&lt;br /&gt;
&lt;br /&gt;
==== Notable Sites using Ruby on Rails ====&lt;br /&gt;
&lt;br /&gt;
* [http://twitter.com/ Twitter]&lt;br /&gt;
* [https://github.com/ Github]&lt;br /&gt;
* [http://www.groupon.com/ Groupon]&lt;br /&gt;
* [http://www.yellowpages.com/ YellowPages]&lt;br /&gt;
&lt;br /&gt;
=== CakePHP ===&lt;br /&gt;
&lt;br /&gt;
If you want to stay in the familiar land of PHP, '''CakePHP''' is an open source web framework similar to Ruby on Rails and Django but written with PHP instead of Ruby or Python.  Almost everything in CakePHP takes advantage of the object-oriented power of PHP5 to make development more agile.&lt;br /&gt;
&lt;br /&gt;
CakePHP uses object-relational mapping for database interaction, as well as an MVC architecture.&lt;br /&gt;
&lt;br /&gt;
CahePHP is great for small or large web sites that can benefit from using a language that you already know.&lt;br /&gt;
&lt;br /&gt;
==== CakePHP Resources ====&lt;br /&gt;
&lt;br /&gt;
* [http://cakephp.org/ Official Web Site]&lt;br /&gt;
* [http://book.cakephp.org/2.0/en/getting-started.html Getting Started Guide]&lt;br /&gt;
* [http://api20.cakephp.org/ Documentation]&lt;br /&gt;
* [http://phpmaster.com/speeding-up-your-cakephp-websites/ CakePHP Performance Optimization]&lt;br /&gt;
&lt;br /&gt;
==== Notable Sites using CakePHP ====&lt;br /&gt;
&lt;br /&gt;
* [http://www.store-locator.com/ Store-Locator.com]&lt;br /&gt;
* [http://www.cdrecyclingcenter.com/ CD Recycling Center of America]&lt;br /&gt;
* [http://www.wipe.com.ar/ Wipe Buenos Aires]&lt;br /&gt;
&lt;br /&gt;
== Other Web Frameworks ==&lt;br /&gt;
&lt;br /&gt;
Beyond Rails, Django, and CakePHP, there are hundreds, if not thousands, of web frameworks.  Here are some things to keep in mind when choosing a framework:&lt;br /&gt;
&lt;br /&gt;
* All good frameworks will take care of rudimentary security details for you, like preventing CSRF attacks and sealing up any XSS holes.  '''Read your framework's security article before continuing.  If your framework does not have a security article, ''you probably shouldn't be using that framework.'' '''&lt;br /&gt;
* Choose a framework '''written in a language that best suits your needs'''.  In addition to Ruby, Python, and PHP, there are frameworks written in Java, ASP.NET, C++, JavaScript, and more.&lt;br /&gt;
* '''Make sure that the framework is still being maintained.'''  You don't want to start using a framework that hasn't been updated in several years.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=JQuery&amp;diff=2014</id>
		<title>JQuery</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=JQuery&amp;diff=2014"/>
		<updated>2015-09-01T04:46:35Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;jQuery is a fairly lightweight javascript library that has a number of particularly useful features.  Even thought it's only been around for a few years now, it has gained a lot of momentum in the web development community.  jQuery provides a simple interface to easily modify CSS attributes on all the elements in the HTML document, has simplified AJAX integration, and is accompanied by a number of handy user interface related APIs.  You can get a good overview of jQuery in the jQuery [http://docs.jquery.com/Tutorials:How_jQuery_Works Tutorials], and there is a short summary on [http://en.wikipedia.org/wiki/JQuery Wikipedia].  Of course, there are plenty of other tutorials a google search away.&lt;br /&gt;
&lt;br /&gt;
To use jQuery in your javascript, you need to include the jQuery javascript library, which is just another JavaScript file.  Google hosts jQuery for free, and it is recommended that you use Google's hosted jQuery for your projects ([http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/ here is a blog post that gives some of the main reasons]).  Add the following line inside the '''&amp;lt;head&amp;gt;''' tag of your web page (adjust the version in the middle):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/x.x.x/jquery.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get the link to the latest hosted jQuery, see the [https://developers.google.com/speed/libraries/devguide#jquery Google Hosted Libraries Developer's Guide].&lt;br /&gt;
&lt;br /&gt;
You can also link to the jQuery library directly on other websites as mentioned in the above tutorials.  The trade-off is that having a local copy will load faster, but then requires you to manage the library files your self (e.g., downloading new versions).&lt;br /&gt;
&lt;br /&gt;
A few code snippets are given below, but the best way to learn about all the features of jQuery is to head to the [http://jquery.com jQuery website] and look through the tutorials, references, and examples there.&lt;br /&gt;
&lt;br /&gt;
The ''$'' symbol is used to denote jQuery functionality.  You can use it to call jQuery functions, access HTML document elements in order to read or write values, or modify style information via CSS for a range of document elements.  For example, here is some code that sets up a function to be called whenever the user clicks on a link:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $(&amp;quot;a&amp;quot;).click( function(event)&lt;br /&gt;
 {&lt;br /&gt;
   event.preventDefault();&lt;br /&gt;
   $(this).hide(&amp;quot;slow&amp;quot;);&lt;br /&gt;
 } );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above code leverages many useful javascript and jQuery features.  ''$(&amp;quot;a&amp;quot;)'' is the jQuery way of selecting all HTML ''a'' elements.  That is, in this case, all elements in the HTML document that are ''&amp;lt;a&amp;gt;'' tags.  The ''click'' function is invoked for all such ''a'' elements in the document.  The argument to the ''click'' function is another function that is to be called when the selected elements are clicked by the user.  The ''event'' argument to this user-defined function is a default argument sent to functions which handle user actions like clicking a mouse button.  In this example, the code calls another function, ''preventDefault()'' on the event passed to stop the standard action on that event.  Here that means stopping the web browser from following the link that the user clicked on.  Finally, the ''$(this)'' variable is the jQuery way of accessing the current encapsulating object, as in Java.  This example calls the jQuery hide function on the object to make the object (again, in this case, ''this'' is referring to the ''&amp;lt;a&amp;gt;'' tag that the user clicked) disappear from the browser.  The script also passes an argument to the hide function to make the link disappear slowly as described in the API.&lt;br /&gt;
&lt;br /&gt;
jQuery also comes with some easy to use widgets for building better user interfaces.  One of the handiest is the [http://docs.jquery.com/UI/Dialog dialog] widget that pops-up an in-browser dialog window.  To use the dialog functions, you need to include a few more javascript libraries in your HTML header block like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;link href=&amp;quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/start/jquery-ui.css&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
type=&amp;quot;text/css&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; /&amp;gt; &amp;lt;!-- We need the style sheet linked&lt;br /&gt;
 above or the dialogs/other parts of jquery-ui won't display correctly!--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;!-- The main library. &lt;br /&gt;
Note: must be listed before the jquery-ui library --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;!-- jquery-UI &lt;br /&gt;
hosted on Google's Ajax CDN--&amp;gt;&lt;br /&gt;
&amp;lt;!-- Note: you can download the javascript file from the link&lt;br /&gt;
&lt;br /&gt;
provided on the google doc, or simply provide its URL&lt;br /&gt;
&lt;br /&gt;
in the src attribute (microsoft and google also host the jQuery&lt;br /&gt;
&lt;br /&gt;
library--&amp;gt;&lt;br /&gt;
 &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
   // your code goes here&lt;br /&gt;
 &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then use the ''$().dialog()'' function to make dialog boxes.  The ''dialog'' function can take many arguments to customize its behavior and add standard elements like buttons; see the documentation for details.  The content of the dialog box is typically placed in a ''div'' container and then that container is hidden when the document loads.  You can put any elements in the ''div'' and they will be displayed as normal in the dialog box.  Here is a full example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
  &amp;lt;style&amp;gt;&lt;br /&gt;
    #mydialog { display:none }&lt;br /&gt;
  &amp;lt;/style&amp;gt;&lt;br /&gt;
  &amp;lt;link href=&amp;quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/start/jquery-ui.css&amp;quot;&lt;br /&gt;
   type=&amp;quot;text/css&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; /&amp;gt; &lt;br /&gt;
  &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
  &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
    function showdialog()&lt;br /&gt;
    {&lt;br /&gt;
      $(&amp;quot;#mydialog&amp;quot;).dialog();&lt;br /&gt;
    }&lt;br /&gt;
  &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
  &amp;lt;input type=&amp;quot;button&amp;quot; value=&amp;quot;Show Dialog&amp;quot; onclick=showdialog() /&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;mydialog&amp;quot; title=&amp;quot;Howdy&amp;quot;&amp;gt;Look at me!&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To understand the page, start at the bottom.  There is a ''div'' element with a title and some string content.  It also has a unique id (the ids can be anything you want) which is used to identify this particular element in the rest of the document.  This div's id is ''mydialog''.  Above that is a button input.  The only thing special about it is the ''onclick'' attribute which specifies a javascript function to call when the button is clicked by a user.  In this case, the function is ''showdialog()'' which is a user defined javascript function contained in the document header.  All the function does is access the document element with id ''mydialog'' (the ''#identifier'' is the jQuery way of accessing an individual element based on the assigned id in the element attribute list), and build a dialog box from it.  Here, the dialog box will have the title ''Howdy'' from the title attribute in the ''mydialog'' element, and have a text string ''Look at me!''.  Finally, at the top of the document is the ''style'' section, which is a normal HTML/CSS section describing appearance of parts of the document.  There is only one entry, again describing the document element with id ''mydialog''.  One style attribute is set, namely the ''display'' attribute is set to ''none'' to indicate that the element should not be displayed.  Otherwise, the ''mydialog'' div would be displayed like any other part of the document rather than being used solely for our dialog box.&lt;br /&gt;
&lt;br /&gt;
Here is another example of using jQuery to do simple animations by moving an image across the browser window:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;amp;lt;html&amp;gt;                                                                  &lt;br /&gt;
&amp;amp;lt;head&amp;gt;                                                                  &lt;br /&gt;
&amp;amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://code.jquery.com/jquery-latest.js&amp;quot;&amp;gt;&amp;amp;lt;/script&amp;gt;          &lt;br /&gt;
&amp;amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;                                         &lt;br /&gt;
  // these are for storing target locations&lt;br /&gt;
  var targetLeft=0;&lt;br /&gt;
  var targetTop=0;&lt;br /&gt;
  function moveTarget()&lt;br /&gt;
  {&lt;br /&gt;
    targetLeft+=10; //increase target location&lt;br /&gt;
    targetTop+=10; &lt;br /&gt;
    $(&amp;quot;#target&amp;quot;).css(&amp;quot;top&amp;quot;,targetTop); //move target to (top,left)&lt;br /&gt;
    $(&amp;quot;#target&amp;quot;).css(&amp;quot;left&amp;quot;,targetLeft); &lt;br /&gt;
    if(targetLeft&amp;amp;lt;200) &lt;br /&gt;
    { //stop if we reached left=200&lt;br /&gt;
      window.setTimeout(&amp;quot;moveTarget()&amp;quot;,200); //set the next timer&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  $(document).ready( function() &lt;br /&gt;
  { //at the beginning create a clock timeout&lt;br /&gt;
    window.setTimeout(&amp;quot;moveTarget()&amp;quot;,200); //call this function in 200 ms.&lt;br /&gt;
  });&lt;br /&gt;
&amp;amp;lt;/script&amp;gt;                                                               &lt;br /&gt;
&amp;amp;lt;/head&amp;gt;                                                                 &lt;br /&gt;
&amp;amp;lt;body&amp;gt;                                                                  &lt;br /&gt;
&amp;amp;lt;!-- this is my target--&amp;gt;                                        &lt;br /&gt;
&amp;amp;lt;img id=&amp;quot;target&amp;quot;  src=&amp;quot;http://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/180px-Smiley.svg.png&amp;quot; style=&amp;quot;position:relative&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;amp;lt;/body&amp;gt;                                                                 &lt;br /&gt;
&amp;amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Former Content]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=2013</id>
		<title>Getting MEAN</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Getting_MEAN&amp;diff=2013"/>
		<updated>2015-09-01T04:38:59Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Installation=&lt;br /&gt;
To install MEAN, make sure you already have all of the following components installed and configured correctly.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''1. Node.js''' (should come with npm) &amp;lt;br/&amp;gt;&lt;br /&gt;
To find out if you have node and npm, try checking their versions (may not be the same):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
node --version&lt;br /&gt;
v0.10.25&lt;br /&gt;
npm --version&lt;br /&gt;
1.3.24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
IF you don't have node.js, install it [http://nodejs.org/ here].&lt;br /&gt;
&lt;br /&gt;
'''2. Bower'''&lt;br /&gt;
&lt;br /&gt;
Bower is a web application manager used by MEAN. To install bower, type the following command in your terminal: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm install -g bower&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''3. MongoDB'''&lt;br /&gt;
To install MongoDB, follow the instructions for your OS [http://docs.mongodb.org/manual/installation/ here].&lt;br /&gt;
&lt;br /&gt;
'''4. Grunt'''&lt;br /&gt;
To install Grunt type the following command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;npm install -g grunt-cli&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''5. and finally, MEAN'''&lt;br /&gt;
In your terminal, type:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; &amp;gt; sudo npm install -g mean-cli &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What did all that mean? ==&lt;br /&gt;
&lt;br /&gt;
You just installed four different command line tools.  Here's what they all do.&lt;br /&gt;
&lt;br /&gt;
* '''npm''' is the package manager for Node.JS.  It installs libraries for use by your Node.JS applications.  The configuration file for ''npm'' (the list of packages for ''npm'' to install) is ''package.json''.&lt;br /&gt;
* '''bower''' is a package manager for front-end libraries.  Rather than manually downloading your jQuery, Bootstrap, Angular, and other front-end JavaScript and CSS (and remembering to update them when a new version of one of those libraries comes out), ''bower'' installs them for you.  The configuration file for ''bower'' (the list of packages for ''bower'' to install) is ''bower.json''.&lt;br /&gt;
* '''grunt''' is a build tool designed for JavaScript.  It's like ''make'' or ''ant'', but for JavaScript.  The configuration file for ''grunt'' (the list of commands to run when building your project) is ''Gruntfile.js'' (a name inspired by the ''Makefile'' for ''make'', the dominant C and C++ build tool).&lt;br /&gt;
* '''mean''' is a utility designed to help you carry out routine tasks associated with developing for the MEAN stack.&lt;br /&gt;
&lt;br /&gt;
Don't be confused by the fact that you use ''npm'' to install ''bower'', ''grunt'', and ''mean''.  The people who made ''bower'', ''grunt'', and ''mean'' just all decided to use ''npm'' as the place to publish their projects, probably because the executables themselves are written in Node.JS.  They could just as well have chosen ''apt-get'' or ''yum'' or any of the other package managers you've been using in this class.&lt;br /&gt;
&lt;br /&gt;
=Running the Default App =&lt;br /&gt;
* Init and run an app. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean init myApp // create your first app&lt;br /&gt;
&amp;gt; cd myApp &lt;br /&gt;
&amp;gt; npm install // Install dependencies&lt;br /&gt;
&amp;gt; grunt // Launch mean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure MongoDB is connected and running (if you run into problems, refer to the section on MongoDB)&lt;br /&gt;
&lt;br /&gt;
* Go ahead and explore features of the default Article app (such as logging in, adding/deleting articles).&lt;br /&gt;
&lt;br /&gt;
=Generating a Package =&lt;br /&gt;
* By now you should know what a package is in MEAN. If you don't, read [http://learn.mean.io/#mean-io-packages this].&lt;br /&gt;
&lt;br /&gt;
* Try creating a package named myPackage by typing: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mean package myPackage&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Locate it inside the packages folder:&lt;br /&gt;
* Compare the structure of myPackage folder to that of the default app. Make sure you see both '''public''' and  '''server''' folders and their subfolders.&lt;br /&gt;
* Restart your app, make sure you can see a link to the newly created package.&lt;br /&gt;
&lt;br /&gt;
=A Closer Look at the App =&lt;br /&gt;
Take a look at the directory where you app resides, you will see two folders '''public''' and  '''server''', which contain code for the client side and server side respectively.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Models ==&lt;br /&gt;
&lt;br /&gt;
Open up article.js in /server/models&lt;br /&gt;
&lt;br /&gt;
MEAN is MVC on the client side and the server side.  Since the model is tied to the backend to MongoDB, you will only see the models folder on the server side, which is normal. &lt;br /&gt;
The models are mongoose models that's why we need to require mongoose (what the following line does):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var mongoose = require('mongoose'), Schema = mongoose.Schema;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The following part then defines the schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var ArticleSchema = new Schema({&lt;br /&gt;
    created: {&lt;br /&gt;
        type: Date,&lt;br /&gt;
        default: Date.now&lt;br /&gt;
    },&lt;br /&gt;
    title: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    content: {&lt;br /&gt;
        type: String,&lt;br /&gt;
        default: '',&lt;br /&gt;
        trim: true&lt;br /&gt;
    },&lt;br /&gt;
    user: {&lt;br /&gt;
        type: Schema.ObjectId,&lt;br /&gt;
        ref: 'User'&lt;br /&gt;
    }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The next part is validations, or criteria an object needs to pass before it can be saved to the DB. &lt;br /&gt;
The following code is to make sure that an article has a title:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.path('title').validate(function(title) {&lt;br /&gt;
    return title.length;&lt;br /&gt;
}, 'Title cannot be blank');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, Mongoose allows us to define methods to our data objects as well. &lt;br /&gt;
These are called statics. From the Mongoose doc: Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.&lt;br /&gt;
The following code defines a method called load for the article schema:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
ArticleSchema.statics.load = function(id, cb) {&lt;br /&gt;
    this.findOne({&lt;br /&gt;
        _id: id&lt;br /&gt;
    }).populate('user', 'name username').exec(cb);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have trouble understanding what the code does, review the Mongoose [http://mongoosejs.com/docs/index.html quick start] guide.&lt;br /&gt;
&lt;br /&gt;
=== Models Practice === &lt;br /&gt;
Define a schema for a model named '''Phone''', name it phone.js and save it in the corresponding folder in 'myPackage' (hint: /packages/myPackage/server/models/)&lt;br /&gt;
A product needs to have the following fields with specific types. Here is an example of a Phone object can be stored in the MongoDB:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        &amp;quot;age&amp;quot;: 0, &lt;br /&gt;
        &amp;quot;id&amp;quot;: &amp;quot;motorola-xoom-with-wi-fi&amp;quot;, &lt;br /&gt;
        &amp;quot;imageUrl&amp;quot;: &amp;quot;img/phones/motorola-xoom-with-wi-fi.0.jpg&amp;quot;, &lt;br /&gt;
        &amp;quot;name&amp;quot;: &amp;quot;Motorola XOOM\u2122 with Wi-Fi&amp;quot;, &lt;br /&gt;
        &amp;quot;snippet&amp;quot;: &amp;quot;The Next, Next Generation\r\n\r\nExperience the future with Motorola XOOM wi.. d by Android 3.0 (Honeycomb).&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is taken from phones.json used by the AngularJS tutorial. If you have gone through the tutorial, you should have realized that instead of using a DB, json files were used to simplify the tutorial.&lt;br /&gt;
Find phones.json in /app/phones in the angular tutorial folder and try importing its content to MongoDB so you can use them in your current MEAN package.&lt;br /&gt;
&amp;lt;br/&amp;gt; Here is how (assuming mongod is running):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&amp;gt; mongo --shell // connect to mongo shell &lt;br /&gt;
&amp;gt; use mean-dev // switches to database used by mean.&lt;br /&gt;
&amp;gt; mongoimport --db mean-dev --collection phones --type json --file ''&amp;lt;path to phones.json&amp;gt;'' --jsonArray // imports json file to the DB&lt;br /&gt;
&amp;gt; show collections // check to see if phones are added to your database&lt;br /&gt;
&amp;gt; coll = db.phones // to see the content of the file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controllers ==&lt;br /&gt;
&lt;br /&gt;
You'll find a controllers folder on both the server side and the client (public) side.  &lt;br /&gt;
* The client side controllers are part of the Angular MVC scheme that contains client side logic and may issue requests to the server.&lt;br /&gt;
* The server side controllers deal with the models and requests from the client side.&lt;br /&gt;
&lt;br /&gt;
'''Server side:'''&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in the controllers folder. Try to understand what each part does. &lt;br /&gt;
&lt;br /&gt;
'''Client side:''' open up articles.js in /articles/public/controllers&lt;br /&gt;
Compare the functions defined in ArticlesController, can you find the server side implementation of corresponding functions? &lt;br /&gt;
&lt;br /&gt;
Here is a diagram to help you understand how this works:&lt;br /&gt;
&lt;br /&gt;
[[File:Mean.png]]&lt;br /&gt;
&lt;br /&gt;
== Views &amp;amp; Routing ==&lt;br /&gt;
Even though typically views are implemented and used for the client end, routing happens on both ends.&lt;br /&gt;
&lt;br /&gt;
* Find articles.js in /server/routes&lt;br /&gt;
You'll see that it requires the articles controller and its methods for querying the database.&lt;br /&gt;
&lt;br /&gt;
The first section requires the articles controller, which defines different methods &lt;br /&gt;
&lt;br /&gt;
For example, code below tells the server to use a method named &amp;quot;all&amp;quot; in the articles controller when the url is pointed to /articles:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;   &lt;br /&gt;
app.route('/articles')&lt;br /&gt;
      .get(articles.all)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Go to http://localhost:3000/articles, what do you see? Does it make sense?&lt;br /&gt;
&lt;br /&gt;
Let's switch to the public folder where the views reside.  Go to articles/public/views, open up list.html: &amp;lt;br/&amp;gt;&lt;br /&gt;
The first line tells the framework that  ArticlesController is responsible for this particular view and when this view is loaded, use find() to initiate data binding.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;section data-ng-controller=&amp;quot;ArticlesController&amp;quot; data-ng-init=&amp;quot;find()&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Feel free to take a look at what find() does. Make sure you understand that what find() does is actually done by the backend, where a corresponding find() is written (as mentioned above).&lt;br /&gt;
Hopefully you have a better understanding of how these technologies all work together now.&lt;br /&gt;
&lt;br /&gt;
Review the AngularJS section if you have any questions regarding the view data binding.&lt;br /&gt;
&lt;br /&gt;
The view files in articles/views only defines the code for displaying the articles, where does the navigation bar gets defined.&lt;br /&gt;
The answer is in /public/system. &lt;br /&gt;
*The .html files in public/system/views provide a container/layout for the application. &lt;br /&gt;
For example, header.html includes the menu bar (displayed on the top of the page):&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;left pull-left&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;ul class=&amp;quot;navbar-nav nav&amp;quot;&amp;gt;&lt;br /&gt;
         &amp;lt;li data-ng-repeat=&amp;quot;item in menus.main&amp;quot; ui-route=&amp;quot;/{{item.link}}&amp;quot; ng-class=&amp;quot;{active: $uiRoute}&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;a mean-token=&amp;quot;item.link&amp;quot; ui-sref='{{item.link}}'&amp;gt;{{item.title}}&amp;lt;/a&amp;gt;&lt;br /&gt;
        &amp;lt;/li&amp;gt;&lt;br /&gt;
   &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try changing &amp;lt;nowiki&amp;gt;{{item.title}} &amp;lt;/nowiki&amp;gt; inside the &amp;lt;a&amp;gt; &amp;lt;/a&amp;gt;tags to &amp;quot;my articles&amp;quot; see what happens to the page.&lt;br /&gt;
* The ui-sref is &amp;quot;href&amp;quot; in ui-route, an AngularJS plugin, try changing &amp;lt;nowiki&amp;gt;{{item.link}}&amp;lt;/nowiki&amp;gt; to #!/myarticles, &lt;br /&gt;
* What happens to the application now? When you click on &amp;quot;my articles&amp;quot;?&lt;br /&gt;
&lt;br /&gt;
The page to articles is no longer served!&lt;br /&gt;
&lt;br /&gt;
But how does the framework know which page to serve given a certain url?  The file responsible for this (called routing in web development) is in public/articles/routes&lt;br /&gt;
&lt;br /&gt;
open up articles.js in this folder and find the line that specifies the routing scheme for /articles:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            .state('all articles', {&lt;br /&gt;
                url: '/articles',&lt;br /&gt;
                templateUrl: 'public/articles/views/list.html',&lt;br /&gt;
                resolve: {&lt;br /&gt;
                    loggedin: checkLoggedin&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is ui-route's way of telling the server what to serve the page specified by the templateUrl when it sees &amp;quot;localhost:3000/#!/phones&amp;quot;. &lt;br /&gt;
The #! is a hash prefix used for MEAN to make ajax calls so make sure to include it when coding your views.&lt;br /&gt;
Now try changing the url to &amp;quot;/myarticles&amp;quot;, save and go back to your app, click on &amp;quot;my articles&amp;quot; now, what happens?&lt;br /&gt;
&lt;br /&gt;
*This is important if you want to customize your navigation bar and links. Just remember that each url needs an entry in the route file, in the format of the example above.&lt;br /&gt;
&lt;br /&gt;
= Practice = &lt;br /&gt;
&lt;br /&gt;
Can you implement a view in your myPackage to display all phones injected in the DB? &lt;br /&gt;
Hint: myPackage has the same file structure as the default app.&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=2012</id>
		<title>Preparations</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Preparations&amp;diff=2012"/>
		<updated>2015-09-01T04:37:48Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* AngularJS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Full Stack==&lt;br /&gt;
In web development, full stack refers to all the layers involved in building a working web application, including data modeling, server, network, user interface, business logic etc. &lt;br /&gt;
In this module we will focus on the technical layers that are essential for a successful web product, which translates to front end and back end skills. &lt;br /&gt;
&lt;br /&gt;
MEAN is a collection of javascript frameworks and its components are:&lt;br /&gt;
Front end: AngularJS (client side MVC) , Bootstrap*&lt;br /&gt;
Back end: Express(server side MVC), with Node.js API &lt;br /&gt;
Data Base: MongoDB&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why MEAN? ==&lt;br /&gt;
Can I use a SQL database instead of MongoDB? Or a different front end framework like instead of Angular? Sure, but these technologies work beautifully together as they all use the same language – Javascript. For the first time ever we can create web software applications entirely using one language and this gives developers tremendous power. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== MongoDB ===&lt;br /&gt;
MongoDB is a leading NoSQL database that uses JSON-style documents with dynamic schemas. It uses Javascript as a language to modify and query the database and JSON format to store the data&lt;br /&gt;
'''Go through this very short tutorial for MongoDB''' [http://try.mongodb.org here]. This 5 minute tutorial will help you understand how MongoDB works as a noSQL DB service.&lt;br /&gt;
Even though MongoDB is fast, scalable and easy to use, to make it work with the MEAN stack, we need an object modeling service called Mongoose. &amp;lt;br/&amp;gt;&lt;br /&gt;
'''Skim through the Mongoose guide (getting started)''' [http://mongoosejs.com/docs/index.html here] to understand how it works. &lt;br /&gt;
&lt;br /&gt;
=== Express===&lt;br /&gt;
Express is a minimal and flexible node.js web application framework, and has become the dominant server-side MVC framework for Node.js. Express defines the responses to each type of HTTP request at each defined route and treats the request and responses as objects you can manipulate in any way you see fitting.&lt;br /&gt;
You will not be coding anything for Express in this module (already done by MEAN.io). Take a look at it [http://expressjs.com here]&lt;br /&gt;
&lt;br /&gt;
=== AngularJS===&lt;br /&gt;
AngularJS is a client-side MVC javascript framework by Google and it aims to increase developer productivity and creativity by providing a complete solution for large-scale applications and many powerful out of the box features.&lt;br /&gt;
AngularJS is important to this module. Please go through the tutorial [https://docs.angularjs.org/tutorial here].&lt;br /&gt;
&lt;br /&gt;
===Node.js===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Bootstrap===&lt;br /&gt;
Bootstrap is the default front end framework for the MEAN.io project. Though you could switch to other frameworks such as Foundation pretty easily.&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=2011</id>
		<title>CSE 330 Online Textbook - Table of Contents</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=CSE_330_Online_Textbook_-_Table_of_Contents&amp;diff=2011"/>
		<updated>2015-08-19T15:55:41Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;[[File:CSE330Banner.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&amp;lt;div style=&amp;quot;column-width: 300px; -moz-column-width: 300px; -webkit-column-width: 300px;&amp;quot;&amp;gt;&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=1&lt;br /&gt;
|subject=HTML and CSS Fundamentals&lt;br /&gt;
|links=&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=2&lt;br /&gt;
|subject=Linux, Apache, and PHP&lt;br /&gt;
|links=&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=3&lt;br /&gt;
|subject=SQL Databases&lt;br /&gt;
|links=&lt;br /&gt;
* [[Introduction to MySQL]] (installation)&lt;br /&gt;
* [[MySQL Schema and State]] (queries)&lt;br /&gt;
* [[PHP and MySQL]] (using MySQL from PHP)&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=4&lt;br /&gt;
|subject=Scripting for Rapid Prototyping&lt;br /&gt;
|links=&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=5&lt;br /&gt;
|subject=JavaScript and APIs&lt;br /&gt;
|links=&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=6&lt;br /&gt;
|subject=Real-Time Web Applications&lt;br /&gt;
|links=&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=7&lt;br /&gt;
|subject=Angular JS&lt;br /&gt;
|links=&lt;br /&gt;
* [[Preparations]]&lt;br /&gt;
* [[Getting MEAN]]&lt;br /&gt;
* [[Git]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=8&lt;br /&gt;
|subject=Creative Project&lt;br /&gt;
|links=&lt;br /&gt;
* [[Choosing a Platform]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{FrontPageModule&lt;br /&gt;
|num=9&lt;br /&gt;
|subject=Web Frameworks&lt;br /&gt;
|links=&lt;br /&gt;
* [[Web Frameworks]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
Use this wiki as a starting place for your projects in CSE 330.  However, web development is a large field, so it is impossible for us to document everything you might need to know.  Here are some other places you should look when you need to find something:&lt;br /&gt;
&lt;br /&gt;
* [http://www.webplatform.org/ WebPlatform.org], a community-driven source containing documentation and tutorials for Web technologies&lt;br /&gt;
* [http://www.w3.org/community/webed/wiki/Main_Page The Web Education Community Group Wiki], also sponsored by the W3C.&lt;br /&gt;
* [http://reference.sitepoint.com/html SitePoint], which has a reference page as well as quality articles and tutorials&lt;br /&gt;
* Also take a look at [http://designfestival.com/13-time-saving-tools-for-web-designers/ this list of productivity tools] for web development.&lt;br /&gt;
&lt;br /&gt;
If you can't find what you need in any of these places, try using your favorite search engine.  '''Be wary of sites that come up on search engines.'''  Many HTML reference sites document bad practices and dated techniques.  If you're unsure whether a reference site you find is legitimate, ask a TA.&lt;br /&gt;
&lt;br /&gt;
== Want to Learn More? ==&lt;br /&gt;
&lt;br /&gt;
The limited amount of time in CSE 330 means that we can cover only a subset of the wide range of possible topics in the field of rapid prototyping and web development.  Indeed, the exact topics covered in CSE 330 change from year to year.&lt;br /&gt;
&lt;br /&gt;
Feel free to browse some of the topics that have previously been covered in CSE 330: [[:Category:Former Content|CSE 330 Former Content]]&lt;br /&gt;
&lt;br /&gt;
You should also consider following blogs like [http://www.sitepoint.com/ SitePoint] to keep up-to-date on the latest developments in the field of web development.&lt;br /&gt;
&lt;br /&gt;
== Content License ==&lt;br /&gt;
&lt;br /&gt;
The content of this wiki is copyright (c) 2013, Washington University in St. Louis, Department of Computer Science.  All rights reserved.&lt;br /&gt;
&lt;br /&gt;
=== Modified BSD License ===&lt;br /&gt;
&lt;br /&gt;
Redistribution and use in source and binary forms, with or without modification, by a Third Party who has not completed and is not in the process of completing CSE 330, of the code examples or concepts on this wiki, are permitted, provided that the following conditions are met:&lt;br /&gt;
&lt;br /&gt;
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.&lt;br /&gt;
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
* Neither the name of the Washington University School of Engineering and Applied Science nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.&lt;br /&gt;
&lt;br /&gt;
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS TO ALL PARTIES &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
&lt;br /&gt;
=== What it Means ===&lt;br /&gt;
&lt;br /&gt;
If you are a student in CSE 330, you may use the code from this wiki freely in your projects without the need for attribution.  If you are not a student in CSE 330, you may use the code from this wiki freely in your projects with attribution.  Either way, the code examples are provided &amp;quot;as is&amp;quot;, without any warranty, and Washington University holds no liability for problems arising from the use of the content in this wiki.&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2010</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2010"/>
		<updated>2015-08-19T15:55:06Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Optional Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://docs.angularjs.org/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2009</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2009"/>
		<updated>2015-08-19T15:54:47Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Optional Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the Old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://docs.angularjs.org/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2008</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2008"/>
		<updated>2015-08-19T15:54:10Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Optional Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the Old module 7 reference pages:&lt;br /&gt;
*[[git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
*[[Getting_MEAN]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://docs.angularjs.org/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2007</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2007"/>
		<updated>2015-08-19T15:53:16Z</updated>

		<summary type="html">&lt;p&gt;Jimmy: /* Optional Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the Old module 7 reference pages:&lt;br /&gt;
*[[git]]&lt;br /&gt;
*[[preperations]]&lt;br /&gt;
*[[getting_mean]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://docs.angularjs.org/tutorial this] tutorial, and focus on steps 0-9.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
	Note: Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
''Note: in order to keep a variable in a controller when you switch between two different views (instead of resetting the variables), use $rootScope as a dependency for that controller.''&lt;br /&gt;
&lt;br /&gt;
*''For example, if you want to keep the id of the selected coffee, making it $rootScope.selectedID in your controller will keep the value of that variable when you switch from coffees.html to reviews.html. ''&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS and UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
Please follow the installation instructions carefully. The following should be in your index.html if you are using UI Bootstrap:&lt;br /&gt;
          &amp;lt;script src &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src=&amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At the end, your coffee site may look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&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;
&lt;br /&gt;
'''Assignments must be demoed within 2 weeks of the assignment being due. We will grade late penalties based on Bitbucket submission time-stamps, so you are allowed to demo at TA office hours. However, after two weeks of not demoing, you will receive a zero for the assignment.''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-9 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (45 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one controller for the project ( 2 points)&lt;br /&gt;
#***	Use scope and rootScope injections (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Jimmy</name></author>
		
	</entry>
</feed>