Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, redirect, render_template, request, url_for
- from server import app, user_input
- from question_class import Question
- from sqlalchemy import Column, ForeignKey, Integer, String
- from sqlalchemy.ext.declarative import declarative_base
- from sqlalchemy.orm import relationship,sessionmaker
- from sqlalchemy import create_engine
- from sqlite3
- class Response:
- def __init__(self, SID, userID, option1, option2, option3, option4, option5, option6, option7, option8)
- self._SID = name
- self._userID = userID
- self._option1 = option1
- self._option2 = option2
- self._option3 = option3
- self._option4 = option4
- self._option5 = option5
- self._option6 = option6
- self._option7 = option7
- self._option8 = option8
- def get_SID(self):
- return self._SID
- def get_userID(self):
- return self._userID
- def add_response(self):
- con = sqlite3.connect("library.db")
- cur = con.cursor()
- # checks in db whether there is a response with the same SID and userID
- # as the one we want to add
- response_query = "SELECT * FROM response_pool WHERE SID=SID AND UserID=userID"
- curr_responses = cur.execute(response_query)
- con.commit()
- # if there is no SID and UserID is not in db
- if curr_responses.rowcount == 0:
- # adding into response_pool
- cur.execute("INSERT INTO response_pool (SID,UserID,Option1,Option2,Option3,Option4,Option5,Option6,Option7,Option8)
- VALUES(?,?,?,?,?,?,?,?,?,?);",self._SID, self._userID, self._option1,self._option2,self._option3,self._option4,
- self._option5,self._option6,self._option7,self._option8))
- con.commit()
- # if the userID has already submitted a response for that survey
- else:
- # do not add their response
- break
- cur.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement