def submitGeneralQuestions(): questions= getQuestions() Answers=[] for question in questions: answer=request.form.get("answer"+question) Answers.append(answer) submitAnswers(Answers) return index()
def update_ques(user_ask, coin): try: icoin = int(coin) list_questions = getQuestions() q = question(list_questions, user_ask) cur_coin = q.coin - icoin sql = "UPDATE users SET coin = {} WHERE user_ask={}".format( cur_coin, user_ask) conn = mysql.connect() cursor = conn.cursor() cursor.execute(sql) conn.commit() res = jsonify('User updated successfully.') res.status_code = 200 return res except Exception as e: print(e) finally: cursor.close() conn.close()
def mentor(): list_questions = getQuestions() return render_template('mentor.html', template_list_questions = list_questions, template_name = "mentor")
def chatroom(username): list_questions = getQuestions() q = question(list_questions, username) return render_template('chatroom.html', template_q = q)
def gameLogic(self, form): # Pregame prep self.disp.restart() ROUND_TIME = self.get_config('TIME', 'ROUND_TIME', type=int, default=10) self.disp.setRoundTimer(ROUND_TIME) self.disp.setGameTimer( self.get_config('TIME', 'GAME_TIME', type=int, default=300)) self.disp.playVideo(self.get_config('VIDEOS', 'SPLASH', type=str)) self.sleep(self.get_config('TIME', 'START_DELAY', type=int, default=1)) plyrs = assignPlayers(len(self.team), self.manager) Q = questions.getQuestions(self.get_config('LINK', 'DB_URL')) P = cyclePlayers(plyrs) for b in self.manager: for i in range(32): b.turnOff(i + 1) b.run() for b in self.manager: for i in range(32): b.turnOn(i + 1) b.run() while True: # Match player to question question = next(Q) logger.debug("Got question") player = next(P) logger.debug("Got player") # Step 1: invite player self.block() logger.debug("Invite player") for b in self.manager: for i in range(32): b.turnOff(i + 1) b.run() # player.flash(Times.Invite_Sleep) player.lightAll(True) logger.debug("Light player podium") self.disp.invitePlayer(player._id) logger.debug("Invite player flash") # self.disp.playAudio(START_MUSIC) # self.startRound() # Step 2: Display question self.block() logger.debug("Loading question") question.show() displayQuestion(self.disp, question) logger.debug("Posted question to display") # Step 3: Judge answer self.block() logger.debug("Judging answer") ans = player.catchAnswer(ROUND_TIME, self.round_tick) logger.debug("Caught answer %s" % ans) if ans is None: logger.debug("Answer is none") raise Exception('Answer cannot be none') if ans == '': self.disp.timeout() logger.debug("Display timeout flash") self.subScore(1) logger.debug("Sub 1 from score") else: if question == ans: logger.debug("Correct answer") self.disp.doCorrect() self.disp.setSelected(ans) logger.debug("Correct answer flash") self.addScore(1) logger.debug("Add score") else: self.disp.doWrong() logger.debug("Wrong answer flash") self.disp.setSelected(ans) logger.debug("Set %a to selected" % ans) self.subScore(1) logger.debug("Sub one from score") # Step 4 disinvite player logger.debug("Disinvite player") self.disp.flush() logger.debug("Clear display buffer") player.lightAll(False) logger.debug("Turn off podium") # self.stopRound() self.sleep( self.get_config('TIME', 'BETWEEN_ROUNDS', type=int, default=1))
def questionOverview(): questions = getQuestions() return render_template("questionOverview.html", questions=questions)