diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 9781f10ae6..816a01e4b4 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -967,12 +967,13 @@ registry.register(DesignProtein2dInput) class EditAGeneInput(InputTypeBase): """ - An input type for editing a gene. Integrates with the genex java applet. + An input type for editing a gene. + Integrates with the genex GWT application. Example: - - """ + + """ template = "editageneinput.html" tags = ['editageneinput'] @@ -982,9 +983,7 @@ class EditAGeneInput(InputTypeBase): """ Note: width, height, and dna_sequencee are required. """ - return [Attribute('width'), - Attribute('height'), - Attribute('dna_sequence'), + return [Attribute('genex_dna_sequence'), Attribute('genex_problem_number') ] diff --git a/common/lib/capa/capa/templates/editageneinput.html b/common/lib/capa/capa/templates/editageneinput.html index 3465c62593..5da422ce12 100644 --- a/common/lib/capa/capa/templates/editageneinput.html +++ b/common/lib/capa/capa/templates/editageneinput.html @@ -13,7 +13,7 @@ % endif
- + diff --git a/common/static/js/capa/edit-a-gene.js b/common/static/js/capa/edit-a-gene.js index bd6d10cc64..eb404de881 100644 --- a/common/static/js/capa/edit-a-gene.js +++ b/common/static/js/capa/edit-a-gene.js @@ -12,22 +12,49 @@ } } - //NOTE: - // Genex uses six global functions: - // genexSetDNASequence (exported from GWT) - // genexSetClickEvent (exported from GWT) - // genexSetKeyEvent (exported from GWT) - // genexSetProblemNumber (exported from GWT) + // NOTE: + // Genex uses 8 global functions, all prefixed with genex: + // 6 are exported from GWT: + // genexSetInitialDNASequence + // genexSetDNASequence + // genexGetDNASequence + // genexSetClickEvent + // genexSetKeyEvent + // genexSetProblemNumber // // It calls genexIsReady with a deferred command when it has finished // initialization and has drawn itself - // genexStoreAnswer(answer) is called when the GWT [Store Answer] button - // is clicked + // genexStoreAnswer(answer) is called each time the DNA sequence changes + // through user interaction + + //Genex does not call the following function + genexGetInputField = function() { + var problem = $('#genex_container').parents('.problem'); + return problem.find('input[type="hidden"][name!="genex_dna_sequence"][name!="genex_problem_number"]'); + }; genexIsReady = function() { - //Load DNA sequence - var dna_sequence = $('#dna_sequence').val(); - genexSetDNASequence(dna_sequence); + var input_field = genexGetInputField(); + var genex_saved_state = input_field.val(); + var genex_initial_dna_sequence; + var genex_dna_sequence; + + //Get the sequence from xml file + genex_initial_dna_sequence = $('#genex_dna_sequence').val(); + //Call this function to set the value used by reset button + genexSetInitialDNASequence(genex_initial_dna_sequence); + + if (genex_saved_state === '') { + //Load DNA sequence from xml file + genex_dna_sequence = genex_initial_dna_sequence; + } + else { + //Load DNA sequence from saved value + genex_saved_state = JSON.parse(genex_saved_state); + genex_dna_sequence = genex_saved_state.genex_dna_sequence; + } + + genexSetDNASequence(genex_dna_sequence); //Now load mouse and keyboard handlers genexSetClickEvent(); genexSetKeyEvent(); @@ -35,10 +62,9 @@ var genex_problem_number = $('#genex_problem_number').val(); genexSetProblemNumber(genex_problem_number); }; - genexStoreAnswer = function(ans) { - var problem = $('#genex_container').parents('.problem'); - var input_field = problem.find('input[type="hidden"][name!="dna_sequence"][name!="genex_problem_number"]'); - input_field.val(ans); + genexStoreAnswer = function(answer) { + var input_field = genexGetInputField(); + var value = {'genex_dna_sequence': genexGetDNASequence(), 'genex_answer': answer}; + input_field.val(JSON.stringify(value)); }; -}).call(this); - +}).call(this); \ No newline at end of file diff --git a/common/static/js/capa/genex/3F4ADBED36D589545A9300A1EA686D36.cache.html b/common/static/js/capa/genex/3F4ADBED36D589545A9300A1EA686D36.cache.html deleted file mode 100644 index c5ad0d1b89..0000000000 --- a/common/static/js/capa/genex/3F4ADBED36D589545A9300A1EA686D36.cache.html +++ /dev/null @@ -1,639 +0,0 @@ - - - - \ No newline at end of file diff --git a/common/static/js/capa/genex/46DBCB09BEC38A6DEE76494C6517111B.cache.html b/common/static/js/capa/genex/46DBCB09BEC38A6DEE76494C6517111B.cache.html new file mode 100644 index 0000000000..054ef6c31a --- /dev/null +++ b/common/static/js/capa/genex/46DBCB09BEC38A6DEE76494C6517111B.cache.html @@ -0,0 +1,641 @@ + + + + \ No newline at end of file diff --git a/common/static/js/capa/genex/557C7018CDCA52B163256408948A1722.cache.html b/common/static/js/capa/genex/557C7018CDCA52B163256408948A1722.cache.html new file mode 100644 index 0000000000..3862093b1b --- /dev/null +++ b/common/static/js/capa/genex/557C7018CDCA52B163256408948A1722.cache.html @@ -0,0 +1,651 @@ + + + + \ No newline at end of file diff --git a/common/static/js/capa/genex/73F4B6D6D466BAD6850A60128DF5B80D.cache.html b/common/static/js/capa/genex/73F4B6D6D466BAD6850A60128DF5B80D.cache.html deleted file mode 100644 index d5441b656e..0000000000 --- a/common/static/js/capa/genex/73F4B6D6D466BAD6850A60128DF5B80D.cache.html +++ /dev/null @@ -1,649 +0,0 @@ - - - - \ No newline at end of file diff --git a/common/static/js/capa/genex/866AF633CAA7EA4DA7E906456CDEC65A.cache.html b/common/static/js/capa/genex/866AF633CAA7EA4DA7E906456CDEC65A.cache.html new file mode 100644 index 0000000000..472502dde2 --- /dev/null +++ b/common/static/js/capa/genex/866AF633CAA7EA4DA7E906456CDEC65A.cache.html @@ -0,0 +1,627 @@ + + + \ No newline at end of file diff --git a/common/static/js/capa/genex/8F9C3F1A91187AA8391FD08BA7F8716D.cache.html b/common/static/js/capa/genex/8F9C3F1A91187AA8391FD08BA7F8716D.cache.html new file mode 100644 index 0000000000..f488b6fcf6 --- /dev/null +++ b/common/static/js/capa/genex/8F9C3F1A91187AA8391FD08BA7F8716D.cache.html @@ -0,0 +1,641 @@ + + + + \ No newline at end of file diff --git a/common/static/js/capa/genex/A016796CF7FB22261AE1160531B5CF82.cache.html b/common/static/js/capa/genex/A016796CF7FB22261AE1160531B5CF82.cache.html new file mode 100644 index 0000000000..f799ecf5b7 --- /dev/null +++ b/common/static/js/capa/genex/A016796CF7FB22261AE1160531B5CF82.cache.html @@ -0,0 +1,653 @@ + + + + \ No newline at end of file diff --git a/common/static/js/capa/genex/BA18AC23ACC5016C5D0799E864BBDFFE.cache.html b/common/static/js/capa/genex/BA18AC23ACC5016C5D0799E864BBDFFE.cache.html deleted file mode 100644 index 261aa02849..0000000000 --- a/common/static/js/capa/genex/BA18AC23ACC5016C5D0799E864BBDFFE.cache.html +++ /dev/null @@ -1,639 +0,0 @@ - - - - \ No newline at end of file diff --git a/common/static/js/capa/genex/C7B18436BA03373FB13ED589C2CCF417.cache.html b/common/static/js/capa/genex/C7B18436BA03373FB13ED589C2CCF417.cache.html deleted file mode 100644 index 13d25ddf09..0000000000 --- a/common/static/js/capa/genex/C7B18436BA03373FB13ED589C2CCF417.cache.html +++ /dev/null @@ -1,649 +0,0 @@ - - - - \ No newline at end of file diff --git a/common/static/js/capa/genex/E1A9A95677AFC620CAD5759B7ACC3E67.cache.html b/common/static/js/capa/genex/E1A9A95677AFC620CAD5759B7ACC3E67.cache.html deleted file mode 100644 index 7078dee4f8..0000000000 --- a/common/static/js/capa/genex/E1A9A95677AFC620CAD5759B7ACC3E67.cache.html +++ /dev/null @@ -1,625 +0,0 @@ - - - \ No newline at end of file diff --git a/common/static/js/capa/genex/F28D6C3D881F6C18E3357AAB004477EF.cache.html b/common/static/js/capa/genex/F28D6C3D881F6C18E3357AAB004477EF.cache.html new file mode 100644 index 0000000000..0c242fde9c --- /dev/null +++ b/common/static/js/capa/genex/F28D6C3D881F6C18E3357AAB004477EF.cache.html @@ -0,0 +1,651 @@ + + + + \ No newline at end of file diff --git a/common/static/js/capa/genex/FF175D5583BDD5ACF40C7F0AFF9A374B.cache.html b/common/static/js/capa/genex/FF175D5583BDD5ACF40C7F0AFF9A374B.cache.html deleted file mode 100644 index ca07bf3292..0000000000 --- a/common/static/js/capa/genex/FF175D5583BDD5ACF40C7F0AFF9A374B.cache.html +++ /dev/null @@ -1,651 +0,0 @@ - - - - \ No newline at end of file diff --git a/common/static/js/capa/genex/genex.nocache.js b/common/static/js/capa/genex/genex.nocache.js index fe892a53dc..f457e80b6c 100644 --- a/common/static/js/capa/genex/genex.nocache.js +++ b/common/static/js/capa/genex/genex.nocache.js @@ -1,4 +1,4 @@ -function genex(){var P='',xb='" for "gwt:onLoadErrorFn"',vb='" for "gwt:onPropertyErrorFn"',ib='"><\/script>',Z='#',Xb='.cache.html',_='/',lb='//',Qb='3F4ADBED36D589545A9300A1EA686D36',Rb='73F4B6D6D466BAD6850A60128DF5B80D',Wb=':',pb='::',dc='