Added edit a gene
This commit is contained in:
@@ -899,3 +899,38 @@ class DesignProtein2dInput(InputTypeBase):
|
||||
|
||||
registry.register(DesignProtein2dInput)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
class EditAGeneInput(InputTypeBase):
|
||||
"""
|
||||
An input type for editing a gene. Integrates with the genex java applet.
|
||||
|
||||
Example:
|
||||
|
||||
<editagene width="800" hight="500" dna_sequence="ETAAGGCTATAACCGA" />
|
||||
"""
|
||||
|
||||
template = "editageneinput.html"
|
||||
tags = ['editageneinput']
|
||||
|
||||
@classmethod
|
||||
def get_attributes(cls):
|
||||
"""
|
||||
Note: width, hight, and dna_sequencee are required.
|
||||
"""
|
||||
return [Attribute('width'),
|
||||
Attribute('height'),
|
||||
Attribute('dna_sequence')
|
||||
]
|
||||
|
||||
def _extra_context(self):
|
||||
"""
|
||||
"""
|
||||
context = {
|
||||
'applet_loader': '/static/js/capa/edit-a-gene.js',
|
||||
}
|
||||
|
||||
return context
|
||||
|
||||
registry.register(EditAGeneInput)
|
||||
|
||||
|
||||
@@ -876,7 +876,7 @@ def sympy_check2():
|
||||
allowed_inputfields = ['textline', 'textbox', 'crystallography',
|
||||
'chemicalequationinput', 'vsepr_input',
|
||||
'drag_and_drop_input', 'editamoleculeinput',
|
||||
'designprotein2dinput']
|
||||
'designprotein2dinput', 'editageneinput']
|
||||
|
||||
def setup_response(self):
|
||||
xml = self.xml
|
||||
|
||||
39
common/lib/capa/capa/templates/editageneinput.html
Normal file
39
common/lib/capa/capa/templates/editageneinput.html
Normal file
@@ -0,0 +1,39 @@
|
||||
<section id="editageneinput_${id}" class="editageneinput">
|
||||
<div class="script_placeholder" data-src="${applet_loader}"/>
|
||||
|
||||
% if status == 'unsubmitted':
|
||||
<div class="unanswered" id="status_${id}">
|
||||
% elif status == 'correct':
|
||||
<div class="correct" id="status_${id}">
|
||||
% elif status == 'incorrect':
|
||||
<div class="incorrect" id="status_${id}">
|
||||
% elif status == 'incomplete':
|
||||
<div class="incorrect" id="status_${id}">
|
||||
% endif
|
||||
|
||||
<object type="application/x-java-applet" id="applet_${id}" class="applet" width="${width}" height="${height}">
|
||||
<param name="archive" value="/static/applets/capa/genex.jar" />
|
||||
<param name="code" value="GX.GenexApplet.class" />
|
||||
<param name="DNA_SEQUENCE" value="${dna_sequence}" />
|
||||
Applet failed to run. No Java plug-in was found.
|
||||
</object>
|
||||
|
||||
<input type="hidden" name="input_${id}" id="input_${id}" value="${value|h}"/>
|
||||
|
||||
<p class="status">
|
||||
% if status == 'unsubmitted':
|
||||
unanswered
|
||||
% elif status == 'correct':
|
||||
correct
|
||||
% elif status == 'incorrect':
|
||||
incorrect
|
||||
% elif status == 'incomplete':
|
||||
incomplete
|
||||
% endif
|
||||
</p>
|
||||
|
||||
<p id="answer_${id}" class="answer"></p>
|
||||
% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
|
||||
</div>
|
||||
% endif
|
||||
</section>
|
||||
BIN
common/static/applets/capa/genex.jar
Normal file
BIN
common/static/applets/capa/genex.jar
Normal file
Binary file not shown.
27
common/static/js/capa/edit-a-gene.js
Normal file
27
common/static/js/capa/edit-a-gene.js
Normal file
@@ -0,0 +1,27 @@
|
||||
(function () {
|
||||
var timeout = 1000;
|
||||
|
||||
function initializeApplet(applet) {
|
||||
console.log("Initializing " + applet);
|
||||
waitForApplet(applet);
|
||||
}
|
||||
|
||||
function waitForApplet(applet) {
|
||||
if (applet.isActive && applet.isActive()) {
|
||||
console.log("Applet is ready.");
|
||||
var answerStr = applet.checkAnswer();
|
||||
console.log(answerStr);
|
||||
var input = $('.editageneinput input');
|
||||
console.log(input);
|
||||
input.val(answerStr);
|
||||
} else if (timeout > 30 * 1000) {
|
||||
console.error("Applet did not load on time.");
|
||||
} else {
|
||||
console.log("Waiting for applet...");
|
||||
setTimeout(function() { waitForApplet(applet); }, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
var applets = $('.editageneinput object');
|
||||
applets.each(function(i, el) { initializeApplet(el); });
|
||||
}).call(this);
|
||||
Reference in New Issue
Block a user