def setUp(self): self.user = User.objects.create_user(username='******', password='******') self.course = Course(title='test_title', addedBy=self.user) self.course.save() self.concept = Concept(title='test title', addedBy=self.user) self.concept.save() self.lesson = Lesson(title='ugh', text='brr', addedBy=self.user, kind=Lesson.ORCT_QUESTION) self.lesson.save_root() self.lesson.add_concept_link(self.concept, ConceptLink.TESTS, self.user) self.unit = Unit(title='test unit title', addedBy=self.user) self.unit.save() self.unit_lesson = UnitLesson(unit=self.unit, addedBy=self.user, treeID=42, lesson=self.lesson) self.unit_lesson.save() self.response = Response(course=self.course, lesson=self.lesson, author=self.user, unitLesson=self.unit_lesson, confidence=Response.GUESS, title='test title', text='test text') self.response.save() self.context = { 'actionTarget': '/ct/courses/1/units/1/', 'ul': self.unit_lesson, 'test_text': 'This is a test text', 'r': self.response }
def get_message(self, chat, next_lesson, is_additional, *args, **kwargs) -> Message: _response_data = { 'lesson': chat.state.unitLesson.lesson, 'unitLesson': chat.state.unitLesson, 'course': chat.enroll_code.courseUnit.course, 'author': chat.user, 'activity': chat.state.activity, 'is_test': chat.is_test, 'is_preview': chat.enroll_code.isPreview, 'is_trial': chat.is_trial, } resp = Response(**_response_data) resp.save() _data = { 'contenttype': 'response', 'content_id': resp.id, 'input_type': 'options', # This is needed to track the last response to handle status 'lesson_to_answer_id': chat.state.unitLesson.id, 'chat': chat, 'owner': chat.user, 'kind': 'response', 'userMessage': True, 'is_additional': is_additional } message = Message(**_data) message.save() return message
def setUp(self): self.username, self.password = '******', 'test' self.user = User.objects.create_user(self.username, '*****@*****.**', self.password) self.instructor = Instructor.objects.create(user=self.user, institution='institute', what_do_you_teach='something') self.username2, self.password2 = 'test1', 'test' self.user2 = User.objects.create_user(self.username2, '*****@*****.**', self.password2) self.instructor2 = Instructor.objects.create(user=self.user2, institution='institute', what_do_you_teach='something') self.unit = Unit(title='Test title', addedBy=self.user) self.unit.save() self.course = Course(title='Test title', description='test description', access='Public', enrollCode='111', lockout='222', addedBy=self.user) self.course.save() self.courseunit = CourseUnit( unit=self.unit, course=self.course, order=0, addedBy=self.user, releaseTime=timezone.now() ) self.courseunit.save() self.lesson = Lesson(title='title', text='text', addedBy=self.user) self.lesson.save() self.unitlesson = UnitLesson( unit=self.unit, order=0, lesson=self.lesson, addedBy=self.user, treeID=self.lesson.id ) self.unitlesson.save() self.resp1 = Response( unitLesson=self.unitlesson, kind=Response.ORCT_RESPONSE, lesson=self.lesson, course=self.course, text="Some text user may respond", author=self.user, status=NEED_HELP_STATUS, selfeval=Response.DIFFERENT ) self.resp1.save() self.resp2 = Response( unitLesson=self.unitlesson, kind=Response.ORCT_RESPONSE, lesson=self.lesson, course=self.course, text="Some text user may be responded 2", author=self.user, status=NEED_HELP_STATUS, selfeval=Response.DIFFERENT ) self.resp2.save() self.default_data = {} self.client.login(username=self.username, password=self.password) self.url = reverse('ctms:course_settings', kwargs={'pk': self.course.id})