def get_skill_dict(self, student):
     """
     Return skill dictionary for given student
     """
     skill_dict = {}
     for student_factor in FlowFactors.student_factors():
         skill_dict[student_factor] = self.get(student_factor, student=student)
     return skill_dict
 def get_difficulty_dict(self, task):
     """
     Return difficulty dictionary for given task
     """
     difficulty_dict = {}
     for task_factor in FlowFactors.task_factors():
         difficulty_dict[task_factor] = self.get(task_factor, task=task)
     return difficulty_dict
Esempio n. 3
0
 def get_difficulty_dict(self, task):
     """
     Return difficulty dictionary for given task
     """
     difficulty_dict = {}
     for task_factor in FlowFactors.task_factors():
         difficulty_dict[task_factor] = self.get(task_factor, task=task)
     return difficulty_dict
Esempio n. 4
0
 def get_skill_dict(self, student):
     """
     Return skill dictionary for given student
     """
     skill_dict = {}
     for student_factor in FlowFactors.student_factors():
         skill_dict[student_factor] = self.get(student_factor,
                                               student=student)
     return skill_dict
Esempio n. 5
0
def update_student_skills(
        student_id, task_id, reported_flow, predicted_flow, last_solved_delta, practice_context):
    """ Updates all student's skills according to task he just solved.

    Args:
        student_id: id of student
        task_id: id of task the student finnished
        reported_flow: real flow collected from the student
        predicted_flow: flow predicted by our model for student and task
        practice_context: object with skill a difficulty vectors
    """
    difficulty_dict = practice_context.get_difficulty_dict(task_id)

    for key in FlowFactors.game_factors() + FlowFactors.concept_factors():
        practice_context.update(
            key,
            student=student_id,
            task=None,
            update=lambda original: update_other_skill_function(
                original,
                reported_flow,
                difficulty_dict[key]
            )
        )

    practice_context.update(
        FlowFactors.STUDENT_BIAS,
        student=student_id,
        task=None,
        update=lambda original: update_global_skill_function(
            original,
            predicted_flow,
            reported_flow,
            last_solved_delta
        )
    )
    def run_simulation(self):
        """
        Run the simulation and create simulation log as a list of dictionaries,
        each dictonary for one task instance taken.
        """
        # TODO: decomposition
        # create some task instances to avoid time bonuses for poor performances
        any_student = StudentModel.objects.create(user=User.objects.create(username='******'))
        for task in TaskModel.objects.all():
            TaskInstanceModel.objects.create(task=task, student=any_student,
                                             solved=True, time_spent=300)
        user = User.objects.create()
        instances_count, time_spent = 0, 0
        while instances_count < self.max_instances and time_spent < self.max_time:
            self.logger.new_round()
            self.logger.log('instance', instances_count + 1)

            task_info = practice_service.get_next_task_in_session(user)
            task_id = task_info.task.pk
            task_difficulty = TasksDifficultyModel.objects.get(task_id=task_id)

            student = StudentModel.objects.get(user=user)
            self.logger.log('level', student.level.block_level)
            self.logger.log('total-credits', student.total_credits)
            self.logger.log('free-credits', student.free_credits)
            student_skill = student.get_skill_dict()
            for factor in FlowFactors.student_factors():
                self.logger.log('student-' + factor.name, student_skill[factor])

            self.logger.log('task-id', task_id)
            self.logger.log('task-title', task_info.task.title)
            self.logger.log('task-level', task_info.task.level)
            task_difficulty = task_difficulty.get_difficulty_dict()
            for factor in FlowFactors.task_factors():
                self.logger.log('task-' + factor.name, task_difficulty[factor])
            self.logger.log('instructions', ' '.join(task_info.instructions))


            #self.logger.log('flow-prediction', TaskInstanceModel.objects
            #    .get(id=task_info.task_instance.['task-instance-id']).predicted_flow)
            self.logger.log('flow-prediction', task_info.task_instance.predicted_flow)

            solved, time = self.behavior.solve_task(task_difficulty)
            self.logger.log('solved', solved)
            self.logger.log('time-spent', time)
            result = practice_service.process_attempt_report(user, report={
                'task-instance-id': task_info.task_instance.pk,
                'attempt': 1,
                'solved': solved,
                'time': time,
            })
            instance_pk = task_info.task_instance.pk
            if solved:
                flow = self.behavior.report_flow()
                practice_service.process_flow_report(
                        user=user,
                        task_instance_id=instance_pk,
                        reported_flow=flow)
            else:
                practice_service.process_giveup_report(
                        user=user,
                        task_instance_id=instance_pk,
                        time_spent=time)
            self.logger.log('flow-report',
                    TaskInstanceModel.objects.get(pk=instance_pk).reported_flow)

            self.logger.log('result-earned-credits', result.credits)
            self.logger.log('result-speed-bonus', result.speed_bonus)
            self.logger.log('result-new-blocks', len(result.purchases))
            self.logger.log('updated-task-difficulty',
                    TasksDifficultyModel.objects.get(task_id=task_id) \
                    .get_difficulty_dict()[FlowFactors.TASK_BIAS])

            instances_count += 1
            time_spent += time
