-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraining.py
68 lines (56 loc) · 2.22 KB
/
training.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import database as db
import pages as page
import prev_page as pv
import registration as reg
import menus as menu
def check_courses(selection):
if page.pagesVisited[-1] != "courses":
page.pagesVisited.append("courses")
tmpcon = db.sqlite3.connect('inCollege.db')
tmpcursor = tmpcon.cursor()
alltakencourses = tmpcursor.execute( "SELECT * FROM courses WHERE (username = '{}' COLLATE NOCASE)".format(reg.username))
rows = alltakencourses.fetchall()
#testing print(rows)
if rows == None:
tmpcursor.execute("INSERT INTO courses VALUES(? , ?)" , (selection , reg.username))
tmpcon.commit()
tmpcon.close()
print("\nYou have now completed this training ")
else:
takencourse = tmpcursor.execute( "SELECT * FROM courses WHERE (username = '{}' COLLATE NOCASE)".format(reg.username)).fetchall()
if any (selection in i for i in takencourse):
menu.print_takencourse_menu()
tmpcon.close()
else:
tmpcursor.execute("INSERT INTO courses VALUES(? , ?)" , (selection , reg.username))
tmpcon.commit()
tmpcon.close()
print("\nYou have now completed this training ")
def inCollegeLearningPage():
if page.pagesVisited[-1] != "inCollege Learning":
page.pagesVisited.append("inCollege Learning")
tmpcon = db.sqlite3.connect('inCollege.db')
tmpcursor = tmpcon.cursor()
tmpcon.commit()
courses = tmpcursor.execute('Select courses from coursenames').fetchall()
for i in range(0, len(courses)):
print("{}. Course {}: {}".format((i + 1), i + 1, courses[i][0]))
print('\nEnter 0 to go back\n')
selection = menu.user_input(len(courses))
check_courses(selection)
pv.previous()
#if selection == 1:
#check_courses(1)
#pv.previous()
#elif selection == 2:
#check_courses(2)
#pv.previous()
#elif selection == 3:
#check_courses(3)
#pv.previous()
#elif selection == 4:
#check_courses(4)
#pv.previous()
#elif selection == 5:
#check_courses(5)
#pv.previous()