コード例 #1
0
ファイル: test_user.py プロジェクト: phyhuhu/yummylog
    def setUp(self):
        """Create test client, add sample data."""
        db.drop_all()
        db.create_all()

        que1 = Questions(question='What is the name of your first pet?')
        que2 = Questions(question='Where did you grow up?')
        que3 = Questions(question='What is your favorite food?')

        db.session.add_all([que1, que2, que3])
        db.session.commit()

        u1 = Users.signup("test1", "*****@*****.**", "password", 1, 'answer',
                          None, None, None, None)
        uid1 = 1111
        u1.id = uid1

        u2 = Users.signup("test2", "*****@*****.**", "password", 2, 'answer',
                          None, None, None, None)
        uid2 = 2222
        u2.id = uid2

        db.session.commit()

        u1 = Users.query.get(uid1)
        u2 = Users.query.get(uid2)

        self.u1 = u1
        self.uid1 = uid1

        self.u2 = u2
        self.uid2 = uid2

        self.client = app.test_client()
コード例 #2
0
ファイル: test_food.py プロジェクト: phyhuhu/yummylog
    def setUp(self):
        """Create test client, add sample data."""
        db.drop_all()
        db.create_all()

        # ===============
        api1 = APIs(
            api='TheMealDB',
            api_url='https://www.themealdb.com/api.php?ref=apilist.fun')
        api2 = APIs(
            api='TheCockTailDB',
            api_url='https://www.thecocktaildb.com/api.php?ref=apilist.fun')
        api3 = APIs(api='EDAMAM', api_url='https://www.edamam.com/')
        api4 = APIs(
            api='IBM_text_to_speech',
            api_url='https://cloud.ibm.com/apidocs/text-to-speech?code=python')
        api5 = APIs(
            api='Recipe Puppy',
            api_url='http://www.recipepuppy.com/about/api/?ref=apilist.fun')

        db.session.add_all([api1, api2, api3, api4, api5])
        db.session.commit()

        que1 = Questions(question='What is the name of your first pet?')
        que2 = Questions(question='Where did you grow up?')
        que3 = Questions(question='What is your favorite food?')

        db.session.add_all([que1, que2, que3])
        db.session.commit()

        meals = requests.get(
            'https://www.themealdb.com/api/json/v1/1/list.php?c=list')
        categories = json.loads(meals.text)['meals']

        food_categories = [
            FoodCategories(food_category=i['strCategory']) for i in categories
        ]
        food_categories.append(FoodCategories(food_category='Unknown'))
        db.session.add_all(food_categories)
        db.session.commit()

        meals = requests.get(
            'https://www.themealdb.com/api/json/v1/1/list.php?a=list')
        areas = json.loads(meals.text)['meals']

        food_areas = [FoodAreas(food_area=i['strArea']) for i in areas]
        db.session.add_all(food_areas)
        db.session.commit()
        # ===============

        self.uid = 94566
        u = Users.signup("test", "*****@*****.**", "password", 1, 'answer',
                         None, None, None, None)
        u.id = self.uid
        db.session.commit()

        self.u = Users.query.get(self.uid)

        self.client = app.test_client()
コード例 #3
0
def addQues(request):
    if request.method == 'POST':

        QuestionList = request.POST.getlist('QuestionList')
    else:
        print "testing"
    for i in QuestionList:
        newQues = Questions()
        newQues.ques = i
        newQues.save()
        Q = Questions.objects.all()
    return render(request, "preview.html", {'Q1': Q})
コード例 #4
0
def post_questions():
    error = False
    response = {}
    body = request.get_json()
    if body:
        quest = body.get('question')
        answer = body.get('answer')
        difficulty = body.get('difficulty')
        cat = body.get('cat')
        if quest and answer and difficulty:
            try:
                question = Questions(id=None,
                                     question=quest,
                                     answer=answer,
                                     difficulty=difficulty,
                                     cat=cat)
                question.insert()
                response['new question id'] = question.id
            except:
                error = True
                question.rollback()
                print(sys.exc_info())
                abort(500)
            finally:
                question.sesion_close()
        else:
            print(sys.exc_info())
            abort(400)
    else:
        print(sys.exc_info())
        abort(400)
    response['success'] = True
    return jsonify(response)
コード例 #5
0
ファイル: views.py プロジェクト: Alexandrov-Michael/helpdesk
 def create_question(self, user_from, user_to, body, post, department=None, pc_from=None, worker_from=''):
     """
     Создание вопроса
     """
     question = Questions(
         user_from=user_from,
         pc_from=pc_from,
         worker_from=worker_from,
         user_to=user_to,
         body=body,
         date=now(),
         post=post,
         department=department,
     )
     question.save()
     self.update_slug_plus(question=question, user=self.user)
