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,39 +9,49 @@ function ${ id }_load() { ...@@ -9,39 +9,49 @@ 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;
}); });
$.getJSON('/modx/problem/${ id }/problem_check',
submit_data,
function(json) {
${ id }_load();
});
log_event('problem_check', submit_data);
});
if($('#check_${ id }').attr('value').substring(0,5) != 'Reset') { $('#reset_${ id }').click(function() {
$.getJSON('/modx/problem/${ id }/problem_check', var submit_data={};
submit_data, $.each($("[id^=input_${ id }_]"), function(index,value){
function(json) { submit_data[value.id]=value.value;
${ id }_load(); });
});
} else /* if 'Reset' */ { $.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){
submit_data[value.id]=value.value;}); submit_data[value.id]=value.value;});
$.getJSON('/modx/problem/${ id }/problem_save', $.getJSON('/modx/problem/${ id }/problem_save',
submit_data, function(data){ submit_data, function(data){
if(data.success) { if(data.success) {
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