Add in some JS messages for when things go wrong.
This commit is contained in:
@@ -702,7 +702,6 @@ class MatlabInput(CodeInput):
|
||||
log.error("External message should be a JSON serialized dict."
|
||||
" Received queue_msg = %s" % queue_msg)
|
||||
raise
|
||||
# TODO: needs more error checking
|
||||
msg = result['msg']
|
||||
return msg
|
||||
|
||||
|
||||
@@ -60,9 +60,21 @@
|
||||
|
||||
$("#textbox_${id}").find('.CodeMirror-scroll').height(${int(13.5*eval(rows))});
|
||||
|
||||
var gentle_alert = function (parent_elt, msg) {
|
||||
if($(parent_elt).find('.capa_alert').length) {
|
||||
$(parent_elt).find('.capa_alert').remove();
|
||||
}
|
||||
var alert_elem = "<div>" + msg + "</div>";
|
||||
alert_elem = $(alert_elem).addClass('capa_alert');
|
||||
$(parent_elt).find('.action').after(alert_elem);
|
||||
$(parent_elt).find('.capa_alert').css({opacity: 0}).animate({opacity: 1}, 700);
|
||||
}
|
||||
|
||||
|
||||
// hook up the plot button
|
||||
var plot = function(event) {
|
||||
url = $(this).closest('.problems-wrapper').data('url');
|
||||
var problem_elt = $(event.target).closest('.problems-wrapper');
|
||||
url = $(event.target).closest('.problems-wrapper').data('url');
|
||||
input_id = "${id}";
|
||||
|
||||
// save the codemirror text to the textarea
|
||||
@@ -73,31 +85,30 @@
|
||||
|
||||
answer = input.serialize();
|
||||
|
||||
// setup callback for
|
||||
// setup callback for after we send information to plot
|
||||
var plot_callback = function(response) {
|
||||
if(response.success) {
|
||||
window.location.reload();
|
||||
}
|
||||
else {
|
||||
// TODO: show message
|
||||
gentle_alert(problem_elt, msg);
|
||||
}
|
||||
}
|
||||
|
||||
var save_callback = function(response) {
|
||||
if(response.success) {
|
||||
// send information to the problem's plot functionality
|
||||
Problem.inputAjax(url, input_id, 'plot',
|
||||
{'submission': submission}, plot_callback);
|
||||
}
|
||||
else {
|
||||
// TODO: show any messages
|
||||
gentle_alert(problem_elt, msg);
|
||||
}
|
||||
}
|
||||
|
||||
// save the answer
|
||||
$.postWithPrefix(url + '/problem_save', answer, save_callback);
|
||||
|
||||
|
||||
|
||||
}
|
||||
$('#plot_${id}').click(plot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user