2023-06-09 15:01:46 -04:00
|
|
|
import threading
|
2023-06-08 16:53:46 -04:00
|
|
|
import requests
|
2023-06-09 15:01:46 -04:00
|
|
|
from datetime import datetime
|
2023-06-08 16:53:46 -04:00
|
|
|
|
|
|
|
|
def get_results():
|
2023-06-14 17:30:03 -04:00
|
|
|
# threading.Timer(5.0, get_results).start()
|
2023-06-08 16:53:46 -04:00
|
|
|
url = "https://ondemand.questionmark.com/deliveryodata/406287/Results"
|
2023-06-09 15:01:46 -04:00
|
|
|
params = "?$filter=ParticipantName eq 'norm@northpass.com'"
|
|
|
|
|
# params = "?$filter=ParticipantName eq 'tom.leggett@questionmark.com'"
|
2023-06-08 16:53:46 -04:00
|
|
|
# params = "?$filter=AssessmentID eq 352630000352630L"
|
2023-06-09 15:01:46 -04:00
|
|
|
# Alexa Test 1 AssesmentID = 0346128000346128
|
2023-06-08 16:53:46 -04:00
|
|
|
url_params = f"{url}{params}"
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
|
"Accept": "application/json",
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"Authorization": "Basic bm9ydGhwYXNzX2FwaTpobWUycXl4KlRGVSphcHkuZnBr"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# response = requests.get(url, headers=headers)
|
|
|
|
|
response = requests.get(url_params, headers=headers)
|
2023-06-09 15:01:46 -04:00
|
|
|
data = response.json()
|
2023-06-14 17:30:03 -04:00
|
|
|
print(data)
|
2023-06-09 15:01:46 -04:00
|
|
|
data = data["value"]
|
|
|
|
|
|
|
|
|
|
now = datetime.now()
|
|
|
|
|
current_time = now.strftime("%H:%M:%S")
|
|
|
|
|
|
|
|
|
|
if data == []:
|
|
|
|
|
logfile = open("qm-log.txt", "a") # append mode
|
|
|
|
|
logfile.write(f"No Data - {current_time} \n")
|
|
|
|
|
logfile.close()
|
|
|
|
|
else:
|
|
|
|
|
datalist = []
|
|
|
|
|
for item in data:
|
|
|
|
|
email = item["ParticipantName"]
|
|
|
|
|
passval = item["ScoreBandTitle"]
|
|
|
|
|
score = item["PercentageScore"]
|
|
|
|
|
assesmentid = item["AssessmentID"]
|
|
|
|
|
finished = item["WhenFinished"]
|
|
|
|
|
|
|
|
|
|
datalist = [email, assesmentid, score, passval, finished]
|
2023-06-14 17:30:03 -04:00
|
|
|
# print(datalist)
|
2023-06-09 15:01:46 -04:00
|
|
|
logfile = open("qm-log.txt", "a") # append mode
|
|
|
|
|
logfile.write(str(datalist))
|
|
|
|
|
logfile.write(f" - {current_time} \n")
|
|
|
|
|
logfile.close()
|
2023-06-08 16:53:46 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
get_results()
|