summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py30
-rw-r--r--yaksh/static/yaksh/css/custom.css10
-rw-r--r--yaksh/templates/yaksh/grade_user.html54
-rw-r--r--yaksh/test_views.py588
4 files changed, 663 insertions, 19 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 9bcb132..b64ac77 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -773,14 +773,20 @@ class LearningModule(models.Model):
def get_passing_status(self, user, course):
course_status = CourseStatus.objects.filter(user=user, course=course)
+ ordered_units = []
if course_status.exists():
- learning_units_with_quiz = self.learning_unit.filter(type='quiz')
+ learning_units_with_quiz = self.learning_unit.filter(
+ type='quiz'
+ ).order_by("order")
ordered_units = learning_units_with_quiz.order_by("order")
- statuses = [
- unit.quiz.get_answerpaper_passing_status(user, course)
- for unit in ordered_units
- ]
+ if ordered_units:
+ statuses = [
+ unit.quiz.get_answerpaper_passing_status(user, course)
+ for unit in ordered_units
+ ]
+ else:
+ statuses = []
if not statuses:
status = False
@@ -1452,6 +1458,19 @@ class Question(models.Model):
tc_list.extend(test_case)
return tc_list
+ def get_test_cases_as_dict(self, **kwargs):
+ tc_list = []
+ for tc in self.testcase_set.values_list("type", flat=True).distinct():
+ test_case_ctype = ContentType.objects.get(app_label="yaksh",
+ model=tc)
+ test_case = test_case_ctype.get_all_objects_for_this_type(
+ question=self,
+ **kwargs
+ )
+ for tc in test_case:
+ tc_list.append(model_to_dict(tc))
+ return tc_list
+
def get_test_case(self, **kwargs):
for tc in self.testcase_set.all():
test_case_type = tc.type
@@ -1743,6 +1762,7 @@ class QuestionPaper(models.Model):
for question_set in self.random_questions.all():
marks += question_set.marks * question_set.num_questions
self.total_marks = marks
+ self.save()
def _get_questions_for_answerpaper(self):
""" Returns fixed and random questions for the answer paper"""
diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css
index 3979e3e..697361d 100644
--- a/yaksh/static/yaksh/css/custom.css
+++ b/yaksh/static/yaksh/css/custom.css
@@ -98,6 +98,13 @@ body, .dropdown-menu {
transition: all 0.3s;
}
+@media (min-width: 1024px) {
+
+ .students-list {
+ position: fixed !important;
+ }
+}
+
/* ---------------------------------------------------
FORUM STYLE
----------------------------------------------------- */
@@ -117,4 +124,5 @@ body, .dropdown-menu {
.description {
font-size: 16px;
-} \ No newline at end of file
+}
+>>>>>>> 53a0c4ad3e733f3960000527f83565f2fd8fc412
diff --git a/yaksh/templates/yaksh/grade_user.html b/yaksh/templates/yaksh/grade_user.html
index 7206525..f4c7d67 100644
--- a/yaksh/templates/yaksh/grade_user.html
+++ b/yaksh/templates/yaksh/grade_user.html
@@ -15,7 +15,24 @@ $(document).ready(function()
{
$("#marks_table").tablesorter({sortList: [[2,1]]});
});
+function searchNames() {
+ var input, filter, ul, li, a, i, txtValue;
+ input = document.getElementById('myInput');
+ filter = input.value.toUpperCase();
+ $("#myUL").toggle();
+ ul = document.getElementById("myUL");
+ li = ul.getElementsByTagName('li');
+ for (i = 0; i < li.length; i++) {
+ a = li[i].getElementsByTagName("a")[0];
+ txtValue = a.textContent || a.innerText;
+ if (txtValue.toUpperCase().indexOf(filter) > -1) {
+ li[i].style.display = "";
+ } else {
+ li[i].style.display = "none";
+ }
+ }
+}
</script>
{% endblock script %}
@@ -87,16 +104,17 @@ $(document).ready(function()
<div class="row">
{% if status == "grade" %}
{% if users %}
- <div id="student" class="col-md-3">
- <ul class="nav nav-pills list-group">
- {% for user in users %}
- <li class="nav-item">
- <a href="{% url 'yaksh:grade_user' quiz_id user.user__id course_id %}" class="list-group-item{% if user.user__id == data.user.id %} active {% endif %}">
- {{user.user__first_name}} {{user.user__last_name}}
- </a>
- </li>
- {% endfor %}
- </ul>
+ <div id="student" class="col-lg-3">
+ <div class="students-list">
+ <select onchange="window.location.href=this.value" class="custom-select">
+ <option value="">Select student</option>
+ {% for user in users %}
+ <option value="{% url 'yaksh:grade_user' quiz_id user.user__id course_id %}" {% if user.user__id == data.user.id %} selected {% endif %} title="{{user.user__first_name|upper}} {{user.user__last_name|upper}}">
+ {{user.user__first_name|upper}} {{user.user__last_name|truncatechars:5|upper}}
+ </option>
+ {% endfor %}
+ </select>
+ </div>
</div>
{% else %}
<div class="col-md-1"></div>
@@ -110,7 +128,7 @@ $(document).ready(function()
{% endif %}
{% endif %}
- <div id="paper" class="col-md-9">
+ <div id="paper" class="col-lg-9">
{% if has_quiz_assignments %}
<a href="{% url 'yaksh:download_quiz_assignment' quiz_id course_id %}" class="btn btn-outline-info">
<i class="fa fa-download"></i>&nbsp;Download All Assignments
@@ -128,8 +146,22 @@ $(document).ready(function()
</div>
{% endfor %}
{% endif %}
+ {% if status == "grade" and users %}
+ <input type="text" id="myInput" onkeyup="searchNames()" placeholder="Type to search for names" class="form-control">
+ <ul class="nav nav-pills list-group" style="display: none;" id="myUL">
+ {% for user in users %}
+ <li class="nav-item">
+ <a href="{% url 'yaksh:grade_user' quiz_id user.user__id course_id %}" class="list-group-item">
+ {{user.user__first_name|upper}} {{user.user__last_name|upper}}
+ </a>
+ </li>
+ {% endfor %}
+ <br>
+ </ul>
+ {% endif %}
{% if data %}
+ <hr>
<div class="card">
<div class="card-header">
Student Details
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 94b81ad..5d2e5b5 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -6402,7 +6402,7 @@ class TestPost(TestCase):
self.assertContains(response, 'csrfmiddlewaretoken')
def test_view_course_forum_denies_anonymous_user(self):
- url = reverse('yaksh:course_forum', kwargs= {
+ url = reverse('yaksh:course_forum', kwargs={
'course_id': self.course.id
})
response = self.client.get(url, follow=True)
@@ -6464,7 +6464,6 @@ class TestPost(TestCase):
})
self.assertContains(response, 'href="{0}'.format(post_comments_url))
-
def test_new_post_valid_post_data(self):
self.client.login(
username=self.student.username,
@@ -6812,3 +6811,588 @@ class TestPostComment(TestCase):
self.user.delete()
self.course.delete()
self.mod_group.delete()
+
+
+class TestStartExam(TestCase):
+ def setUp(self):
+ self.client = Client()
+ self.mod_group = Group.objects.create(name='moderator')
+ tzone = pytz.timezone('UTC')
+
+ # Create Moderator with profile
+ self.user1_plaintext_pass = 'demo'
+ self.user1 = User.objects.create_user(
+ username='demo_user',
+ password=self.user1_plaintext_pass,
+ first_name='first_name',
+ last_name='last_name',
+ email='demo@test.com',
+ )
+ Profile.objects.create(
+ user=self.user1,
+ roll_number=10,
+ institute='IIT',
+ department='Chemical',
+ position='Moderator',
+ timezone='UTC',
+ is_moderator=True
+ )
+
+ # Add to moderator group
+ self.mod_group.user_set.add(self.user1)
+
+ # Create Student
+ self.student_plaintext_pass = 'demo_student'
+ self.student = User.objects.create_user(
+ username='demo_student',
+ password=self.student_plaintext_pass,
+ first_name='student_first_name',
+ last_name='student_last_name',
+ email='demo_student@test.com'
+ )
+ Profile.objects.create(
+ user=self.student,
+ roll_number=10,
+ institute='IIT',
+ department='Chemical',
+ position='Moderator',
+ timezone='UTC'
+ )
+
+ # Create courses for user1
+ self.user1_course1 = Course.objects.create(
+ name="Demo Course",
+ enrollment="Enroll Request", creator=self.user1
+ )
+ # course1 status
+ self.course1_status = CourseStatus.objects.create(
+ course=self.user1_course1, user=self.user1
+ )
+
+ # Create learning modules for user1
+ self.learning_module1 = LearningModule.objects.create(
+ order=1, name="Demo Module", description="Demo Module",
+ check_prerequisite=False, creator=self.user1
+ )
+ self.learning_module2 = LearningModule.objects.create(
+ order=2, name="Demo Module 2", description="Demo Module 2",
+ check_prerequisite=False, creator=self.user1
+ )
+
+ self.quiz1 = Quiz.objects.create(
+ time_between_attempts=0, description='Demo Quiz',
+ creator=self.user1
+ )
+
+ self.quiz2 = Quiz.objects.create(
+ time_between_attempts=0, description='Demo Quiz 2',
+ creator=self.user1
+ )
+
+ self.question_paper1 = QuestionPaper.objects.create(
+ quiz=self.quiz1, total_marks=1.0
+ )
+
+ self.question_paper2 = QuestionPaper.objects.create(
+ quiz=self.quiz2, total_marks=1.0
+ )
+
+ self.question1 = Question.objects.create(
+ summary="Test_question 1", description="Add two numbers",
+ points=1.0, language="python", type="code", user=self.user1
+ )
+
+ user_answer = "def add(a, b)\n\treturn a+b"
+ self.new_answer = Answer.objects.create(
+ question=self.question1, answer=user_answer,
+ correct=True, error=json.dumps([])
+ )
+
+ self.answerpaper = AnswerPaper.objects.create(
+ user=self.student, question_paper=self.question_paper1,
+ attempt_number=1,
+ start_time=datetime(2014, 10, 9, 10, 8, 15, 0, tzone),
+ end_time=datetime(2020, 10, 9, 10, 15, 15, 0, tzone),
+ user_ip="127.0.0.1", status="inprogress", passed=True,
+ percent=1, marks_obtained=1, course=self.user1_course1
+ )
+
+ self.answerpaper.answers.add(self.new_answer)
+ self.answerpaper.questions_answered.add(self.question1)
+
+ # Create lessons for user1
+ self.lesson1 = Lesson.objects.create(
+ name="Demo Lesson", description="Demo Lession",
+ creator=self.user1
+ )
+
+ self.lesson2 = Lesson.objects.create(
+ name="Test Lesson", description="Test Lession",
+ creator=self.user1
+ )
+
+ # Create units for lesson and quiz
+ self.lesson_unit1 = LearningUnit.objects.create(
+ order=1, type="lesson", lesson=self.lesson1
+ )
+ self.quiz_unit1 = LearningUnit.objects.create(
+ order=2, type="quiz", quiz=self.quiz1
+ )
+ self.lesson_unit2 = LearningUnit.objects.create(
+ order=1, type="lesson", lesson=self.lesson2
+ )
+ self.quiz_unit2 = LearningUnit.objects.create(
+ order=2, type="quiz", quiz=self.quiz2
+ )
+
+ # Add units to module
+ self.learning_module1.learning_unit.add(self.lesson_unit1)
+ self.learning_module1.learning_unit.add(self.quiz_unit1)
+
+ self.learning_module2.learning_unit.add(self.lesson_unit2)
+ self.learning_module2.learning_unit.add(self.quiz_unit2)
+
+ # Add module to course
+ self.user1_course1.learning_module.add(self.learning_module1)
+ self.user1_course1.learning_module.add(self.learning_module2)
+
+ def test_start_question_paper_does_not_exists_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': 99,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 404)
+
+ def test_start_question_paper_does_not_exists_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': 99,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_question_paper_has_no_question_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 404)
+
+ def test_start_question_paper_has_no_question_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_has_no_active_learning_module_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = False
+ self.learning_module1.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 404)
+
+ def test_start_learning_module_has_prerequisite_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = True
+ self.learning_module2.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_learning_module_prerequisite_passes_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = False
+ self.learning_module2.check_prerequisite_passes = True
+ self.learning_module2.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_user_enrolled_in_the_course_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_user_enrolled_in_the_course_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_course_is_active_and_not_expired_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.students.add(self.student)
+ self.user1_course1.active = False
+ self.user1_course1.end_enroll_time = timezone.now()
+ self.user1_course1.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_course_is_active_and_not_expired_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.students.add(self.user1)
+ self.user1_course1.active = False
+ self.user1_course1.end_enroll_time = timezone.now()
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_quiz_is_active_and_is_not_expired_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.students.add(self.student)
+ self.user1_course1.save()
+
+ self.question_paper1.quiz.end_date_time = timezone.now()
+ self.question_paper1.quiz.active = False
+ self.question_paper1.quiz.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_quiz_is_active_and_is_not_expired_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.students.add(self.user1)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ self.question_paper1.quiz.end_date_time = timezone.now()
+ self.question_paper1.quiz.active = False
+ self.question_paper1.quiz.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_prereq_check_and_pass_criteria_for_quiz_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = False
+ self.learning_module2.check_prerequisite_passes = False
+ self.learning_module2.save()
+
+ self.user1_course1.students.add(self.student)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_prereq_check_and_pass_criteria_for_quiz_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = False
+ self.learning_module2.check_prerequisite_passes = False
+ self.learning_module2.save()
+
+ self.user1_course1.students.add(self.user1)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_not_allowed_to_start_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.students.add(self.student)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ learning_unit = self.learning_module1.learning_unit.get(
+ quiz=self.question_paper1.quiz.id
+ )
+ learning_unit.check_prerequisite = False
+ learning_unit.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper1.id,
+ 'module_id': self.learning_module1.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_not_allowed_to_start_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ self.question_paper1.fixed_questions.add(self.question1)
+
+ self.learning_module1.active = True
+ self.learning_module1.check_prerequisite = False
+ self.learning_module1.check_prerequisite_passes = False
+ self.learning_module1.save()
+
+ self.user1_course1.students.add(self.user1)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ learning_unit = self.learning_module1.learning_unit.get(
+ quiz=self.question_paper1.quiz.id
+ )
+ learning_unit.check_prerequisite = False
+ learning_unit.save()
+
+ def test_start_allowed_to_start_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = False
+ self.learning_module2.check_prerequisite_passes = False
+ self.learning_module2.save()
+
+ self.user1_course1.students.add(self.student)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ learning_unit = self.learning_module2.learning_unit.get(
+ quiz=self.question_paper2.quiz.id
+ )
+ learning_unit.check_prerequisite = False
+ learning_unit.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_allowed_to_start_for_moderator(self):
+ self.client.login(
+ username=self.user1.username,
+ password=self.user1_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = False
+ self.learning_module2.check_prerequisite_passes = False
+ self.learning_module2.save()
+
+ self.user1_course1.students.add(self.user1)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ learning_unit = self.learning_module2.learning_unit.get(
+ quiz=self.question_paper2.quiz.id
+ )
+ learning_unit.check_prerequisite = False
+ learning_unit.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def test_start_allowed_to_start_when_quiz_is_exercise_for_user(self):
+ self.client.login(
+ username=self.student.username,
+ password=self.student_plaintext_pass
+ )
+ self.question_paper2.fixed_questions.add(self.question1)
+
+ self.learning_module2.active = True
+ self.learning_module2.check_prerequisite = False
+ self.learning_module2.check_prerequisite_passes = False
+ self.learning_module2.save()
+
+ self.user1_course1.students.add(self.student)
+ self.user1_course1.is_trial = True
+ self.user1_course1.save()
+
+ learning_unit = self.learning_module2.learning_unit.get(
+ quiz=self.question_paper2.quiz.id
+ )
+ learning_unit.check_prerequisite = False
+ learning_unit.save()
+
+ self.question_paper2.quiz.is_exercise = True
+ self.question_paper2.quiz.save()
+
+ url = reverse('yaksh:start_quiz', kwargs={
+ 'questionpaper_id': self.question_paper2.id,
+ 'module_id': self.learning_module2.id,
+ 'course_id': self.user1_course1.id
+ })
+ response = self.client.get(url)
+ self.assertEqual(response.status_code, 200)
+
+ def tearDown(self):
+ self.client.logout()
+ self.user1.delete()
+ self.student.delete()
+ self.quiz1.delete()
+ self.user1_course1.delete()