-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquestion_test.py
61 lines (45 loc) · 1.85 KB
/
question_test.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
import json, sys, requests
host = sys.argv[1]
user = sys.argv[2]
answer = int(sys.argv[3])
headers = {'Content-type': 'application/json'}
r = requests.get('http://'+host+':9000/api/v1/course/CMUSTAT101/user/'+user, headers=headers)
r = r.json()
print "First user status: "
print r
print
print
if r['next'] is not None:
payload = {'problem':str(r['next']['problem_name'])}
r = requests.post('http://'+host+':9000/api/v1/course/CMUSTAT101/user/'+user+'/pageload', data=json.dumps(payload), headers=headers)
#print 'http://'+host+':9000/api/v1/course/CMUSTAT101/user/'+user+'/pageload'
#print payload
print "Pageload reply: "
print r.json()
print
print
r = requests.get('http://'+host+':9000/api/v1/course/CMUSTAT101/user/'+user, headers=headers)
r = r.json()
print "Second user status: "
print r
print
print
payload = {'problem':r['current']['problem_name'], 'correct':answer, 'attempt':1}
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ANSWERING " + str(answer) + " TO PROBLEM: " + str(r['current']['problem_name'])
r = requests.post('http://'+host+':9000/api/v1/course/CMUSTAT101/user/'+user+'/interaction', data=json.dumps(payload), headers=headers)
print "Question attempt post: "
print r.json()
print
print
"""
payload = json.dumps({'user_id':user})
r = requests.post('http://'+host+':9000/api/v1/course/CMUSTAT101/user', data=payload, headers=headers)
print str(r) + str(r.json())
# give no problems (hopefully)
p = {'pg': 0.25, 'ps': 0.25, 'pi': 0.99, 'pt': 0.5, 'threshold':0.5}
skills = ['center', 'shape', 'spread', 'x axis', 'y axis', 'h to d', 'd to h', 'histogram']
for skill in skills:
payload = json.dumps({'course_id':'CMUSTAT101', 'params': p, 'user_id':user, 'skill_name':skill})
r = requests.post('http://'+host+':9000/api/v1/parameters', data=payload, headers=headers)
print str(r) + str(r.json())
"""