예제 #1
0
파일: app.py 프로젝트: flywind2/ohms
def calculate_grade(user, hw):
    """
    helper function that calculates a student's grade on a given homework
    """

    # total up the points
    score = 0.
    if len(hw.questions) == 0:
        return None
    for q in hw.questions:
        out = q.load_response(user)
        if out['submission'] is None:
            continue
        elif out['submission'].score is None:
            return None
        else:
            score += out['submission'].score
    # fill in grades
    grade = get_grade(user.stuid, hw.id)
    if not grade:
        add_grade(user, hw, score)
    elif grade.score != score:
        grade.score = score
    else:
        return grade

    return grade
예제 #2
0
파일: app.py 프로젝트: dlsun/ohms
def calculate_grade(user, hw):
    """
    helper function that calculates a student's grade on a given homework
    """

    # total up the points
    score = 0.
    if len(hw.questions) == 0:
        return None
    for q in hw.questions:
        out = q.load_response(user)
        if out['submission'] is None:
            continue
        elif out['submission'].score is None:
            return None
        else:
            score += out['submission'].score
    # fill in grades
    grade = get_grade(user.stuid, hw.id)
    if not grade:
        add_grade(user, hw, score)
    elif grade.score != score:
        grade.score = score
    else:
        return grade

    return grade
예제 #3
0
파일: app.py 프로젝트: flywind2/ohms
def update_grade():
    admin = validate_admin()

    stuid = request.form['stuid']
    hw_id = request.form['hw_id']
    score = request.form['score'].strip()
    excused = 1 if request.form['excused'] == "true" else 0

    # check that score is valid
    try:
        float(score)
    except:
        assert (score in ["", "E"])

    # fill in grades
    grade = get_grade(stuid, hw_id)
    if not grade:
        add_grade(get_user(stuid), get_homework(hw_id), score, excused)
    else:
        grade.score = score
        grade.excused = excused
    session.commit()

    return "Grade update successful!"
예제 #4
0
파일: app.py 프로젝트: dlsun/ohms
def update_grade():
    admin = validate_admin()

    stuid = request.form['stuid']
    hw_id = request.form['hw_id']
    score = request.form['score'].strip()
    excused = 1 if request.form['excused'] == "true" else 0

    # check that score is valid
    try:
        float(score)
    except:
        assert(score in ["", "E"])

    # fill in grades
    grade = get_grade(stuid, hw_id)
    if not grade:
        add_grade(get_user(stuid), get_homework(hw_id), score, excused)
    else:
        grade.score = score
        grade.excused = excused
    session.commit()

    return "Grade update successful!"