From c70cf2a0fd8e51d4b689e08d78021cac848b0187 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 1 Feb 2019 14:47:20 +0530 Subject: Change Course Listing UI on Student Dashboard --- yaksh/forms.py | 7 ++- yaksh/templates/yaksh/course_modules.html | 16 +----- yaksh/templates/yaksh/quizzes_user.html | 89 +++++++++++++++++++------------ yaksh/views.py | 16 ++++-- 4 files changed, 76 insertions(+), 52 deletions(-) (limited to 'yaksh') diff --git a/yaksh/forms.py b/yaksh/forms.py index a51e6c2..57140bc 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -282,8 +282,11 @@ class CourseForm(forms.ModelForm): class Meta: model = Course - fields = ['name', 'enrollment', 'active', 'code', 'instructions', - 'start_enroll_time', 'end_enroll_time', 'grading_system'] + fields = [ + 'name', 'enrollment', 'active', 'code', 'instructions', + 'start_enroll_time', 'end_enroll_time', 'grading_system', + 'view_grade' + ] class ProfileForm(forms.ModelForm): diff --git a/yaksh/templates/yaksh/course_modules.html b/yaksh/templates/yaksh/course_modules.html index 244c2d9..d5bbfd3 100644 --- a/yaksh/templates/yaksh/course_modules.html +++ b/yaksh/templates/yaksh/course_modules.html @@ -16,20 +16,8 @@
-
-
{{ course.name }}
-
-
-
Overall - Course
Completion : -
-
- - {{ course_percentage }} % completed - -
-
-
+
+
{{ course.name }}
diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html index 548eef4..ee5b684 100644 --- a/yaksh/templates/yaksh/quizzes_user.html +++ b/yaksh/templates/yaksh/quizzes_user.html @@ -72,21 +72,21 @@
-

- - {{ course.name }} by {{ course.creator.get_full_name }} - -

- {% if course.is_active_enrollment %} + + {% if course.data.is_active_enrollment %}
- {{course.start_enroll_time}}   to   {{course.end_enroll_time}} + {{course.data.start_enroll_time}}   to   {{course.data.end_enroll_time}}
{% endif %}
- {% if course.days_before_start != 0 %} + {% if course.data.days_before_start != 0 %} - {{course.days_before_start}} day(s) to start + {{course.data.days_before_start}} day(s) to start {% endif %} @@ -94,20 +94,27 @@
- + - {% if user in course.requests.all %} Request Pending - {% elif user in course.rejected.all %}Request Rejected - {% elif user in course.students.all %}START + {% if user in course.data.requests.all %} Request Pending + {% elif user in course.data.rejected.all %}Request Rejected + {% elif user in course.data.students.all %} + + {% if course.completion_percentage > 0 %} + CONTINUE + {% else %} + START + {% endif %} + {% else %} - {% if course.active %} - {% if course.is_active_enrollment %} - {% if course.is_self_enroll %} - ENROLL + {% if course.data.active %} + {% if course.data.is_active_enrollment %} + {% if course.data.is_self_enroll %} + ENROLL {% else %} - ENROLL + ENROLL {% endif %} {% else %} @@ -124,39 +131,55 @@
-
+
-

{{ course.name }} by {{ course.creator.get_full_name }}


+

{{ course.data.name }} by {{ course.data.creator.get_full_name }}


- {% if course.description %} + {% if course.data.description %}

About the course
- {{ course.description }} + {{ course.data.description }}

{% endif %} - {% if course.get_learning_modules %} + {% if course.data.get_learning_modules %}

What you'll learn

    - {% for module in course.get_learning_modules %} + {% for module in course.data.get_learning_modules %}
  • {{module.name|title}}
  • {% endfor %}

{% endif %}

Instructor
- {{ course.creator.get_full_name }} + {{ course.data.creator.get_full_name }}

- {% if course.instructions %} -

Requirement(s)
- {{ course.instructions|safe }} + {% if course.data.instructions %} +

Instructions
+ {{ course.data.instructions|safe }}

{% endif %}
-
- - - -
STARTS ON {{course.start_enroll_time}}
ENDS ON {{course.end_enroll_time}}
+
+
+
+ STARTS ON +
+
+ {{course.data.start_enroll_time}} +
+
+
+
+ ENDS ON +
+
+ {{course.data.end_enroll_time}} +
+
+
+
{{course.completion_percentage}} % completed +
+
diff --git a/yaksh/views.py b/yaksh/views.py index 6c7a12e..4c1b7f7 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -156,6 +156,7 @@ def user_logout(request): def quizlist_user(request, enrolled=None, msg=None): """Show All Quizzes that is available to logged-in user.""" user = request.user + courses_data = [] if request.method == "POST": course_code = request.POST.get('course_code') @@ -164,18 +165,27 @@ def quizlist_user(request, enrolled=None, msg=None): title = 'Search' elif enrolled is not None: - courses = user.students.all() + courses = user.students.all().order_by('-id') title = 'Enrolled Courses' else: courses = Course.objects.filter( active=True, is_trial=False ).exclude( ~Q(requests=user), ~Q(rejected=user), hidden=True - ) + ).order_by('-id') title = 'All Courses' + for c in courses: + _percent = c.get_completion_percent(user) if user in c.students.all() else None + courses_data.append( + { + 'data': c, + 'completion_percentage': _percent, + } + ) + context = { - 'user': user, 'courses': courses, + 'user': user, 'courses': courses_data, 'title': title, 'msg': msg } -- cgit