Difference between revisions of "Module 5"

From CSE330 Wiki
Jump to: navigation, search
(Grading)
(Grading)
Line 124: Line 124:
  
 
{|
 
{|
!Assignment
+
!Python Assignment
 
!Points
 
!Points
 
|-
 
|-
|Tables Correct
+
|Compute Final Grades
|2
+
|1
 
|-
 
|-
|Data Queries Correct
+
|Compute Letter Grade
|2
+
|1
 
|-
 
|-
!colspan="2"|Group Portion:
+
|Sort by Last Name
 +
|1
 
|-
 
|-
|User Authentication
+
|Accept Command Line Argument
 
|1
 
|1
 
|-
 
|-
|User Registration
+
!colspan="2"|Django Assignment:
 +
|-
 +
|Models defined and database set up
 
|1
 
|1
 
|-
 
|-
|Salted One-Way Encryption
+
|Admin app enabled and working
 
|1
 
|1
 
|-
 
|-
|Main page displays all stories (or most recent stories)
+
|urls matched to correct views
 
|1
 
|1
 
|-
 
|-
|Page with individual story and comments
+
|Templates for viewing and voting using generic views
 
|1
 
|1
 
|-
 
|-
|Story Submission
+
!colspan="2"|Group Portion:
|1
+
|-
 +
|Models defined and database set up
 +
|2
 +
|-
 +
|View of single image with current tag and list of all tags
 +
|2
 
|-
 
|-
|Comment System
+
|Navigation between images and tags
|1
+
|2
 
|-
 
|-
|Administrator Deletion of Stories/Comments
+
|Main page displays all tags sorted by number of images
|1
+
|2
 
|-
 
|-
|User Edit/Delete of Story (1 pt) and Delete of Comment (1 pt)
+
|User registration, login/logout and change password
 
|2
 
|2
 
|-
 
|-
|Protect Against SQL Injection Attack
+
|Forgot password send email with working reset link
|1
+
|2
 
|-
 
|-
|Sanitize Output
+
|Validation of all user input
|1
+
|2
 
|-
 
|-
|CSRF Safe and Validation
+
|Add new images and tags, only if logged in
|1
+
|2
 +
 
 
|-
 
|-
 
|Creative Portion
 
|Creative Portion

Revision as of 00:12, 19 October 2012

THIS PAGE UNDER CONSTRUCTION


In Module 6, you will learn about python, a scripting language, and Django, a web framework.

This article contains your assignments for Module 6.

Individual Assignments

Python tutorial Django tutorial

Python Tutorial

Install Python Tools

  • sudo yum install python-setuptools
  • sudo yum install python-devel

Python Assignment

  • You will write a python script that reads a set of student grades in from a file and does some basic parsing and processing. here is the section of the python tutorial on reading and writing files.
  • An example grades file is here. For the sake of simplicity you can assume that the file name is always going to be grades.txt.
  • The first line of the file is of the form: NUM_LABS,NUM_EXAMS,LAB_WEIGHT
  • All of the other lines in the file are of the form: FIRSTNAME LASTNAME|GRADE|TYPE
  • The FIRSTNAME and LASTNAME fields are the student's full name (always only a first and last name), the GRADE is one grade for the student, and the TYPE describes what kind of assignment the grade was for, in this case either a 'lab' or an 'exam'.
  • Your script should read in a grades file with the above format and perform the following:
    1. Compute the final grade for every student, given that there were a total of NUM_LABS labs, NUM_EXAMS exams, and that the labs account for a total of LAB_WEIGHT percent of the grade.
    2. Compute the final letter grade based on the final numeric grade (A = 90 or above, B = 80 - 90, C = 70 - 80, D = 60 - 70, F = below 60). 
    3. Ignore any blank lines.
    4. Sort the students by last name, and print out final grades in that sorted order.
    5. No names should be hard coded into the script (you will run your script on another file with different student names when we grade your assignment).
    6. Finally, the script should take one optional command line argument, which is a string to match against student names.  Only names that match the string in full or in part, should be printed out with their final grades.
      • For example, with the argument 'John' grades for both John Smith and John Locke should be printed (if those are the only two Johns in the grades.txt file)

Django Tutorial

Install Djgano

This procedure assumes you are using and Amazon AMI Linux on an ec2 instance. An in-depth install guide can be found on the Django website, but a quick version is below. Run these commands as root.

That's it.

Django Assignment

Complete the tutorial on the django website. You will create a Polls app. There are four parts to this tutorial.

It is important you do all the steps in the tutorial to get comfortable defining models, views, templates, and using the interactive shell and the admin app. Understanding the concepts will make the project go much quicker.

  • Part 1
    • Create a project
    • Start the development server
    • Setup an SQLite database
    • Create the Polls app and define the models
    • Interact with the database using the interactive python shell
  • Part 2
    • Activate the admin site
    • Add the poll app to the admin site
    • Modify the database using the admin site
  • Part 3
    • Configure URL handling
    • Create some views
  • Part 4
    • Write a form that modifies the database
    • Refactor to use generic views

Group Project

You may work in pairs on this project. Your group will create a new project using one of the options below.

Option 1: Image Tagging/Browsing Site

A site that lets users upload images, apply multiple tags to them, and browse through images of a certain tag. When looking at an image, it lists all associated tags so you can switch albums.

Requirements

  • Make a backend database that stores images and tags. An image can have multiple tags, and each tag can have multiple images.
  • The home page should allow users to find tags that they want to view. (e.g. lolcat).
  • After clicking a link to a tag, it should take you to a page with the newest image for that tag.
  • Clicking on the current image should take to to the next image according to date added. When at the last image, link to the first.
  • Make it clear which tag you are currently browsing. Beside or below the current image, also display the full list of tags that belong to the current image (e.g. lolcat, meme, internet, funny). You should be able to click on any of the tags to begin looking through that collection of images.
  • Provide a way for users who are logged in to add new images and new tags.
  • Validate user input
  • Provide a way for users to register, login, and change their password.
  • Have a link that sends an email to a user with a link for resetting their password in case they forget it.
  • Style the site with statically-served CSS (i.e. link to static .css files and don't write CSS inside the html templates)

Notes

  • You may store images as an external web links.
  • Try to find and figure out as many Django shortcuts as you can. You do not need to write your own url parsing, validation, login/registration/reset forms etc. For these common tasks, there is almost always built-in functionality that will do what you want in very few lines.
  • The admin interface and the interactive python shell will be very helpful when getting started with the database.
  • It may be helpful to use the ordering in the Grading section as a plan of attack.

Option 2: Create Your Own

Read the details for option 1 to get a feel for how big the project should be. Before you begin, work with the professor or TA's to create a grading rubric.

Pick something that is database-driven, and can leverage the features of Django to get things up and running quickly.

Grading

Due Date: ??

Python Assignment Points
Compute Final Grades 1
Compute Letter Grade 1
Sort by Last Name 1
Accept Command Line Argument 1
Django Assignment:
Models defined and database set up 1
Admin app enabled and working 1
urls matched to correct views 1
Templates for viewing and voting using generic views 1
Group Portion:
Models defined and database set up 2
View of single image with current tag and list of all tags 2
Navigation between images and tags 2
Main page displays all tags sorted by number of images 2
User registration, login/logout and change password 2
Forgot password send email with working reset link 2
Validation of all user input 2
Add new images and tags, only if logged in 2
Creative Portion 2


Total Points = 19