working on js
This commit is contained in:
@@ -1,11 +1,33 @@
|
||||
$(document).on('click', 'section.sa-wrapper input#show', ( ->
|
||||
root = location.protocol + "//" + location.host
|
||||
post_url=$('section.sa-wrapper input#show').attr('url')
|
||||
alert(post_url)
|
||||
final_url="/courses/MITx/6.002x/2012_Fall/modx/#{post_url}/sa_show"
|
||||
alert(final_url)
|
||||
|
||||
#@$('section.action input.check').click @check
|
||||
$('input#show').click(@show)
|
||||
#$('#save').click(function -> alert('save'))
|
||||
$.post final_url, answer, (response) ->
|
||||
if response.success
|
||||
$('p.rubric').replace(response.rubric)
|
||||
|
||||
$(document).on('click', 'input#save', ( ->
|
||||
answer=$('#answer').text()
|
||||
$.postWithPrefix "modx/6.002x/sa_save", answer, (response) ->
|
||||
alert("save")
|
||||
));
|
||||
|
||||
$(document).on('click', 'section.sa-wrapper input#save', ( ->
|
||||
answer=$('section.sa-wrapper input#answer').val()
|
||||
alert(answer)
|
||||
assessment=0
|
||||
assessment_correct=$('section.sa-wrapper input#assessment_correct').val()
|
||||
alert(assessment_correct)
|
||||
assessment_incorrect=$('section.sa-wrapper input#assessment_incorrect').val()
|
||||
alert(assessment_incorrect)
|
||||
|
||||
root = location.protocol + "//" + location.host
|
||||
post_url=$('section.sa-wrapper input#show').attr('url')
|
||||
alert(post_url)
|
||||
final_url="/courses/MITx/6.002x/2012_Fall/modx/#{post_url}/sa_save"
|
||||
alert(final_url)
|
||||
|
||||
$.post final_url, answer, (response) ->
|
||||
if response.success
|
||||
$('p.rubric').replace(response.rubric)
|
||||
|
||||
@@ -21,5 +43,3 @@ show: =>
|
||||
save: =>
|
||||
alert("save")
|
||||
|
||||
alert($('input#save').attr('url'))
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
|
||||
|
||||
log = logging.getLogger("mitx.courseware")
|
||||
|
||||
rubric_form=('<section class="sa-wrapper" sa_id="two"><input type="radio" name="assessment" value="correct"/>Correct<br/>'
|
||||
'<input type="radio" name="assessment" value="incorrect">'
|
||||
'Incorrect<br/><input type="button" value="Save" id="show" name="show"/></section>')
|
||||
rubric_form=('<section class="sa-wrapper"><input type="radio" name="assessment" id="assessment_correct" value="correct"/>Correct<br/>'
|
||||
'<input type="radio" id="assessment_incorrect" name="assessment" value="incorrect">'
|
||||
'Incorrect<br/><input type="button" value="Save" id="save" name="save"/></section>')
|
||||
|
||||
def only_one(lst, default="", process=lambda x: x):
|
||||
"""
|
||||
@@ -58,9 +58,9 @@ class SelfAssessmentModule(XModule):
|
||||
self.rubric=''.join([etree.tostring(child) for child in only_one(dom2.xpath('rubric'))])
|
||||
self.problem=''.join([etree.tostring(child) for child in only_one(dom2.xpath('problem'))])
|
||||
|
||||
problem_form=('<section class="sa-wrapper" sa_id="one"><input type="text" name="answer" '
|
||||
problem_form=('<section class="sa-wrapper"><input type="text" name="answer" '
|
||||
'id="answer"/><br/>'
|
||||
'<input type="button" value="Check" id ="save" name="save" url="{0}"/>'
|
||||
'<input type="button" value="Check" id ="show" name="show" url="{0}"/>'
|
||||
'<p id="rubric"></p></section>').format(self.location)
|
||||
|
||||
self.problem=''.join([self.problem,problem_form])
|
||||
@@ -87,7 +87,6 @@ class SelfAssessmentModule(XModule):
|
||||
'''
|
||||
|
||||
handlers = {
|
||||
'sa_get' : self.show_problem,
|
||||
'sa_show': self.show_rubric,
|
||||
'sa_save': self.save_problem,
|
||||
}
|
||||
@@ -104,6 +103,12 @@ class SelfAssessmentModule(XModule):
|
||||
})
|
||||
return json.dumps(d, cls=ComplexEncoder)
|
||||
|
||||
|
||||
|
||||
def show_rubric:
|
||||
return {'success': True}
|
||||
|
||||
|
||||
def save_problem(self, get):
|
||||
'''
|
||||
Save the passed in answers.
|
||||
@@ -129,7 +134,7 @@ class SelfAssessmentModule(XModule):
|
||||
|
||||
self.system.track_function('save_problem_succeed', event_info)
|
||||
|
||||
return {'success': True, 'rubric' : self.rubric}
|
||||
return {'success': True}
|
||||
|
||||
|
||||
class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
|
||||
@@ -144,8 +149,6 @@ class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
|
||||
has_score = True
|
||||
template_dir_name = "html"
|
||||
|
||||
|
||||
|
||||
js = {'coffee': [resource_string(__name__, 'js/src/html/edit.coffee')]}
|
||||
js_module_name = "HTMLEditingDescriptor"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user