Permalink
Browse files

more

  • Loading branch information...
2 parents 00cb9f8 + 206562c commit f362b44794b6b82fed0961ab9d5d301338dfc54f Ian Outhwaite committed Oct 15, 2012
Showing 340 changed files with 15,622 additions and 358 deletions.
View
@@ -5,10 +5,10 @@ Group 7UP
## Members: ##
-* Benjamin Huber
-* Ian Outhwaite
-* Raymond Zeng
-* Zachary Zimmerman
+* Benjamin Huber - app part (apple.py)
+* Ian Outhwaite - utils and database (all in datastorage.py)
+* Raymond Zeng - utils and database (all in datastorage.py)
+* Zachary Zimmerman - html templates (in templates folder)
## Progress: ##
View
@@ -3,9 +3,21 @@
import math
from flask import session,url_for,redirect,flash
+global questions
+#global email
+
+questions = []
+for line in open('question.txt').readlines():
+ questions.append(line)
+
+
+
+
+
app = Flask(__name__)
app.secret_key = 'some_secret'
+<<<<<<< HEAD
global questions
global email
global loggedin
@@ -16,6 +28,13 @@
def home():
if email in session:
return redirect(url_for('/rate'))
+=======
+
+@app.route("/",methods=['GET','POST'])
+def home():
+ if session.get('username'):
+ return redirect(url_for('rate'))
+>>>>>>> 206562c3275e328c9bdd4725a1dfd34a6a88a7a7
else:
return redirect(url_for('/login'))
@@ -38,64 +57,102 @@ def logout():
@app.route('/rate', methods=['GET','POST'])
def rate():
- if email in session:
- if request.method=='POST':
- rater = email
- rating1 = request.form('question1')
- rating2 = request.form('question2')
- rating3 = request.form('question3')
- ratee = request.form('ratees')
- datastorage.ratePerson(rater=rater, ratee=ratee,question=questions[1],score=rating1,comments=None)
- datastorage.ratePerson(rater=rater, ratee=ratee,question=questions[2],score=rating2,comments=None)
+ if session.get('username'):
+ #if request.method == 'POST':
+
+ if email == None:
+ return redirect(url_for('login'))
+ info = datastorage.getData(email)
- datastorage.ratePerson(rater=rater, ratee=ratee,question=questions[3],score=rating2,comments=None)
- info = datastorage.getData(email)
- projects = []
- count = 1
- while(count <= len(info)):
- projects.append(datastorage.getGroupMembers(email,count))
- count = count + 1
+ projects = []
+ count = 1
+ while(count <= len(info)):
+ projects.append(datastorage.getGroupMembers(email,str(count)))
+ count = count + 1
- numratings = 0
- sumratings = 0
- scores = []
- for projs in info:
- for ratings in info[projs]:
- numratings = numratings + 1
- sumratings = sumratings + info[projs][ratings]['score']
- scores.append(info[projs][ratings]['score'])
- avgrating = sumratings / numratings
+ numratings = 0
+ sumratings = 0
+ scores = []
+ for projs in info:
+ for ratings in projs:
+ numratings = numratings + 1
+ # sumratings = sumratings + info[projs][ratings]['score']
+ # scores.append(info[projs][ratings]['score'])
+ avgrating = datastorage.getAvgOverallIndividualPoints(email)
+ stdev = 0
+ if numratings != 0:
ex = 0
for score in scores:
- ex = ex + (scores[score]-avgrating) * (scores[score]-avgrating)
- stdev = sqrt(ex/numratings)
+ ex = ex + (score-avgrating) * (score-avgrating)
+ stdev = math.sqrt(ex/numratings)
- first = datastorage.getFirst(email)
- last = datastorage.getLast(email)
+ first = datastorage.getFirst(email)
+ last = datastorage.getLast(email)
- questions=['how smart was your groupmate', 'how much did they help', 'blah,blah, blah']
+ questionavgs=[]
+
+ for x in range(len(questions)):
+ r=0
+ for i in range(len(info)):
+ r=r+datastorage.getTotalIndividualAvgForQuestion(email,x)#(email,i+1,questions[x])
+ questionavgs.append(r/len(info))
+ loggedin=True
+
- questionavgs=[]
- for x in range(len(questions)):
- r=0
- for i in range(len(info)):
- r=r+datastorage.getAvgForQuestion(email,i+1,questions[x])
- questionavgs.append(r/len(info))
+
+ if request.method == 'POST':
+
+ rater = email
+ ratee = request.form('ratees')
+ num = 0
+ for n in questions:
+ datastorage.ratePerson(rater=rater, ratee=ratee,question=n,score=request.form(n),comments=None)
+ # rating1 = request.form('question1')
+ # rating2 = request.form('question2')
+ # rating3 = request.form('question3')
+
+ # datastorage.ratePerson(rater=rater, ratee=ratee,question=questions[1],score=rating1,comments=None)
+ # datastorage.ratePerson(rater=rater, ratee=ratee,question=questions[2],score=rating2,comments=None)
+
+ # datastorage.ratePerson(rater=rater, ratee=ratee,question=questions[3],score=rating2,comments=None)
+
+
+ return render_template('index.html',loggedin=True,projects=projects,questions=questions,avgrating=avgrating,stdev=stdev,questionavgs=questionavgs)
+ #return render_template('index.html', loggedin=True)
- return render_template('index.html',loggedin=True,projects=projects,questions=questions,\
-avgrating=avgrating,stdex=stdev,questionavgs=questionavgs)
+<<<<<<< HEAD
+=======
+
+@app.route('/login', methods=['GET','POST'])
+def login():
+ if request.method == 'POST':
+ ermail = request.form["username"]
+ paswrd = request.form["idnum"]
+ if datastorage.isUser(ermail):
+ loggedin = True
+ session["username"]=True
+ global email
+ email = ermail
+ return redirect(url_for('home'))
+ return render_template('index.html',loggedin=False,projects=None,questions=questions,avgrating=None,stdex=None,questionavgs=None)
+
+@app.route('/logout')
+def logout():
+ session.pop('username', None)
+ return redirect(url_for('home'))
+>>>>>>> 206562c3275e328c9bdd4725a1dfd34a6a88a7a7
if __name__=="__main__":
app.debug=True # remove this line to turn off debugging
- app.run() # connect to localhost:5000 or http://127.0.0.1:5000
+ app.run(port=7007) # connect to localhost:5000 or http://127.0.0.1:5000
View
@@ -4,9 +4,150 @@
<head>
<title> Home </title>
<meta http-equiv="Content-Language" content="en-us" />
- <!--<style type="text/css" media="all">@import "style.css";</style>
- <style type="text/css" media="screen and (max-width: 760px)">@import "mobile.css";</style>-->
- <link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css')}}">
+ <style type="text/css" media="all">
+
+ * { margin: 0; padding: 0; font-family: Georgia; }
+
+ html,body { width: 100%; height: 100%; min-width: 330px; }
+
+ h3 { padding-bottom: 8px; }
+
+ header
+ {
+ width: 100%;
+ height: 60px;
+ background-color: #DDD;
+ border-bottom: 5px solid #666;
+ }
+
+ header ul
+ {
+ list-style: none;
+ }
+
+ header ul li a
+ {
+ color: #666;
+ display: block;
+ width: 33.33%;
+ height: 60px;
+ text-align: center;
+ text-transform: uppercase;
+ font-size: 30px;
+ line-height: 60px;
+ float: left;
+ }
+
+ header ul li a.selected
+ {
+ background-color: #666;
+ color: #DDD;
+ }
+
+ header ul li a:hover, header ul li a:focus, header ul li a:active
+ {
+ color: black;
+ }
+
+ input[type="password"], input[type="text"]
+ {
+ width: 100px;
+ }
+
+ input[type="submit"]
+ {
+ width: 100px;
+ text-align: center;
+ }
+
+ body>div
+ {
+ width: 28%;
+ float: left;
+ padding: 20px 2.66%;
+ }
+
+ body>div h1
+ {
+ text-align: center;
+ font-size: 20px;
+ padding-bottom: 15px;
+ }
+
+ body>div form, body>div#stats dl, body>div#stats h3
+ {
+ text-align: center;
+ max-width: 260px;
+ width: 88%;
+ margin-left: auto;
+ margin-right: auto;
+ }
+
+ body>div form *
+ {
+ text-align: left;
+ margin-bottom: 10px;
+ }
+
+ body>div#login form
+ {
+ max-width: 200px;
+ }
+
+ #login form p
+ {
+ text-align: right;
+ }
+
+ dl
+ {
+ background-color: #DDD;
+ border: 1px solid #666;
+ padding: 10px;
+ margin-bottom: 10px;
+ text-transform: uppercase;
+ }
+
+ dl dt
+ {
+ float: left;
+ }
+
+ dl dd
+ {
+ float: right;
+ }
+
+ body>div.selected
+ {
+ background-color: #EAEAAE;
+ }
+
+ @media only screen and (max-width : 330px)
+ {
+ header
+ {
+ width: 330px;
+ }
+
+ header ul li a
+ {
+ width: 110px;
+ }
+ }
+
+ </style>
+
+ <style type="text/css" media="screen and (max-width: 760px)">
+
+ body>div
+ {
+ width: 100%;
+ padding: 20px 0;
+ }
+
+ </style>
+
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
@@ -39,7 +180,7 @@
<form method="POST" action="">
- <select name='ratees'>
+ <select name="ratees" >
{% for proj in projects %}
<optgroup label="Project {{loop.index}}">
{% for person in proj %}
@@ -54,7 +195,7 @@
{% set qnum=loop.index %}
<li>{{question}}<br />
{% for number in range(10) %}
- <input type="radio" name="question{{qnum}}" value="{{number}}"> {{number}}
+ <input type="radio" name="{{question}}" value="{{number}}"> {{number}}
{% endfor %}
</li>
{% endfor %}
@@ -93,9 +234,9 @@
<h3>Average per question:</h3>
<dl>
- {% for avgs in questionavgs %}
+ {% for question in questionavgs %}
<dt>Question {{loop.index}}:</dt>
- <dd>{{avgs}}</dd> <br />
+ <dd>{{question}}</dd> <br />
{% endfor %}
<div style="clear:both;"></div>
</dl>
Oops, something went wrong.

0 comments on commit f362b44

Please sign in to comment.