-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautomationMoodle_alpha0.0.1
More file actions
204 lines (153 loc) · 8 KB
/
automationMoodle_alpha0.0.1
File metadata and controls
204 lines (153 loc) · 8 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import time
import tkinter as tk
from selenium import webdriver
from selenium.webdriver.common.by import By
from tkinter import messagebox
from tkinter import *
driver = webdriver.Chrome()
def login(username, password):
# selenium code to open the window and
driver.maximize_window()
driver.get("http://moodle.mitsgwalior.in/login/index.php")
driver.find_element(By.ID, "username").send_keys(username)
driver.find_element(By.ID, "password").send_keys(password)
driver.find_element(By.ID, "loginbtn").click()
win.destroy()
def teachers(teachnames):
if teachnames.lower() == "dkj" or "deepak" in teachnames.lower():
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=344")
elif teachnames.lower() == "aso" or "angad" in teachnames.lower():
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=355")
elif teachnames.lower() == "psharma" or "prabhakar" in teachnames.lower():
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=366")
elif teachnames.lower() == "sk" or "sk bharadwaj" in teachnames.lower():
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=590")
elif teachnames.lower() == "ashish" or "ashish kumar" in teachnames.lower():
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=771")
elif teachnames.lower() == "vs" or "vivek" in teachnames.lower():
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=724")
def prompt(userchoice):
x = userchoice.split()
if "attendance" in x:
win2.destroy()
root = Tk()
root.geometry("500x500")
enter_info = Label(root, text="Moodle Automation", bg="lightgrey", font=("Arial", 14))
enter_info.grid(row=0, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
enter_info = Label(root, text="version = 0.1.1", bg="lightgrey")
enter_info.grid(row=1, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
# For entering a text
Label(root, text="Teacher Name ").grid(row=2)
Label(root, text="Teacher Subject ").grid(row=3)
teacher_entry = Entry(root, width=35)
teacher_subject = Entry(root, width=35)
teacher_entry.grid(row=2, column=2, padx=20, pady=20)
teacher_subject.grid(row=3, column=2, padx=20, pady=20)
# Button which says Click Here
button2 = Button(root, text="Click Here", command=lambda: teacher_attendance(teacher_entry.get().lower(), teacher_subject.get().lower())).grid(row=4, column=2, sticky=tk.W, pady=25, padx=25)
root.mainloop()
elif "page" in x:
win2.destroy()
var = Tk()
var.geometry("500x500")
canvas = Canvas(var)
canvas.create_text(200, 200, text="Moodle Automation", fill="black", font=('Helvetica 15 bold'))
canvas.create_text(200, 220, text="Version: 0.0.1α", fill="black", font=('Helvetica 10 bold'))
canvas.create_text(200, 250, text="Who's page do you want to access?", fill="black")
canvas.pack()
# For entering a text
userentry = Entry(var)
userentry.pack()
# Button which says Click Here
button1 = Button(var, text="Click Here", command=lambda: teachers(userentry.get()))
button1.pack()
var.mainloop()
def teacher_attendance(teachername, subject):
teachersplit = teachername.split()
subjsplit = subject.split()
if "dkj" in teachersplit or "Deepak" in teachersplit and "vector" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=344§ion=2")
elems = driver.find_element(By.LINK_TEXT, "Attendance")
if len(str(elems)) > 0:
elems.click()
if (driver.find_element(By.CLASS_NAME, "empty")):
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
else:
driver.get("http://moodle.mitsgwalior.in/mod/attendance/view.php?id=78742")
else:
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
elif "skb" in teachersplit or "sk bharadwaj" in teachersplit and "python" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=590§ion=4")
elems = driver.find_element(By.LINK_TEXT, "Attendance (MAC II Year A)")
if len(str(elems)) > 0:
elems.click()
if (driver.find_element(By.CLASS_NAME, "empty")):
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
else:
driver.get("http://moodle.mitsgwalior.in/mod/attendance/view.php?id=78742")
else:
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
elif "ashish" in teachersplit or "ashish kumar" in teachersplit and "daa" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=771§ion=2")
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
elif "aso" in teachersplit or "ojha" in teachersplit and "number theory" in subjsplit:
a = ("http://moodle.mitsgwalior.in/course/view.php?id=355")
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
elif "khanna" in teachersplit or "sanjiv" in teachersplit or "ickt" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=530")
elems = driver.find_element(By.LINK_TEXT, "Attendance")
if len(str(elems)) > 0:
elems.click()
if (driver.find_element(By.CLASS_NAME, "empty")):
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
else:
driver.get("http://moodle.mitsgwalior.in/mod/attendance/view.php?id=78742")
else:
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
elif "vivek" in teachersplit or "vs" in teachersplit and "toc" in subjsplit:
driver.get("http://moodle.mitsgwalior.in/course/view.php?id=724")
elems = driver.find_element(By.LINK_TEXT, "Attendance")
if len(str(elems)) > 0:
elems.click()
if (driver.find_element(By.CLASS_NAME, "empty")):
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
else:
driver.get("http://moodle.mitsgwalior.in/mod/attendance/view.php?id=78742")
else:
messagebox.showinfo("Not Found", "The teacher has not made any attendance prompt!")
win = Tk()
# customization of the tkinter window
win.title("Moodle Automation")
win.geometry("400x350")
win.maxsize(500, 500)
win.config(bg="lightgrey")
enter_info = Label(win, text="Moodle Automation", bg="lightgrey", font=("Arial", 14))
enter_info.grid(row=0, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
enter_info = Label(win, text="version = 0.1.1", bg="lightgrey")
enter_info.grid(row=1, column=1, rowspan=1, columnspan=4, padx=5, pady=5)
Label(win, text="Username").grid(row=2)
Label(win, text="Password").grid(row=3)
# userinput and password
userinput = Entry(win, width=35)
password = Entry(win, width=35, show="*")
userinput.grid(row=2, column=2, padx=20, pady=20)
password.grid(row=3, column=2, padx=20, pady=20)
# Button which says Click Here
tk.Button(win, text="Click Here to Start", command=lambda: login(userinput.get(), password.get())).grid(row=4, column=2, sticky=tk.W, pady=25, padx=25)
win.mainloop()
# window for user entry
win2 = Tk()
win2.geometry("500x500")
canvas = Canvas(win2)
canvas.create_text(200, 200, text="Moodle Automation", fill="black", font=('Helvetica 15 bold'))
canvas.create_text(200, 250, text="What do you want to access?", fill="black")
canvas.create_text(200, 220, text="Version: 0.0.1α", fill="black", font=('Helvetica 10 bold'))
canvas.pack()
# For entering a text
userentry = Entry(win2)
userentry.pack()
# Button which says Click Here
button1 = Button(win2, text="Click Here", command=lambda: prompt(userentry.get()))
button1.pack()
win2.mainloop()
time.sleep(5000)