summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/models.py15
-rw-r--r--yaksh/templates/yaksh/course_teachers.html2
-rw-r--r--yaksh/templates/yaksh/user_data.html24
-rw-r--r--yaksh/test_models.py8
-rw-r--r--yaksh/views.py1
5 files changed, 31 insertions, 19 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 84cad1e..8297ec8 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2323,6 +2323,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):
@@ -2332,7 +2343,7 @@ class AnswerPaper(models.Model):
return self.questions.filter(active=True)
def get_questions_answered(self):
- return self.questions_answered.all()
+ return self.questions_answered.all().distinct()
def get_questions_unanswered(self):
return self.questions_unanswered.all()
@@ -2531,7 +2542,7 @@ class AssignmentUploadManager(models.Manager):
class AssignmentUpload(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
assignmentQuestion = models.ForeignKey(Question, on_delete=models.CASCADE)
- assignmentFile = models.FileField(upload_to=get_assignment_dir)
+ assignmentFile = models.FileField(upload_to=get_assignment_dir, max_length=255)
question_paper = models.ForeignKey(QuestionPaper, blank=True, null=True,
on_delete=models.CASCADE)
course = models.ForeignKey(Course, null=True, blank=True,
diff --git a/yaksh/templates/yaksh/course_teachers.html b/yaksh/templates/yaksh/course_teachers.html
index 1b1af87..ebbbb57 100644
--- a/yaksh/templates/yaksh/course_teachers.html
+++ b/yaksh/templates/yaksh/course_teachers.html
@@ -9,11 +9,13 @@
<tr>
<th>Select</th>
<th>Name</th>
+ <th>Email</th>
</tr>
{% for teacher in teachers %}
<tr>
<td><input type="checkbox" name="remove" value="{{ teacher.id }}"></td>
<td>{{ teacher.get_full_name }}</td>
+ <td>{{ teacher.email }}</td>
</tr>
{% endfor %}
<table>
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/test_models.py b/yaksh/test_models.py
index e24a38e..7ef1ca7 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -1791,12 +1791,14 @@ class AnswerPaperTestCases(unittest.TestCase):
answers_saved = Answer.objects.filter(question=question)
error_list = [json.loads(ans.error) for ans in answers_saved]
if answers_saved:
- self.assertEqual(len(answered[question]), len(answers_saved))
+ self.assertGreater(len(answered[question]), len(answers_saved))
ans = []
err = []
for val in answered[question]:
- ans.append(val.get('answer'))
- err.append(val.get('error_list'))
+ if val.get('answer') is not None:
+ ans.append(val.get('answer'))
+ if val.get('error_list') is not None:
+ err.append(val.get('error_list'))
self.assertEqual(set(ans), set(answers_saved))
self.assertEqual(error_list, err)
diff --git a/yaksh/views.py b/yaksh/views.py
index 01f5e4e..0ed8f9f 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1798,7 +1798,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)