summaryrefslogtreecommitdiff
path: root/testapp
diff options
context:
space:
mode:
authorprathamesh2013-08-19 13:09:10 +0530
committerprathamesh2013-08-19 13:09:10 +0530
commitfbeed0456532b2b36f02a26dbfffc132235d5e4c (patch)
tree3a4f08f8e889b4d27a018ea6915d954bf445f1c3 /testapp
parent754244da53f7e0a63c272ce6d1ffb15c1d5be0ae (diff)
downloadonline_test-fbeed0456532b2b36f02a26dbfffc132235d5e4c.tar.gz
online_test-fbeed0456532b2b36f02a26dbfffc132235d5e4c.tar.bz2
online_test-fbeed0456532b2b36f02a26dbfffc132235d5e4c.zip
This branch was created for testing the app.
Changes made here are during the testing phase. And the feedbacks recevied are implemented.
Diffstat (limited to 'testapp')
-rwxr-xr-xtestapp/c_cpp_files/main_array_check.cpp34
-rwxr-xr-xtestapp/c_cpp_files/main_array_check_all.cpp34
-rwxr-xr-xtestapp/c_cpp_files/main_check_digit.cpp32
-rwxr-xr-xtestapp/c_cpp_files/main_count667.cpp42
-rwxr-xr-xtestapp/c_cpp_files/main_count7.cpp42
-rwxr-xr-xtestapp/c_cpp_files/main_mean.cpp38
-rwxr-xr-xtestapp/c_cpp_files/main_roundTo10.cpp42
-rwxr-xr-xtestapp/c_cpp_files/main_specialSum.cpp42
-rwxr-xr-xtestapp/c_cpp_files/main_within.cpp38
-rw-r--r--testapp/exam/urls.py6
-rw-r--r--testapp/exam/views.py44
-rw-r--r--testapp/templates/exam/quizzes_user.html2
-rw-r--r--testapp/templates/exam/results_user.html2
-rw-r--r--testapp/templates/exam/show_quiz.html1
-rw-r--r--testapp/templates/exam/showquestionpapers.html4
15 files changed, 378 insertions, 25 deletions
diff --git a/testapp/c_cpp_files/main_array_check.cpp b/testapp/c_cpp_files/main_array_check.cpp
new file mode 100755
index 0000000..38b9004
--- /dev/null
+++ b/testapp/c_cpp_files/main_array_check.cpp
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern bool array_check(int [], int);
+
+template <class T>
+
+void check(T expect,T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ bool result;
+ int a[] = {1,2,3,0,0};
+ result = array_check(a, 2);
+ printf("Input submitted to the function: {1, 2, 3, 0, 0} and index 2");
+ check(false, result);
+ int b[] = {1,2,3,4,5};
+ result = array_check(b, 3);
+ printf("Input submitted to the function: {1, 2, 3, 4, 5} and index 3");
+ check(true, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_array_check_all.cpp b/testapp/c_cpp_files/main_array_check_all.cpp
new file mode 100755
index 0000000..fc740a9
--- /dev/null
+++ b/testapp/c_cpp_files/main_array_check_all.cpp
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern bool array_check_all(int []);
+
+template <class T>
+
+void check(T expect,T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ bool result;
+ int a[] = {1,2,3,2,8};
+ result = array_check_all(a);
+ printf("Input submitted to the function: {1, 2, 3, 2, 8}");
+ check(false, result);
+ int b[] = {4,2,32,4,56};
+ result = array_check_all(b);
+ printf("Input submitted to the function: {4, 2, 32, 4, 56}");
+ check(true, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_check_digit.cpp b/testapp/c_cpp_files/main_check_digit.cpp
new file mode 100755
index 0000000..80a92aa
--- /dev/null
+++ b/testapp/c_cpp_files/main_check_digit.cpp
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern bool check_digit(int, int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ bool result;
+ result = check_digit(12, 23);
+ printf("Input submitted to the function: 12, 23");
+ check(true, result);
+ result = check_digit(22, 11);
+ printf("Input submitted to the function: 121");
+ check(false, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_count667.cpp b/testapp/c_cpp_files/main_count667.cpp
new file mode 100755
index 0000000..dc33ede
--- /dev/null
+++ b/testapp/c_cpp_files/main_count667.cpp
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int count667(int[]);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ int arr[5] = {2,6,4,5,6};
+ result = count667(arr);
+ printf("Input submitted to the function: [2, 6, 4, 5,6]");
+ check(0, result);
+ int arr2[5] = {6,6,2,17,9};
+ result = count667(arr2);
+ printf("Input submitted to the function: [6, 6, 2, 17, 9]");
+ check(1, result);
+ int arr3[5] = {6,6,6,7,1};
+ result = count667(arr3);
+ printf("Input submitted to the function: [6, 6, 7, 2, 1]");
+ check(3, result);
+ int arr4[5] = {6,7,7,6,6};
+ result = count667(arr4);
+ printf("Input submitted to the function: [6, 7, 7, 6, 6]");
+ check(2, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_count7.cpp b/testapp/c_cpp_files/main_count7.cpp
new file mode 100755
index 0000000..92971fd
--- /dev/null
+++ b/testapp/c_cpp_files/main_count7.cpp
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int count7(int[]);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ int arr[4] = {2,3,4,5};
+ result = count7(arr);
+ printf("Input submitted to the function: [2, 3, 4, 5]");
+ check(0, result);
+ int arr2[4] = {1,2,17,9};
+ result = count7(arr2);
+ printf("Input submitted to the function: [1, 2, 17, 9]");
+ check(0, result);
+ int arr3[4] = {7,9,2,1};
+ result = count7(arr3);
+ printf("Input submitted to the function: [7, 9, 2, 1]");
+ check(1, result);
+ int arr4[4] = {1,7,7,7};
+ result = count7(arr4);
+ printf("Input submitted to the function: [1, 7, 7, 7]");
+ check(3, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_mean.cpp b/testapp/c_cpp_files/main_mean.cpp
new file mode 100755
index 0000000..f23db68
--- /dev/null
+++ b/testapp/c_cpp_files/main_mean.cpp
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern bool mean(int, int , int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ bool result;
+ result = mean(11, 11, 11);
+ printf("Input submitted to the function: 11, 121, 11");
+ check(true, result);
+ result = mean(16, 12, 9);
+ printf("Input submitted to the function: 16, 144, 9");
+ check(true, result);
+ result = mean(19, 221, 9);
+ printf("Input submitted to the function: 19, 221, 9");
+ check(false, result);
+ result = mean(34, 12, 3);
+ printf("Input submitted to the function: 11, 121, 11");
+ check(false, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_roundTo10.cpp b/testapp/c_cpp_files/main_roundTo10.cpp
new file mode 100755
index 0000000..0a1284e
--- /dev/null
+++ b/testapp/c_cpp_files/main_roundTo10.cpp
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int roundTo10(int,int,int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ result = roundTo10(10, 22, 39);
+ printf("Input submitted to the function: 10, 22, 39");
+ check(70, result);
+ result = roundTo10(45, 42, 39);
+ printf("Input submitted to the function: 45, 42, 39");
+ check(130, result);
+ result = roundTo10(7, 3, 9);
+ printf("Input submitted to the function: 7, 3, 9");
+ check(20, result);
+ result = roundTo10(1, 2, 3);
+ printf("Input submitted to the function: 1, 2, 3");
+ check(0, result);
+ result = roundTo10(30, 40, 50);
+ printf("Input submitted to the function: 30, 40, 50");
+ check(120, result);
+
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_specialSum.cpp b/testapp/c_cpp_files/main_specialSum.cpp
new file mode 100755
index 0000000..5d0fcae
--- /dev/null
+++ b/testapp/c_cpp_files/main_specialSum.cpp
@@ -0,0 +1,42 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern int specialSum(int,int,int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ int result;
+ result = specialSum(10, 2, 9);
+ printf("Input submitted to the function: 10, 2, 9");
+ check(21, result);
+ result = specialSum(1, 21, 9);
+ printf("Input submitted to the function: 1, 21, 9");
+ check(1, result);
+ result = specialSum(21, 2, 3);
+ printf("Input submitted to the function: 21, 2, 3");
+ check(0, result);
+ result = specialSum(10, 2, 21);
+ printf("Input submitted to the function: 10, 2, 21");
+ check(12, result);
+ result = specialSum(10, 2, 6);
+ printf("Input submitted to the function: 10, 2, 6");
+ check(18, result);
+
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/c_cpp_files/main_within.cpp b/testapp/c_cpp_files/main_within.cpp
new file mode 100755
index 0000000..d83c50d
--- /dev/null
+++ b/testapp/c_cpp_files/main_within.cpp
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+extern bool within(int, int, int);
+
+template <class T>
+
+void check(T expect, T result)
+{
+ if (expect == result)
+ {
+ printf("\nCorrect:\n Expected %d got %d \n",expect,result);
+ }
+ else
+ {
+ printf("\nIncorrect:\n Expected %d got %d \n",expect,result);
+ exit (1);
+ }
+}
+
+int main(void)
+{
+ bool result;
+ result = within(12, 3, 20);
+ printf("Input submitted to the function: 12, 3, 20");
+ check(true, result);
+ result = within(12, 13, 20);
+ printf("Input submitted to the function: 12, 13, 20");
+ check(false, result);
+ result = within(29, 13, 120);
+ printf("Input submitted to the function: 29, 13, 120");
+ check(true, result);
+ result = within(12, 12, 20);
+ printf("Input submitted to the function: 12, 3, 20");
+ check(false, result);
+ printf("All Correct\n");
+ return 0;
+}
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py
index 14aaa8a..33b2edf 100644
--- a/testapp/exam/urls.py
+++ b/testapp/exam/urls.py
@@ -8,14 +8,14 @@ urlpatterns = patterns('exam.views',
url(r'^start/$', 'start'),
url(r'^start/(?P<questionpaper_id>\d+)/$','start'),
url(r'^quit/(?P<questionpaper_id>\d+)/$', 'quit'),
- url(r'^intro/$','start'),
+ url(r'^intro/(?P<questionpaper_id>\d+)/$','intro'),
url(r'^complete/$', 'complete'),
url(r'^complete/(?P<questionpaper_id>\d+)/$', 'complete'),
url(r'^register/$', 'user_register'),
url(r'^(?P<q_id>\d+)/$', 'question'),
url(r'^(?P<q_id>\d+)/check/$', 'check'),
url(r'^(?P<q_id>\d+)/check/(?P<questionpaper_id>\d+)/$', 'check'),
-
+ url(r'^intro/$', 'start'),
url(r'^manage/$', 'prof_manage'),
url(r'^manage/addquestion/$', 'add_question'),
@@ -32,7 +32,7 @@ urlpatterns = patterns('exam.views',
url(r'^manage/showquestionpapers/$','show_all_questionpapers'),
url(r'^manage/showquestionpapers/(?P<questionpaper_id>\d+)/$',\
'show_all_questionpapers'),
- url(r'^manage/monitor/(?P<quiz_id>\d+)/$', 'monitor'),
+ url(r'^manage/monitor/(?P<questionpaper_id>\d+)/$', 'monitor'),
url(r'^manage/user_data/(?P<username>[a-zA-Z0-9_.]+)/$','user_data'),
url(r'^manage/designquestionpaper/$','design_questionpaper'),
url(r'^manage/designquestionpaper/(?P<questionpaper_id>\d+)/$',\
diff --git a/testapp/exam/views.py b/testapp/exam/views.py
index 2545d8b..f21357e 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -151,6 +151,14 @@ def quizlist_user(request):
context = {'quizzes': avail_quiz, 'user': user}
return my_render_to_response("exam/quizzes_user.html", context)
+def intro(request, questionpaper_id):
+ """Show introduction page before quiz starts"""
+ user = request.user
+ context = {'user': user, 'paper_id': questionpaper_id }
+ ci = RequestContext(request)
+ return my_render_to_response('exam/intro.html', context,
+ context_instance=ci)
+
def results_user(request):
"""Show list of Results of Quizzes that is taken by logged-in user."""
@@ -158,7 +166,11 @@ def results_user(request):
papers = AnswerPaper.objects.filter(user=user)
quiz_marks = []
for paper in papers:
- temp = paper.question_paper.quiz.description, paper.get_total_marks()
+ marks_obtained = paper.get_total_marks()
+ max_marks = paper.question_paper.total_marks
+ percentage = round((marks_obtained/max_marks)*100,2)
+ temp = paper.question_paper.quiz.description, marks_obtained,\
+ max_marks, percentage
quiz_marks.append(temp)
context = {'papers': quiz_marks}
return my_render_to_response("exam/results_user.html", context)
@@ -653,16 +665,9 @@ def start(request, questionpaper_id=None):
questions = [str(_.id) for _ in questionpaper.questions.all()]
random.shuffle(questions)
- #questions = questionpaper.questions
- #random.shuffle(questions)
new_paper.questions = "|".join(questions)
new_paper.save()
- # Show the user the intro page.
- context = {'user': user, 'paper_id': questionpaper_id}
- ci = RequestContext(request)
- return my_render_to_response('exam/intro.html', context,
- context_instance=ci)
-
+ return start(request, questionpaper_id)
def question(request, q_id, questionpaper_id,success_msg=None):
"""Check the credentials of the user and start the exam."""
@@ -680,7 +685,9 @@ def question(request, q_id, questionpaper_id,success_msg=None):
if not paper.question_paper.quiz.active:
reason='The quiz has been deactivated!'
return complete(request, reason, questionpaper_id)
-
+ #if new:
+ # paper.start_time = datetime.datetime.now()
+ # paper.end_time = datetime.datetime.now()
time_left = paper.time_left()
if time_left == 0:
return complete(request, reason='Your time is up!')
@@ -731,7 +738,6 @@ def check(request, q_id, questionpaper_id=None):
if question.type == 'mcq':
# Add the answer submitted, regardless of it being correct or not.
if user_answer is not None :
- print "EEERRRROOOORRRRRRR :P"
new_answer = Answer(question=question, answer=user_answer,
correct=False)
new_answer.save()
@@ -790,13 +796,9 @@ def check(request, q_id, questionpaper_id=None):
context_instance=ci)
else:
if time_left <= 0:
- print "success"
- print str(time_left)
reason='Your time is up!'
return complete(request, reason, questionpaper_id)
else:
- print "fail"
- print time_left
next_q = paper.completed_question(question.id)
return show_question(request, next_q, questionpaper_id,success_msg)
@@ -850,14 +852,14 @@ def complete(request, reason=None, questionpaper_id=None):
return my_redirect('/exam/')
-def monitor(request, quiz_id=None):
+def monitor(request, questionpaper_id=None):
"""Monitor the progress of the papers taken so far."""
user = request.user
if not user.is_authenticated() or not is_moderator(user):
raise Http404('You are not allowed to view this page!')
- if quiz_id is None:
+ if questionpaper_id is None:
q_paper = QuestionPaper.objects.all()
context = {'papers': [],
'quiz': None,
@@ -866,15 +868,15 @@ def monitor(request, quiz_id=None):
context_instance=RequestContext(request))
# quiz_id is not None.
try:
- quiz = QuestionPaper.objects.get(id=quiz_id)
+ q_paper = QuestionPaper.objects.get(id=questionpaper_id)
except QuestionPaper.DoesNotExist:
papers = []
- quiz = None
+ q_paper = None
else:
- papers = AnswerPaper.objects.all().annotate(
+ papers = AnswerPaper.objects.filter(question_paper=q_paper).annotate(
total=Sum('answers__marks')).order_by('-total')
- context = {'papers': papers, 'quiz': quiz, 'quizzes': None}
+ context = {'papers': papers, 'quiz': q_paper, 'quizzes': None}
return my_render_to_response('exam/monitor.html', context,
context_instance=RequestContext(request))
diff --git a/testapp/templates/exam/quizzes_user.html b/testapp/templates/exam/quizzes_user.html
index af2d98a..b55d3e5 100644
--- a/testapp/templates/exam/quizzes_user.html
+++ b/testapp/templates/exam/quizzes_user.html
@@ -12,7 +12,7 @@
<center><h4>No active quizzes for you</h4></center>
{% endif %}
{% for paper in quizzes %}
- <a href="{{ URL_ROOT }}/exam/start/{{paper.id}}">{{ paper.quiz.description }}</a><br>
+ <a href="{{ URL_ROOT }}/exam/intro/{{paper.id}}">{{ paper.quiz.description }}</a><br>
{% endfor %}
{% endblock %}
diff --git a/testapp/templates/exam/results_user.html b/testapp/templates/exam/results_user.html
index bf847c0..2a2a309 100644
--- a/testapp/templates/exam/results_user.html
+++ b/testapp/templates/exam/results_user.html
@@ -13,6 +13,8 @@
<center><table class="span6">
<th>Quiz Description
<th>Obtained Marks
+ <th>Maximum Marks
+ <th>Percentage
{% for paper in papers %}
<tr>
{% for i in paper %}
diff --git a/testapp/templates/exam/show_quiz.html b/testapp/templates/exam/show_quiz.html
index 886a696..cf3f552 100644
--- a/testapp/templates/exam/show_quiz.html
+++ b/testapp/templates/exam/show_quiz.html
@@ -10,6 +10,7 @@
{% block manage %}
{% if not quizzes and not quiz %}
<center><h5> No quizzes available. </h5></center>
+<button class="btn" type="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/addquiz");'>Add New Quiz</button>&nbsp;&nbsp;
{% endif %}
{# ############################################################### #}
diff --git a/testapp/templates/exam/showquestionpapers.html b/testapp/templates/exam/showquestionpapers.html
index 26b756d..e511472 100644
--- a/testapp/templates/exam/showquestionpapers.html
+++ b/testapp/templates/exam/showquestionpapers.html
@@ -8,6 +8,7 @@
{% endblock %}
{% block manage %}
+{% if papers %}
<form name=frm action="" method="post">
{% csrf_token %}
{% for i in papers %}
@@ -16,4 +17,7 @@
<br>
<button class="btn" type="submit" onClick="return confirm_delete(frm);" name='delete' value='delete'>Delete Selected</button>
</form>
+{% else %}
+<center><h3>No Question Papers available</h3></center>
+{% endif %}
{% endblock %}