-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathedx-problem-code.xml
68 lines (60 loc) · 2.09 KB
/
edx-problem-code.xml
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
<!--
README:
This is the code that should be C&P into the edX UI for a problem.
Add a new component called "problem"
Select the problem type "Blank Advanced Problem"
Edit the settings to give the problem a reasonable name.
Paste this entire file in the text box.
When using this file, you need to set:
html_file='' to the proper HTML file path. It should start with '/static'
If you have a starter file:
set initial_state='' to 'starter file',
otherwise it should be 'no starter file'.
-->
<problem>
<link rel="stylesheet" type="text/css" href="/static/hintstyle.css" />
<script type="loncapa/python">
import json
import urllib
def process_ag_response(e, ans):
par = json.loads(ans)
log = urllib.unquote(par['answer']).decode('utf8')
answer = json.loads(log)
state = False
#if answer["feedback"]["pScore"] == 1:
#state = True
#return {'input_list': [{ 'ok': state, 'msg': '', 'grade_decimal': answer["feedback"]["pScore"]}]}
return {'input_list': [{ 'ok': True, 'msg': ''}]}
#return answer["checkState"]
def feedback_print(feedback):
output = ""
return output
def hint_fn(answer_ids, student_answers, new_cmap, old_cmap):
aid = answer_ids[0]
grade = json.loads(student_answers[aid])
#ans = json.loads(grade["answer"])
log = urllib.unquote(grade['answer']).decode('utf8')
ans = json.loads(log)
#log = ans["feedback"]
hint = str(log)
#comment = str(ans["comment"])
output=""
new_cmap.set_hint_and_mode(aid, '','always')
</script>
<p style="color: red" id="pre_req"></p>
<!--
EDIT ME: ?test_file='*.js'
DO NOT INCLUDE /static in the path
NOTE: The full URL is a current hack!
-->
<customresponse cfn="process_ag_response">
<jsinput gradefn="AG_EDX.getGrade"
get_statefn="AG_EDX.getState"
set_statefn="AG_EDX.setState"
initial_state="starter file"
width="100%" height="600"
html_file="https://courses.edx.org/c4x/BerkeleyX/BJC.3x/asset/edx-snap-ag.html#test_file=FILENAME.js"
sop="false"/>
<hintgroup hintfn="hint_fn"/>
</customresponse>
</problem>