diff options
author | adityacp | 2018-05-29 15:40:50 +0530 |
---|---|---|
committer | adityacp | 2018-05-29 15:43:38 +0530 |
commit | 5da8a3537b1ffb51145cbba0500cedda9f2b48da (patch) | |
tree | 0fa0a2f2798f5c3209f23c43b94b91a1e28e7320 | |
parent | 458134e4d110be451ed7e7c5f001c2d204e1e892 (diff) | |
download | online_test-5da8a3537b1ffb51145cbba0500cedda9f2b48da.tar.gz online_test-5da8a3537b1ffb51145cbba0500cedda9f2b48da.tar.bz2 online_test-5da8a3537b1ffb51145cbba0500cedda9f2b48da.zip |
Change in models, templates, js
- Remove else condition in get_current_unit model method
- Reduce ajax timeout in course.js
- Create a new model method to set current unit
- Change views test
-rw-r--r-- | yaksh/models.py | 9 | ||||
-rw-r--r-- | yaksh/static/yaksh/js/course.js | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 7 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_detail.html | 4 | ||||
-rw-r--r-- | yaksh/test_views.py | 2 | ||||
-rw-r--r-- | yaksh/views.py | 3 |
6 files changed, 13 insertions, 14 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 4c9ab98..36e859c 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -788,10 +788,7 @@ class Course(models.Model): def get_current_unit(self, user): course_status = CourseStatus.objects.filter(course=self, user=user) if course_status.exists(): - unit = course_status.first().current_unit - else: - unit = "NA" - return unit + return course_status.first().current_unit def days_before_start(self): """ Get the days remaining for the start of the course """ @@ -862,6 +859,10 @@ class CourseStatus(models.Model): break return complete + def set_current_unit(self, unit): + self.current_unit = unit + self.save() + ############################################################################### class ConcurrentUser(models.Model): diff --git a/yaksh/static/yaksh/js/course.js b/yaksh/static/yaksh/js/course.js index 36e565a..bd197a8 100644 --- a/yaksh/static/yaksh/js/course.js +++ b/yaksh/static/yaksh/js/course.js @@ -81,7 +81,7 @@ $('.user_data').click(function() { "/exam/manage/get_user_status/" + course_id + "/" + student_id;
$.ajax({
url: get_url,
- timeout: 15000,
+ timeout: 8000,
type: "GET",
dataType: "json",
contentType: 'application/json; charset=utf-8',
diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 567d01f..a3627d0 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -3,11 +3,10 @@ {% block pagetitle %}<img src="{{ URL_ROOT }}/static/yaksh/images/yaksh_text.png" width="80" alt="YAKSH"></img>{% endblock %} {% block content %} -{% if module_id and not user == "moderator" %} +{% if module_id and not paper.question_paper.quiz.is_trial %} <center> <div class="alert alert-info"> - Note:- Please Click on the Next button to submit the quiz. Please do not close the browser - without clicking next. + Note:- Please Click on the Next button to submit the quiz. Please do not close the browser without clicking Next. </div> </center> {% endif %} @@ -41,7 +40,7 @@ width="80" alt="YAKSH"></img>{% endblock %} <center><h3>{{message}}</h3></center> <center> <br> - {% if module_id and not user == "moderator" %} + {% if module_id and not paper.question_paper.quiz.is_trial %} {% if first_unit %} <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}/1" class="btn btn-info" id="Next"> Next <span class="glyphicon glyphicon-chevron-right"> diff --git a/yaksh/templates/yaksh/course_detail.html b/yaksh/templates/yaksh/course_detail.html index d069b5d..2bf725c 100644 --- a/yaksh/templates/yaksh/course_detail.html +++ b/yaksh/templates/yaksh/course_detail.html @@ -163,14 +163,14 @@ </div> </td> <td> - {% if unit != "NA" %} + {% if unit %} {% if unit.type == 'quiz' %} {{unit.quiz.description}} {% else %} {{unit.lesson.name}} {% endif %} {% else %} - {{unit}} + NA {% endif%} </td> <td> diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 211ba19..7f72e61 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -2629,7 +2629,7 @@ class TestCourseDetail(TestCase): self.assertEqual(student.username, "demo_student") self.assertEqual(grade, "NA") self.assertEqual(percent, 0.0) - self.assertEqual(current_unit, "NA") + self.assertIsNone(current_unit) # Check student details when student starts the course self.course_status = CourseStatus.objects.create( diff --git a/yaksh/views.py b/yaksh/views.py index 3a0b4e7..f458ad8 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -2774,8 +2774,7 @@ def _update_unit_status(course_id, user, unit): user=user, course_id=course_id, ) # make next available unit as current unit - course_status.current_unit = unit - course_status.save() + course_status.set_current_unit(unit) def _update_course_percent(course, user): |