コード例 #1
0
ファイル: tokens.py プロジェクト: soartech/fluent
    def learner_behavior_tokens(self, activity: LearningActivity,
                                mastery_estimate: str,
                                last_activity: Optional[LearningActivity]):
        point_sum = 0
        if educational_use_in_activity(activity,
                                       MagicStrings.EducationalUses.ASSESSES):
            if mastery_estimate == MagicStrings.MasteryEstimates.NOT_HELD:
                point_sum += self.LOW_REWARD
            elif mastery_estimate == MagicStrings.MasteryEstimates.FORGOT:
                point_sum += self.MED_RAND_REWARD
        else:
            if has_learner_seen_activity(self.learner, activity):
                point_sum += self.HIGH_RAND_REWARD
            else:
                if mastery_estimate == MagicStrings.MasteryEstimates.FORGOT:
                    point_sum += self.MEDIUM_REWARD

        # Last activity completed was hard
        if last_activity is not None:
            last_elo = get_aligned_elo(last_activity)
            if has_challenge_level(last_elo, activity,
                                   MagicStrings.ChallengeLevels.COMPLEX):
                point_sum += self.LOW_RAND_OPTIONAL_REWARD

        return point_sum
コード例 #2
0
    def filter_activities_by_chosen_elo(
            self, chosen_elo_id: str,
            activities: List[LearningActivity]) -> List[LearningActivity]:
        filtered_activities = list()
        for activity in activities:
            aligned_elo_id = utils.get_aligned_elo(activity)
            if aligned_elo_id is not None and aligned_elo_id == chosen_elo_id:
                filtered_activities.append(activity)\

        return filtered_activities
コード例 #3
0
 def _get_metacognitive_prompt_for_elo(
         self, elo_id: str) -> Optional[LearningActivity]:
     all_activities = self.query_cacher.get_activities()
     for activity in all_activities:
         activity_elo = utils.get_aligned_elo(activity)
         if utils.target_url_equals_competency(
                 activity_elo, elo_id
         ) and activity.learning_resource_type == MagicStrings.LearningResourceTypes.METACOGNITIVE_PROMPT:
             return activity
     return None
コード例 #4
0
ファイル: test_recommender.py プロジェクト: soartech/fluent
    def test_something_new_strategy_returns_activities_for_an_elo_where_the_user_has_no_competency_attempts(
            self):
        # Given a learner
        john_superlearner = self.name_to_learners['John Superlearner']

        john_superlearner = self._clear_user(john_superlearner)

        target_parent_id = 'https://insertCassUrl/api/data/insertCassSchemaUrl.0.3.Competency/6bdc90f5-6d6c-4884-9581-dc2e0c9c07f1'
        john_superlearner.goals.append(
            Goal(context='http://insertCassSchemaUrl/0.3',
                 competency_id=target_parent_id,
                 type='Goal'))

        self._clear_user(john_superlearner)

        target_elo_id = 'https://insertCassUrl/api/data/insertCassSchemaUrl.0.3.Competency/86b50eaa-74e2-412f-b858-9d5610b52bef'

        # Who only has one non-mastered and attempted elo
        for competency in self.cass_graph.get_entire_chain():
            if competency.id != target_elo_id and competency.id != target_parent_id:
                # print(competency.id)
                self._master_competency(competency, john_superlearner)
                self._add_competency_attempt(competency, john_superlearner)

        active_elos = get_current_elos(john_superlearner, self.cass_graph)
        self.assertEqual(len(active_elos), 1)
        active_elo = active_elos[0]

        self.assertTrue(CassConfig.ILL_DEFINED_CONCEPT_TERM in
                        active_elo.ceasnconcept_term)
        self.assertEqual(active_elo.id, target_elo_id)

        # Then the SomethingNew strategy can only instantiate that ELO
        query_mock = self._default_query_mock()
        strategy = NewCompetency(john_superlearner, query_mock,
                                 self.cass_graph, False)
        applicable_elos = strategy.can_instantiate(active_elos)
        self.assertTrue(len(applicable_elos) == 1)
        applicable_elo = applicable_elos[0]
        self.assertEqual(applicable_elo, active_elo)

        # And when a recommendation is made with that elo
        row = strategy.instantiate_row(applicable_elo)

        # Then the recommendation has activities for only that ELO
        activities = [
            query_mock.get_activity(
                mongo_id_from_url(recommended_activity.activity_id))
            for recommended_activity in row.activities
        ]
        self.assertTrue(
            all(
                get_aligned_elo(activity) == applicable_elo.id
                for activity in activities))
