diff options
-rw-r--r-- | CHANGELOG.txt | 7 | ||||
-rw-r--r-- | online_test/__init__.py | 2 | ||||
-rw-r--r-- | yaksh/models.py | 2 | ||||
-rw-r--r-- | yaksh/templates/base.html | 11 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_module.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 9 | ||||
-rw-r--r-- | yaksh/test_models.py | 6 | ||||
-rw-r--r-- | yaksh/views.py | 23 |
8 files changed, 48 insertions, 14 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d94534b..9124125 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,10 @@ +=== 0.25.0 (14-09-2020) === + +* Fix bug to show missing marks in grade user +* Recalculate and save total marks of paper after saving or changing +* Remove MathJax references and replace Katex CDN +* Add feature to allow to extend time even if the paper is completed + === 0.24.0 (09-09-2020) === * Fix rendering of the quiz list diff --git a/online_test/__init__.py b/online_test/__init__.py index 101b525..b9e8f77 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.24.0' +__version__ = '0.25.0' diff --git a/yaksh/models.py b/yaksh/models.py index 7757951..0c5a6f5 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1784,6 +1784,8 @@ class QuestionPaper(models.Model): for question in questions: marks += question.points for question_set in self.random_questions.all(): + question_set.marks = question_set.questions.first().points + question_set.save() marks += question_set.marks * question_set.num_questions self.total_marks = marks self.save() diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html index 8bf7fbc..093ccf3 100644 --- a/yaksh/templates/base.html +++ b/yaksh/templates/base.html @@ -22,7 +22,9 @@ <link rel="stylesheet" href="{% static 'yaksh/css/ontop.css' %}" type="text/css" /> <link rel="stylesheet" href="{% static 'yaksh/css/plyr.css' %}" /> <link rel="stylesheet" type="text/css" href="{% static 'yaksh/css/simplemde.min.css' %}"> - <link rel="stylesheet" href="{% static 'yaksh/css/toastr.min.css' %}" />"> + <link rel="stylesheet" href="{% static 'yaksh/css/toastr.min.css' %}" /> + <!-- https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css --> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css" integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous"> {% block meta %} @@ -45,6 +47,13 @@ </script> <script type="text/javascript" src="{% static 'yaksh/js/toastr.min.js' %}"> </script> + + <!-- The loading of KaTeX is deferred to speed up page rendering --> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js" integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4" crossorigin="anonymous"></script> + + <!-- To automatically render math in text elements, include the auto-render extension: --> + <script defer src="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/contrib/auto-render.min.js" integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous" + onload="renderMathInElement(document.body);"></script> <script> new WOW().init(); diff --git a/yaksh/templates/yaksh/add_module.html b/yaksh/templates/yaksh/add_module.html index 14e7630..aee50c1 100644 --- a/yaksh/templates/yaksh/add_module.html +++ b/yaksh/templates/yaksh/add_module.html @@ -11,8 +11,6 @@ </script> <script type="text/javascript" src="{% static 'yaksh/js/jquery-ui.js' %}"> </script> -<script type="text/javascript" src="{% static 'yaksh/js/mathjax/MathJax.js' %}?config=TeX-MML-AM_CHTML"> -</script> {% endblock %} {% block css %} diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 3f7e67e..2dbfeed 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -276,6 +276,15 @@ question_type = "{{ question.type }}"; {% if question.type == "upload" %} <p>Upload assignment file for the said question<p> <input type=file id="assignment" name="assignment" multiple=""> + {% if assignment_files %} + <ul class="list-group"> + {% for as_file in assignment_files %} + <li class="list-group-item"> + <a href="{{as_file.assignmentFile.url}}" target="_blank">{{ as_file.assignmentFile.name|file_title }}</a> + </li> + {% endfor %} + </ul> + {% endif %} {% endif %} <!-- Arrange type question --> diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 7ef1ca7..11ab6cd 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -994,7 +994,7 @@ class QuestionPaperTestCases(unittest.TestCase): # create two QuestionSet for random questions # QuestionSet 1 self.question_set_1 = QuestionSet.objects.create( - marks=2, num_questions=2 + marks=1, num_questions=2 ) # add pool of questions for random sampling @@ -1007,7 +1007,7 @@ class QuestionPaperTestCases(unittest.TestCase): # QuestionSet 2 self.question_set_2 = QuestionSet.objects.create( - marks=3, num_questions=3 + marks=1, num_questions=3 ) # add pool of questions @@ -1074,7 +1074,7 @@ class QuestionPaperTestCases(unittest.TestCase): """ Test update_total_marks() method of Question Paper""" self.assertEqual(self.question_paper.total_marks, 0) self.question_paper.update_total_marks() - self.assertEqual(self.question_paper.total_marks, 15) + self.assertEqual(self.question_paper.total_marks, 7.0) def test_get_random_questions(self): """ Test get_random_questions() method of Question Paper""" diff --git a/yaksh/views.py b/yaksh/views.py index be19d19..a3d7def 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -668,6 +668,7 @@ def show_question(request, question, paper, error_message=None, quiz = paper.question_paper.quiz quiz_type = 'Exam' can_skip = False + assignment_files = [] if previous_question: delay_time = paper.time_left_on_question(previous_question) else: @@ -709,6 +710,13 @@ def show_question(request, question, paper, error_message=None, test_cases = question.get_ordered_test_cases(paper) else: test_cases = question.get_test_cases() + if question.type == 'upload': + assignment_files = AssignmentUpload.objects.filter( + assignmentQuestion_id=question.id, + course_id=course_id, + user=request.user, + question_paper_id=paper.question_paper_id + ) files = FileUpload.objects.filter(question_id=question.id, hide=False) course = Course.objects.get(id=course_id) module = course.learning_module.get(id=module_id) @@ -728,6 +736,7 @@ def show_question(request, question, paper, error_message=None, 'delay_time': delay_time, 'quiz_type': quiz_type, 'all_modules': all_modules, + 'assignment_files': assignment_files, } answers = paper.get_previous_answers(question) if answers: @@ -1920,8 +1929,8 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, course.is_teacher(current_user): raise Http404('This course does not belong to you') has_quiz_assignments = AssignmentUpload.objects.filter( - question_paper_id__in=questionpaper_id - ).exists() + course_id=course_id, question_paper_id__in=questionpaper_id + ).exists() context = { "users": user_details, "quiz_id": quiz_id, @@ -1940,9 +1949,9 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None, except IndexError: raise Http404('No attempts for paper') has_user_assignments = AssignmentUpload.objects.filter( - question_paper_id__in=questionpaper_id, - user_id=user_id - ).exists() + course_id=course_id, question_paper_id__in=questionpaper_id, + user_id=user_id + ).exists() user = User.objects.get(id=user_id) data = AnswerPaper.objects.get_user_data( user, questionpaper_id, course_id, attempt_number @@ -2203,12 +2212,12 @@ def view_answerpaper(request, questionpaper_id, course_id): if quiz.view_answerpaper and user in course.students.all(): data = AnswerPaper.objects.get_user_data(user, questionpaper_id, course_id) - has_user_assignment = AssignmentUpload.objects.filter( + has_user_assignments = AssignmentUpload.objects.filter( user=user, course_id=course.id, question_paper_id=questionpaper_id ).exists() context = {'data': data, 'quiz': quiz, 'course_id': course.id, - "has_user_assignment": has_user_assignment} + "has_user_assignments": has_user_assignments} return my_render_to_response( request, 'yaksh/view_answerpaper.html', context ) |