def test_get_all_task_instances(self):
     instance1 = TaskInstanceModel.objects.create(task=self.task, student=self.student)
     instance2 = TaskInstanceModel.objects.create(task=self.task, student=self.student)
     instance3 = TaskInstanceModel.objects.create(task=self.task, student=self.student)
     session = service.create_session(instance3)
     service.next_task_in_session(self.student, instance1)
     task_instances = service.get_all_task_instances(session)
     self.assertEquals(len(task_instances), 2)
     self.assertEquals(task_instances[0].pk, instance3.pk)
     self.assertEquals(task_instances[1].pk, instance1.pk)
示例#2
0
 def setUp(self):
     self.user = User.objects.create()
     self.student = StudentModel.objects.create(user=self.user)
     self.task = TaskModel.objects.create(maze_settings="{}", workspace_settings='{}')
     self.instance1 = TaskInstanceModel.objects.create(task=self.task, student=self.student, solved=True)
     self.instance2 = TaskInstanceModel.objects.create(task=self.task, student=self.student, given_up=True)
     self.instance3 = TaskInstanceModel.objects.create(task=self.task, student=self.student)
     self.session = practice_session_service.create_session(self.instance1)
     self.toolbox = []
     practice_session_service.next_task_in_session(self.student, self.instance2)
     practice_session_service.next_task_in_session(self.student, self.instance3)
示例#3
0
 def test_get_all_task_instances(self):
     instance1 = TaskInstanceModel.objects.create(task=self.task,
                                                  student=self.student)
     instance2 = TaskInstanceModel.objects.create(task=self.task,
                                                  student=self.student)
     instance3 = TaskInstanceModel.objects.create(task=self.task,
                                                  student=self.student)
     session = service.create_session(instance3)
     service.next_task_in_session(self.student, instance1)
     task_instances = service.get_all_task_instances(session)
     self.assertEquals(len(task_instances), 2)
     self.assertEquals(task_instances[0].pk, instance3.pk)
     self.assertEquals(task_instances[1].pk, instance1.pk)
def get_next_task_in_session(user):
    student = StudentModel.objects.get_or_create(user=user)[0]
    if sess_service.has_unresolved_task(student):
        return get_active_task_in_session(student)
    # next task in the session or new session
    task_info = get_task(student, RandomizedScoreTaskSelector())
    sess_service.next_task_in_session(student, task_info.task_instance)
    # add info about session
    session = sess_service.get_session(student)
    task_info_with_sess = TaskInfo(
        task_instance=task_info.task_instance,
        task=task_info.task,
        student_toolbox=task_info.student_toolbox,
        new_instructions=task_info.new_instructions,
        all_instructions=task_info.all_instructions,
        session=session
    )
    return task_info_with_sess
示例#5
0
文件: tests.py 项目: m3rryqold/flocs
 def setUp(self):
     self.user = User.objects.create()
     self.student = StudentModel.objects.create(user=self.user)
     self.task = TaskModel.objects.create(maze_settings="{}",
                                          workspace_settings='{}')
     self.instance1 = TaskInstanceModel.objects.create(task=self.task,
                                                       student=self.student,
                                                       solved=True)
     self.instance2 = TaskInstanceModel.objects.create(task=self.task,
                                                       student=self.student,
                                                       given_up=True)
     self.instance3 = TaskInstanceModel.objects.create(task=self.task,
                                                       student=self.student)
     self.session = practice_session_service.create_session(self.instance1)
     self.toolbox = []
     practice_session_service.next_task_in_session(self.student,
                                                   self.instance2)
     practice_session_service.next_task_in_session(self.student,
                                                   self.instance3)
示例#6
0
 def test_next_task_in_session(self):
     self.assertEquals(1, self.session.task_counter)
     # create new task instance
     taskInstance = TaskInstanceModel.objects.create(task=self.task,
                                                     student=self.student)
     # start session
     service.next_task_in_session(self.student, taskInstance)
     # assert counter was increased
     session = PracticeSession.objects.filter(student=self.student,
                                              _active=True)[0]
     self.assertEquals(2, session.task_counter)
     self.assertEquals(taskInstance, session.last_task)
     # set last task
     self.session.task_counter = service.TASKS_IN_SESSION
     self.session.save()
     service.next_task_in_session(self.student, taskInstance)
     # assert new session was created
     new_session = PracticeSession.objects.filter(student=self.student,
                                                  _active=True)[0]
     self.assertNotEquals(self.session, new_session)
     self.assertEquals(1, new_session.task_counter)
 def test_next_task_in_session(self):
     self.assertEquals(1, self.session.task_counter)
     # create new task instance
     taskInstance = TaskInstanceModel.objects.create(
             task=self.task,
             student=self.student)
     # start session
     service.next_task_in_session(self.student, taskInstance)
     # assert counter was increased
     session = PracticeSession.objects.filter(student=self.student, _active=True)[0]
     self.assertEquals(2, session.task_counter)
     self.assertEquals(taskInstance, session.last_task)
     # set last task
     self.session.task_counter = service.TASKS_IN_SESSION
     self.session.save()
     service.next_task_in_session(self.student, taskInstance)
     # assert new session was created
     new_session = PracticeSession.objects.filter(
             student=self.student, _active=True)[0]
     self.assertNotEquals(self.session, new_session)
     self.assertEquals(1, new_session.task_counter)