def test_get_quiz_feedback_with_only_subjects_and_no_linked_resource(self): # fill database course = Course(pk=159, name="Test_course1", courseId=1, version_time=datetime.datetime(2020, 1, 28)) course.save() Quiz.objects.create(course_id=159, name="Test_quiz1", external_id=18, subjects_id=1, version_time=datetime.datetime(2020, 1, 28)) resource = Resource( course_id=159, name="Book 1", target="http://localhost:4000/mod/book/view.php?id=12", type="book", external=False, external_id=12, version_time=datetime.datetime(2020, 1, 28)) resource.save() subject = Subject(course=course, name="Test_subject1") subject.save() self.assertEqual(feedback_manager.get_quiz_feedback_link(18), "the course resource")
def test_get_quiz_feedback_with_only_resource(self): # fill database Course.objects.create(pk=159, name="Test_course1", courseId=1, version_time=datetime.datetime(2020, 1, 28)) resource = Resource( course_id=159, name="Book 1", target="http://localhost:4000/mod/book/view.php?id=12", type="book", external=False, external_id=12, version_time=datetime.datetime(2020, 1, 28)) resource.save() quiz = Quiz(course_id=159, name="Test_quiz1", external_id=18, resources=resource, version_time=datetime.datetime(2020, 1, 28)) quiz.save() message = '<a href="http://localhost:4000/mod/book/view.php?id=12">Book 1</a>' self.assertEqual(feedback_manager.get_quiz_feedback_link(18), message)
def test_get_quiz_feedback_with_only_subjects_and_linked_resource(self): # fill database course = Course(pk=159, name="Test_course1", courseId=1, version_time=datetime.datetime(2020, 1, 28)) course.save() quiz = Quiz.objects.create(course_id=159, name="Test_quiz1", external_id=18, subjects_id=1, version_time=datetime.datetime(2020, 1, 28)) quiz.save() resource = Resource( course_id=159, name="Book 1", target="http://localhost:4000/mod/book/view.php?id=12", type="book", external=False, external_id=12, version_time=datetime.datetime(2020, 1, 28)) resource.save() subject = Subject(course=course, name="Test_subject1") subject.save() # add the link between subjects and resources subject.resources.add(resource) message = '\r\n- <a href="http://localhost:4000/mod/book/view.php?id=12">Book 1</a>' self.assertEqual(feedback_manager.get_quiz_feedback_link(18), message)
def test_get_quiz_feedback_with_no_resource_and_no_subjects(self): Course.objects.create(pk=159, name="Test_course1", courseId=1, version_time=datetime.datetime(2020, 1, 28)) Quiz.objects.create(course_id=159, name="Test_quiz1", external_id=18, version_time=datetime.datetime(2020, 1, 28)) self.assertEqual(feedback_manager.get_quiz_feedback_link(18), "the course resource")