summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rwxr-xr-xyaksh/code_server.py2
-rw-r--r--yaksh/live_server_tests/selenium_test.py6
-rw-r--r--yaksh/models.py2
-rw-r--r--yaksh/static/yaksh/js/requesthandler.js10
-rw-r--r--yaksh/views.py4
5 files changed, 15 insertions, 9 deletions
diff --git a/yaksh/code_server.py b/yaksh/code_server.py
index 75dd9b2..fc8ef4c 100755
--- a/yaksh/code_server.py
+++ b/yaksh/code_server.py
@@ -203,6 +203,7 @@ def submit(url, uid, json_data, user_dir):
user_dir : str
User directory.
'''
+ print("submitted")
requests.post(
url, data=dict(uid=uid, json_data=json_data, user_dir=user_dir)
)
@@ -229,6 +230,7 @@ def get_result(url, uid, block=False):
Set to True if you wish to block till result is done.
'''
+ print("get triggered")
def _get_data():
r = requests.get(urllib.parse.urljoin(url, str(uid)))
return json.loads(r.content.decode('utf-8'))
diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py
index 859d032..d9ae9cd 100644
--- a/yaksh/live_server_tests/selenium_test.py
+++ b/yaksh/live_server_tests/selenium_test.py
@@ -75,7 +75,7 @@ class SeleniumTest():
def test_c_question(self, question_label):
# Incorrect Answer
- loop_count = 10
+ loop_count = 3
answer = '\"int add(int a, int b, int c)\\n{return;}\"'
self.submit_answer(question_label, answer, loop_count)
@@ -91,7 +91,7 @@ class SeleniumTest():
def test_python_question(self, question_label):
# Incorrect Answer
- loop_count = 10
+ loop_count = 3
answer = '\"def is_palindrome(s):\\n return s\"'
self.submit_answer(question_label, answer, loop_count)
@@ -107,7 +107,7 @@ class SeleniumTest():
def test_bash_question(self, question_label):
# Incorrect Answer
- loop_count = 10
+ loop_count = 3
answer = '\"#!/bin/bash\\nls\"'
self.submit_answer(question_label, answer, loop_count)
diff --git a/yaksh/models.py b/yaksh/models.py
index 9b3cabe..2aee435 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1329,7 +1329,7 @@ class AnswerPaper(models.Model):
user_dir = self.user.profile.get_user_dir()
url = 'http://localhost:%s' % SERVER_POOL_PORT
submit(url, uid, json_data, user_dir)
- result = {'uid': uid, 'state': 'running'}
+ result = {"uid": uid, "state": "running"}
return result
def regrade(self, question_id):
diff --git a/yaksh/static/yaksh/js/requesthandler.js b/yaksh/static/yaksh/js/requesthandler.js
index c5629ab..39114e7 100644
--- a/yaksh/static/yaksh/js/requesthandler.js
+++ b/yaksh/static/yaksh/js/requesthandler.js
@@ -53,13 +53,13 @@ function get_result(uid){
dataType: "html", // Your server can response html, json, xml format.
success: function(data, status, xhr) {
content_type = xhr.getResponseHeader("content-type");
- if(content_type.includes("text/html")) {
+ if(content_type.indexOf("text/html") !== -1) {
clearInterval(checker);
unlock_screen();
document.open();
document.write(data);
document.close();
- } else if(content_type.includes("application/json")) {
+ } else if(content_type.indexOf("application/json") !== -1) {
res = JSON.parse(data);
request_status = res.status;
check_state(request_status, uid);
@@ -116,7 +116,7 @@ $(document).ready(function(){
global_editor.editor.clearHistory();
}
$('#code').submit(function(e) {
- checker = setInterval(check_lock_screen, 30000);
+ checker = setInterval(check_lock_screen, 20000);
lock_screen();
$.ajax({
type: 'POST',
@@ -125,7 +125,7 @@ $(document).ready(function(){
dataType: "html", // Your server can response html, json, xml format.
success: function(data, status, xhr) {
content_type = xhr.getResponseHeader("content-type");
- if(content_type.includes("text/html")) {
+ if(content_type.indexOf("text/html") !== -1) {
request_status = "initial"
count = 0;
clearInterval(checker);
@@ -133,7 +133,7 @@ $(document).ready(function(){
document.open();
document.write(data);
document.close();
- } else if(content_type.includes("application/json")) {
+ } else if(content_type.indexOf("application/json") !== -1) {
res = JSON.parse(data);
var uid = res.uid;
request_status = res.state;
diff --git a/yaksh/views.py b/yaksh/views.py
index fc550ed..dd50d24 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -475,6 +475,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
current_question = get_object_or_404(Question, pk=q_id)
if request.method == 'POST':
+ print("check post")
# Add the answer submitted, regardless of it being correct or not.
if current_question.type == 'mcq':
user_answer = request.POST.get('answer')
@@ -558,6 +559,8 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
result)
return show_question(request, next_question, paper, error_message)
else:
+ print("post response")
+ print(result)
return JsonResponse(result)
else:
next_question, error_message, paper = _update_paper(request, uid, result)
@@ -576,6 +579,7 @@ def get_results(request, uid):
result = json.loads(result_state.get('result'))
next_question, error_message, paper = _update_paper(request, uid, result)
return show_question(request, next_question, paper, error_message)
+ print("get result")
return JsonResponse(result)