def gettopic(roundnum, indexnum, sessionid): outval = genfunc.queryfield(adminmodels.Sessions, "sessid", int(sessionid))[0] print(outval) questions = eval("outval.topic_" + str(roundnum)) maintopic = questions[0] stance = questions[int(indexnum)] return maintopic, stance
def updateroundnum(sessid): session = genfunc.queryfield(adminmodels.Sessions, "sessid", int(sessid))[0] if session.round_num > 3: return True, -1 session.round_num += 1 session.put() time.sleep(2) return False, session.round_num
def timedif(sessionid, timeallowed): session = genfunc.queryfield(adminmodels.Sessions, "sessid", int(sessionid))[0] timedelta = session.session_start - datetime.datetime.now() secdelta = timedelta.total_seconds() + timeallowed return round(secdelta / 60, 6)
def querytopic(topic_category="", fieldval=""): outval = genfunc.queryfield(contentmodels.Topics, topic_category, str(fieldval)) #"" is user input category outputdict = {"topic": outval} return outputdict
def getroundnum(sessid): outval = genfunc.queryfield(adminmodels.Sessions, "sessid", int(sessid))[0] return outval.round_num
def querytopicrand(topic_category="", fieldval=""): outval = genfunc.queryfield(contentmodels.Topics, topic_category, str(fieldval)) random.shuffle(outval) outputdict = {"topic": outval} return outputdict