Skip to content

Commit

Permalink
Fix on lessons and evaluations
Browse files Browse the repository at this point in the history
Lessons:  can not find a clear valid record per day when keeping historical already loaded for that day, too many combinations exist with cancel/change/etc.
fix> with each run, remove all entries for lessons of today and future
Evaluations: contained duplicates because key sees 'null' as unique value
fix> amend table to fix 'null', added few additional fields
  • Loading branch information
vingerha committed Oct 26, 2022
1 parent 0fbbbc1 commit e38f518
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions app/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ def init(self,p2mVersion,dbVersion):
, subject TEXT
, date TEXT
, aid TEXT
, acquisition_name TEXT
, acquisition_name TEXT NOT NULL DEFAULT "na"
, acquisition_abbreviation TEXT
, acquisition_level TEXT
, acquisition_domain TEXT
, acquisition_coefficient TEXT
, PRIMARY KEY(period_name,studentname,subject,date,aid))''')
, PRIMARY KEY(period_name,studentname,subject,date,aid,acquisition_name,acquisition_level, acquisition_domain,acquisition_coefficient))''')
self.cur.execute('''CREATE UNIQUE INDEX IF NOT EXISTS idx_evaluations_aid
ON evaluations (period_name,studentname,subject,date,aid)''')

ON evaluations (period_name,studentname,subject,date,aid,acquisition_name,acquisition_level,acquisition_domain,acquisition_coefficient)''')
# using key on period id and evalid
logging.debug("Creation of Absences table")
self.cur.execute('''CREATE TABLE IF NOT EXISTS absences (
Expand Down Expand Up @@ -170,9 +172,9 @@ def init(self,p2mVersion,dbVersion):
, lessonCanceled TEXT
, lessonStatus TEXT DEFAULT "nc" NOT NULL
, lessonNum TEXT
, PRIMARY KEY(studentname,lessonDateTime,lessonSubject,lessonRoom, lessonCanceled))''')
# self.cur.execute('''CREATE UNIQUE INDEX IF NOT EXISTS idx_lessons_lid
# ON lessons (studentname,lessonDateTime,LessonSubject, lessonStatus)''')
, PRIMARY KEY(studentname,lessonDateTime,lessonSubject,lessonRoom, lessonCanceled, lessonCanceled))''')
self.cur.execute('''CREATE UNIQUE INDEX IF NOT EXISTS idx_lessons_lid
ON lessons (studentname,lessonDateTime,LessonSubject, lessonRoom, lessonStatus, lessonCanceled)''')

# using key on period id and evalid
logging.debug("Creation of Homework table")
Expand Down Expand Up @@ -266,6 +268,11 @@ def connect(self,g2mVersion,dbVersion):
self.con = sqlite3.connect(self.path + "/" + DATABASE_NAME, timeout=DATABASE_TIMEOUT)
self.cur = self.con.cursor()

# delete data from lessons as impossible to distinguish between historical records for a lesson and new/changed records for the very same lesson
# With the presented attribues, one cannot identify which has the real value/truth
logging.debug("Delete today & future Lessons to fix mismatches/duplicates that avoid presenting the correct lesson/status")
self.cur.execute('''DELETE from lessons where lessonDateTime >= date('now')''')

# Get measures statistics
def getGradesCount(self):

Expand Down Expand Up @@ -523,10 +530,12 @@ def __init__(self,result):
self.evalDescription = result[10]
self.evalSubject = result[11]
self.evalDate = result[12]
self.acqId = result[13]
self.acqId = result[13]
self.acqName = result[14]
self.acqLevel = result[15]
self.acqCoefficient = result[16]
self.acqAbbreviation = result[15]
self.acqLevel = result[16]
self.acqDomain = result[17]
self.acqCoefficient = result[18]

class Absences():

Expand Down

0 comments on commit e38f518

Please sign in to comment.