From 9066bda04242f6dd8a3620fd766f311792e9f3ae Mon Sep 17 00:00:00 2001 From: Joshua Yee Date: Thu, 2 May 2019 14:15:10 -0400 Subject: [PATCH 1/4] Update database --- application/db_connect.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/application/db_connect.py b/application/db_connect.py index f03faa9..0ead91a 100644 --- a/application/db_connect.py +++ b/application/db_connect.py @@ -18,7 +18,7 @@ def db_init(): # Create table - people c.execute( """CREATE TABLE people( - person_id INTEGER PRIMARY KEY, + person_id INTEGER PRIMARY KEY AUTOINCREMENT, isTeacher INTEGER, username TEXT, password TEXT, @@ -31,7 +31,7 @@ def db_init(): # Create table - classes c.execute( """CREATE TABLE classes( - class_id INTEGER PRIMARY KEY, + class_id INTEGER PRIMARY KEY AUTOINCREMENT, teacher_id INTEGER, name TEXT, FOREIGN KEY(teacher_id) @@ -41,11 +41,10 @@ def db_init(): c.execute( """CREATE TABLE quizzes( - quiz_id INTEGER PRIMARY KEY, + quiz_id INTEGER PRIMARY KEY AUTOINCREMENT, creator_id INTEGER, class_id INTEGER, - name TEXT, - grader TEXT, + name text, FOREIGN KEY(creator_id) REFERENCES people(person_id), FOREIGN KEY(class_id) @@ -55,7 +54,7 @@ def db_init(): c.execute( """CREATE TABLE roster( - roster_id INTEGER PRIMARY KEY, + roster_id INTEGER PRIMARY KEY AUTOINCREMENT, person_id INTEGER, class_id INTEGER, FOREIGN KEY(person_id) @@ -67,7 +66,7 @@ def db_init(): c.execute( """CREATE TABLE questions( - question_id INTEGER PRIMARY KEY, + question_id INTEGER PRIMARY KEY AUTOINCREMENT, quiz_id INTEGER, question_type INTEGER, question_text TEXT, @@ -76,6 +75,7 @@ def db_init(): c_text TEXT, d_text TEXT, correct_answer TEXT, + response TEXT, FOREIGN KEY(quiz_id) REFERENCES quizzes(quiz_id) )""" @@ -83,10 +83,10 @@ def db_init(): c.execute( """CREATE TABLE quiz_grades( - grade_id INTEGER PRIMARY KEY, - student_id INTEGER, + grade_id INTEGER PRIMARY KEY AUTOINCREMENT, + student_id integer, quiz_id INTEGER, - grade TEXT, + grade REAL, FOREIGN KEY(student_id) REFERENCES people(person_id), FOREIGN KEY(quiz_id) @@ -96,7 +96,7 @@ def db_init(): c.execute( """CREATE TABLE quiz_responses( - response_id INTEGER PRIMARY KEY, + response_id INTEGER PRIMARY KEY AUTOINCREMENT, student_id INTEGER, quiz_id INTEGER, question_id INTEGER, From ddb9f0b9219d892d75280478cbae17b4225a375d Mon Sep 17 00:00:00 2001 From: Joshua Yee Date: Thu, 2 May 2019 14:15:50 -0400 Subject: [PATCH 2/4] Autoincrement all PK, need to delete other db --- data/quizagator2.db | Bin 0 -> 32768 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/quizagator2.db diff --git a/data/quizagator2.db b/data/quizagator2.db new file mode 100644 index 0000000000000000000000000000000000000000..877d37f5ffbae4a46c9002463de95c932a07bd51 GIT binary patch literal 32768 zcmeI#!A{#S7zgkKC}C)z-73T;tZ``s+GV$$)}g>UpsrNZSv&TP|WUXcWGM4`=e_#6X@WtZq2T$cC4hTR10uX=z1gZ** zBFk#7ubVgP!ao_%^NaARcgp-e<%QFQE!Sy#4)NNr_8d~EXf2Y$kv`W8`=rzLoE^s{ zhi+%T?H-d|=a{tLc?X@Y47Bfby-npgE-v~s63LTcBgHcDjw_SEw2 z1J~*7bd$DQ(*|s%Vb|GqT&KI`9FZZ7hXdLgQpV#*_Qcjl%etctmDFER-YUJ%zJ5J# zHP_b6Z@mnhauLRnc zR;D_$2Cpz<|D*inYBp8A-c6OWyR)A;MLCb8D5r%5tg6g{`oTx4XHFsiT}z6P(-74m zmA>1DGxN=j4f8l1IzJ!CoobKEzdRZRa;7PlvkJwn%2v|bP5GofS~k-a;QBI+IZovG zdq# Date: Thu, 2 May 2019 14:25:27 -0400 Subject: [PATCH 3/4] Fix inadvertant database changes --- application/db_connect.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/db_connect.py b/application/db_connect.py index 2db5067..2682fb1 100644 --- a/application/db_connect.py +++ b/application/db_connect.py @@ -44,7 +44,8 @@ def db_init(): quiz_id INTEGER PRIMARY KEY AUTOINCREMENT, creator_id INTEGER, class_id INTEGER, - name text, + name TEXT, + grader TEXT, FOREIGN KEY(creator_id) REFERENCES people(person_id), FOREIGN KEY(class_id) @@ -75,7 +76,6 @@ def db_init(): c_text TEXT, d_text TEXT, correct_answer TEXT, - response TEXT, FOREIGN KEY(quiz_id) REFERENCES quizzes(quiz_id) )""" @@ -84,9 +84,9 @@ def db_init(): c.execute( """CREATE TABLE quiz_grades( grade_id INTEGER PRIMARY KEY AUTOINCREMENT, - student_id integer, + student_id INTEGER, quiz_id INTEGER, - grade REAL, + grade TEXT, FOREIGN KEY(student_id) REFERENCES people(person_id), FOREIGN KEY(quiz_id) From b4f3caeab2047c1245702688da71d944f7bb917c Mon Sep 17 00:00:00 2001 From: Saejin Mahlau-Heinert Date: Thu, 2 May 2019 14:25:36 -0400 Subject: [PATCH 4/4] Clean and regenerate database --- data/quizagator.db | Bin 32768 -> 36864 bytes data/quizagator2.db | Bin 32768 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 data/quizagator2.db diff --git a/data/quizagator.db b/data/quizagator.db index 90d895d63beb7e67d5505d92034d7811e8854e5d..c9afeae73ce4a12b82bf4e24b1afc9c8e5ac37b5 100644 GIT binary patch delta 509 zcmZo@U}{*vG(nz`bE1NW2nXvj2EO-vb9oo=C~{rlRAJxDx@=>k7Asc^7YDnzrY2*% z|Kt=lMMloaZEPNV3XY*6{+@o$L9V{8ej$?&a(GY9=i;2q&Be7@hh2|RHIJQLTv?g1 zRkKU$%yYU0hn4vDF{${3?jkffVcH-8{DFw*TM}XOyjC2J33}2J1@BNh~f- zErwDolXdv)&~#1C;+q^3z{Do5t<4w-)>B-VlUb4)UknVf)VyS%l_*?hU~oHzxGID= qI{CONph;@vCFZ8;0Cj3M@iBr!p}BlAJAVM0otwk?R~9T%5C8z{@tkV_ delta 267 zcmZozz|_#dG(nz`W1@nG5Ib8G1K(dhKAySUah!WNBH5xg3kp17eXMcqi*|iZilJcH?xO?8%|M`4FctqqGeRySStzV@q&JVp2|OQGRhrY7vBF zo&15zj!|c_Jii>!j^na<%FZ%f7i diff --git a/data/quizagator2.db b/data/quizagator2.db deleted file mode 100644 index 877d37f5ffbae4a46c9002463de95c932a07bd51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI#!A{#S7zgkKC}C)z-73T;tZ``s+GV$$)}g>UpsrNZSv&TP|WUXcWGM4`=e_#6X@WtZq2T$cC4hTR10uX=z1gZ** zBFk#7ubVgP!ao_%^NaARcgp-e<%QFQE!Sy#4)NNr_8d~EXf2Y$kv`W8`=rzLoE^s{ zhi+%T?H-d|=a{tLc?X@Y47Bfby-npgE-v~s63LTcBgHcDjw_SEw2 z1J~*7bd$DQ(*|s%Vb|GqT&KI`9FZZ7hXdLgQpV#*_Qcjl%etctmDFER-YUJ%zJ5J# zHP_b6Z@mnhauLRnc zR;D_$2Cpz<|D*inYBp8A-c6OWyR)A;MLCb8D5r%5tg6g{`oTx4XHFsiT}z6P(-74m zmA>1DGxN=j4f8l1IzJ!CoobKEzdRZRa;7PlvkJwn%2v|bP5GofS~k-a;QBI+IZovG zdq#