summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCruiseDevice2020-08-28 18:30:42 +0530
committerCruiseDevice2020-08-28 18:36:17 +0530
commitb41cf01f58544a6c71c16bab1854142a3ffc8e03 (patch)
tree196fce9ca16bdef2d37ec038cc1cd3581b962b26
parent9569e3ef6bbaeb8b36ad78c272006a538e044894 (diff)
downloadonline_test-b41cf01f58544a6c71c16bab1854142a3ffc8e03.tar.gz
online_test-b41cf01f58544a6c71c16bab1854142a3ffc8e03.tar.bz2
online_test-b41cf01f58544a6c71c16bab1854142a3ffc8e03.zip
Show max marks for all attempts in answerpaper
- Latest attempt marks were shown in the answerpaper, which made it difficult to analyze the paper. This PR fixes the issue and the best marks of all the attempt are provided.
-rw-r--r--yaksh/models.py11
-rw-r--r--yaksh/templates/yaksh/user_data.html24
-rw-r--r--yaksh/views.py1
3 files changed, 22 insertions, 14 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 1094bb0..0456b52 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2305,6 +2305,17 @@ class AnswerPaper(models.Model):
'answer': answer,
'error_list': [e for e in json.loads(answer.error)]
}]
+
+ for question, answers in q_a.items():
+ answers = q_a[question]
+ q_a[question].append({
+ 'marks': max([
+ answer['answer'].marks
+ for answer in answers
+ if question == answer['answer'].question
+ ])
+ })
+
return q_a
def get_latest_answer(self, question_id):
diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html
index 6252fb3..a79071d 100644
--- a/yaksh/templates/yaksh/user_data.html
+++ b/yaksh/templates/yaksh/user_data.html
@@ -74,19 +74,17 @@
</tr>
</thead>
<tbody>
- {% for question, answers in paper.get_question_answers.items %}
- {% with answers|last as answer %}
- <tr>
+ {% for question, answers in paper.get_question_answers.items %}
+ <tr>
+ <td>{{question.summary}}</td>
+ <td>{{question.type}}</td>
<td>
- <a href="#question_{{question.id}}">
- {{ question.summary }}
- </a>
+ {% for answer in answers %}
+ {{answer.marks}}
+ {% endfor %}
</td>
- <td>{{ question.type }}</td>
- <td>{{ answer.answer.marks }}</td>
- </tr>
- {% endwith %}
- {% endfor %}
+ </tr>
+ {% endfor %}
</tbody>
</table>
{% for question, answers in paper.get_question_answers.items %}
@@ -313,12 +311,12 @@
<div class="col-md-2">
<label class="col-form-label" for="q{{ question.id }}">Marks:</label>
{% with answers|last as answer %}
- <input id="q{{ question.id }}" type="text" name="q{{ question.id }}_marks" size="4" class="form-control" value="{{ answer.answer.marks }}" readonly=""><br><br>
+ <input id="q{{ question.id }}" type="text" name="q{{ question.id }}_marks" size="4" class="form-control" value="{{ answer.marks }}" readonly=""><br><br>
{% endwith %}
</div>
</div>
<hr/>
- {% endfor %} {# for question, answers ... #}
+ {% endfor %} {# for question, answers ... #}
<div class="form-group">
<h3>Teacher comments: </h3>
<textarea id="comments_{{paper.question_paper.id}}" class="form-control"
diff --git a/yaksh/views.py b/yaksh/views.py
index 8413889..b955608 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1757,7 +1757,6 @@ def user_data(request, user_id, questionpaper_id=None, course_id=None):
raise Http404('You are not allowed to view this page!')
user = User.objects.get(id=user_id)
data = AnswerPaper.objects.get_user_data(user, questionpaper_id, course_id)
-
context = {'data': data, 'course_id': course_id}
return my_render_to_response(request, 'yaksh/user_data.html', context)