diff options
author | adityacp | 2017-11-22 12:02:49 +0530 |
---|---|---|
committer | adityacp | 2017-11-22 12:02:49 +0530 |
commit | acce9174639224234325c007f30d5679712e4c2c (patch) | |
tree | ea3e8a7e83b9964f9c289f63a7f54ca1243fdfe7 | |
parent | 8e5354fb2fdab96780bfd147ba5b1724eebd673b (diff) | |
download | online_test-acce9174639224234325c007f30d5679712e4c2c.tar.gz online_test-acce9174639224234325c007f30d5679712e4c2c.tar.bz2 online_test-acce9174639224234325c007f30d5679712e4c2c.zip |
Change forms.py, models.py, views.py, templates, templatetags
- Add start_time, end_time enrollement in course form
- Change get_quiz_details in course model
- Add validation to check if course is active and not expired
- Template changes for cleaner dashboard
-rw-r--r-- | yaksh/forms.py | 3 | ||||
-rw-r--r-- | yaksh/models.py | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_course.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/moderator_dashboard.html | 51 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 23 | ||||
-rw-r--r-- | yaksh/templates/yaksh/quizzes_user.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/show_video.html | 25 | ||||
-rw-r--r-- | yaksh/templatetags/custom_filters.py | 6 | ||||
-rw-r--r-- | yaksh/views.py | 19 |
11 files changed, 78 insertions, 61 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 25eb2c5..52e6a12 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -272,7 +272,8 @@ class CourseForm(forms.ModelForm): class Meta: model = Course - fields = ['name', 'enrollment', 'active', 'code', 'instructions'] + fields = ['name', 'enrollment', 'active', 'code', 'instructions', + 'start_enroll_time', 'end_enroll_time'] class ProfileForm(forms.ModelForm): diff --git a/yaksh/models.py b/yaksh/models.py index 296ec48..d611f6b 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -637,7 +637,7 @@ class Course(models.Model): return quiz_list def get_quiz_details(self): - return [(self, quiz, quiz.get_total_students(self), + return [(quiz, quiz.get_total_students(self), quiz.get_passed_students(self), quiz.get_failed_students(self)) for quiz in self.get_quizzes()] diff --git a/yaksh/templates/yaksh/add_course.html b/yaksh/templates/yaksh/add_course.html index 904cf5f..47a637d 100644 --- a/yaksh/templates/yaksh/add_course.html +++ b/yaksh/templates/yaksh/add_course.html @@ -15,7 +15,7 @@ <form name=frm id=frm action="" method="post" > {% csrf_token %} <center> - <table class=span1> + <table class="table table-bordered"> {{ form.as_table }} </table> <br/> @@ -25,7 +25,7 @@ </script> </center> - <center><button class="btn primary" type="submit" id="submit" name="questionpaper">Add Course</button> + <center><button class="btn primary" type="submit" id="submit" name="questionpaper">Save</button> <button class="btn primary" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/courses");'>Cancel</button> </center> </form> {% endblock %} diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 242b6da..c99b8f0 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -36,7 +36,7 @@ <br><center><h4>You may now close the browser.</h4></center><br> {% endif %} <a href="{{URL_ROOT}}/exam/" id="home" class="btn btn-success"> Home </a> - {% if module_id %} + {% if module_id and not user == "moderator" %} {% if first_unit %} <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}/1" class="btn btn-info"> Next Unit <span class="glyphicon glyphicon-chevron-right"> diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 50c845b..5daf944 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -66,7 +66,7 @@ {% for course in courses %} <tr> <td width="30%"> - <a href="{{URL_ROOT}}/exam/manage/course_detail/{{course.id}}/">{{ course.name }} + <a href="{{URL_ROOT}}/exam/manage/course_detail/{{course.id}}">{{ course.name }} </a> {% if course.active %} <span class="label label-success">Active</span> diff --git a/yaksh/templates/yaksh/moderator_dashboard.html b/yaksh/templates/yaksh/moderator_dashboard.html index 490ec83..17a4924 100644 --- a/yaksh/templates/yaksh/moderator_dashboard.html +++ b/yaksh/templates/yaksh/moderator_dashboard.html @@ -1,4 +1,5 @@ {% extends "manage.html" %} +{% load custom_filters %} {% block pagetitle %} Moderator's Dashboard {% endblock pagetitle %} {% block script %} @@ -9,27 +10,43 @@ <center><h4>List of quizzes! Click on the given links to have a look at answer papers for a quiz.</h4></center> <table class="table table-bordered"> - <th>Course</th> - <th>Quiz</th> - <th>Taken By</th> - <th>No. of users Passed</th> - <th>No. of users Failed</th> - {% for course, quiz, answer_papers, users_passed, users_failed in users_per_paper %} + <th>Courses</th> + <th>Quizzes</th> + {% for course in courses %} <tr> <td> + <a href="{{URL_ROOT}}/exam/manage/course_detail/{{course.id}}"> {{ course }} + </a> </td> <td> - <a href="{{URL_ROOT}}/exam/manage/monitor/{{ quiz.id }}/{{course.id}}">{{ quiz.description }}</a> - </td> - <td> - {{ answer_papers }} user(s) - </td> - <td> - {{ users_passed }} - </td> - <td> - {{ users_failed }} + {% get_course_details course as course_details %} + {% if course_details %} + <table class="table table-bordered"> + <th>Quiz</th> + <th>Taken By</th> + <th>No. of users Passed</th> + <th>No. of users Failed</th> + {% for quiz, users_no, passed, failed in course_details %} + <tr> + <td> + <a href="{{URL_ROOT}}/exam/manage/monitor/{{ quiz.id }}/{{course.id}}">{{ quiz.description }}</a> + </td> + <td> + {{users_no}} user(s) + </td> + <td> + {{passed}} + </td> + <td> + {{failed}} + </td> + </tr> + {% endfor %} + </table> + {% else %} + No Quizzes + {% endif %} </td> </tr> {% endfor %} @@ -47,7 +64,7 @@ <span class="glyphicon glyphicon-question-sign"></span> What's This </a> <div id="help" class="collapse"> - <ul> + <ul class="list"> <li>A Demo Course and Demo Quiz will be created (Click Courses link on nav bar to view courses).</li> <li>Some Demo Questions are also created for you (Click Questions link on nav bar to view questions).</li> <li>In Courses you can view Demo Quiz.</li> diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index eab3289..12f5da6 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -110,23 +110,18 @@ module_id = "{{module.id}}" {% endif %} {% if unit.learning_type == "quiz" %} - {% if status == "completed" %} - <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> + <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> {{ unit.quiz.description }} - </a> - <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> - {% else %} - {{ unit.quiz.description }} - {% endif %} + </a> {% else %} - {% if status == "completed" %} - <a href="{{ URL_ROOT }}/exam/show_video/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> + <a href="{{ URL_ROOT }}/exam/show_video/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> {{ unit.lesson.name }} - </a> - <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> - {% else %} - {{ unit.lesson.name }} - {% endif %} + </a> +{% endif %} +{% if status == "completed" %} + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> +{% else %} + <span class="glyphicon glyphicon-remove" style="color: #FF0000"></span> {% endif %} </li> </span> diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html index d564a8f..3c4b985 100644 --- a/yaksh/templates/yaksh/quizzes_user.html +++ b/yaksh/templates/yaksh/quizzes_user.html @@ -5,7 +5,7 @@ {% block main %} {% if msg %} <div class="alert alert-warning" role="alert"> - {{ msg }} + <center>{{ msg }}</center> </div> {% endif %} {% if 'Enrolled Courses' not in title%} diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html index fa80ddb..ffb0c68 100644 --- a/yaksh/templates/yaksh/show_video.html +++ b/yaksh/templates/yaksh/show_video.html @@ -15,27 +15,22 @@ {% get_unit_status course learning_module unit user as status %} {% if unit.id == current_unit.id %} - <span class="glyphicon glyphicon-pencil" data-toggle="tooltip" title="Current Unit"> + <span class="glyphicon glyphicon-pencil" data-toggle="tooltip" title="Currently on"> </span> {% endif %} {% if unit.learning_type == "quiz" %} - {% if status == "completed" %} - <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> - {{ unit.quiz.description }} - </a> - <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> - {% else %} + <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> {{ unit.quiz.description }} - {% endif %} + </a> {% else %} - {% if status == "completed" %} <a href="{{ URL_ROOT }}/exam/show_video/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> {{ unit.lesson.name }} </a> - <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> - {% else %} - {{ unit.lesson.name }} - {% endif %} +{% endif %} +{% if status == "completed" %} + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> +{% else %} + <span class="glyphicon glyphicon-remove" style="color: #FF0000"></span> {% endif %} </li> </span> @@ -57,7 +52,7 @@ </div> </div> <div style="text-align: center;"> - <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{first_unit.id}}/1" class="btn btn-primary">Next Unit + <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{first_unit.id}}/1" class="btn btn-info">Next Unit <span class="glyphicon glyphicon-chevron-right"> </span> </a> @@ -70,7 +65,7 @@ </div> </div> <div style="text-align: center;"> - <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{current_unit.id}}" class="btn btn-primary" style="display: inline-block;">Next Unit + <a href="{{ URL_ROOT }}/exam/next_unit/{{course.id}}/{{learning_module.id}}/{{current_unit.id}}" class="btn btn-info" style="display: inline-block;">Next Unit <span class="glyphicon glyphicon-chevron-right"> </span> </a> diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py index 1749d71..6ddd213 100644 --- a/yaksh/templatetags/custom_filters.py +++ b/yaksh/templatetags/custom_filters.py @@ -39,6 +39,12 @@ def file_title(name): def get_unit_status(course, module, unit, user): return course.get_unit_completion_status(module, user, unit) + @register.simple_tag def get_module_status(user, module, course): return module.get_status(user, course) + + +@register.simple_tag +def get_course_details(course): + return course.get_quiz_details() diff --git a/yaksh/views.py b/yaksh/views.py index 90ef5f9..1147bb4 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -364,10 +364,7 @@ def prof_manage(request, msg=None): qpaper.quiz.delete() else: answerpaper.delete() - users_per_paper = [] - for course in courses: - users_per_paper.extend(course.get_quiz_details()) - context = {'user': user, 'users_per_paper': users_per_paper, + context = {'user': user, 'courses': courses, 'trial_paper': trial_paper, 'msg': msg } return my_render_to_response( @@ -437,16 +434,14 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, msg = 'You are not enrolled in {0} course'.format(course.name) if is_moderator(user): return prof_manage(request, msg=msg) - return view_module(request, module_id=module_id, course_id=course_id, - msg=msg) + return quizlist_user(request, msg=msg) # if course is active and is not expired if not course.active or not course.is_active_enrollment(): msg = "{0} is either expired or not active".format(course.name) if is_moderator(user): return prof_manage(request, msg=msg) - return view_module(request, module_id=module_id, course_id=course_id, - msg=msg) + return quizlist_user(request, msg=msg) # is quiz is active and is not expired if quest_paper.quiz.is_expired() or not quest_paper.quiz.active: @@ -815,6 +810,8 @@ def complete(request, reason=None, attempt_num=None, questionpaper_id=None, context = {'message': message, 'paper': paper, 'module_id': learning_module.id, 'course_id': course_id, 'learning_unit': learning_unit} + if is_moderator(user): + context['user'] = "moderator" return my_render_to_response('yaksh/complete.html', context) @@ -2217,6 +2214,9 @@ def show_video(request, lesson_id, module_id, course_id): course = Course.objects.get(id=course_id) if user not in course.students.all(): raise Http404('This course does not belong to you') + if not course.active or not course.is_active_enrollment(): + msg = "{0} is either expired or not active".format(course.name) + return quizlist_user(request, msg=msg) learn_module = course.learning_module.get(id=module_id) learn_unit = learn_module.learning_unit.get(lesson_id=lesson_id) learning_units = learn_module.get_learning_units() @@ -2503,6 +2503,9 @@ def view_module(request, module_id, course_id, msg=None): if user not in course.students.all(): raise Http404('You are not enrolled for this course!') context = {} + if not course.active or not course.is_active_enrollment(): + msg = "{0} is either expired or not active".format(course.name) + return quizlist_user(request, msg=msg) learning_module = course.learning_module.get(id=module_id) if learning_module.has_prerequisite(): if not learning_module.is_prerequisite_passed(user, course): |