Esempio n. 7
0
    def run_simulation(self):
        """
        Run the simulation and create simulation log as a list of dictionaries,
        each dictonary for one task instance taken.
        """
        # TODO: decomposition
        # create some task instances to avoid time bonuses for poor performances
        any_student = StudentModel.objects.create(user=User.objects.create(
            username='******'))
        for task in TaskModel.objects.all():
            TaskInstanceModel.objects.create(task=task,
                                             student=any_student,
                                             solved=True,
                                             time_spent=300)
        user = User.objects.create()
        instances_count, time_spent = 0, 0
        while instances_count < self.max_instances and time_spent < self.max_time:
            self.logger.new_round()
            self.logger.log('instance', instances_count + 1)

            task_info = practice_service.get_next_task_in_session(user)
            task_id = task_info.task.pk
            task_difficulty = TasksDifficultyModel.objects.get(task_id=task_id)

            student = StudentModel.objects.get(user=user)
            self.logger.log('level', student.level.block_level)
            self.logger.log('total-credits', student.total_credits)
            self.logger.log('free-credits', student.free_credits)
            student_skill = student.get_skill_dict()
            for factor in FlowFactors.student_factors():
                self.logger.log('student-' + factor.name,
                                student_skill[factor])

            self.logger.log('task-id', task_id)
            self.logger.log('task-title', task_info.task.title)
            self.logger.log('task-level', task_info.task.level)
            task_difficulty = task_difficulty.get_difficulty_dict()
            for factor in FlowFactors.task_factors():
                self.logger.log('task-' + factor.name, task_difficulty[factor])
            self.logger.log('instructions', ' '.join(task_info.instructions))

            #self.logger.log('flow-prediction', TaskInstanceModel.objects
            #    .get(id=task_info.task_instance.['task-instance-id']).predicted_flow)
            self.logger.log('flow-prediction',
                            task_info.task_instance.predicted_flow)

            solved, time = self.behavior.solve_task(task_difficulty)
            self.logger.log('solved', solved)
            self.logger.log('time-spent', time)
            result = practice_service.process_attempt_report(
                user,
                report={
                    'task-instance-id': task_info.task_instance.pk,
                    'attempt': 1,
                    'solved': solved,
                    'time': time,
                })
            instance_pk = task_info.task_instance.pk
            if solved:
                flow = self.behavior.report_flow()
                practice_service.process_flow_report(
                    user=user,
                    task_instance_id=instance_pk,
                    reported_flow=flow)
            else:
                practice_service.process_giveup_report(
                    user=user, task_instance_id=instance_pk, time_spent=time)
            self.logger.log(
                'flow-report',
                TaskInstanceModel.objects.get(pk=instance_pk).reported_flow)

            self.logger.log('result-earned-credits', result.credits)
            self.logger.log('result-speed-bonus', result.speed_bonus)
            self.logger.log('result-new-blocks', len(result.purchases))
            self.logger.log('updated-task-difficulty',
                    TasksDifficultyModel.objects.get(task_id=task_id) \
                    .get_difficulty_dict()[FlowFactors.TASK_BIAS])

            instances_count += 1
            time_spent += time