diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/templates/yaksh/grade_user.html | 9 | ||||
-rw-r--r-- | yaksh/templates/yaksh/user_data.html | 10 | ||||
-rw-r--r-- | yaksh/templates/yaksh/view_answerpaper.html | 23 | ||||
-rw-r--r-- | yaksh/views.py | 14 |
4 files changed, 45 insertions, 11 deletions
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html index ec8c244..2ab5047 100644 --- a/yaksh/templates/yaksh/grade_user.html +++ b/yaksh/templates/yaksh/grade_user.html @@ -130,7 +130,14 @@ Status : <b style="color: green;"> Passed </b><br/> {% if question.type == "mcq" or question.type == "mcc" %} <h5> <u>Choices:</u></h5> {% for testcase in question.get_test_cases %} - <br/><strong>{{ forloop.counter }}. {{ testcase.options|safe }}</strong> + {% if testcase.correct %} + <br/><strong><mark style="background-color:#4cff00"> + {{ forloop.counter }}. {{ testcase.options|safe }} + </mark></strong> + {% else %} + <br/><strong> + {{ forloop.counter }}. {{ testcase.options|safe }}</strong> + {% endif %} {% endfor %} {% else %} <h5> <u>Test cases: </u></h5> diff --git a/yaksh/templates/yaksh/user_data.html b/yaksh/templates/yaksh/user_data.html index 9c11dd9..27c5237 100644 --- a/yaksh/templates/yaksh/user_data.html +++ b/yaksh/templates/yaksh/user_data.html @@ -66,7 +66,15 @@ User IP address: {{ paper.user_ip }} {% if question.type == "mcq" or question.type == "mcc" %} <h5> <u>Choices:</u></h5> {% for testcase in question.get_test_cases %} - <br/><strong>{{ forloop.counter }}. {{ testcase.options|safe }}</strong> + {% if testcase.correct %} + <br/><strong><mark style="background-color:#4cff00"> + {{ forloop.counter }}. {{ testcase.options|safe }} + </mark> + </strong> + {% else %} + <br/><strong> + {{ forloop.counter }}. {{ testcase.options|safe }}</strong> + {% endif %} {% endfor %} {% else %} <h5> <u>Test cases: </u></h5> diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html index cd607dd..172444f 100644 --- a/yaksh/templates/yaksh/view_answerpaper.html +++ b/yaksh/templates/yaksh/view_answerpaper.html @@ -40,11 +40,24 @@ <div class="panel-body"> <h5><u>Question:</u></h5> <strong>{{ question.description|safe }}</strong> {% if question.type == "mcq" or question.type == "mcc" %} - <h5> <u>Choices:</u></h5> - {% for testcase in question.get_test_cases %} - <br/><strong>{{ forloop.counter }}. {{ testcase.options|safe }}</strong> - {% endfor %} - {%endif%} + <h5> <u>Choices:</u></h5> + {% for testcase in question.get_test_cases %} + {% if testcase.correct %} + <br/><strong><mark style="background-color:#4cff00"> + {{ forloop.counter }}. {{ testcase.options|safe }} + </mark> + </strong> + {% else %} + <br/><strong> + {{ forloop.counter }}. {{ testcase.options|safe }}</strong> + {% endif %} + {% endfor %} + {% else %} + <h5> <u>Test cases: </u></h5> + {% for testcase in question.get_test_cases %} + <br/><strong>{{ forloop.counter }}. {{ testcase }}</strong> + {% endfor %} + {% endif %} </div> </div> diff --git a/yaksh/views.py b/yaksh/views.py index 41539b4..1dc7ea2 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1291,21 +1291,27 @@ def download_course_csv(request, course_id): if not course.is_creator(user) and not course.is_teacher(user): raise Http404('The question paper does not belong to your course') students = course.get_only_students().values("id", "first_name", "last_name") - quizzes = Quiz.objects.filter(course=course) + quizzes = Quiz.objects.filter(course=course, is_trial=False) + for student in students: total_course_marks = 0.0 + user_course_marks = 0.0 for quiz in quizzes: quiz_best_marks = AnswerPaper.objects.get_user_best_of_attempts_marks\ (quiz, student["id"]) - total_course_marks += quiz_best_marks + user_course_marks += quiz_best_marks + total_course_marks += quiz.questionpaper_set.values_list\ + ("total_marks", flat=True)[0] student["{}".format(quiz.description)] = quiz_best_marks - student["total"] = total_course_marks + student["total_scored"] = user_course_marks + student["out_of"] = total_course_marks + response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="{0}.csv"'.format( (course.name).lower().replace('.', '')) header = ['first_name', 'last_name']+[quiz.description for quiz in quizzes]\ - + ['total'] + + ['total_scored', 'out_of'] writer = csv.DictWriter(response,fieldnames=header, extrasaction='ignore') writer.writeheader() for student in students: |