From fca319fefcd2a0e476415968b18873b0c791a5fe Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 1 Feb 2021 17:38:00 +0530 Subject: Change templates and models - Remove unwanted model manager methods - Minor UI refactor for course and question interface --- grades/templates/add_grades.html | 10 +- grades/templates/grading_systems.html | 6 +- yaksh/forms.py | 2 +- yaksh/models.py | 52 ---- yaksh/static/yaksh/css/custom.css | 2 +- yaksh/static/yaksh/js/show_courses.js | 7 + yaksh/static/yaksh/js/show_question.js | 7 + yaksh/templates/yaksh/add_course.html | 4 +- yaksh/templates/yaksh/courses.html | 462 +++++++++++++++---------------- yaksh/templates/yaksh/showquestions.html | 133 ++++----- 10 files changed, 330 insertions(+), 355 deletions(-) diff --git a/grades/templates/add_grades.html b/grades/templates/add_grades.html index c7006a9..29da212 100644 --- a/grades/templates/add_grades.html +++ b/grades/templates/add_grades.html @@ -7,8 +7,8 @@ {% endblock %} -{% block main %} - +{% block content %} +

+
View Grading Systems @@ -89,7 +90,6 @@ {{ hidden }} {% endfor %} Grade Range {{forloop.counter}}. -
{% for field in form.visible_fields %}
@@ -100,7 +100,6 @@
{% endfor %}
-
{% endfor %}
@@ -114,5 +113,6 @@ {% endif %}

- +
+ {% endblock %} diff --git a/grades/templates/grading_systems.html b/grades/templates/grading_systems.html index 46b3d30..841b1ad 100644 --- a/grades/templates/grading_systems.html +++ b/grades/templates/grading_systems.html @@ -1,8 +1,9 @@ {% extends "manage.html" %} {% block title %} View Grading Systems {% endblock %} {% block pagetitle %} View Grading Systems {% endblock %} -{% block main %} +{% block content %} +

+
 Add a Grading System @@ -95,5 +97,7 @@ {% endfor %} {% endif %} +
