From f4f5f815ac87f788e00b933ce51f5f6d587e9afb Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Mon, 26 Dec 2011 19:15:39 -0500 Subject: [PATCH] Slightly more logging --- problem.html | 5 ++++- problem.js | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/problem.html b/problem.html index 6e003ca7c0..72fecb6b19 100644 --- a/problem.html +++ b/problem.html @@ -4,7 +4,10 @@ % if check_button: - + +% endif +% if reset_button: + % endif % if save_button: diff --git a/problem.js b/problem.js index f003d0cd82..d58ab7cbe0 100644 --- a/problem.js +++ b/problem.js @@ -9,39 +9,49 @@ function ${ id }_load() { $.each($("[id^=input_${ id }_]"), function(index,value){ submit_data[value.id]=value.value; }); - - if($('#check_${ id }').attr('value').substring(0,5) != 'Reset') { - $.getJSON('/modx/problem/${ id }/problem_check', - submit_data, - function(json) { - ${ id }_load(); - }); - } else /* if 'Reset' */ { - $.getJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(json) { - ${ id }_load(); - }); - } + $.getJSON('/modx/problem/${ id }/problem_check', + submit_data, + function(json) { + ${ id }_load(); + }); + log_event('problem_check', submit_data); }); + + $('#reset_${ id }').click(function() { + var submit_data={}; + $.each($("[id^=input_${ id }_]"), function(index,value){ + submit_data[value.id]=value.value; + }); + + $.getJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(json) { + ${ id }_load(); + }); + log_event('problem_reset', submit_data); + }); + $('#show_${ id }').click(function() { $.getJSON('/modx/problem/${ id }/problem_show', function(data) { for (var key in data) { $("#answer_${ id }_"+key).text(data[key]); } }); + log_event('problem_show', submit_data); }); + $('#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'); - }} - ); + $.getJSON('/modx/problem/${ id }/problem_save', + submit_data, function(data){ + if(data.success) { + alert('Saved'); + }} + ); + log_event('problem_save', submit_data); }); } );} $(function() { ${ id }_load(); -}); + });