Skip to content
Snippets Groups Projects
Commit 5e037d5d authored by Björn Modée's avatar Björn Modée
Browse files

add question answer

parent da468b93
No related branches found
No related tags found
1 merge request!125Resolve "Scoreboard in operator view"
......@@ -62,7 +62,7 @@ import {
* TODO:
* - Instead of copying code for others to join the competition, copy URL.
*
* - Make code popup less code by using .map instead
*
*
* - Fix scoreboard
*
......
......@@ -29,13 +29,12 @@ from app.database.models import (
ViewType,
Whitelist,
)
from app.database.types import ID_IMAGE_COMPONENT, ID_QUESTION_COMPONENT, ID_TEXT_COMPONENT
from flask import current_app
from flask.globals import current_app
from flask_restx import abort
from PIL import Image
from sqlalchemy import exc
from flask import current_app
from app.database.types import ID_IMAGE_COMPONENT, ID_QUESTION_COMPONENT, ID_TEXT_COMPONENT
def db_add(item):
......
......@@ -5,9 +5,8 @@ each other.
"""
from app.core import bcrypt, db
from sqlalchemy.ext.hybrid import hybrid_method, hybrid_property
from app.database.types import ID_IMAGE_COMPONENT, ID_QUESTION_COMPONENT, ID_TEXT_COMPONENT
from sqlalchemy.ext.hybrid import hybrid_method, hybrid_property
STRING_SIZE = 254
......@@ -201,8 +200,8 @@ class QuestionAnswer(db.Model):
question_id = db.Column(db.Integer, db.ForeignKey("question.id"), nullable=False)
team_id = db.Column(db.Integer, db.ForeignKey("team.id"), nullable=False)
def __init__(self, data, score, question_id, team_id):
self.data = data
def __init__(self, answer, score, question_id, team_id):
self.answer = answer
self.score = score
self.question_id = question_id
self.team_id = team_id
......
......@@ -43,8 +43,8 @@ def _add_items():
city_id = City.query.filter(City.name == "Linköping").one().id
# Add users
dbc.add.user("admin@test.se", "password", admin_id, city_id)
dbc.add.user("test@test.se", "password", editor_id, city_id)
dbc.add.user("admin@test.se", "password", admin_id, city_id, "Admina Denfina")
dbc.add.user("test@test.se", "password", editor_id, city_id, "Test Osteron")
question_types_items = dbc.get.all(QuestionType)
......@@ -105,6 +105,11 @@ def _add_items():
for name in teams:
dbc.add.team(f"{name}{i}", item_comp.id)
# question_answer(answer, score, question_id, team_id)
dbc.add.question_answer("ett svar som ger 2p", 2, 1, 1)
dbc.add.question_answer("ett svar som ger 2p", 2, 1, 2)
dbc.add.question_answer("ett svar som ger 3p", 3, 1, 3)
if __name__ == "__main__":
app, _ = create_app("configmodule.DevelopmentConfig")
......
......@@ -49,8 +49,8 @@ def add_default_values():
db.session.add(Code("111111", 1, item_competition.id, item_team1.id)) # Team
db.session.add(Code("222222", 2, item_competition.id)) # Judge
dbc.add.QuestionAnswer("hej", 5, item_question.id, item_team1)
dbc.add.QuestionAnswer("", 5, item_question.id, item_team2)
dbc.add.question_answer("hej", 5, item_question.id, item_team1)
dbc.add.question_answer("", 5, item_question.id, item_team2)
db.session.commit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment