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)
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))
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)
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))
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))
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'))
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)
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')
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)
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)
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)
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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))
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)
def lect_list(class_id): return render_template('lectureList.html', classId=class_id, username=API.get_authentication().first_name)
def user_id(): auth = API.get_authentication() if auth: return jsonify(results=auth.id) return jsonify(results=[])
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')