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 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)