diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 066f6d46a1..0185b5fd7d 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -580,6 +580,7 @@ class JSInput(InputTypeBase): Attribute('gradefn', "gradefn"), Attribute('get_statefn', None), # Function to call in iframe # to get current state. + Attribute('initial_state', None), # JSON string to be used as initial state Attribute('set_statefn', None), # Function to call iframe to # set state Attribute('width', "400"), # iframe width diff --git a/common/lib/capa/capa/templates/jsinput.html b/common/lib/capa/capa/templates/jsinput.html index b45dbda431..b798d5800a 100644 --- a/common/lib/capa/capa/templates/jsinput.html +++ b/common/lib/capa/capa/templates/jsinput.html @@ -3,6 +3,9 @@ % if saved_state: data-stored="${saved_state|x}" % endif + % if initial_state: + data-initial-state="${initial_state|x}" + % endif % if get_statefn: data-getstate="${get_statefn}" % endif diff --git a/common/lib/xmodule/xmodule/templates/problem/jsinput_response.yaml b/common/lib/xmodule/xmodule/templates/problem/jsinput_response.yaml index bd7c622cd5..5e23be55ac 100644 --- a/common/lib/xmodule/xmodule/templates/problem/jsinput_response.yaml +++ b/common/lib/xmodule/xmodule/templates/problem/jsinput_response.yaml @@ -36,6 +36,7 @@ data: |