summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py2
-rw-r--r--yaksh/templates/base.html11
-rw-r--r--yaksh/templates/yaksh/add_module.html2
-rw-r--r--yaksh/templates/yaksh/question.html9
-rw-r--r--yaksh/test_models.py6
-rw-r--r--yaksh/views.py23
6 files changed, 40 insertions, 13 deletions
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
)