-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.py
50 lines (33 loc) · 1.17 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import subprocess
import datetime
class User:
def __init__(self,name,matric):
self.name=name
self.matric=matric
self.logfile=""
self.pathdir=""
def getName(self):
"""Return user instance of id, return None if not exist"""
try:
return self.name
except UserWarning:
return None
def getMatric(self):
try:
return self.matric
except UserWarning:
return None
def createDir(self,quizid):
self.pathdir = os.path.dirname(os.path.abspath(__file__)) + "/subjects/{0}${1}".format(self.matric,datetime.datetime.now().strftime("%Y-%m-%d"))
if not os.path.exists(self.pathdir):
os.makedirs(self.pathdir)
return self.pathdir
def setLogfile(self,quizid):
self.logfile = self.matric + quizid + ".txt"
return self.logfile
def record(self,quizid):
self.setLogfile(quizid)
subprocess.Popen(['python', 'keym.py',self.pathdir,self.logfile])
def playback(self, log,starttime,endtime):
subprocess.Popen(['python', 'play.py',log, starttime,endtime])