From 164d4d79787f3f6ef21a213bd647e885bf1cc899 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 28 Jan 2021 10:40:40 +0530 Subject: Minor template changes --- yaksh/templates/yaksh/courses.html | 12 ++++++----- yaksh/templates/yaksh/post_comments.html | 4 ++-- yaksh/templates/yaksh/question.html | 32 ++++++++++------------------- yaksh/templates/yaksh/quizzes_user.html | 4 ++-- yaksh/templates/yaksh/show_lesson_quiz.html | 28 ++++++++++--------------- yaksh/views.py | 15 +++++++++++--- 6 files changed, 45 insertions(+), 50 deletions(-) diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 38c106c..0c59b2b 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -213,13 +213,15 @@ {{course.name}}
- - {% if user.id != course.creator.id %} + {% if user.id != course.creator.id %} + Allotted Course - {% else %} + + {% else %} + Created Course - {% endif %} - + + {% endif %}
{% if course.active %} diff --git a/yaksh/templates/yaksh/post_comments.html b/yaksh/templates/yaksh/post_comments.html index aadc48b..17576b8 100644 --- a/yaksh/templates/yaksh/post_comments.html +++ b/yaksh/templates/yaksh/post_comments.html @@ -25,8 +25,8 @@
{% endif %} -
-
+
+
{{post.title}}
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 67bbf3f..56edcf3 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -158,28 +158,18 @@ question_type = "{{ question.type }}"; {% else %} Language: {{question.language}} {% endif %} - {% if question.type == "mcq" %} - Type: SINGLE CORRECT CHOICE - {% elif question.type == "mcc" %} - Type: MULTIPLE CORRECT CHOICES - {% elif question.type == "code" %} - Type: PROGRAMMING - {% elif question.type == "upload" %} - Type: ASSIGNMENT UPLOAD - {% elif question.type == "integer" %} - Type: FILL IN THE BLANKS WITH INTEGER ANSWER - {% elif question.type == "string" %} - Type: FILL IN THE BLANKS WITH STRING ANSWER - {% if testcase.string_check == "lower" %} -
(CASE INSENSITIVE) - {% else %} -
(CASE SENSITIVE) + Type: + + {{question.get_type_display}} + {% if question.type == "string" %} + {% if testcase.string_check == "lower" %} + (CASE INSENSITIVE) + {% else %} + (CASE SENSITIVE) + {% endif %} {% endif %} - {% elif question.type == "float" %} - Type: FILL IN THE BLANKS WITH FLOAT ANSWER - {% elif question.type == "arrange" %} - Type: ARRANGE THE OPTIONS IN CORRECT ORDER - {% endif %} + + Marks: {{ question.points }} diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html index b1c5e3c..3dfcbac 100644 --- a/yaksh/templates/yaksh/quizzes_user.html +++ b/yaksh/templates/yaksh/quizzes_user.html @@ -67,7 +67,7 @@
{% if user in course.data.requests.all %} - + Request Pending {% elif user in course.data.rejected.all %} @@ -94,7 +94,7 @@ {% endif %} {% else %} - Enrollment Closed + No Enrollments allowed {% endif %} {% else %} diff --git a/yaksh/templates/yaksh/show_lesson_quiz.html b/yaksh/templates/yaksh/show_lesson_quiz.html index 71c997d..48765bd 100644 --- a/yaksh/templates/yaksh/show_lesson_quiz.html +++ b/yaksh/templates/yaksh/show_lesson_quiz.html @@ -35,24 +35,18 @@ {% else %} Language: {{question.language}} {% endif %} - {% if question.type == "mcq" %} - Type: SINGLE CORRECT CHOICE - {% elif question.type == "mcc" %} - Type: MULTIPLE CORRECT CHOICES - {% elif question.type == "integer" %} - Type: FILL IN THE BLANKS WITH INTEGER ANSWER - {% elif question.type == "string" %} - Type: FILL IN THE BLANKS WITH STRING ANSWER - {% if testcase.string_check == "lower" %} -
(CASE INSENSITIVE) - {% else %} -
(CASE SENSITIVE) + Type: + + {{question.get_type_display}} + {% if question.type == "string" %} + {% if testcase.string_check == "lower" %} + (CASE INSENSITIVE) + {% else %} + (CASE SENSITIVE) + {% endif %} {% endif %} - {% elif question.type == "float" %} - Type: FILL IN THE BLANKS WITH FLOAT ANSWER - {% elif question.type == "arrange" %} - Type: ARRANGE THE OPTIONS IN CORRECT ORDER - {% endif %} + + Points: {{ question.points }} diff --git a/yaksh/views.py b/yaksh/views.py index 2b5ea8d..83b6766 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -681,8 +681,9 @@ def show_question(request, question, paper, error_message=None, delay_time = paper.time_left_on_question(question) if previous_question and quiz.is_exercise: - if (delay_time <= 0 or previous_question in - paper.questions_answered.all()): + is_prev_que_answered = paper.questions_answered.filter( + id=previous_question.id).exists() + if (delay_time <= 0 or is_prev_que_answered): can_skip = True question = previous_question if not question: @@ -798,6 +799,14 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, course_id=course_id ) current_question = get_object_or_404(Question, pk=q_id) + def is_valid_answer(answer): + status = True + if ((current_question.type == "mcc" or + current_question.type == "arrange") and not answer): + status = False + elif answer is None or not str(answer): + status = False + return status if request.method == 'POST': # Add the answer submitted, regardless of it being correct or not. @@ -877,7 +886,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, previous_question=current_question) else: user_answer = request.POST.get('answer') - if not str(user_answer): + if not is_valid_answer(user_answer): msg = "Please submit a valid answer." return show_question( request, current_question, paper, notification=msg, -- cgit