コード例 #6
0
def question():
    if request.method == 'GET':
        return render_template('question.html')
    else:
        title = request.form.get('title')
        content = request.form.get('content')
        # user_id = session.get('user_id')
        # user = User.query.filter(User.id == user_id).first()
        user = g.user
        questions = Questions(title=title, content=content)
        questions.author = user
        db.session.add(questions)
        db.session.commit()
        # print("---------------------------------------------")
        # return render_template('index.html')
        return redirect(url_for('index'))
コード例 #7
0
    def manage_deck():

        form = MainFormNoLabel()

        # insert for the Stanza
        note = form.create_questions.note.data.strip()

        deck_name = form.create_questions.deck_name.data.strip()

        sentences_list = text_area_field_handler(note)

        # assign output from the Stanza into database
        stanza_output = stanza_wrapper(sentences_list)

        if form.validate():
            flash(form.errors)
            return redirect(url_for('/'))

        else:
            error_in_insert = False

            try:

                new_deck = Decks(name=deck_name)
                db.session.add(new_deck)

                for index, record in stanza_output.iterrows():

                    new_record = AuditTrail(username="******")

                    db.session.add(new_record)

                    new_question = Questions(question=record['Question'],
                                             answer=record['Answer'],
                                             sentence=record['Sentence'],
                                             auditTrail=new_record)

                    db.session.add(new_question)

                    # https://stackoverflow.com/questions/16433338/inserting-new-records-with-one-to-many-relationship-in-sqlalchemy
                    new_deck.auditTrail.append(new_record)

                db.session.commit()

            except Exception as e:
                error_in_insert = True
                print(f'Exception "{e}" in manage_deck()')
                db.session.rollback()
            finally:
                db.session.close()

            if not error_in_insert:
                return redirect(url_for('index'))
            else:
                print("Error in manage_deck()")
                abort(500)
コード例 #8
0
def add_question(username, text, answer, is_one_attempt, score):
    question = Questions(creator=username,
                         text=text,
                         time=get_current_datetime(),
                         correct_answer=answer,
                         one_attempt=is_one_attempt,
                         score=score,
                         total_answers=0)
    db.session.add(question)
    db.session.commit()
コード例 #9
0
ファイル: test_crud.py プロジェクト: YurikAbdulayev/test_prof
def create_question(json):
    question = Questions(json["body"], json["direction"], json["test_id"],
                         json["is_control"])
    # question = Questions(json["body"], json["direction"], json["test_id"], False)
    db.session.add(question)
    db.session.flush()
    answers = json["answers"]
    for answer in answers:
        create_answers(answer, question.id)
    db.session.commit()
コード例 #10
0
ファイル: api.py プロジェクト: mohammadH95/WouldYouRather
    def create_question(token):
        try:
            body = request.get_json()

            new_id = body.get('id', None)
            new_optionOne = body.get('optionOne', None)
            new_optionTwo = body.get('optionTwo', None)
            author = body.get('user_id', None)

            question = Questions(id=new_id, author=author, optionOne=new_optionOne, optionTwo=new_optionTwo)
            question.insert()

            question = question.format()
            
            return jsonify({
                'success': True,
                'created': question
            })    
        except:
            abort(422)
コード例 #11
0
def post(request, ptype, pk):
    """Display a post form."""
    action = reverse("BCAforum.views.%s" % ptype, args=[pk])
    if ptype == "new_thread":
        title = "Ask a question"
        subject = ''
    elif ptype == "reply":
        title = "Answer"
        subject = "Re: " + Questions.get(pk).question

    return render_to_response("question.html", add_csrf(request, subject=subject,
        action=action, title=title))
コード例 #12
0
ファイル: Demo.py プロジェクト: lili0219/DemoBlog
def post():
    if request.method == 'GET':
        return render_template("post.html")
    else:
        title = request.form.get('title')
        content = request.form.get('content')
        user_id = session.get('user_id')
        author = User.query.filter(id=user_id)
        question = Questions(title=title, content=content, author=author)
        db.session.add(question)
        db.session.commit()
        return redirect(url_for("index"))
