From d3149f66aa63756d265f30b220c6ae46a8973082 Mon Sep 17 00:00:00 2001 From: Chris Terman Date: Mon, 30 Jun 2014 11:59:16 -0400 Subject: [PATCH] add initial_state attribute to jsinput tag --- common/lib/capa/capa/inputtypes.py | 1 + common/lib/capa/capa/templates/jsinput.html | 3 ++ .../templates/problem/jsinput_response.yaml | 1 + common/static/js/capa/src/jsinput.js | 28 ++++++++++++------- .../source/extending_platform/javascript.rst | 5 +++- 5 files changed, 27 insertions(+), 11 deletions(-) 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: |