+
{% endblock %} diff --git a/yaksh/forms.py b/yaksh/forms.py index 7a9eb87..01e691d 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -387,7 +387,7 @@ class QuestionFilterForm(forms.Form): class SearchFilterForm(forms.Form): search_tags = forms.CharField( label='Search Tags', - widget=forms.TextInput(attrs={'placeholder': 'Search', + widget=forms.TextInput(attrs={'placeholder': 'Search by course name', 'class': form_input_class, }), required=False ) diff --git a/yaksh/models.py b/yaksh/models.py index 662a8b4..0f62948 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1985,58 +1985,6 @@ class QuestionSet(models.Model): ############################################################################### class AnswerPaperManager(models.Manager): - def get_all_questions(self, questionpaper_id, attempt_number, course_id, - status='completed'): - ''' Return a dict of question id as key and count as value''' - papers = self.filter(question_paper_id=questionpaper_id, - course_id=course_id, - attempt_number=attempt_number, status=status) - all_questions = list() - questions = list() - for paper in papers: - all_questions += paper.get_questions() - for question in all_questions: - questions.append(question.id) - return Counter(questions) - - def get_per_answer_stats(self, questionpaper_id, attempt_number, - course_id, status='completed'): - papers = self.filter(question_paper_id=questionpaper_id, - course_id=course_id, - attempt_number=attempt_number, status=status) - questions = Question.objects.filter( - questions__id__in=papers, - ).distinct() - - stats = {} - for question in questions: - answers = Answer.objects.filter( - answerpaper__id__in=papers, question=question.id - ).values('answer', 'question__id', 'answerpaper__id') - question_ans_count = {} - answerpaper_count = [] - for ans in answers: - if ans.get('answerpaper__id'): - if ans.get('answer') not in question_ans_count: - question_ans_count[ans.get('answer')] = 1 - else: - question_ans_count[ans.get('answer')] += 1 - answerpaper_count.append(ans.get('answerpaper__id')) - stats[question] = question_ans_count - return stats - - def get_all_questions_answered(self, questionpaper_id, attempt_number, - course_id, status='completed'): - ''' Return a dict of answered question id as key and count as value''' - papers = self.filter(question_paper_id=questionpaper_id, - course_id=course_id, - attempt_number=attempt_number, status=status) - questions_answered = list() - for paper in papers: - for question in filter(None, paper.get_questions_answered()): - if paper.is_answer_correct(question): - questions_answered.append(question.id) - return Counter(questions_answered) def get_attempt_numbers(self, questionpaper_id, course_id, status='completed'): diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css index 91f68b5..78eaba4 100644 --- a/yaksh/static/yaksh/css/custom.css +++ b/yaksh/static/yaksh/css/custom.css @@ -210,4 +210,4 @@ iframe { bottom: 0; width: 100%; text-align: center; -} \ No newline at end of file +} diff --git a/yaksh/static/yaksh/js/show_courses.js b/yaksh/static/yaksh/js/show_courses.js index 1209ce3..b887d01 100644 --- a/yaksh/static/yaksh/js/show_courses.js +++ b/yaksh/static/yaksh/js/show_courses.js @@ -36,4 +36,11 @@ window.onload = function() { $('#gridbtn').addClass('active'); $('#listbtn').removeClass('active'); } + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { + $("#course-list").removeClass("col-9"); + $("#course-list").addClass("col"); + } else{ + $("#course-list").addClass("col-9"); + $("#course-list").removeClass("col"); + } } \ No newline at end of file diff --git a/yaksh/static/yaksh/js/show_question.js b/yaksh/static/yaksh/js/show_question.js index d7b6a44..abebdab 100644 --- a/yaksh/static/yaksh/js/show_question.js +++ b/yaksh/static/yaksh/js/show_question.js @@ -61,4 +61,11 @@ $(document).ready(function() { }); } }); + if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { + $("#question-list").removeClass("col-9"); + $("#question-list").addClass("col"); + } else{ + $("#question-list").addClass("col-9"); + $("#question-list").removeClass("col"); + } }); diff --git a/yaksh/templates/yaksh/add_course.html b/yaksh/templates/yaksh/add_course.html index b264c5e..1afa34b 100644 --- a/yaksh/templates/yaksh/add_course.html +++ b/yaksh/templates/yaksh/add_course.html @@ -14,7 +14,7 @@ {% block title %} Add Course {% endblock %} {% block pagetitle %} Add Course {% endblock %} {% block content %} -
+

+
{% csrf_token %}
@@ -60,5 +61,6 @@

+
{% endblock %} diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 0c59b2b..02cbad9 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -10,127 +10,218 @@ {% block content %}
-
-
- + -
+
+
{% if not objects %}

No Courses Found

{% else %} -
-
-
-
-

Search/Filter Courses

-
-
-
-
- {{ form.search_tags }} +
+
+ +
+
+

Search/Filter Courses

-
- {{ form.search_status }} +
+
+ {{form.search_tags}} +
+ {{form.search_status}} +
+
+ + +  Clear +
-
- - -  Clear - -
+
- -
-

{{ courses_found }} Course(s) Available

+
+

{{ courses_found }} Course(s) Available

- {% if messages %} - {% for message in messages %} -
- - {{ message }} -
- {% endfor %} - {% endif %} - {% with objects as courses %} -
-
- {% include "yaksh/paginator.html" %} -
-
- -
-
-
- -
-
-
- {% for course in courses %} -
-
-
- {{course.name}} -
- {% if user.id != course.creator.id %} - - Allotted Course - - {% else %} - - Created Course - - {% endif %} -
-
-
-
-
- Starts On: - {{course.start_enroll_time}} +
+
+ +
+
+
+ {% for course in courses %} +
+
+
+ {{course.name}} +
+ {% if user.id != course.creator.id %} + + Allotted Course + + {% else %} + + Created Course + + {% endif %} +
+
+
+
+
+ Starts On: + {{course.start_enroll_time}} +
+ Ends On: + {{course.end_enroll_time}} +
+
+
+
+
+ {% if course.active %} + + Active + + {% else %} + + Inactive + + {% endif %} +
+ +
+
+
- Ends On: - {{course.end_enroll_time}} +
+ +
+
+ + +
+
+
-
+
+
+ {% endfor %} +
+
+
+
+ +
+ {% for course in courses %} +
+
+
+ {{course.name}} +
+ {% if user.id != course.creator.id %} + + Allotted Course + + {% else %} + + Created Course + + {% endif %} +
+
{% if course.active %} Active @@ -141,7 +232,7 @@ {% endif %}
- +
+
+
+
+ Starts On: + {{course.start_enroll_time}} +
+ Ends On: + {{course.end_enroll_time}} +
+

-
+ - -
-
-
+ -
+
- - + +

-
- {% endfor %} -
-
-
-
- -
- {% for course in courses %} -
-
-
-
- {{course.name}} -
-
- {% if user.id != course.creator.id %} - - Allotted Course - - {% else %} - - Created Course - - {% endif %} -
-
- {% if course.active %} - - Active - - {% else %} - - Inactive - - {% endif %} -
- -
-
-
-
-
- Starts On: - {{course.start_enroll_time}} -
- Ends On: - {{course.end_enroll_time}} -
-
-
-
- - -
-
- - -
-
- -
-
+ {% endfor %} +
-
- {% endfor %} -
+
+ {% include "yaksh/paginator.html" %} + {% endwith %}
- {% include "yaksh/paginator.html" %} - {% endwith %} {% endif %}
diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index 81bf01a..aefb3a6 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -78,74 +78,73 @@
{% endfor %} {% endif %} -
-
- -

Filters Questions:

-
- -
-
{{ form.question_type }}
-
{{ form.language }}
-
{{ form.marks }}
-

-
- + + +
+

OR

+ +

Search using Tags:

+ +
+
+
+ + + -
-
- - -
- -

Search using Tags:

-
-
-
-
- - - - -
-
-
-
- -
+ +
+ +
+ + +  Clear +
-
- - -  Clear - +
-
+
{% csrf_token %}

- -  Add Question {% if objects %} -

- {% include "yaksh/paginator.html" %} +
+
+ {% include "yaksh/paginator.html" %} +
+ +

Select All
@@ -158,7 +157,7 @@ Select - Sr No. + Sr No. Summary  Language  Type  @@ -174,8 +173,14 @@ - {{forloop.counter}} - {{question.summary|capfirst}} + + {{forloop.counter}} + + + + {{question.summary|capfirst}} + + {{question.language|capfirst}} {{question.type|capfirst}} {{question.points}} @@ -185,9 +190,9 @@ -  Download + -  Delete + {% endfor %} @@ -212,6 +217,8 @@ {% endif %} +
+
-- cgit