summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprathamesh2016-08-25 16:48:29 +0530
committerprathamesh2016-08-25 16:48:29 +0530
commitc0909251ecffcdc0df34bb9ad4a90994708c3a5c (patch)
tree1f68e7b63d6b817d56a0fb34af29b78c8003a7d5
parente1e299b671a19b65705fb256d282e1e802a4c051 (diff)
downloadonline_test-c0909251ecffcdc0df34bb9ad4a90994708c3a5c.tar.gz
online_test-c0909251ecffcdc0df34bb9ad4a90994708c3a5c.tar.bz2
online_test-c0909251ecffcdc0df34bb9ad4a90994708c3a5c.zip
Students can view their submission i.e. answer paper
A simple interface for students to view their answerpaper. Moderator has an option where he can allow to students to view their answerpaper.
-rw-r--r--yaksh/models.py3
-rw-r--r--yaksh/templates/base.html1
-rw-r--r--yaksh/templates/manage.html1
-rw-r--r--yaksh/templates/user.html1
-rw-r--r--yaksh/templates/yaksh/login.html1
-rw-r--r--yaksh/templates/yaksh/quizzes_user.html8
-rw-r--r--yaksh/templates/yaksh/view_answerpaper.html57
-rw-r--r--yaksh/urls.py1
-rw-r--r--yaksh/views.py16
9 files changed, 87 insertions, 2 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 73d4b27..eb73499 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -428,6 +428,9 @@ class Quiz(models.Model):
is_trial = models.BooleanField(default=False)
+ view_answerpaper = models.BooleanField('Allow student to view their answer\
+ paper', default=False)
+
objects = QuizManager()
class Meta:
diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html
index 17df0d9..7fe2d27 100644
--- a/yaksh/templates/base.html
+++ b/yaksh/templates/base.html
@@ -16,6 +16,7 @@
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/base.css">
+ <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/font-awesome.css" type="text/css" />
<style>
body {
diff --git a/yaksh/templates/manage.html b/yaksh/templates/manage.html
index 334f6a2..2fd0f7a 100644
--- a/yaksh/templates/manage.html
+++ b/yaksh/templates/manage.html
@@ -13,6 +13,7 @@
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/base.css" type="text/css" />
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/manage.css" type="text/css" />
+ <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/font-awesome.css" type="text/css" />
{% block css %}
{% endblock %}
<script language="JavaScript" type="text/javascript" src="{{ URL_ROOT }}/static/yaksh/js/jquery-1.4.2.min.js"></script>
diff --git a/yaksh/templates/user.html b/yaksh/templates/user.html
index 4074656..7f93f00 100644
--- a/yaksh/templates/user.html
+++ b/yaksh/templates/user.html
@@ -15,6 +15,7 @@
{% endblock %}
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/base.css" type="text/css" />
+ <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/font-awesome.css" type="text/css" />
{% block css %}
{% endblock %}
diff --git a/yaksh/templates/yaksh/login.html b/yaksh/templates/yaksh/login.html
index 0a78c1b..5694f75 100644
--- a/yaksh/templates/yaksh/login.html
+++ b/yaksh/templates/yaksh/login.html
@@ -6,7 +6,6 @@
{% block css %}
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/bootstrap-social.css" type="text/css" />
<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/login.css" type="text/css" />
-<link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/font-awesome.css" type="text/css" />
{% endblock %}
{% block content %}
diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html
index 6403a21..98c156b 100644
--- a/yaksh/templates/yaksh/quizzes_user.html
+++ b/yaksh/templates/yaksh/quizzes_user.html
@@ -48,6 +48,7 @@
{% endif %}
<table>
<th>Quiz</th>
+ <th>View Answer Paper</th>
<th>Pre requisite quiz</th>
{% for quiz in quizzes %}
{% if quiz.course_id == course.id %}
@@ -63,6 +64,13 @@
</td>
{% endif %}
<td>
+ {% if quiz.view_answerpaper %}
+ <a href="{{ URL_ROOT }}/exam/view_answerpaper/{{ quiz.questionpaper_set.get.id }}/"><i class="fa fa-eye" aria-hidden="true"></i> Can View </a>
+ {% else%}
+ <a><i class="fa fa-eye-slash" aria-hidden="true"></i> Cannot view now </a>
+ {% endif %}
+ </td>
+ <td>
{% if quiz.prerequisite %}
You have to pass {{ quiz.prerequisite.description }} for taking {{ paper.quiz.description }}
{% else %}
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html
new file mode 100644
index 0000000..d8d6912
--- /dev/null
+++ b/yaksh/templates/yaksh/view_answerpaper.html
@@ -0,0 +1,57 @@
+{% extends "user.html" %}
+
+{% block title %} Answer Paper for {{ quiz.description }}{% endblock title %}
+
+{% block manage %}
+
+{% block subtitle %} Answer Paper for {{ quiz.description }}{% endblock %}
+
+
+{% if not data.papers %}
+ <p><b> You have not attempted the quiz {{ quiz.description }} </b></p>
+{% else %}
+ {% for paper in data.papers %}
+ {% if forloop.counter == 2 and data.questionpaperid %}
+ <U><h2> Previous attempts </h2></U>
+ {% endif %}
+ <h2> Quiz: {{ paper.question_paper.quiz.description }} </h2>
+
+ <p>
+ Attempt Number: {{ paper.attempt_number }}<br/>
+ Questions correctly answered: {{ paper.get_answered_str }} <br/>
+ Marks obtained: {{ paper.marks_obtained }} <br/>
+ Start time: {{ paper.start_time }} <br/>
+ </p>
+
+ {% if paper.answers.count %}
+ <h3> Answers </h3>
+ {% for question, answers in paper.get_question_answers.items %}
+ <p><strong> Question: {{ question.id }}. {{ question.summary }} (Mark(s): {{ question.points }})</strong> </p>
+ {% if question.type == "mcq" or question.type == "mcc" %}
+ <p> Choices:
+ {% for testcase in question.get_test_cases %} <br>{{ testcase.options }} {% endfor %}
+ </p>
+ <p>Student answer: {{ answers.0 }}</p>
+ Autocheck: {{ answers.0.error }}
+ {% else %}{# non-mcq questions #}
+ <p>Student answer: </p>
+ <pre>
+ {% for answer in answers %}################################################################################
+ {{ answer.answer.strip }}
+ # Autocheck: {{ answer.error }}
+ {% endfor %}</pre>
+ {% endif %}
+ {% with answers|last as answer %}
+ <p><em>Obtained Marks: {{answer.marks}} </em> </p>
+ {% endwith %}
+ <hr>
+ {% endfor %} {# for question, answers ... #}
+ <h3>Teacher comments: </h3>
+ {{ paper.comments|default:"None" }}
+ <hr><hr>
+ {% endif %} {# if paper.answers.count #}
+
+ {% endfor %} {# for paper in data.papers #}
+
+{% endif %} {# if not data.papers #}
+{% endblock %}
diff --git a/yaksh/urls.py b/yaksh/urls.py
index cd97dd4..931e69c 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -49,6 +49,7 @@ urlpatterns += [
views.skip),
url(r'^enroll_request/(?P<course_id>\d+)/$', views.enroll_request, name='enroll_request'),
url(r'^self_enroll/(?P<course_id>\d+)/$', views.self_enroll, name='self_enroll'),
+ url(r'^view_answerpaper/(?P<questionpaper_id>\d+)/$', views.view_answerpaper, name='view_answerpaper'),
url(r'^manage/$', views.prof_manage, name='manage'),
url(r'^manage/addquestion/$', views.add_question),
url(r'^manage/addquestion/(?P<question_id>\d+)/$', views.edit_question),
diff --git a/yaksh/views.py b/yaksh/views.py
index e1ec44e..9e0edac 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -530,7 +530,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
msg = "Please submit a valid option or code"
return show_question(request, question, paper, msg)
elif question.type == 'code' and user_answer:
- msg = "Correct Output"
+ msg = 'Correct Output'
paper.completed_question(question.id)
return show_question(request, question, paper, msg)
else:
@@ -558,12 +558,14 @@ def validate_answer(user, user_answer, question, json_data=None):
expected_answer = question.get_test_case(correct=True).options
if user_answer.strip() == expected_answer.strip():
correct = True
+ result['error'] = 'Correct Answer'
elif question.type == 'mcc':
expected_answers = []
for opt in question.get_test_cases(correct=True):
expected_answers.append(opt.options)
if set(user_answer) == set(expected_answers):
correct = True
+ result['error'] = 'Correct Answer'
elif question.type == 'code':
user_dir = get_user_dir(user)
json_result = code_server.run_code(question.language, question.test_case_type, json_data, user_dir)
@@ -1271,3 +1273,15 @@ def test_quiz(request, mode, quiz_id):
trial_questionpaper = test_mode(current_user, godmode, None, quiz_id)
return my_redirect("/exam/start/{0}".format(trial_questionpaper.id))
+
+
+@login_required
+def view_answerpaper(request, questionpaper_id):
+ user = request.user
+ quiz = get_object_or_404(QuestionPaper, pk=questionpaper_id).quiz
+ if quiz.view_answerpaper:
+ data = AnswerPaper.objects.get_user_data(user, questionpaper_id)
+ context = {'data': data, 'quiz': quiz}
+ return my_render_to_response('yaksh/view_answerpaper.html', context)
+ else:
+ return my_redirect('/exam/quizzes/')