summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py6
-rw-r--r--yaksh/templates/yaksh/grade_user.html26
-rw-r--r--yaksh/templates/yaksh/question.html12
-rw-r--r--yaksh/templates/yaksh/user_data.html18
-rw-r--r--yaksh/templates/yaksh/view_answerpaper.html29
-rw-r--r--yaksh/test_models.py4
-rw-r--r--yaksh/test_views.py10
7 files changed, 79 insertions, 26 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index b5bde04..4859d3e 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1321,15 +1321,15 @@ class AnswerPaper(models.Model):
'weight': 0.0}
if user_answer is not None:
if question.type == 'mcq':
- expected_answer = question.get_test_case(correct=True).options
- if user_answer.strip() == expected_answer.strip():
+ expected_answer = question.get_test_case(correct=True).id
+ if user_answer.strip() == str(expected_answer).strip():
result['success'] = 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)
+ expected_answers.append(str(opt.id))
if set(user_answer) == set(expected_answers):
result['success'] = True
result['error'] = ['Correct answer']
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 2038210..37bc788 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -236,7 +236,7 @@ Status : <b style="color: green;"> Passed </b><br/>
<col width="40%">
<col width="40%">
<col width="10%">
- <tr class="info">
+ <tr>
<th><center>Line No.</center></th>
<th><center>Expected Output</center></th>
<th><center>User output</center></th>
@@ -256,7 +256,7 @@ Status : <b style="color: green;"> Passed </b><br/>
</table>
<table width="100%" class='table table-bordered'>
<col width="10">
- <tr class = "danger">
+ <tr>
<td><b>Error:</b></td>
<td>{{error.error_msg}}</td>
</tr>
@@ -268,12 +268,28 @@ Status : <b style="color: green;"> Passed </b><br/>
</div>
<div class="panel-body">
- {% if question.type != "code" %}
+ {% if question.type == "code" %}
+ <pre><code>{{ ans.answer.answer.strip|safe }}</code></pre>
+ {% elif question.type == "mcc"%}
<div class="well well-sm">
- {{ ans.answer.answer.strip|safe }}
+ {% for testcases in question.get_test_cases %}
+ {%if testcases.id|stringformat:"i" in ans.answer.answer.strip|safe %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endif %}
+ {% endfor %}
+ </div>
+ {% elif question.type == "mcq"%}
+ <div class="well well-sm">
+ {% for testcases in question.get_test_cases %}
+ {%if testcases.id|stringformat:"i" == ans.answer.answer.strip|safe %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endif %}
+ {% endfor %}
</div>
{% else %}
- <pre><code>{{ ans.answer.answer.strip|safe }}</code></pre>
+ <div class="well well-sm">
+ {{ ans.answer.answer.strip|safe }}
+ </div>
{% endif %}
</div>
</div>
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index bc7acf1..1e1f38f 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -153,11 +153,11 @@ lang = "{{ question.language }}"
<div class="panel-body">
{% if question.type == "mcq" %}
{% for test_case in test_cases %}
- {% if last_attempt and last_attempt|safe == test_case.options|safe %}
- <input name="answer" type="radio" value="{{ test_case.options }}" checked />
+ {% if last_attempt and last_attempt|safe == test_case.id|safe %}
+ <input name="answer" type="radio" value="{{ test_case.id }}" checked />
{{ test_case.options|safe }} <br/>
{% else %}
- <input name="answer" type="radio" value="{{ test_case.options }}" />
+ <input name="answer" type="radio" value="{{ test_case.id }}" />
{{ test_case.options|safe }} <br/>
{% endif %}
{% endfor %}
@@ -183,11 +183,11 @@ lang = "{{ question.language }}"
{% if question.type == "mcc" %}
{% for test_case in test_cases %}
- {% if last_attempt and test_case.options|safe in last_attempt|safe %}
- <input name="answer" type="checkbox" value="{{ test_case.options }}" checked/> {{ test_case.options }}
+ {% if last_attempt and test_case.id|safe in last_attempt|safe %}
+ <input name="answer" type="checkbox" value="{{ test_case.id }}" checked/> {{ test_case.options }}
<br>
{% else %}
- <input name="answer" type="checkbox" value="{{ test_case.options }}">
+ <input name="answer" type="checkbox" value="{{ test_case.id }}">
{{ test_case.options}}
<br/>
{% endif %}
diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html
index a8adc22..31a023d 100644
--- a/yaksh/templates/yaksh/user_data.html
+++ b/yaksh/templates/yaksh/user_data.html
@@ -104,11 +104,29 @@ User IP address: {{ paper.user_ip }}
</div>
<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 %}
+ {%if testcases.id|stringformat:"i" in answers.0.answer|safe %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endif %}
+ {% endfor %}
+ </div>
+ {% elif question.type == "mcq"%}
+ <div class="well well-sm">
+ {% for testcases in question.get_test_cases %}
+ {%if testcases.id|stringformat:"i" == answers.0.answer|safe %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endif %}
+ {% endfor %}
+ </div>
+ {%else%}
<div class="well well-sm">
{{ answers.0.answer|safe }}
</div>
</div>
</div>
+ {% endif %}
{% else %}
<h5>Student answer: </h5>
{% for answer in answers %}
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html
index 9edff5a..850d789 100644
--- a/yaksh/templates/yaksh/view_answerpaper.html
+++ b/yaksh/templates/yaksh/view_answerpaper.html
@@ -82,16 +82,35 @@
Autocheck: {{ answers.0.error_list.0 }}
</div>
<div class="panel-body">
- <h5><u>Student answer:</u></h5>
- <div class="well well-sm">
- {{ answers.0.answer|safe }}
- {% if question.type == "upload" and has_user_assignment %}
+ {% if question.type == "mcc"%}
+ <div class="well well-sm">
+ {% for testcases in question.get_test_cases %}
+ {%if testcases.id|stringformat:"i" in answers.0.answer|safe %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endif %}
+ {% endfor %}
+ </div>
+ {% elif question.type == "mcq"%}
+ <div class="well well-sm">
+ {% for testcases in question.get_test_cases %}
+ {%if testcases.id|stringformat:"i" == answers.0.answer|safe %}
+ <li>{{ testcases.options.strip|safe }}</li>
+ {% endif %}
+ {% 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">
<div class="panel">
Assignment File for {{ data.user.get_full_name.title }}
</div></a>
- {% endif %}
</div>
+ {% else %}
+ <h5><u>Student answer:</u></h5>
+ <div class="well well-sm">
+ {{ answers.0.answer|safe }}
+ </div>
+ {% endif %}
</div>
</div>
{% else %}
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index ac90c53..2c83024 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -592,7 +592,7 @@ class AnswerPaperTestCases(unittest.TestCase):
def test_validate_and_regrade_mcc_correct_answer(self):
# Given
- mcc_answer = ['a']
+ mcc_answer = [str(self.mcc_based_testcase.id)]
self.answer = Answer(question=self.question3,
answer=mcc_answer,
)
@@ -629,7 +629,7 @@ class AnswerPaperTestCases(unittest.TestCase):
def test_validate_and_regrade_mcq_correct_answer(self):
# Given
- mcq_answer = 'a'
+ mcq_answer = str(self.mcq_based_testcase.id)
self.answer = Answer(question=self.question2,
answer=mcq_answer,
)
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 5ef97d6..2d86b77 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -3535,7 +3535,7 @@ class TestQuestionPaper(TestCase):
)
# Given Wrong Answer
- wrong_user_answer = "b"
+ wrong_user_answer = "25"
# When
self.client.post(
@@ -3550,7 +3550,7 @@ class TestQuestionPaper(TestCase):
self.assertEqual(wrong_answer_paper.marks_obtained, 0)
# Given Right Answer
- right_user_answer = "a"
+ right_user_answer = str(self.mcq_based_testcase.id)
# When
self.client.post(
@@ -3575,7 +3575,7 @@ class TestQuestionPaper(TestCase):
)
# Given Right Answer
- right_user_answer = "a"
+ right_user_answer = str(self.mcq_based_testcase.id)
# When
self.client.post(
@@ -3590,7 +3590,7 @@ class TestQuestionPaper(TestCase):
self.assertEqual(updated_answerpaper.marks_obtained, 1)
# Given Wrong Answer
- wrong_user_answer = "b"
+ wrong_user_answer = "25"
# When
self.client.post(
@@ -3615,7 +3615,7 @@ class TestQuestionPaper(TestCase):
)
# Given Right Answer
- right_user_answer = "a"
+ right_user_answer = str(self.mcc_based_testcase.id)
# When
self.client.post(