コード例 #5
0
 def filter_activites_by_activity_type(
         self, activity_type: str, active_elos: List[Competency],
         activities: List[LearningActivity]) -> List[LearningActivity]:
     filtered_activities = list()
     for activity in activities:
         if activity.learning_resource_type == activity_type:
             aligned_elo_id = utils.get_aligned_elo(activity)
             if aligned_elo_id is not None and aligned_elo_id in [
                     elo.id for elo in active_elos
             ]:
                 filtered_activities.append(activity)
     return filtered_activities
コード例 #6
0
 def filter_activities_by_author(
         self, author_id: str, active_elos: List[Competency],
         activities: List[LearningActivity]) -> List[LearningActivity]:
     filtered_activities = list()
     for activity in activities:
         if activity.author.identifier == author_id:
             aligned_elo_id = utils.get_aligned_elo(activity)
             if aligned_elo_id is not None and aligned_elo_id in [
                     elo.id for elo in active_elos
             ]:
                 filtered_activities.append(activity)
     return filtered_activities
コード例 #7
0
    def _get_metacognitive_prompt(self) -> Optional[LearningActivity]:
        # Get the metacognitive prompt if the learner has mastered an ELO and
        # they have not seen the metacognitive prompt before.
        last_activity = self._get_last_activity()
        if last_activity is not None:
            aligned_elo = utils.get_aligned_elo(last_activity)
            if aligned_elo is not None and utils.get_elo_mastery_estimate(
                    aligned_elo,
                    self.learner) == MagicStrings.MasteryEstimates.HELD:
                metacognitive_prompt = self._get_metacognitive_prompt_for_elo(
                    aligned_elo)
                if metacognitive_prompt is not None and not self._has_learner_taken_activity(
                        metacognitive_prompt):
                    return metacognitive_prompt

        return None
コード例 #8
0
ファイル: tokens.py プロジェクト: soartech/fluent
    def get_activity_tokens(self):
        elo_id = get_aligned_elo(self.activity)
        mastery_estimate = get_elo_mastery_estimate(elo_id, self.learner)
        # TODO - Figure out better way around this
        try:
            last_activity = self.query_cacher.get_activity(
                mongo_id_from_url(
                    get_last_activity_url_identifier(self.learner)))
        except:
            last_activity = None

        if TokenConfig.ADVANCED_TOKEN_DECIDER:
            lb_tokens = self.learner_behavior_tokens(self.activity,
                                                     mastery_estimate,
                                                     last_activity)
            am_tokens = self.activity_metadata_tokens(elo_id, self.activity)
            history_multiplier = self.learner_activity_history_multiplier(
                self.learner, self.activity)
            return int(round((lb_tokens + am_tokens) * history_multiplier, 0))
        else:
            return self.simple_token_decider()
コード例 #9
0
ファイル: learner_test.py プロジェクト: soartech/fluent
def handle_activities(activities: List[LearningActivity]):
    for activity in activities:
        aligned_elo_id = get_aligned_elo(activity)
        if activity.interactivity_type == "Passive" and has_challenge_level(
                aligned_elo_id, activity, MagicStrings.ChallengeLevels.SIMPLE):
            print(activity.metadata_file)