diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/models.py | 4 | ||||
-rw-r--r-- | yaksh/static/yaksh/css/yakshcustom.css | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/course_modules.html | 15 | ||||
-rw-r--r-- | yaksh/views.py | 29 |
4 files changed, 35 insertions, 17 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 7e0364a..1d6bb89 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1604,7 +1604,9 @@ class QuestionPaper(models.Model): attempts = AnswerPaper.objects.get_total_attempt(questionpaper=self, user=user, course_id=course_id) - return attempts != self.quiz.attempts_allowed + attempts_allowed = attempts < self.quiz.attempts_allowed + infinite_attempts = self.quiz.attempts_allowed == -1 + return attempts_allowed or infinite_attempts def can_attempt_now(self, user, course_id): if self._is_attempt_allowed(user, course_id): diff --git a/yaksh/static/yaksh/css/yakshcustom.css b/yaksh/static/yaksh/css/yakshcustom.css index bdc0e92..4aba382 100644 --- a/yaksh/static/yaksh/css/yakshcustom.css +++ b/yaksh/static/yaksh/css/yakshcustom.css @@ -230,3 +230,7 @@ html { overflow-y: auto; -ms-overflow-style: -ms-autohiding-scrollbar; } + +#card{ + flex-wrap: wrap; +}
\ No newline at end of file diff --git a/yaksh/templates/yaksh/course_modules.html b/yaksh/templates/yaksh/course_modules.html index d5bbfd3..e1fdc51 100644 --- a/yaksh/templates/yaksh/course_modules.html +++ b/yaksh/templates/yaksh/course_modules.html @@ -14,10 +14,17 @@ {% block main %} <div class="container"> -<div class="row justify-content-md-center yakshwell "> - <div class="col-md-10 bg-light card"> - <div class="row align-items-center my-3"> - <div class="col h4 text-center"> {{ course.name }} </div> +<div class="row justify-content-md-center yakshwell"> + <div class="col-md-10 bg-light card" id="card"> + <div class="row align-items-center"> + <div class="col h4"> {{ course.name }} </div> + <div class = "col"> + {% if course.has_lessons %} + <a href="{% url 'yaksh:download_course' course.id %}" data-toggle="tooltip" title="Download course content" class="btn btn-primary pull-right"> + Download Course + </a> + {% endif %} + </div> </div> </div> </div> diff --git a/yaksh/views.py b/yaksh/views.py index 94ef19b..9199a3a 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -528,23 +528,28 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, # if any previous attempt last_attempt = AnswerPaper.objects.get_user_last_attempt( quest_paper, user, course_id) - if last_attempt and last_attempt.is_attempt_inprogress(): - return show_question( - request, last_attempt.current_question(), last_attempt, - course_id=course_id, module_id=module_id, - previous_question=last_attempt.current_question() - ) + + if last_attempt: + if last_attempt.is_attempt_inprogress(): + return show_question( + request, last_attempt.current_question(), last_attempt, + course_id=course_id, module_id=module_id, + previous_question=last_attempt.current_question() + ) + attempt_number = last_attempt.attempt_number + 1 + else: + attempt_number = 1 + # allowed to start if not quest_paper.can_attempt_now(user, course_id)[0]: msg = quest_paper.can_attempt_now(user, course_id)[1] if is_moderator(user): return prof_manage(request, msg=msg) - return view_module(request, module_id=module_id, course_id=course_id, - msg=msg) - if not last_attempt: - attempt_number = 1 - else: - attempt_number = last_attempt.attempt_number + 1 + return complete( + request, msg, last_attempt.attempt_number, quest_paper.id, + course_id=course_id, module_id=module_id + ) + if attempt_num is None and not quest_paper.quiz.is_exercise: context = { 'user': user, |