コード例 #13
0
def submit():
    # Validate form submission server side - check that all the required 'name="xyz"' attributes
    # are received. if not, redirect to error. (server-side)
    if not request.form.get("year"):
        return render_template("error.html",
                               message="You failed to provide a year")
    if not request.form.get("choosequestion"):
        return render_template(
            "error.html", message="You failed to provide a question number")
    if not request.form.get("answer"):
        return render_template("error.html",
                               message="You failed to provide an answer")

    year = request.form.get('year')
    question = request.form.get('choosequestion')
    answer = request.form.get('answer')
    # Check answer, using our check function in solutions.py.
    response = check(year, question, answer)
    if response == "correct":
        if current_user.is_authenticated:
            # Find question_id from the Questionnames static table, to insert as foreign key in
            # Questions record
            questionAnswered = year + '-' + question
            question_row = Questionnames.query.filter_by(
                question_number=questionAnswered).first()
            question_id = question_row.question_id
            # Insert the solution into the Questions record, so user knows they've solved this one
            user = User.query.filter_by(email=current_user.email).first()
            already_solved = Questions.query.filter_by(user_id=user.id, question_id=question_id).\
                first()
            if already_solved:
                flash(
                    f"Well done, you solved {year}'s Question #{question} - {answer} is correct!\
                        But you've solved this one before!", 'info')
            else:  # Has not solved this puzzle yet
                this_solved = Questions(question_id=question_id,
                                        user_id=user.id)
                db.session.add(this_solved)
                db.session.commit()
                flash(
                    f"Well done, you solved {year}'s Question #{question} - {answer} is correct!",
                    'success')
        else:
            flash(
                f"Well done, you solved {year}'s Question #{question} - {answer} is correct!",
                'success')
    else:
        flash(
            f"Unfortunately, {answer} is not the correct answer for {year}'s Question\
              #{question}", 'danger')
    return redirect(url_for('index'))
コード例 #14
0
 def create_question(self,
                     user_from,
                     user_to,
                     body,
                     post,
                     department=None,
                     pc_from=None,
                     worker_from=''):
     """
     Создание вопроса
     """
     question = Questions(
         user_from=user_from,
         pc_from=pc_from,
         worker_from=worker_from,
         user_to=user_to,
         body=body,
         date=now(),
         post=post,
         department=department,
     )
     question.save()
     self.update_slug_plus(question=question, user=self.user)
コード例 #15
0
def post():
    if request.method =='GET':
        return render_template('post.html')
    else:
        #从前端录入form
        title = request.form.get('title')
        content = request.form.get('content')
        user_id = session.get('user_id')
        user = User.query.filter(User.id == user_id).first()
        question = Questions(title=title, content=content, author=user)
        db.session.add(question)
        db.session.commit()

        return redirect(url_for('index'))
コード例 #16
0
ファイル: app.py プロジェクト: knightrohit/flash-quiz-app
def add_ques():
    if request.method == 'POST':
        #Fetch form data
        ques_detail = request.form
        ques = ques_detail['question']
        opt1 = ques_detail['option1']
        opt2 = ques_detail['option2']
        opt3 = ques_detail['option3']
        opt4 = ques_detail['option4']
        ans = ques_detail['answer']

        ques_obj = Questions(ques, opt1, opt2, opt3, opt4, ans)
        db.session.add(ques_obj)
        db.session.commit()
    return render_template('feed_question.html')
コード例 #17
0
ファイル: app.py プロジェクト: Renddslow/hn5club.house
def questions():
	_form = request.form
	#setup = requests.get("https://api.flatlandchurch.com/v1/sms/settings?number=14025094631", verify=False).json()
	setup = {
		'is_active': True,
		'numbers': ['+14028850620', '+14026900493']
	}
	response = Element('Response')
	message_tag = SubElement(response, 'Message')

	lonely = Lonely()

	if setup['is_active'] and _form['From'] is not "+16103347182":
		for number in setup['numbers']:
			lonely.client.messages.create(
				body = _form['Body'],
				to = number,
				from_ = "+14025094631"
			)
		message_tag.text = "Thanks so much for your question! If we are unable to get to your question tonight, we recommend reaching out to your life group leader or [email protected]."
		try:
			sender = Questions.get(question_sender = _form['From'])
		except Questions.DoesNotExist:
			Questions.create(
				question_text = _form['Body'],
				question_sender = _form['From']
			)
		else:
			Questions.create(
				question_text = _form['Body'],
				question_sender = _form['From'],
				question_sender_name = sender.question_sender_name
			)
	else:
		message_tag.text = "Unfortunately we are not taking questions right now."
	return Response(prettify(response), mimetype='text/xml')
