summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2018-02-05 20:04:43 +0530
committermaheshgudi2018-03-16 15:15:50 +0530
commit537d0fc5c5884ab620e587ff977ed61a2a50504d (patch)
treead6e82fe18a4e6c2a75359d1f5294dcfef2da9ed /yaksh
parent453a5d8f191b62af45426d5c98a99552c34ba396 (diff)
downloadonline_test-537d0fc5c5884ab620e587ff977ed61a2a50504d.tar.gz
online_test-537d0fc5c5884ab620e587ff977ed61a2a50504d.tar.bz2
online_test-537d0fc5c5884ab620e587ff977ed61a2a50504d.zip
Add arrange options type question in answerpaper htmls
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/templates/yaksh/grade_user.html19
-rw-r--r--yaksh/templates/yaksh/user_data.html18
-rw-r--r--yaksh/templates/yaksh/view_answerpaper.html21
-rw-r--r--yaksh/templatetags/custom_filters.py13
4 files changed, 66 insertions, 5 deletions
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 93f00e0..09887c4 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -167,7 +167,7 @@ Status : <b style="color: red;"> Failed </b><br/>
{% endif %}
{% endfor %}
- {% elif question.type == "integer" or "string" or "float" %}
+ {% elif question.type == "integer" or question.type == "string" or question.type == "float" %}
<h5> <u>Correct Answer:</u></h5>
{% for testcase in question.get_test_cases %}
<strong>{{ testcase.correct|safe }}</strong>
@@ -175,6 +175,14 @@ Status : <b style="color: red;"> Failed </b><br/>
<strong>{{ testcase.error_margin|safe }}</strong>
{% endif %}
{% endfor %}
+ {% elif question.type == "arrange" %}
+ <h5> <u>Correct Order:</u></h5>
+ <div class="list-group" >
+ {% for testcase in question.get_test_cases %}
+ <li class="list-group-item"><strong>{{ testcase.options|safe }}</strong></li>
+ {% endfor %}
+ </div>
+
{% else %}
<h5> <u>Test cases: </u></h5>
{% for testcase in question.get_test_cases %}
@@ -307,6 +315,15 @@ Status : <b style="color: red;"> Failed </b><br/>
{% endif %}
{% endfor %}
</div>
+
+ {% elif question.type == "arrange"%}
+ <div class="well well-sm">
+ {% get_arrange_user_answer ans.answer.answer question as tc_list %}
+ {% for testcases in tc_list %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endfor %}
+ </div>
+
{% else %}
<div class="well well-sm">
{{ ans.answer.answer.strip|safe }}
diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html
index ce2533e..fe3f2a6 100644
--- a/yaksh/templates/yaksh/user_data.html
+++ b/yaksh/templates/yaksh/user_data.html
@@ -80,6 +80,13 @@ User IP address: {{ paper.user_ip }}
<strong>{{ testcase.correct|safe }}</strong>
{% endfor %}
+ {% elif question.type == "arrange" %}
+ <h5> <u>Correct Order:</u></h5>
+ <div class="list-group" >
+ {% for testcase in question.get_test_cases %}
+ <li class="list-group-item"><strong>{{ testcase.options|safe }}</strong></li>
+ {% endfor %}
+ </div>
{% else %}
<h5> <u>Test cases: </u></h5>
@@ -99,6 +106,7 @@ User IP address: {{ paper.user_ip }}
{% endif %}
<div class="panel-body">
<h5><u>Student answer:</u></h5>
+
{% if question.type == "mcc"%}
<div class="well well-sm">
{% for testcases in question.get_test_cases %}
@@ -107,6 +115,7 @@ User IP address: {{ paper.user_ip }}
{% endif %}
{% endfor %}
</div>
+
{% elif question.type == "mcq"%}
<div class="well well-sm">
{% for testcases in question.get_test_cases %}
@@ -115,6 +124,15 @@ User IP address: {{ paper.user_ip }}
{% endif %}
{% endfor %}
</div>
+
+ {% elif question.type == "arrange"%}
+ <div class="well well-sm">
+ {% get_arrange_user_answer answers.0.answer question as tc_list %}
+ {% for testcases in tc_list %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endfor %}
+ </div>
+
{%else%}
<div class="well well-sm">
{{ answers.0.answer|safe }}
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html
index 971ef77..3d39092 100644
--- a/yaksh/templates/yaksh/view_answerpaper.html
+++ b/yaksh/templates/yaksh/view_answerpaper.html
@@ -35,9 +35,9 @@
End time : {{ paper.end_time }} <br/>
Percentage obtained: {{ paper.percent }}% <br/>
{% if paper.passed %}
- Status : <b style="color: red;"> Failed </b><br/>
- {% else %}
Status : <b style="color: green;"> Passed </b><br/>
+ {% else %}
+ Status : <b style="color: red;"> Failed </b><br/>
{% endif %}
</p>
@@ -67,12 +67,20 @@
{% endif %}
{% endfor %}
- {% elif question.type == "integer" or "string" or "float" %}
+ {% elif question.type == "integer" or question.type == "string" or question.type == "float" %}
<h5> <u>Correct Answer:</u></h5>
{% for testcase in question.get_test_cases %}
<strong>{{ testcase.correct|safe }}</strong>
{% endfor %}
+ {% elif question.type == "arrange" %}
+ <h5> <u>Correct Order:</u></h5>
+ <div class="list-group">
+ {% for testcase in question.get_test_cases %}
+ <li class="list-group-item"><strong>{{ testcase.options|safe }}</strong></li>
+ {% endfor %}
+ </div>
+
{% else %}
<h5> <u>Test cases: </u></h5>
{% for testcase in question.get_test_cases %}
@@ -108,6 +116,13 @@
{% endif %}
{% endfor %}
</div>
+ {% elif question.type == "arrange"%}
+ <div class="well well-sm">
+ {% get_arrange_user_answer answers.0.answer question as tc_list %}
+ {% for testcases in tc_list %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endfor %}
+ </div>
{% elif question.type == "upload" and has_user_assignment %}
<a href="{{URL_ROOT}}/exam/download/user_assignment/{{question.id}}/{{data.user.id}}/{{paper.question_paper.quiz.id}}">
<div class="well well-sm">
diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py
index fa0802f..05c363c 100644
--- a/yaksh/templatetags/custom_filters.py
+++ b/yaksh/templatetags/custom_filters.py
@@ -1,5 +1,6 @@
from django import template
from django.template.defaultfilters import stringfilter
+from ast import literal_eval
import os
try:
from itertools import zip_longest
@@ -66,4 +67,14 @@ def course_completion_percent(course, user):
@register.simple_tag
def get_ordered_testcases(question, answerpaper):
- return question.get_ordered_test_cases(answerpaper) \ No newline at end of file
+ return question.get_ordered_test_cases(answerpaper)
+
+@register.simple_tag
+def get_arrange_user_answer(ans, question):
+ ans = str(ans)
+ ans_list = literal_eval(ans)
+ testcase_list = []
+ for answer_id in ans_list:
+ tc = question.get_test_case(id=int(answer_id))
+ testcase_list.append(tc)
+ return testcase_list