diff options
-rw-r--r-- | CHANGELOG.txt | 6 | ||||
-rw-r--r-- | online_test/__init__.py | 2 | ||||
-rw-r--r-- | yaksh/migrations/0024_release_0_24_0.py | 19 | ||||
-rw-r--r-- | yaksh/models.py | 15 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_teachers.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/grade_user.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/micromanaged.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/user_data.html | 24 | ||||
-rw-r--r-- | yaksh/test_models.py | 8 | ||||
-rw-r--r-- | yaksh/views.py | 3 |
10 files changed, 61 insertions, 24 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 275624f..d94534b 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,9 @@ +=== 0.24.0 (09-09-2020) === + +* Fix rendering of the quiz list +* Fix bug to show maximum marks for all attempts in answerpaper +* Fix bug to show only distinct answered questions + === 0.23.0 (09-09-2020) === * Allow a single user or multiple users to reattempt a quiz diff --git a/online_test/__init__.py b/online_test/__init__.py index 63a9920..101b525 100644 --- a/online_test/__init__.py +++ b/online_test/__init__.py @@ -4,4 +4,4 @@ from online_test.celery_settings import app as celery_app __all__ = ('celery_app',) -__version__ = '0.21.0' +__version__ = '0.24.0' diff --git a/yaksh/migrations/0024_release_0_24_0.py b/yaksh/migrations/0024_release_0_24_0.py new file mode 100644 index 0000000..60ffc23 --- /dev/null +++ b/yaksh/migrations/0024_release_0_24_0.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.7 on 2020-09-14 10:45 + +from django.db import migrations, models +import yaksh.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('yaksh', '0023_release_0_23_0'), + ] + + operations = [ + migrations.AlterField( + model_name='assignmentupload', + name='assignmentFile', + field=models.FileField(max_length=255, upload_to=yaksh.models.get_assignment_dir), + ), + ] diff --git a/yaksh/models.py b/yaksh/models.py index 9f8c634..95a5da0 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -2338,6 +2338,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): @@ -2347,7 +2358,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() @@ -2546,7 +2557,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/grade_user.html b/yaksh/templates/yaksh/grade_user.html index a9ab53e..341fd7c 100644 --- a/yaksh/templates/yaksh/grade_user.html +++ b/yaksh/templates/yaksh/grade_user.html @@ -327,7 +327,7 @@ function searchNames() { </a> </td> <td>{{ question.type }}</td> - <td>{{ answer.answer.marks }}</td> + <td>{{ answer.marks }}</td> <td> <a href="{% url 'yaksh:regrade_by_question' course_id quiz.questionpaper_set.get.id paper.id question.id %}" class="btn btn-outline-success"> <i class="fa fa-repeat"></i> Regrade @@ -567,7 +567,7 @@ function searchNames() { <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 }}"><br><br> + <input id="q{{ question.id }}" type="text" name="q{{ question.id }}_marks" size="4" class="form-control" value="{{ answer.marks }}"><br><br> {% endwith %} </div> </div> diff --git a/yaksh/templates/yaksh/micromanaged.html b/yaksh/templates/yaksh/micromanaged.html index 336feec..5d7e58c 100644 --- a/yaksh/templates/yaksh/micromanaged.html +++ b/yaksh/templates/yaksh/micromanaged.html @@ -17,6 +17,6 @@ </div> {% endif %} {% endfor %} -{% endif %} </div> +{% endif %} 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 e8bc2c6..2be8734 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) @@ -1965,7 +1964,7 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, for paper in papers: for question, answers in paper.get_question_answers().items(): marks = float(request.POST.get('q%d_marks' % question.id, 0)) - answer = answers[-1]['answer'] + answer = answers[0]['answer'] answer.set_marks(marks) answer.save() paper.update_marks() |