コード例 #18
0
def question():
    if request.method=='GET':
       return render_template('question.html')
    else:
        if hasattr(g,'user'):
          question_title=request.form.get('question_title')
          question_desc = request.form.get('question_desc')
          author_id=g.user.id
          #author_id = Users.query.filter(Users.username == session.get('username')).first().id
          new_question=Questions(title=question_title,content=question_desc,author_id=author_id)
          db.session.add(new_question)
          db.session.commit()
          return redirect(url_for('home'))
        else:
            flash("请先登录")
            return redirect(url_for('login'))
コード例 #19
0
def new_question(request, pk):
    """Start a new thread."""
    p = request.POST
    if p["body"]:
        q=Questions()
        q.title=p["body"]
        q.username=request.user
        q.bookID=pk
        q.save()
        increment_post_counter(request)
    return HttpResponseRedirect(reverse("BCAforum.views.forum", args=[pk]))
コード例 #20
0
def question():
    if request.method == 'GET':
        return render_template('question.html')
    else:
        if hasattr(g, 'user'):
            question_title = request.form.get('question_title').strip()
            question_desc = request.form.get('question_desc').strip()
            author_id = g.user.id
            new_question = Questions(title=question_title,
                                     content=question_desc,
                                     author_id=author_id)
            db.session.add(new_question)
            db.session.commit()
            return redirect(url_for('home'))
        else:
            flash('请先登录')
            return redirect(url_for('login'))
コード例 #21
0
def upload_quiz():

    json = request.get_json()

    quiz = Quizes(name=json['name'])
    db.session.add(quiz)
    db.session.flush()

    for x in json['questions']:
        db.session.add(
            Questions(quiz_id=quiz.id,
                      question=x['question'],
                      a=x['options']['a'],
                      b=x['options']['b'],
                      c=x['options']['c'],
                      d=x['options']['d']))

    db.session.commit()
コード例 #22
0
ファイル: main.py プロジェクト: anitali2002/cssi2018Allergies
    def post(self):
        genInfoTemplate = theJinjaEnvironment.get_template(
            'templates/genInfo.html')

        questionsDatabase = Questions.query().fetch()

        userQuestion = self.request.get("userQuestion")

        question = None

        for i in range(len(questionsDatabase)):
            if (questionsDatabase[i].question == userQuestion):
                question = questionsDatabase[i]

        if question == None and not userQuestion == "":
            question = Questions(question=userQuestion)
            question.put()

        answerName = self.request.get("answerName")
        answer = self.request.get("answer")
        questionKey = self.request.get("questionKey")

        if (not answerName == "" and not answer == ""):
            for i in range(len(questionsDatabase)):
                if (questionsDatabase[i].question == questionKey):
                    question = questionsDatabase[i]
            question.answerNames.append(answerName)
            question.answers.append(answer)
            question.put()

        questionsDatabase = Questions.query().fetch()

        # if (not question == None):
        #     if (not question in questionsDatabase):
        #         questionsDatabase.append(question)
        #
        # print(questionsDatabase)

        templateDict = {"questionsDatabase": questionsDatabase}

        self.response.write(genInfoTemplate.render(templateDict))
コード例 #23
0
ファイル: HarpQA.py プロジェクト: WeAreHus/StudyRecord
def question():
    if request.method == 'GET':
        return render_template('question.html')
    else:
        # 判断当前是否已有用户登录
        if hasattr(g, 'user'):
            question_title = request.form.get('question_title').strip()
            question_desc = request.form.get('question_desc').strip()
            # 获取g对象中保存的user对象的id属性
            author_id = g.user.id
            new_question = Questions(title=question_title,
                                     content=question_desc,
                                     author_id=author_id)
            db.session.add(new_question)
            db.session.commit()
            return redirect(url_for('home'))
        else:
            flash('Please log in first')
            return redirect(url_for('login'))
コード例 #24
0
def question():
    if request.method == 'GET':
        user = session.get('username')
        if user:
            return render_template('question.html')
        else:
            flash('请先登录!')
            return render_template('login.html')
    else:
        question_title = request.form.get('question_title')
        question_desc = request.form.get('question_desc')
        author_id = Users.query.filter(
            Users.username == session.get('username')).first().id
        new_question = Questions(title=question_title,
                                 content=question_desc,
                                 author_id=author_id)
        db.session.add(new_question)
        db.session.commit()
        return redirect(url_for('hello'))
