def predict_flow(student_id, task_id, practice_context): """ Predict flow from information about student, task and practice context. Return real number with the following interpretation: ~ -1: too difficult task (leading to frustration) ~ 0: optimaly difficul task (leading to flow) ~ +1: too easy task (leading to boredome) """ student_flow_factors = practice_context.get_skill_dict(student_id) task_flow_factors = practice_context.get_difficulty_dict(task_id) student_flow_factors[FlowFactors.TASK_BIAS] = -1 task_flow_factors[FlowFactors.STUDENT_BIAS] = 1 potential = dict_product(student_flow_factors, task_flow_factors) flow = activation(potential) return flow
def test_predict_flow2(self): context = PracticeContext([(FlowFactors.STUDENT_BIAS, 11, None, 5.2), (FlowFactors.CONDITIONS, 11, None, 0), (FlowFactors.LOOPS, 11, None, 1.2), (FlowFactors.LOGIC_EXPR, 11, None, 0), (FlowFactors.COLORS, 11, None, 0), (FlowFactors.TOKENS, 11, None, 0), (FlowFactors.PITS, 11, None, -0.1), (FlowFactors.TASK_BIAS, None, 12, 3.7), (FlowFactors.CONDITIONS, None, 12, 0), (FlowFactors.LOOPS, None, 12, 0.5), (FlowFactors.LOGIC_EXPR, None, 12, 0), (FlowFactors.COLORS, None, 12, 0), (FlowFactors.TOKENS, None, 12, 0), (FlowFactors.PITS, None, 12, 2.0)]) result = predict_flow(student_id=11, task_id=12, practice_context=context) self.assertAlmostEquals(activation(1.9), result)
def test_predict_flow2(self): context = PracticeContext([ (FlowFactors.STUDENT_BIAS, 11, None, 5.2), (FlowFactors.CONDITIONS, 11, None, 0), (FlowFactors.LOOPS, 11, None, 1.2), (FlowFactors.LOGIC_EXPR, 11, None, 0), (FlowFactors.COLORS, 11, None, 0), (FlowFactors.TOKENS, 11, None, 0), (FlowFactors.PITS, 11, None, -0.1), (FlowFactors.TASK_BIAS, None, 12, 3.7), (FlowFactors.CONDITIONS, None, 12, 0), (FlowFactors.LOOPS, None, 12, 0.5), (FlowFactors.LOGIC_EXPR, None, 12, 0), (FlowFactors.COLORS, None, 12, 0), (FlowFactors.TOKENS, None, 12, 0), (FlowFactors.PITS, None, 12, 2.0) ]) result = predict_flow(student_id=11, task_id=12, practice_context=context) self.assertAlmostEquals(activation(1.9), result)