Commit 3ae3356b authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Change platform js lib 'medal-0.0.2.js' to accept an error callback

parent 35a4bf7e
Pipeline #984 passed with stages
in 14 minutes and 9 seconds
......@@ -1064,7 +1064,7 @@ checksum = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48"
[[package]]
name = "medal"
version = "1.7.1"
version = "1.7.2"
dependencies = [
"bcrypt",
"csv",
......
......@@ -14,17 +14,17 @@ function hash_to_dict() {
window.hashdict = hash_to_dict();
window.load_task_object = function (callback) {
window.load_task_object = function (callback, error) {
console.log(callback);
$.get("/load/" + window.hashdict["taskid"], {},
function(data) {
callback(data);
}, "json").fail(function(){
alert("Load failed.");
if (error) { error(); } else { alert("Load failed."); }
})
}
window.save_task_object = function (object, grade, callback) {
window.save_task_object = function (object, grade, callback, error) {
if (!grade) grade = 0;
if (!callback) callback = function(data){};
......@@ -34,12 +34,12 @@ window.save_task_object = function (object, grade, callback) {
grade: JSON.stringify(grade)
}
$.post("/save/" + window.hashdict["taskid"], params, callback, "json").fail(function(){
alert("Save failed.");
if (error) { error(); } else { alert("Save failed."); }
});
}
window.load_subtask_object = function (subtaskname, callback) {
window.load_subtask_object = function (subtaskname, callback, error) {
var params = {
subtask: subtaskname
}
......@@ -47,11 +47,11 @@ window.load_subtask_object = function (subtaskname, callback) {
function(data) {
callback(data);
}, "json").fail(function(){
alert("Load failed.");
if (error) { error(); } else { alert("Load failed."); }
})
}
window.save_subtask_object = function (subtaskname, object, grade, callback) {
window.save_subtask_object = function (subtaskname, object, grade, callback, error) {
if (!grade) grade = 0;
if (!callback) callback = function(data){};
......@@ -62,6 +62,6 @@ window.save_subtask_object = function (subtaskname, object, grade, callback) {
grade: JSON.stringify(grade)
}
$.post("/save/" + window.hashdict["taskid"], params, callback, "json").fail(function(){
alert("Save failed.");
if (error) { error(); } else { alert("Save failed."); }
});
}
......@@ -59,8 +59,12 @@ function getTaskProxyCallback(task) {
task.reloadAnswer('', reloadAnswerCallback, ec("task.reloadAnswer"));
}
}
function load_task_error() {
task.reloadAnswer('', reloadAnswerCallback, ec("task.reloadAnswer"));
alert("Laden fehlgeschlagen");
}
window.load_task_object(load_task_callback);
window.load_task_object(load_task_callback, load_task_error);
}
function showViewsCallback(){
......@@ -83,8 +87,12 @@ function getTaskProxyCallback(task) {
function save_task_callback() {
console.log("OK transmission");
};
function save_task_error() {
console.log("ERROR transmission");
alert("Speichern fehlgeschlagen");
};
window.save_task_object({"text": answer}, score, save_task_callback)
window.save_task_object({"text": answer}, score, save_task_callback, save_task_error);
}
task.gradeAnswer(answer, {}, gradeAnswerCallback, ec("task.gradeAnswer"));
......
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