コード例 #25
0
def add_question():
    question_number = request.args.get('question_number')
    quiz_id = request.args.get('quiz_id')
    question = request.args.get('question')
    answer = request.args.get('answer')

    try:
        questions = Questions(
            question_number = question_number,
            quiz_id = quiz_id,
            question = question,
            answer = answer
        )
    except Exception as e:
        return str(e)
        
    db.session.add(questions)
    db.session.commit()
    return "Question added. question number={}".format(questions.question_number)
コード例 #26
0
def create_question():
    if not session.get('admin'):
        abort(400)
    form = Question_CreateForm()
    if form.validate_on_submit():
        question = form.question.data
        select1 = form.select1.data
        select2 = form.select2.data
        select3 = form.select3.data
        select4 = form.select4.data
        if Questions.query.filter_by(id=1).first():
            result = Results(question=question,
                             select1=select1,
                             select2=select2,
                             select3=select3,
                             select4=select4)
            db.session.add(result)
            que = Questions.query.filter_by(id=1).first()
            que.question = question
            que.select1 = select1
            que.select2 = select2
            que.select3 = select3
            que.select4 = select4
            db.session.add(que)
            flash('增加成功')
            return redirect(url_for('admin_coupon.question'))
        else:
            que = Questions(id=1,
                            question=question,
                            select1=select1,
                            select2=select2,
                            select3=select3,
                            select4=select4)
            result = Results(question=question,
                             select1=select1,
                             select2=select2,
                             select3=select3,
                             select4=select4)
            db.session.add(que)
            db.session.add(result)
            flash('增加成功')
            return redirect(url_for('admin_coupon.question'))
    return render_template('create_question.html', form=form)
コード例 #27
0
 def test_questions_answers_add_model(self):
     """
     Test that the question and then answer is successfully added to the database
     """
     content = Content(header="Test_Header", content="Test_Content")
     question = Questions(question_text="Test_Question?", content=content)
     answer = Answers(answer_text="Answer_Test",
                      correct=0,
                      question=question)
     db.session.add(content)
     db.session.add(question)
     db.session.add(answer)
     db.session.commit()
     self.assertEqual(
         Questions.query.filter_by(question_text="Test_Question?").count(),
         1)
     self.assertEqual(
         Answers.query.filter_by(answer_text="Answer_Test",
                                 correct=0,
                                 question=question).count(), 1)
コード例 #28
0
ファイル: routes.py プロジェクト: oskar8991/KCHosptial-CMS
def add_question():
    form = QuestionForm()
    form.content.choices = [(r.id, r.title) for r in Content.query.all()]

    if form.validate_on_submit():
        question = Questions(question_text = form.question.data, content = Content.query.filter_by(id = form.content.data).first())
        answers = [
            Answers(answer_text = form.first_answer.data, correct = 0, question = question),
            Answers(answer_text = form.second_answer.data, correct = 0, question = question),
            Answers(answer_text = form.third_answer.data, correct = 0, question = question),
            Answers(answer_text = form.correct_answer.data, correct = 1, question = question)
        ]

        db.session.add(question)
        for answer in answers:
            db.session.add(answer)

        db.session.commit()
        return redirect(url_for('quiz.questions'))

    return render_template('questions/add.html', form=form)
コード例 #29
0
    def post(self):
        data = {}
        parser = reqparse.RequestParser()
        parser.add_argument('a', type=str)
        args = parser.parse_args()
        question_data = request.get_json()
        if args.get('a') == 'add':
            q = Questions.query.filter_by(id=question_data.get('id')).first()
            if q:
                q.title = question_data.get('title')
                q.content = question_data.get('content')
                q.start_at = question_data.get('surveyTime')[0]
                q.end_at = question_data.get('surveyTime')[1]
                q.save()
            else:
                Questions(title=question_data.get('title'),
                          content=question_data.get('content'),
                          start_at=question_data.get('surveyTime')[0],
                          end_at=question_data.get('surveyTime')[1]).save()
        if args.get('a') == 'result':
            q = Questions.query.filter_by(
                title=question_data.get('title')).first()
            q.completed_number += 1
            q.save()
            u = to_json(
                Users.query.filter_by(id=question_data.get('uid')).first())
            qs = QuestionResult.query.filter_by(
                title=question_data.get('title'),
                uid=question_data.get('uid')).first()
            if qs:
                qs.result = question_data.get('content')
                qs.save()
            else:
                QuestionResult(title=question_data.get('title'),
                               result=question_data.get('content'),
                               user=u.get('name'),
                               uid=question_data.get('uid')).save()

        return {'code': 200, 'data': data}
