Commit f4f5f815 by Piotr Mitros

Slightly more logging

parent a8d0bafc
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
<input type="hidden" name="problem_id" value="${ problem['name'] }"> <input type="hidden" name="problem_id" value="${ problem['name'] }">
% if check_button: % if check_button:
<input id="check_${ id }" type="button" value="${ check_button }" > <input id="check_${ id }" type="button" value="Check ${ attempts }" >
% endif
% if reset_button:
<input id="reset_${ id }" type="button" value="Reset ${ attempts }" >
% endif % endif
% if save_button: % if save_button:
<input id="save_${ id }" type="button" value="Save" > <input id="save_${ id }" type="button" value="Save" >
......
...@@ -9,26 +9,35 @@ function ${ id }_load() { ...@@ -9,26 +9,35 @@ function ${ id }_load() {
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
submit_data[value.id]=value.value; submit_data[value.id]=value.value;
}); });
if($('#check_${ id }').attr('value').substring(0,5) != 'Reset') {
$.getJSON('/modx/problem/${ id }/problem_check', $.getJSON('/modx/problem/${ id }/problem_check',
submit_data, submit_data,
function(json) { function(json) {
${ id }_load(); ${ id }_load();
}); });
} else /* if 'Reset' */ { 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) { $.getJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(json) {
${ id }_load(); ${ id }_load();
}); });
} log_event('problem_reset', submit_data);
}); });
$('#show_${ id }').click(function() { $('#show_${ id }').click(function() {
$.getJSON('/modx/problem/${ id }/problem_show', function(data) { $.getJSON('/modx/problem/${ id }/problem_show', function(data) {
for (var key in data) { for (var key in data) {
$("#answer_${ id }_"+key).text(data[key]); $("#answer_${ id }_"+key).text(data[key]);
} }
}); });
log_event('problem_show', submit_data);
}); });
$('#save_${ id }').click(function() { $('#save_${ id }').click(function() {
var submit_data={}; var submit_data={};
$.each($("[id^=input_${ id }_]"), function(index,value){ $.each($("[id^=input_${ id }_]"), function(index,value){
...@@ -39,9 +48,10 @@ function ${ id }_load() { ...@@ -39,9 +48,10 @@ function ${ id }_load() {
alert('Saved'); alert('Saved');
}} }}
); );
log_event('problem_save', submit_data);
}); });
} }
);} );}
$(function() { $(function() {
${ id }_load(); ${ id }_load();
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment