Esempio n. 1
0
def logout():
    session_token = request.cookies.get('token')
    API.delete_session(session_token)
    resp = make_response(
        render_template(login_page, message='You have been logged out'))
    resp.set_cookie('token', '')
    return resp
Esempio n. 2
0
def classList():
    authUser = API.get_authentication()
    if not authUser:
        return render_template(login_page, error='You are not logged in')
    return render_template(main_page,
                           username=API.get_authentication().first_name,
                           user_id=API.get_authentication().id)
Esempio n. 3
0
def get_student_gauge(live_lect_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(
        results=API.get_gauge_pace_and_depth(live_lect_id, authUser.id))
Esempio n. 4
0
def add_anon_question(live_lect_id, text):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return json.dumps(
        API.add_anonymous_question(live_lect_id, authUser.id, text))
Esempio n. 5
0
def create_polling_question(lecture_id, qtext, atext, btext, ctext, dtext,
                            ans):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(results=API.create_polling_question(
        lecture_id, qtext, atext, btext, ctext, dtext, ans))
Esempio n. 6
0
def add_live_student(live_lect_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    s1 = API.add_student_to_live_lecture(live_lect_id)
    s2 = API.update_gauge_pace_and_depth(live_lect_id, authUser.id, 0, 0)
    ret = s1 and s2
    return json.dumps(ret)
Esempio n. 7
0
def loginUser(email=None, name=None):
    user = None
    if not email and not name:
        email = request.form['email']
        password = request.form['userpass']
        user = API.validate_login(email, password)
    elif email and name:
        user = API.get_google_user(email, name)
    if user:
        session_token = API.create_session(user.id)
        if not session_token:
            return render_template(login_page, error='Failed to create token')
        resp = make_response(
            render_template(
                main_page,
                username=API.get_authentication(session_token).first_name,
                user_id=API.get_authentication(session_token).id))
        resp.set_cookie('token', str(session_token))
        return resp
    return render_template(login_page, error='Invalid email or password')
Esempio n. 8
0
def getClassList():
    authUser = API.get_authentication()
    if not authUser:
        return render_template(login_page, error='You are not logged in')
    class_list = []
    if API.is_student(authUser.id):
        class_list = API.get_student_class_list(authUser.id)
    else:
        class_list = API.get_professor_class_list(authUser.id)
    class_info = []
    for each_class in class_list:
        class_id = API.get_class_id(each_class)
        live_lecture_id = API.get_live_lecture(class_id)
        if live_lecture_id:
            class_info.append({
                'className': each_class,
                'id': class_id,
                'liveLectureId': live_lecture_id,
                'is_live': True
            })
        else:
            class_info.append({
                'className': each_class,
                'id': class_id,
                'liveLectureId': live_lecture_id,
                'is_live': False
            })
    return jsonify(results=class_info)
Esempio n. 9
0
def update_student_gauge():
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    try:
        json_data = request.get_json()
        live_lect_id = int(json_data['live_lect_id'])
        pace_num = float(json_data['pace_num'])
        depth_num = float(json_data['depth_num'])
    except ValueError:
        return json.dumps(False)
    prev = API.get_gauge_pace_and_depth(live_lect_id, authUser.id)
    if prev is None:
        prev = (0, 0)
    curr = (pace_num, depth_num)
    s1 = API.update_gauge_pace_and_depth(live_lect_id, authUser.id, pace_num,
                                         depth_num)
    s2 = API.change_total_pace_by(live_lect_id, curr[0] - prev[0])
    s3 = API.change_total_depth_by(live_lect_id, curr[1] - prev[1])
    ret = s1 and s2 and s3
    return json.dumps(ret)
Esempio n. 10
0
def get_live_lecture(class_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    liveLectureId = API.get_live_lecture(class_id)
    if liveLectureId:
        lectureId = API.get_lecture_from_live_lecture(liveLectureId)
    if liveLectureId and lectureId:
        lectureTitle = API.get_lecture_title(lectureId)
        return render_template('liveView.html',
                               username=API.get_authentication().first_name,
                               lecture_title=lectureTitle,
                               class_id=class_id,
                               user_id=API.get_authentication().id,
                               lecture_id=lectureId,
                               live_lecture_id=liveLectureId)
    return redirect(url_for('login'))
Esempio n. 11
0
def polling_questions_list(class_id, lecture_id):
    return render_template('pollingQuestionList.html',
                           class_id=class_id,
                           lecture_id=lecture_id,
                           username=API.get_authentication().first_name)
Esempio n. 12
0
def reset_gauges(live_lecture_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(results=API.reset_gauges(live_lecture_id))
Esempio n. 13
0
def delete_polling_question(polling_question_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(results=API.delete_polling_question(polling_question_id))
Esempio n. 14
0
def delete_class_student(student_id, class_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(results=API.delete_class_student(student_id, class_id))
Esempio n. 15
0
def set_student_classes(class_name, student_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return json.dumps(API.set_student_class(class_name, student_id))
Esempio n. 16
0
def get_curr_depth(live_lect_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return json.dumps(API.get_depth(live_lect_id))
Esempio n. 17
0
def get_live_lecture_id(class_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(live_lecture_id=API.get_live_lecture(class_id))
Esempio n. 18
0
def get_polling_questions_list(class_id, lecture_id):
    username = API.get_authentication().first_name
    return render_template('createPollingQuestion.html',
                           class_id=class_id,
                           lecture_id=lecture_id,
                           username=username)
Esempio n. 19
0
def get_anon_questions(live_lect_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return jsonify(results=API.get_anonymous_questions(live_lect_id))
Esempio n. 20
0
def join_lecture(live_lecture_id):
    return json.dumps(API.add_student_to_live_lecture(live_lecture_id))
Esempio n. 21
0
def disable_live_lecture(class_id):
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return json.dumps(API.disable_live_lecture(class_id))
Esempio n. 22
0
def present_polling_question(live_lecture_id, polling_qid):
    authUser = API.get_authentication()
    if not authUser:
        return jsonify(response="Not Authenticated")
    return jsonify(
        success=API.present_polling_question(live_lecture_id, polling_qid))
Esempio n. 23
0
def add_lecture(class_id, lecture_name):
    new_lecture_id = API.create_lecture(lecture_name, class_id)
    return json.dumps(new_lecture_id)
Esempio n. 24
0
def lect_list(class_id):
    return render_template('lectureList.html',
                           classId=class_id,
                           username=API.get_authentication().first_name)
Esempio n. 25
0
def login():
    if API.get_authentication():
        return render_template(main_page,
                               username=API.get_authentication().first_name,
                               user_id=API.get_authentication().id)
    return render_template(login_page)
Esempio n. 26
0
def user_id():
    auth = API.get_authentication()
    if auth:
        return jsonify(results=auth.id)
    return jsonify(results=[])
Esempio n. 27
0
def respond_to_polling_question(student_id, polling_qid, student_ans):
    authUser = API.get_authentication()
    if not authUser:
        return jsonify(response="Not Authenticated")
    return jsonify(success=API.respond_to_polling_question(
        student_id, polling_qid, student_ans))
Esempio n. 28
0
def createClass(className):
    authUser = API.get_authentication()
    if not authUser:
        return render_template(login_page, error='You are not logged in')
    return json.dumps(API.create_prof_class(className, authUser.id))
Esempio n. 29
0
def is_google_user():
    return jsonify(results=API.is_google_account())
Esempio n. 30
0
def stop_polling_questions(live_lecture_id):
    authUser = API.get_authentication()
    if not authUser:
        return jsonify(response="Not Authenticated")
    return json.dumps(API.stop_polling_questions(live_lecture_id))