Exemplo n.º 1
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)
Exemplo n.º 2
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))
Exemplo n.º 3
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)
Exemplo 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))
Exemplo 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))
Exemplo n.º 6
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'))
Exemplo n.º 7
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)
Exemplo n.º 8
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')
Exemplo 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)
Exemplo n.º 10
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)
Exemplo 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)
Exemplo 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))
Exemplo 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))
Exemplo n.º 14
0
def is_student():
    authUser = API.get_authentication()
    if not authUser:
        return render_template(login_page, error='You are not logged in')
    return jsonify(results=API.is_student(authUser.id))
Exemplo n.º 15
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))
Exemplo n.º 16
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))
Exemplo 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))
Exemplo n.º 18
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))
Exemplo n.º 19
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))
Exemplo n.º 20
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))
Exemplo 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))
Exemplo n.º 22
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))
Exemplo n.º 23
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))
Exemplo n.º 24
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))
Exemplo 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)
Exemplo n.º 26
0
def lect_list(class_id):
    return render_template('lectureList.html',
                           classId=class_id,
                           username=API.get_authentication().first_name)
Exemplo n.º 27
0
def user_id():
    auth = API.get_authentication()
    if auth:
        return jsonify(results=auth.id)
    return jsonify(results=[])
Exemplo n.º 28
0
def prof_home():
    authUser = API.get_authentication()
    if not authUser:
        return render_template('authentication/login.html',
                               error='You are not logged in')
    return render_template('professorView/classList.html')