summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Ramachandran2015-07-31 12:49:57 +0530
committerPrabhu Ramachandran2015-07-31 12:49:57 +0530
commit0225aad1492600ed53504b0986fd13da24c28ae9 (patch)
tree06e1598081ed64fcc2b034a0cac263f7fe46e354
parentbbb991f8c6dbbcc6d12e93f3574ffcfbec2cb810 (diff)
parent3f0bb01600535b105c265e9da63814af06c0ab9d (diff)
downloadonline_test-0225aad1492600ed53504b0986fd13da24c28ae9.tar.gz
online_test-0225aad1492600ed53504b0986fd13da24c28ae9.tar.bz2
online_test-0225aad1492600ed53504b0986fd13da24c28ae9.zip
Merge pull request #51 from ankitjavalkar/add-travis
Add travis CI
-rw-r--r--.travis.yml22
-rw-r--r--online_test/settings.py8
-rw-r--r--testapp/exam/bash_code_evaluator.py (renamed from testapp/exam/evaluators/bash_code_evaluator.py)0
-rw-r--r--testapp/exam/code_evaluator.py (renamed from testapp/exam/evaluators/code_evaluator.py)0
-rwxr-xr-xtestapp/exam/code_server.py2
-rw-r--r--testapp/exam/cpp_code_evaluator.py (renamed from testapp/exam/evaluators/cpp_code_evaluator.py)0
-rw-r--r--testapp/exam/docs/sample.args (renamed from testapp/docs/sample.args)0
-rwxr-xr-xtestapp/exam/docs/sample.sh (renamed from testapp/docs/sample.sh)0
-rw-r--r--testapp/exam/docs/sample_questions.py (renamed from testapp/docs/sample_questions.py)0
-rw-r--r--testapp/exam/docs/sample_questions.xml (renamed from testapp/docs/sample_questions.xml)0
-rw-r--r--testapp/exam/evaluators/__init__.py0
-rw-r--r--testapp/exam/forms.py4
-rw-r--r--testapp/exam/java_code_evaluator.py (renamed from testapp/exam/evaluators/java_code_evaluator.py)0
-rw-r--r--testapp/exam/language_registry.py (renamed from testapp/exam/evaluators/language_registry.py)0
-rw-r--r--testapp/exam/models.py5
-rw-r--r--testapp/exam/python_code_evaluator.py (renamed from testapp/exam/evaluators/python_code_evaluator.py)0
-rw-r--r--testapp/exam/scilab_code_evaluator.py (renamed from testapp/exam/evaluators/scilab_code_evaluator.py)0
-rw-r--r--testapp/exam/settings.py12
-rw-r--r--testapp/exam/tests.py29
19 files changed, 53 insertions, 29 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..8c064ac
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,22 @@
+language: python
+
+python:
+ - "2.7"
+
+env:
+ - DJANGO=1.5.7
+ - DJANGO=1.6.4
+
+# command to install dependencies
+install:
+ - "easy_install git+https://github.com/FOSSEE/online_test.git#egg=django_exam-0.1"
+ - pip install -q Django==$DJANGO --use-mirrors
+
+before_install:
+ - sudo apt-get update -qq
+ - sudo apt-get install -y scilab
+
+# command to run tests
+script:
+ - nosetests ./testapp/tests/
+ - python manage.py test \ No newline at end of file
diff --git a/online_test/settings.py b/online_test/settings.py
index 9168b08..8916fe2 100644
--- a/online_test/settings.py
+++ b/online_test/settings.py
@@ -64,14 +64,6 @@ DATABASES = {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
- 'spoken_tutorial' : {
- 'ENGINE' : 'django.db.backends.mysql',
- 'NAME' : 'YOUR DATABASE',
- 'USER' : 'YOUR USERNAME',
- 'PASSWORD': 'YOUR PASSWORD',
- 'HOST' :'',
- 'PORT' :'',
- }
}
# Internationalization
diff --git a/testapp/exam/evaluators/bash_code_evaluator.py b/testapp/exam/bash_code_evaluator.py
index a468fd7..a468fd7 100644
--- a/testapp/exam/evaluators/bash_code_evaluator.py
+++ b/testapp/exam/bash_code_evaluator.py
diff --git a/testapp/exam/evaluators/code_evaluator.py b/testapp/exam/code_evaluator.py
index 381b2e8..381b2e8 100644
--- a/testapp/exam/evaluators/code_evaluator.py
+++ b/testapp/exam/code_evaluator.py
diff --git a/testapp/exam/code_server.py b/testapp/exam/code_server.py
index 7c675cb..8f53425 100755
--- a/testapp/exam/code_server.py
+++ b/testapp/exam/code_server.py
@@ -31,7 +31,7 @@ import re
import json
# Local imports.
from settings import SERVER_PORTS, SERVER_POOL_PORT
-from evaluators.language_registry import get_registry, set_registry
+from language_registry import set_registry, get_registry
MY_DIR = abspath(dirname(__file__))
diff --git a/testapp/exam/evaluators/cpp_code_evaluator.py b/testapp/exam/cpp_code_evaluator.py
index 7242884..7242884 100644
--- a/testapp/exam/evaluators/cpp_code_evaluator.py
+++ b/testapp/exam/cpp_code_evaluator.py
diff --git a/testapp/docs/sample.args b/testapp/exam/docs/sample.args
index 4d9f00d..4d9f00d 100644
--- a/testapp/docs/sample.args
+++ b/testapp/exam/docs/sample.args
diff --git a/testapp/docs/sample.sh b/testapp/exam/docs/sample.sh
index e935cb3..e935cb3 100755
--- a/testapp/docs/sample.sh
+++ b/testapp/exam/docs/sample.sh
diff --git a/testapp/docs/sample_questions.py b/testapp/exam/docs/sample_questions.py
index 60f32cb..60f32cb 100644
--- a/testapp/docs/sample_questions.py
+++ b/testapp/exam/docs/sample_questions.py
diff --git a/testapp/docs/sample_questions.xml b/testapp/exam/docs/sample_questions.xml
index 53c76f8..53c76f8 100644
--- a/testapp/docs/sample_questions.xml
+++ b/testapp/exam/docs/sample_questions.xml
diff --git a/testapp/exam/evaluators/__init__.py b/testapp/exam/evaluators/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testapp/exam/evaluators/__init__.py
+++ /dev/null
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py
index b56e545..b7625be 100644
--- a/testapp/exam/forms.py
+++ b/testapp/exam/forms.py
@@ -17,8 +17,8 @@ languages = (
("select", "Select Language"),
("python", "Python"),
("bash", "Bash"),
- ("C", "C Language"),
- ("C++", "C++ Language"),
+ ("c", "C Language"),
+ ("cpp", "C++ Language"),
("java", "Java Language"),
("scilab", "Scilab"),
)
diff --git a/testapp/exam/evaluators/java_code_evaluator.py b/testapp/exam/java_code_evaluator.py
index 4367259..4367259 100644
--- a/testapp/exam/evaluators/java_code_evaluator.py
+++ b/testapp/exam/java_code_evaluator.py
diff --git a/testapp/exam/evaluators/language_registry.py b/testapp/exam/language_registry.py
index 76a23d7..76a23d7 100644
--- a/testapp/exam/evaluators/language_registry.py
+++ b/testapp/exam/language_registry.py
diff --git a/testapp/exam/models.py b/testapp/exam/models.py
index e5a51af..1e1fbea 100644
--- a/testapp/exam/models.py
+++ b/testapp/exam/models.py
@@ -329,10 +329,7 @@ class AnswerPaper(models.Model):
def questions_left(self):
"""Returns the number of questions left."""
qu = self.get_unanswered_questions()
- if len(qu) == 0:
- return 0
- else:
- return qu.count('|') + 1
+ return len(qu)
def get_unanswered_questions(self):
"""Returns the list of unanswered questions."""
diff --git a/testapp/exam/evaluators/python_code_evaluator.py b/testapp/exam/python_code_evaluator.py
index 0c473cf..0c473cf 100644
--- a/testapp/exam/evaluators/python_code_evaluator.py
+++ b/testapp/exam/python_code_evaluator.py
diff --git a/testapp/exam/evaluators/scilab_code_evaluator.py b/testapp/exam/scilab_code_evaluator.py
index 392cd45..392cd45 100644
--- a/testapp/exam/evaluators/scilab_code_evaluator.py
+++ b/testapp/exam/scilab_code_evaluator.py
diff --git a/testapp/exam/settings.py b/testapp/exam/settings.py
index 5d3fb15..55c82dc 100644
--- a/testapp/exam/settings.py
+++ b/testapp/exam/settings.py
@@ -20,10 +20,10 @@ SERVER_TIMEOUT = 2
URL_ROOT = ''
code_evaluators = {
- "python": "evaluators.python_code_evaluator.PythonCodeEvaluator",
- "c": "evaluators.c_cpp_code_evaluator.CCPPCodeEvaluator",
- "cpp": "evaluators.c_cpp_code_evaluator.CCPPCodeEvaluator",
- "java": "evaluators.java_evaluator.JavaCodeEvaluator",
- "bash": "evaluators.bash_evaluator.BashCodeEvaluator",
- "scilab": "evaluators.scilab_evaluator.ScilabCodeEvaluator",
+ "python": "python_code_evaluator.PythonCodeEvaluator",
+ "c": "c_cpp_code_evaluator.CCPPCodeEvaluator",
+ "cpp": "c_cpp_code_evaluator.CCPPCodeEvaluator",
+ "java": "java_code_evaluator.JavaCodeEvaluator",
+ "bash": "bash_code_evaluator.BashCodeEvaluator",
+ "scilab": "scilab_code_evaluator.ScilabCodeEvaluator",
}
diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py
index 7a8d30c..cd84874 100644
--- a/testapp/exam/tests.py
+++ b/testapp/exam/tests.py
@@ -20,6 +20,7 @@ def setUpModule():
# create a quiz
Quiz.objects.create(start_date='2014-06-16', duration=30, active=False,
+ attempts_allowed=-1, time_between_attempts=0,
description='demo quiz', pass_criteria=40,
language='Python', prerequisite=None)
@@ -60,10 +61,11 @@ class QuestionTestCases(unittest.TestCase):
snippet='def myfunc()')
self.question.save()
self.question.tags.add('python', 'function')
- self.testcase = TestCase(question=self.question,
+ self.testcase = TestCase(question=self.question,
func_name='def myfunc', kw_args='a=10,b=11',
pos_args='12,13', expected_answer='15')
- answer_data = {"user_answer": "demo_answer",
+ answer_data = { "test": "",
+ "user_answer": "demo_answer",
"test_parameter": [{"func_name": "def myfunc",
"expected_answer": "15",
"test_id": self.testcase.id,
@@ -71,8 +73,9 @@ class QuestionTestCases(unittest.TestCase):
"kw_args": {"a": "10",
"b": "11"}
}],
- "id": self.question.id,
- "language": "Python"}
+ "id": self.question.id,
+ "ref_code_path": "",
+ }
self.answer_data_json = json.dumps(answer_data)
self.user_answer = "demo_answer"
@@ -180,6 +183,9 @@ class QuestionPaperTestCases(unittest.TestCase):
self.user = User.objects.get(pk=1)
+ self.attempted_papers = AnswerPaper.objects.filter(question_paper=self.question_paper,
+ user=self.user)
+
def test_questionpaper(self):
""" Test question paper"""
self.assertEqual(self.question_paper.quiz.description, 'demo quiz')
@@ -228,7 +234,10 @@ class QuestionPaperTestCases(unittest.TestCase):
def test_make_answerpaper(self):
""" Test make_answerpaper() method of Question Paper"""
- answerpaper = self.question_paper.make_answerpaper(self.user, self.ip)
+ already_attempted = self.attempted_papers.count()
+ attempt_num = already_attempted + 1
+ answerpaper = self.question_paper.make_answerpaper(self.user, self.ip,
+ attempt_num)
self.assertIsInstance(answerpaper, AnswerPaper)
paper_questions = set((answerpaper.questions).split('|'))
self.assertEqual(len(paper_questions), 7)
@@ -249,13 +258,17 @@ class AnswerPaperTestCases(unittest.TestCase):
self.question_paper.save()
# create answerpaper
- self.answerpaper = AnswerPaper(user=self.user, profile=self.profile,
+ self.answerpaper = AnswerPaper(user=self.user,
questions='1|2|3',
question_paper=self.question_paper,
start_time='2014-06-13 12:20:19.791297',
end_time='2014-06-13 12:50:19.791297',
user_ip=self.ip)
self.answerpaper.questions_answered = '1'
+ self.attempted_papers = AnswerPaper.objects.filter(question_paper=self.question_paper,
+ user=self.user)
+ already_attempted = self.attempted_papers.count()
+ self.answerpaper.attempt_number = already_attempted + 1
self.answerpaper.save()
# answers for the Answer Paper
@@ -271,7 +284,6 @@ class AnswerPaperTestCases(unittest.TestCase):
def test_answerpaper(self):
""" Test Answer Paper"""
self.assertEqual(self.answerpaper.user.username, 'demo_user')
- self.assertEqual(self.answerpaper.profile_id, 1)
self.assertEqual(self.answerpaper.user_ip, self.ip)
questions = self.answerpaper.questions
num_questions = len(questions.split('|'))
@@ -299,7 +311,8 @@ class AnswerPaperTestCases(unittest.TestCase):
def test_skip(self):
""" Test skip() method of Answer Paper"""
- next_question_id = self.answerpaper.skip()
+ current_question = self.answerpaper.current_question()
+ next_question_id = self.answerpaper.skip(current_question)
self.assertTrue(next_question_id is not None)
self.assertEqual(next_question_id, '3')