Exemplo n.º 1
0
def home():
    global email
    
    #email = databaseMethods.getCurrentStudent()
    grades = databaseMethods.retrieveGrades(email)
    q1 = getGradeList(0, grades)
    q2 = getGradeList(1, grades)
    q3 = getGradeList(2, grades)
    q4 = getGradeList(3, grades)
    g1 = getGrades(q1)
    g2 = getGrades(q2)
    g3 = getGrades(q3)
    g4 = getGrades(q4)
    a1 = getAverage(q1)
    a2 = getAverage(q2)
    a3 = getAverage(q3)
    a4 = getAverage(q4)
    if request.method == "GET":
        name = getStudentName()
        return render_template("home.html",
                               name = name,
                               g1 = g1,
                               a1 = a1,
                               g2 = g2, 
                               a2 = a2,
                               g3 = g3, 
                               a3 = a3,
                               g4 = g4, 
                               a4 = a4)
    else:
        return redirect(url_for('rate/'))
Exemplo n.º 2
0
def rate():
    global email
    
    #email = databaseMethods.getCurrentStudent()
    #retrieve the info of the student who logged in
  #studentInfo = databaseMethods.retrieveStudentInfo(email)
    
    #get the group number of that student
    #groupNumber = databaseMethods.getGroupNumber(email)

    #get the members of that group

    groupMembers = databaseMethods.retrieveGroupMembers(email)

    #getMyGrades(email)
    
    f = open("questions.txt", "r").readlines()
    q1 = f[0]
    q2 = f[1]
    q3 = f[2]
    q4 = f[3]
    
    p = getGroupMembers(email)
    # p1 = getGroupMembers(email, 0)
    # p2 = getGroupMembers(email, 1)
    # p3 = getGroupMembers(email, 2)
    
    p1 = p[0]
    p2 = p[1]
    p3 = p[2]


    userInfo = databaseMethods.retrieveGrades(email)
    if request.method == "GET":
        return render_template("rate.html", 
                               p1=p1,
                               p2=p2,
                               p3=p3,
                               q1=q1,
                               q2=q2,
                               q3=q3,
                               q4=q4)
    else:
        x = 0
        s = databaseMethods.retrieveGroupMembers(email)
        e1 = ""
        e2 = ""
        e3 = ""
        for each in range(0,4):
            if s[each] == email:
                pass
            else:
                if e1 == "":
                    e1 = s[each]
                else:
                    if e2 == "":
                        e2 = s[each]
                    else:
                        e3 = s[each]
        
               
#        print e1,e2,e3   
        button=request.form['button'] 
        m1 = [int(request.form['p1q1']),int( request.form['p1q2']), int(request.form['p1q3']), int(request.form['p1q4'])]
        m2 = [int(request.form['p2q1']),int( request.form['p2q2']),int( request.form['p2q3']), int(request.form['p2q4'])]
        m3 = [int(request.form['p3q1']),int( request.form['p3q2']), int(request.form['p3q3']),int( request.form['p3q4'])]
        # print m1
        # print m2
        # print m3
        databaseMethods.setGrades(m1 , e1)
        databaseMethods.setGrades(m2, e2)
        databaseMethods.setGrades(m3, e3)