コード例 #30
0
db.create_all()

api1 = APIs(api='TheMealDB',
            api_url='https://www.themealdb.com/api.php?ref=apilist.fun')
api2 = APIs(api='TheCockTailDB',
            api_url='https://www.thecocktaildb.com/api.php?ref=apilist.fun')
api3 = APIs(api='EDAMAM', api_url='https://www.edamam.com/')
api4 = APIs(api='IBM_text_to_speech',
            api_url='https://cloud.ibm.com/apidocs/text-to-speech?code=python')
api5 = APIs(api='Recipe Puppy',
            api_url='http://www.recipepuppy.com/about/api/?ref=apilist.fun')

db.session.add_all([api1, api2, api3, api4, api5])
db.session.commit()

que1 = Questions(question='What is the name of your first pet?')
que2 = Questions(question='Where did you grow up?')
que3 = Questions(question='What is your favorite food?')

db.session.add_all([que1, que2, que3])
db.session.commit()

meals = requests.get('https://www.themealdb.com/api/json/v1/1/list.php?c=list')
categories = json.loads(meals.text)['meals']

food_categories = [
    FoodCategories(food_category=i['strCategory']) for i in categories
]
food_categories.append(FoodCategories(food_category='Unknown'))
db.session.add_all(food_categories)
db.session.commit()
コード例 #31
0
def question(request, pk):
    """Listing of answers to a question."""
    answers = list(Answers.scan({"questionID":condition.EQ(pk)}))
    title = Questions.get(pk).question
    return render_to_response("question.html", add_csrf(request, answers=answers, pk=pk,
        title=title))
コード例 #32
0
    def question():
        body = request.get_json()
        school = Questions()

        school.title = request.form.get('title', '')
        school.answer = request.form.get('answer', '')
        school.youtube_link = request.form.get('youtube', '')
        school.docs_link = request.form.get('doc', '')
        school.image_link = request.form.get('image', '')
        school.subject = request.form.get('subject', '')
        school.difficulty = request.form.get('difficulty', '')
        school.insert()

        return redirect(url_for('index'))
コード例 #33
0
def book(request, pk):
    questions = list(Questions.scan({"bookID":condition.EQ(pk)}))
    return render_to_response("book.html", add_csrf(request, questions=questions, pk=pk))
コード例 #34
0
ファイル: main.py プロジェクト: Salz0/Derzhavets_bot
async def process_start_command(message: types.Message):
    question = Questions(name=message.from_user.get_mention(),
                         question=message.text)
    await question.save()
    await message.reply(MESSAGES["Q_and_A_confirmation_message"],
                        reply_markup=kb.Q_and_A_keyboard)
コード例 #35
0
ファイル: app.py プロジェクト: Nile-Dixon/Mathabee-Backend
def create_game_route():
	content = request.json
	game_types = [
		'basic_addition',
		'advanced_addition',
		'basic_subtraction' ,
		'advanced_subtraction',
		'basic_multiplication',
		'advanced_multiplication', 
		'basic_division',
		'advanced_division',
		'basic_mixed',
		'advanced_mixed', 
		'add_fractions',
		'subtract_fractions',
		'multiply_fractions',
		'divide_fractions',
		'simplify_fractions', 
		'angles',
		'perimeter', 
		'area',
		'pythagorean',
		'average',
		'median',
		'range',
		'dollars_and_cents',
		'exponents_and_powers',
		'square_roots'
	]

	if content['game_type'] not in game_types:
		return jsonify({
				'status' : 'error',
				'message' : 'Invalid game type.'
			})
	number_of_questions = int(content['number_of_questions'])

	#MAKE TEMPORARY UNIQUE JOIN CODE
	found_join_code = False
	join_code = ""
	while found_join_code == False:
		join_code = generate_short_code()
		query = Games.query.filter_by(live_game = 1).filter_by(join_code = join_code).first()
		if query == None:
			found_join_code = True

	#CREATE GAME HERE
	game_id = generate_random_string(10,20)
	new_game = Games(
		game_id,
		"public",
		content['game_type'],
		number_of_questions,
		1,
		join_code
	)
	db.session.add(new_game)

	#CREATE QUESTIONS
	for x in range(number_of_questions):
		question_data = create_question(content['game_type'])
		new_question = Questions(
			generate_random_string(10,200),
			game_id,
			x + 1,
			question_data['question_text'],
			question_data['answer']
		)
		db.session.add(new_question)

	db.session.commit()

	return jsonify({
			'status' : 'success',
			'game_id' : game_id
		})