summaryrefslogtreecommitdiff
path: root/testapp
diff options
context:
space:
mode:
Diffstat (limited to 'testapp')
-rwxr-xr-xtestapp/c_cpp_files/main_array_check.cpp8
-rwxr-xr-xtestapp/c_cpp_files/main_array_check_all.cpp8
-rwxr-xr-xtestapp/c_cpp_files/main_blackJack.cpp18
-rwxr-xr-xtestapp/c_cpp_files/main_check_digit.cpp4
-rwxr-xr-xtestapp/c_cpp_files/main_count667.cpp18
-rwxr-xr-xtestapp/c_cpp_files/main_count7.cpp18
-rwxr-xr-xtestapp/c_cpp_files/main_lessThan9.cpp8
-rwxr-xr-xtestapp/c_cpp_files/main_mean.cpp10
-rwxr-xr-xtestapp/c_cpp_files/main_roundTo10.cpp19
-rwxr-xr-xtestapp/c_cpp_files/main_specialSum.cpp19
-rwxr-xr-xtestapp/c_cpp_files/main_within.cpp14
-rw-r--r--testapp/exam/views.py32
-rw-r--r--testapp/templates/exam/automatic_questionpaper.html2
13 files changed, 84 insertions, 94 deletions
diff --git a/testapp/c_cpp_files/main_array_check.cpp b/testapp/c_cpp_files/main_array_check.cpp
index 38b9004..ea34fdd 100755
--- a/testapp/c_cpp_files/main_array_check.cpp
+++ b/testapp/c_cpp_files/main_array_check.cpp
@@ -21,13 +21,13 @@ void check(T expect,T result)
int main(void)
{
bool result;
- int a[] = {1,2,3,0,0};
+ 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");
+ 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");
+ 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
index fc740a9..140578e 100755
--- a/testapp/c_cpp_files/main_array_check_all.cpp
+++ b/testapp/c_cpp_files/main_array_check_all.cpp
@@ -21,13 +21,13 @@ void check(T expect,T result)
int main(void)
{
bool result;
- int a[] = {1,2,3,2,8};
+ int a[] = {1,2,3,2,8};
result = array_check_all(a);
- printf("Input submitted to the function: {1, 2, 3, 2, 8}");
+ 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}");
+ 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_blackJack.cpp b/testapp/c_cpp_files/main_blackJack.cpp
index e4f0963..cc54e78 100755
--- a/testapp/c_cpp_files/main_blackJack.cpp
+++ b/testapp/c_cpp_files/main_blackJack.cpp
@@ -22,20 +22,20 @@ int main(void)
{
int result;
result = blackJack(11, 12);
- printf("Input submitted to the function: 11, 12");
+ printf("Input submitted to the function: 11, 12");
check(12, result);
result = blackJack(15, 19);
- printf("Input submitted to the function: 15, 19");
+ printf("Input submitted to the function: 15, 19");
check(19, result);
result = blackJack(10, 21);
- printf("Input submitted to the function: 10, 21");
+ printf("Input submitted to the function: 10, 21");
check(21, result);
- result = blackJack(31, 22);
- printf("Input submitted to the function: 31, 22");
- check(0, result);
- result = blackJack(91, 61);
- printf("Input submitted to the function: 91, 61");
- check(0, result);
+ result = blackJack(31, 22);
+ printf("Input submitted to the function: 31, 22");
+ check(0, result);
+ result = blackJack(91, 61);
+ printf("Input submitted to the function: 91, 61");
+ check(0, 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
index 80a92aa..d3bf3d6 100755
--- a/testapp/c_cpp_files/main_check_digit.cpp
+++ b/testapp/c_cpp_files/main_check_digit.cpp
@@ -22,10 +22,10 @@ int main(void)
{
bool result;
result = check_digit(12, 23);
- printf("Input submitted to the function: 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");
+ 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
index dc33ede..f146e8c 100755
--- a/testapp/c_cpp_files/main_count667.cpp
+++ b/testapp/c_cpp_files/main_count667.cpp
@@ -21,22 +21,22 @@ void check(T expect, T result)
int main(void)
{
int result;
- int arr[5] = {2,6,4,5,6};
+ int arr[5] = {2,6,4,5,6};
result = count667(arr);
- printf("Input submitted to the function: [2, 6, 4, 5,6]");
+ printf("Input submitted to the function: [2, 6, 4, 5,6]");
check(0, result);
- int arr2[5] = {6,6,2,17,9};
+ int arr2[5] = {6,6,2,17,9};
result = count667(arr2);
- printf("Input submitted to the function: [6, 6, 2, 17, 9]");
+ printf("Input submitted to the function: [6, 6, 2, 17, 9]");
check(1, result);
- int arr3[5] = {6,6,6,7,1};
+ int arr3[5] = {6,6,6,7,1};
result = count667(arr3);
- printf("Input submitted to the function: [6, 6, 7, 2, 1]");
+ printf("Input submitted to the function: [6, 6, 7, 2, 1]");
check(3, result);
- int arr4[5] = {6,7,7,6,6};
+ int arr4[5] = {6,7,7,6,6};
result = count667(arr4);
- printf("Input submitted to the function: [6, 7, 7, 6, 6]");
+ printf("Input submitted to the function: [6, 7, 7, 6, 6]");
check(2, result);
- printf("All Correct\n");
+ printf("All Correct\n");
return 0;
}
diff --git a/testapp/c_cpp_files/main_count7.cpp b/testapp/c_cpp_files/main_count7.cpp
index 92971fd..982e930 100755
--- a/testapp/c_cpp_files/main_count7.cpp
+++ b/testapp/c_cpp_files/main_count7.cpp
@@ -21,22 +21,22 @@ void check(T expect, T result)
int main(void)
{
int result;
- int arr[4] = {2,3,4,5};
+ int arr[4] = {2,3,4,5};
result = count7(arr);
- printf("Input submitted to the function: [2, 3, 4, 5]");
+ printf("Input submitted to the function: [2, 3, 4, 5]");
check(0, result);
- int arr2[4] = {1,2,17,9};
+ int arr2[4] = {1,2,17,9};
result = count7(arr2);
- printf("Input submitted to the function: [1, 2, 17, 9]");
+ printf("Input submitted to the function: [1, 2, 17, 9]");
check(0, result);
- int arr3[4] = {7,9,2,1};
+ int arr3[4] = {7,9,2,1};
result = count7(arr3);
- printf("Input submitted to the function: [7, 9, 2, 1]");
+ printf("Input submitted to the function: [7, 9, 2, 1]");
check(1, result);
- int arr4[4] = {1,7,7,7};
+ int arr4[4] = {1,7,7,7};
result = count7(arr4);
- printf("Input submitted to the function: [1, 7, 7, 7]");
+ printf("Input submitted to the function: [1, 7, 7, 7]");
check(3, result);
- printf("All Correct\n");
+ printf("All Correct\n");
return 0;
}
diff --git a/testapp/c_cpp_files/main_lessThan9.cpp b/testapp/c_cpp_files/main_lessThan9.cpp
index 1a89731..722b4bb 100755
--- a/testapp/c_cpp_files/main_lessThan9.cpp
+++ b/testapp/c_cpp_files/main_lessThan9.cpp
@@ -22,16 +22,16 @@ int main(void)
{
bool result;
result = lessThan9(10);
- printf("Input submitted to the function: 10");
+ printf("Input submitted to the function: 10");
check(false, result);
result = lessThan9(17);
- printf("Input submitted to the function: 17");
+ printf("Input submitted to the function: 17");
check(true, result);
result = lessThan9(16);
- printf("Input submitted to the function: 16");
+ printf("Input submitted to the function: 16");
check(true, result);
result = lessThan9(15);
- printf("Input submitted to the function: 15");
+ printf("Input submitted to the function: 15");
check(false, 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
index f23db68..21a4b1a 100755
--- a/testapp/c_cpp_files/main_mean.cpp
+++ b/testapp/c_cpp_files/main_mean.cpp
@@ -21,17 +21,17 @@ void check(T expect, T result)
int main(void)
{
bool result;
- result = mean(11, 11, 11);
- printf("Input submitted to the function: 11, 121, 11");
+ 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");
+ 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");
+ 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");
+ 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
index 0a1284e..12c961d 100755
--- a/testapp/c_cpp_files/main_roundTo10.cpp
+++ b/testapp/c_cpp_files/main_roundTo10.cpp
@@ -22,21 +22,20 @@ int main(void)
{
int result;
result = roundTo10(10, 22, 39);
- printf("Input submitted to the function: 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");
+ 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");
+ 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");
+ 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");
+ result = roundTo10(30, 40, 50);
+ printf("Input submitted to the function: 30, 40, 50");
check(120, result);
-
- printf("All Correct\n");
+ printf("All Correct\n");
return 0;
}
diff --git a/testapp/c_cpp_files/main_specialSum.cpp b/testapp/c_cpp_files/main_specialSum.cpp
index 5d0fcae..d614536 100755
--- a/testapp/c_cpp_files/main_specialSum.cpp
+++ b/testapp/c_cpp_files/main_specialSum.cpp
@@ -22,21 +22,20 @@ int main(void)
{
int result;
result = specialSum(10, 2, 9);
- printf("Input submitted to the function: 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");
+ 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");
+ 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");
+ 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");
+ result = specialSum(10, 2, 6);
+ printf("Input submitted to the function: 10, 2, 6");
check(18, result);
-
- printf("All Correct\n");
+ printf("All Correct\n");
return 0;
}
diff --git a/testapp/c_cpp_files/main_within.cpp b/testapp/c_cpp_files/main_within.cpp
index d83c50d..50f9ad0 100755
--- a/testapp/c_cpp_files/main_within.cpp
+++ b/testapp/c_cpp_files/main_within.cpp
@@ -22,16 +22,16 @@ int main(void)
{
bool result;
result = within(12, 3, 20);
- printf("Input submitted to the function: 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");
+ 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");
+ 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");
+ 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/views.py b/testapp/exam/views.py
index f24215b..92dd029 100644
--- a/testapp/exam/views.py
+++ b/testapp/exam/views.py
@@ -439,19 +439,17 @@ def automatic_questionpaper(request, questionpaper_id=None):
questions = request.POST.getlist('questions')
tot_marks = 0
for quest in questions:
- if quest.isdigit():
- q = Question.objects.get(id=quest)
- tot_marks += q.points
+ q = Question.objects.get(id=quest)
+ tot_marks += q.points
quest_paper.quiz = quiz
quest_paper.total_marks = tot_marks
quest_paper.save()
for quest in questions:
- if quest.isdigit():
- q = Question.objects.get(id=quest)
- quest_paper.questions.add(q)
+ q = Question.objects.get(id=quest)
+ quest_paper.questions.add(q)
return my_redirect('/exam/manage/showquiz')
else:
- no_questions = int(request.POST.get('questions'))
+ no_questions = int(request.POST.get('num_questions'))
fetched_questions = fetch_questions(request)
n = len(fetched_questions)
msg = ''
@@ -482,18 +480,16 @@ def automatic_questionpaper(request, questionpaper_id=None):
questions = request.POST.getlist('questions')
tot_marks = quest_paper.total_marks
for quest in questions:
- if quest.isdigit():
- q = Question.objects.get(id=quest)
- tot_marks += q.points
+ q = Question.objects.get(id=quest)
+ tot_marks += q.points
quest_paper.total_marks = tot_marks
quest_paper.save()
for quest in questions:
- if quest.isdigit():
- q = Question.objects.get(id=quest)
- quest_paper.questions.add(q)
+ q = Question.objects.get(id=quest)
+ quest_paper.questions.add(q)
return my_redirect('/exam/manage/showquiz')
else:
- no_questions = int(request.POST.get('questions'))
+ no_questions = int(request.POST.get('num_questions'))
fetched_questions = fetch_questions(request)
n = len(fetched_questions)
msg = ''
@@ -532,9 +528,8 @@ def manual_questionpaper(request, questionpaper_id=None):
quiz = Quiz.objects.order_by("-id")[0]
tot_marks = 0
for quest in questions:
- if quest.isdigit():
- q = Question.objects.get(id=quest)
- tot_marks += q.points
+ q = Question.objects.get(id=quest)
+ tot_marks += q.points
quest_paper.quiz = quiz
quest_paper.total_marks = tot_marks
quest_paper.save()
@@ -694,9 +689,6 @@ 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!')
diff --git a/testapp/templates/exam/automatic_questionpaper.html b/testapp/templates/exam/automatic_questionpaper.html
index 1175f55..fcd3db5 100644
--- a/testapp/templates/exam/automatic_questionpaper.html
+++ b/testapp/templates/exam/automatic_questionpaper.html
@@ -60,7 +60,7 @@ select
<br>
- <center>Number of question: <input type=text id=questions name='questions' style="width:25px;">&nbsp;<button class=btn type=submit name='fetch' value='fetch'>Fetch Questions</button><br></center>
+ <center>Number of question: <input type=text id=num_questions name='num_questions' style="width:25px;">&nbsp;<button class=btn type=submit name='fetch' value='fetch'>Fetch Questions</button><br></center>
<br>
<br>