diff options
-rw-r--r-- | yaksh/models.py | 20 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_quiz.html | 10 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 4 | ||||
-rw-r--r-- | yaksh/templates/yaksh/statistics_question.html | 24 | ||||
-rw-r--r-- | yaksh/test_models.py | 10 | ||||
-rw-r--r-- | yaksh/views.py | 2 |
6 files changed, 38 insertions, 32 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index d3d90c9..1094bb0 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -1695,17 +1695,15 @@ class QuestionPaperManager(models.Manager): def create_trial_paper_to_test_quiz(self, trial_quiz, original_quiz_id): """Creates a trial question paper to test quiz.""" - if self.filter(quiz=trial_quiz).exists(): - trial_questionpaper = self.get(quiz=trial_quiz) - else: - trial_questionpaper, trial_questions = \ - self._create_trial_from_questionpaper(original_quiz_id) - trial_questionpaper.quiz = trial_quiz - trial_questionpaper.fixed_questions\ - .add(*trial_questions["fixed_questions"]) - trial_questionpaper.random_questions\ - .add(*trial_questions["random_questions"]) - trial_questionpaper.save() + trial_quiz.questionpaper_set.all().delete() + trial_questionpaper, trial_questions = \ + self._create_trial_from_questionpaper(original_quiz_id) + trial_questionpaper.quiz = trial_quiz + trial_questionpaper.fixed_questions\ + .add(*trial_questions["fixed_questions"]) + trial_questionpaper.random_questions\ + .add(*trial_questions["random_questions"]) + trial_questionpaper.save() return trial_questionpaper diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html index 01b6f8c..9b80e0d 100644 --- a/yaksh/templates/yaksh/add_quiz.html +++ b/yaksh/templates/yaksh/add_quiz.html @@ -65,11 +65,11 @@ <br> <h4>You can check the quiz by attempting it in the following modes:</h4> <a class="btn btn-outline-info" name="button" href="{% url 'yaksh:test_quiz' 'usermode' quiz.id course_id %}" target="blank"> - User Mode + Try as student </a> - <a class="btn btn-outline-info" name="button" href="{% url 'yaksh:test_quiz' 'godmode' quiz.id course_id %}" target="blank"> - God Mode + <a class="btn btn-outline-primary" name="button" href="{% url 'yaksh:test_quiz' 'godmode' quiz.id course_id %}" target="blank"> + Try as teacher </a> <a data-toggle="modal" data-target="#help"> <span class="text-info"><i class="fa fa-info-circle"></i> Help</span></a> @@ -88,13 +88,13 @@ </div> <div class="modal-body"> <p> - <b>User Mode:</b> Attempt quiz the way normal users will attempt i.e. - + <b>Try as student:</b> Attempt quiz the way students will attempt i.e. - <ul class="list-group list-group-flush"> <li class="list-group-item">Quiz will have the same duration as that of the original quiz.</li> <li class="list-group-item">Quiz won't start if the course is inactive or the quiz time has expired.</li> <li class="list-group-item">You will be notified about quiz prerequisites.(You can still attempt the quiz though)</li> </ul> - <b>God Mode:</b> Attempt quiz without any time or eligibilty constraints. + <b>Try as teacher:</b> Attempt quiz without any time or eligibilty constraints. </p> </div> </div> diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index ae2f9f4..6489b38 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -127,14 +127,14 @@ question_type = "{{ question.type }}"; <button type="button" class="close" data-dismiss="alert"> <i class="fa fa-close"></i> </button> - <strong>Note:</strong> {{ notification }} + {{ notification }} </div> {% else %} <div id="notification" class="alert alert-info col-md-8" role="alert"> <button type="button" class="close" data-dismiss="alert"> <i class="fa fa-close"></i> </button> - <strong>Note:</strong> {{ notification }} + {{ notification }} </div> {% endif %} {% else %} diff --git a/yaksh/templates/yaksh/statistics_question.html b/yaksh/templates/yaksh/statistics_question.html index 9a54501..52c29d3 100644 --- a/yaksh/templates/yaksh/statistics_question.html +++ b/yaksh/templates/yaksh/statistics_question.html @@ -1,9 +1,10 @@ {% extends "manage.html" %} +{% block title %} Question Statistics {% endblock %} {% block pagetitle %} Statistics for {{ quiz.description }}{% endblock pagetitle %} {% block content %} -<div class="container"> +<div class="container-fluid"> <div class="row"> <div class="col-md-2"> <ul class="list-group"> @@ -18,16 +19,14 @@ <div class="col-md-9"> {% if question_stats %} <p><b>Total number of participants: {{ total }}</b></p> - <table class="table table-bordered table-responsive-sm"> - <tr class="bg-light yakshred"><th>Question</th><th>Type</th><th>Total</th><th>Answered Correctly</th></tr> + <table class="table table-responsive-sm"> + <tr class="bg-light yakshred"><th>Question</th><th></th><th>Type</th><th>Total</th><th>Answered Correctly</th></tr> {% for question, value in question_stats.items %} <tr> - <td>{{ question.summary }} - <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapse_question_{{question.id}}" aria-expanded="false" aria-controls="collapseExample"> - More - </button> + <td width="45%">{{ question.summary }} <div class="collapse" id="collapse_question_{{question.id}}"> - <div class="card card-body" style="width: 18rem;"> + <br> + <div class="card card-body"> <strong> Summary: </strong> @@ -38,7 +37,7 @@ Description: </strong> <p> - {{ question.description }} + {{ question.description|safe }} </p> <strong> Points: @@ -50,7 +49,7 @@ Type: </strong> <p> - {{ question.type }} + {{ question.get_type_display }} </p> {% if question.type in 'mcq mcc' %} <strong> @@ -72,6 +71,11 @@ </div> </div> </td> + <td> + <button class="btn btn-outline-primary" type="button" data-toggle="collapse" data-target="#collapse_question_{{question.id}}" aria-expanded="false" aria-controls="collapseExample"> + <i class="fa fa-angle-down"></i> More + </button> + </td> <td>{{ question.type }}</td> <td>{{value.1}}</td><td>{{ value.0 }} ({% widthratio value.0 value.1 100 %}%)</td> diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 37baf6e..a77c8bf 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -27,7 +27,7 @@ from yaksh import settings def setUpModule(): - Group.objects.create(name='moderator') + Group.objects.get_or_create(name='moderator') # create user profile user = User.objects.create_user(username='creator', @@ -842,7 +842,11 @@ class QuestionPaperTestCases(unittest.TestCase): total_marks=0.0, shuffle_questions=True ) - + self.question_paper_with_time_between_attempts.fixed_question_order = \ + "{0}, {1}".format(self.questions[3].id, self.questions[5].id) + self.question_paper_with_time_between_attempts.fixed_questions.add( + self.questions[3], self.questions[5] + ) self.question_paper.fixed_question_order = "{0}, {1}".format( self.questions[3].id, self.questions[5].id ) @@ -1030,7 +1034,7 @@ class QuestionPaperTestCases(unittest.TestCase): qu_list = [str(self.questions_list[0]), str(self.questions_list[1])] trial_paper = \ QuestionPaper.objects.create_trial_paper_to_test_quiz( - self.trial_quiz, self.quiz.id + self.trial_quiz, self.quiz_with_time_between_attempts.id ) trial_paper.random_questions.add(self.question_set_1) trial_paper.random_questions.add(self.question_set_2) diff --git a/yaksh/views.py b/yaksh/views.py index 53981b5..afa673f 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -821,7 +821,7 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None, previous_question=current_question) else: user_answer = request.POST.get('answer') - if not user_answer: + if not str(user_answer): msg = "Please submit a valid answer." return show_question( request, current_question, paper, notification=msg, |