diff --git a/problem.html b/problem.html index 1004ebd597..6196f7998c 100644 --- a/problem.html +++ b/problem.html @@ -1,7 +1,11 @@

${ problem['name'] }

${ problem['html'] }
+ % if check_button: % endif +% if save_button: + +% endif diff --git a/problem.js b/problem.js index 902d13c194..7dd3d6c4ce 100644 --- a/problem.js +++ b/problem.js @@ -13,25 +13,27 @@ function ${ id }_load() { $.getJSON('/modx/problem/${ id }/problem_check', submit_data, function(json) { - for(p in json) { - if(json[p]=='correct') - $("#status_"+p).attr("class", "ui-icon ui-icon-check"); - if(json[p]=='incorrect') - $("#status_"+p).attr("class", "ui-icon ui-icon-close"); - $('#check_${ id }').attr("value", "Reset"); - } - }); + ${ id }_load(); + }); } else /* if 'Reset' */ { $.getJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(json) { ${ id }_load(); - //$('#main_${ id }').html(json); - //MathJax.Hub.Queue(["Typeset",MathJax.Hub]); }); } }); - }); -} - + $('#save_${ id }').click(function() { + var submit_data={}; + $.each($("[id^=input_${ id }_]"), function(index,value){ + submit_data[value.id]=value.value;}); + $.getJSON('/modx/problem/${ id }/problem_save', + submit_data, function(data){ + if(data.success) { + alert('Saved'); + }} + ); + }); + } + );} $(function() { ${ id }_load(); }); diff --git a/seq_module.js b/seq_module.js index 766f24ef40..7483e89534 100644 --- a/seq_module.js +++ b/seq_module.js @@ -1,4 +1,4 @@ -// CRITICAL TODO: Namespace +// IMPORTANT TODO: Namespace var ${ id }contents=["", %for t in items: @@ -7,19 +7,27 @@ var ${ id }contents=["", "" ]; -var ${ id }functions=["", +var ${ id }init_functions=["", %for t in items: function(){ ${t[1]['init_js']} }, %endfor ""]; -var ${ id }loc; +var ${ id }destroy_functions=["", + %for t in items: + function(){ ${t[1]['destroy_js']} }, + %endfor + ""]; + +var ${ id }loc = -1; function ${ id }goto(i) { // TODO: // ${ id }contents[${ id }loc] = $('#content').html(); + if (${ id }loc!=-1) + ${ id }init_functions[ ${ id }loc ](); $('#content').html(${ id }contents[i]); - ${ id }functions[i]() + ${ id }init_functions[i]() $('#tt_'+${ id }loc).attr("style", "background-color:grey"); ${ id }loc=i; $('#tt_'+i).attr("style", "background-color:red");