summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaheshgudi2017-03-08 14:44:18 +0530
committermaheshgudi2017-03-08 14:44:18 +0530
commit433cc099527acfc7e5146c06f848c283a806f8b5 (patch)
treecfe7e8016cb0518f21f537e1677c102017b8c96f
parent211c12eb1c2002945e228e0f33cd45d494df74ff (diff)
parentaede1c3736077387d63eacd20c2c39d8875e605d (diff)
downloadonline_test-433cc099527acfc7e5146c06f848c283a806f8b5.tar.gz
online_test-433cc099527acfc7e5146c06f848c283a806f8b5.tar.bz2
online_test-433cc099527acfc7e5146c06f848c283a806f8b5.zip
Merge branch 'master' of https://github.com/fossee/online_test into fill_in_the_blanks
-rw-r--r--.travis.yml15
-rw-r--r--requirements/requirements-common.txt2
-rw-r--r--yaksh/live_server_tests/load_test.py30
-rw-r--r--yaksh/live_server_tests/selenium_test.py16
-rw-r--r--yaksh/templates/user.html2
-rw-r--r--yaksh/templates/yaksh/monitor.html20
-rw-r--r--yaksh/templates/yaksh/question.html15
7 files changed, 56 insertions, 44 deletions
diff --git a/.travis.yml b/.travis.yml
index 5b8ff2f..f1c4dab 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,14 +4,6 @@ python:
- "2.7"
- "3.5"
-env:
- - DJANGO=1.9.5
-
-# command to install dependencies
-install:
- - pip install git+https://github.com/FOSSEE/online_test.git#egg=yaksh-0.1
- - pip install -q Django==$DJANGO
-
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y scilab
@@ -19,7 +11,12 @@ before_install:
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
+# command to install dependencies
+install:
+ - pip install -r requirements/requirements-common.txt
+ - python setup.py develop
+
# command to run tests
script:
- python manage.py test -v 2 yaksh
- - python manage.py test -v 2 yaksh.live_server_tests
+ - python manage.py test -v 2 yaksh.live_server_tests.load_test
diff --git a/requirements/requirements-common.txt b/requirements/requirements-common.txt
index 8138a4f..ad29291 100644
--- a/requirements/requirements-common.txt
+++ b/requirements/requirements-common.txt
@@ -3,4 +3,4 @@ django-taggit==0.18.1
pytz==2016.4
python-social-auth==0.2.19
tornado
-selenium
+selenium==2.53.6
diff --git a/yaksh/live_server_tests/load_test.py b/yaksh/live_server_tests/load_test.py
index 17934d4..47d267c 100644
--- a/yaksh/live_server_tests/load_test.py
+++ b/yaksh/live_server_tests/load_test.py
@@ -9,11 +9,11 @@ from selenium.webdriver.firefox.webdriver import WebDriver
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from yaksh.models import User, Profile, Question, Quiz, Course, QuestionPaper, TestCase
-from selenium_test import SeleniumTest
-
from yaksh.code_server import ServerPool
from yaksh import settings
+from .selenium_test import SeleniumTest
+
class YakshSeleniumTests(StaticLiveServerTestCase):
@classmethod
@@ -26,44 +26,42 @@ class YakshSeleniumTests(StaticLiveServerTestCase):
"yaksh.cpp_code_evaluator.CppCodeEvaluator"
settings.code_evaluators['bash']['standardtestcase'] = \
"yaksh.bash_code_evaluator.BashCodeEvaluator"
- settings.SERVER_POOL_PORT = 53578
code_server_pool = ServerPool(ports=settings.SERVER_PORTS, pool_port=settings.SERVER_POOL_PORT)
cls.code_server_pool = code_server_pool
cls.code_server_thread = t = Thread(target=code_server_pool.run)
t.start()
- demo_student = User.objects.create_user(username='demo_student',
+ cls.demo_student = User.objects.create_user(username='demo_student',
password='demo_student',
email='demo_student@test.com'
)
- demo_student_profile = Profile.objects.create(user=demo_student,
+ cls.demo_student_profile = Profile.objects.create(user=cls.demo_student,
roll_number=3, institute='IIT',
department='Chemical', position='Student'
)
- demo_mod = User.objects.create_user(username='demo_mod',
+ cls.demo_mod = User.objects.create_user(username='demo_mod',
password='demo_mod',
email='demo_mod@test.com'
)
- demo_mod_profile = Profile.objects.create(user=demo_mod,
+ cls.demo_mod_profile = Profile.objects.create(user=cls.demo_mod,
roll_number=0, institute='IIT',
department='Chemical', position='Moderator'
)
course_obj = Course()
- course_obj.create_demo(demo_mod)
- demo_course = Course.objects.get(id=1)
+ course_obj.create_demo(cls.demo_mod)
+ cls.demo_course = Course.objects.get(id=1)
- demo_course.students.add(demo_student)
+ cls.demo_course.students.add(cls.demo_student)
@classmethod
def tearDownClass(cls):
- User.objects.all().delete()
- Question.objects.all().delete()
- Quiz.objects.all().delete()
- Course.objects.all().delete()
-
- settings.SERVER_POOL_PORT = 53579
+ cls.demo_student.delete()
+ cls.demo_student_profile.delete()
+ cls.demo_mod.delete()
+ cls.demo_mod_profile.delete()
+ cls.demo_course.delete()
cls.code_server_pool.stop()
cls.code_server_thread.join()
diff --git a/yaksh/live_server_tests/selenium_test.py b/yaksh/live_server_tests/selenium_test.py
index 7eeb22c..d91f3ec 100644
--- a/yaksh/live_server_tests/selenium_test.py
+++ b/yaksh/live_server_tests/selenium_test.py
@@ -8,6 +8,9 @@ from selenium.common.exceptions import WebDriverException
import multiprocessing
import argparse
+class SeleniumTestError(Exception):
+ pass
+
class SeleniumTest():
def __init__(self, url, quiz_name):
self.driver = webdriver.Firefox()
@@ -24,9 +27,12 @@ class SeleniumTest():
self.logout()
self.driver.close()
except Exception as e:
- with open("/tmp/yaksh_load_test_log.txt", "ab") as f:
- f.write('Username: {0}\nError: {1}\n'.format(username, e))
self.driver.close()
+ msg = ("An Error occurred while running the Selenium load"
+ " test on Yaksh!"
+ "Error:\n ".format(e))
+
+ raise SeleniumTestError(msg)
def login(self, username, password):
# get the username, password and submit form elements
@@ -44,7 +50,7 @@ class SeleniumTest():
for count in range(loop_count):
self.driver.find_element_by_link_text(question_label).click()
submit_answer_elem = self.driver.find_element_by_id("check")
- self.driver.execute_script('editor.setValue({})'.format(answer))
+ self.driver.execute_script('global_editor.editor.setValue({});'.format(answer))
submit_answer_elem.click()
def test_c_question(self, question_label):
@@ -105,9 +111,9 @@ class SeleniumTest():
)
start_exam_elem.click()
- self.test_c_question(question_label=1)
+ self.test_c_question(question_label=2)
self.test_python_question(question_label=3)
- self.test_bash_question(question_label=2)
+ self.test_bash_question(question_label=1)
def close_quiz(self):
quit_link_elem = WebDriverWait(self.driver, 5).until(
diff --git a/yaksh/templates/user.html b/yaksh/templates/user.html
index 1707305..0d1f980 100644
--- a/yaksh/templates/user.html
+++ b/yaksh/templates/user.html
@@ -16,7 +16,7 @@
<div class= "collapse navbar-collapse" id="navbar">
<ul class="nav navbar-nav navbar-right">
<li><a href="{{ URL_ROOT }}/exam/viewprofile"> {{ user.get_full_name.title }} </a></li>
- <li><a style='cursor:pointer' onClick='location.replace("{{URL_ROOT}}/exam/logout/");'> <span class="glyphicon glyphicon-log-out">Logout </span></a></li>
+ <li><a style='cursor:pointer' id='logout' onClick='location.replace("{{URL_ROOT}}/exam/complete/");'> <span class="glyphicon glyphicon-log-out">Logout </span></a></li>
</ul>
</div><!-- /.navbar -->
</div><!-- /.container -->
diff --git a/yaksh/templates/yaksh/monitor.html b/yaksh/templates/yaksh/monitor.html
index b84f050..d2c89ce 100644
--- a/yaksh/templates/yaksh/monitor.html
+++ b/yaksh/templates/yaksh/monitor.html
@@ -12,7 +12,16 @@
$(document).ready(function()
{
$("#result-table").tablesorter({sortList: [[5,1]]});
- });
+ var papers_length = "{{papers|length}}";
+ for (var i=0; i < papers_length; i++){
+ var time_left = $("#time_left"+[i]);
+ var time = time_left.text();
+ var hh = Math.floor(time / 3600);
+ var mm = Math.floor((time - (hh * 3600)) / 60);
+ var ss = time - (hh * 3600) - (mm * 60);
+ time_left.text(hh + ":" + mm + ":" + ss)
+ }
+});
</script>
{% endblock %}
@@ -60,7 +69,7 @@ $(document).ready(function()
<p><a href="{{URL_ROOT}}/exam/manage/statistics/question/{{papers.0.question_paper.id}}">Question Statisitics</a></p>
<p><a href="{{URL_ROOT}}/exam/manage/monitor/download_csv/{{papers.0.question_paper.id}}">Download CSV</a></p>
-<table id="result-table" class="tablesorter table">
+<table id="result-table" class="tablesorter table table table-striped">
<thead>
<tr>
<th> Name </th>
@@ -70,7 +79,7 @@ $(document).ready(function()
<th> Questions answered </th>
<th> Marks obtained </th>
<th> Attempts </th>
- <th> Status </th>
+ <th> Time Remaining </th>
</tr>
</thead>
<tbody>
@@ -80,10 +89,11 @@ $(document).ready(function()
<td> {{ paper.user.username }} </td>
<td> {{ paper.user.profile.roll_number }} </td>
<td> {{ paper.user.profile.institute }} </td>
- <td> {{ paper.get_answered_str }} </td>
+ <td> {{ paper.get_answered_str }} </td>
<td> {{ paper.marks_obtained }} </td>
<td> {{ paper.answers.count }} </td>
- <td> {{ paper.status }} </td>
+ <td id="time_left{{forloop.counter0}}"> {{ paper.time_left }} </td>
+ </div>
</tr>
{% endfor %}
</tbody>
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index bfc90a8..0106bac 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -89,7 +89,10 @@ function call_skip(url)
}
</script>
<script>
- $(document).ready(function(){
+
+ var init_val = '{{ last_attempt|escape_quotes|safe }}';
+ var global_editor = {};
+ $(document).ready(function(){
// Codemirror object, language modes and initial content
// Get the textarea node
var textarea_node = document.querySelector('#answer');
@@ -115,17 +118,15 @@ function call_skip(url)
};
// Initialize the codemirror editor
- var editor = CodeMirror.fromTextArea(textarea_node, options);
+ global_editor.editor = CodeMirror.fromTextArea(textarea_node, options);
// Setting code editors initial content
- editor.setValue('{{ last_attempt|escape_quotes|safe }}')
+ global_editor.editor.setValue(init_val);
function reset_editor() {
- editor.setValue('{{ last_attempt|escape_quotes|safe }}');
- editor.clearHistory();
+ global_editor.editor.setValue(init_val);
+ global_editor.editor.clearHistory();
}
-
-
});
</script>