summaryrefslogtreecommitdiff
path: root/yaksh/static
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-11-23 21:47:52 +0530
committerGitHub2017-11-23 21:47:52 +0530
commit63326f9519478f0d9bfb0b843e5dac8ab29428f4 (patch)
tree51b7146d13a6e01ac24778ae0926438e6ffbd571 /yaksh/static
parent8f9bc94eacb013649c427b9279b359e2a17b8869 (diff)
parent252449b7b96d73548f53ecd0c3256aa0e777d1dd (diff)
downloadonline_test-63326f9519478f0d9bfb0b843e5dac8ab29428f4.tar.gz
online_test-63326f9519478f0d9bfb0b843e5dac8ab29428f4.tar.bz2
online_test-63326f9519478f0d9bfb0b843e5dac8ab29428f4.zip
Merge pull request #400 from maheshgudi/ajax_questions
Display error output without page reloading
Diffstat (limited to 'yaksh/static')
-rw-r--r--yaksh/static/yaksh/css/exam.css2
-rw-r--r--yaksh/static/yaksh/js/requesthandler.js25
2 files changed, 23 insertions, 4 deletions
diff --git a/yaksh/static/yaksh/css/exam.css b/yaksh/static/yaksh/css/exam.css
index ec48a14..7d10629 100644
--- a/yaksh/static/yaksh/css/exam.css
+++ b/yaksh/static/yaksh/css/exam.css
@@ -4,4 +4,4 @@ table td, table th { border: black solid 1px !important;
}
#stdio, #assertion {
table-layout: fixed
-} \ No newline at end of file
+}
diff --git a/yaksh/static/yaksh/js/requesthandler.js b/yaksh/static/yaksh/js/requesthandler.js
index 7ff90df..5159c31 100644
--- a/yaksh/static/yaksh/js/requesthandler.js
+++ b/yaksh/static/yaksh/js/requesthandler.js
@@ -53,16 +53,35 @@ function response_handler(method_type, content_type, data, uid){
} else if(content_type.indexOf("application/json") !== -1) {
res = JSON.parse(data);
request_status = res.status;
- if(method_type === "POST") {
- uid = res.uid;
+ if (request_status){
+ if(method_type === "POST") {
+ uid = res.uid;
+ }
+ check_state(request_status, uid);
+ }
+ else{
+ unlock_screen();
+ if ($("#notification")){
+ $("#notification").toggle();
+ }
+
+ var error_output = document.getElementById("error_panel");
+ error_output.innerHTML = res.error;
+ focus_on_error(error_output);
}
- check_state(request_status, uid);
} else {
reset_values();
unlock_screen();
}
}
+function focus_on_error(ele){
+ if (ele) {
+ ele.scrollIntoView(true);
+ window.scrollBy(0, -15);
+ }
+ }
+
function ajax_check_code(url, method_type, data_type, data, uid) {
$.ajax({
method: method_type,