Esempio n. 1
0
    def can_instantiate(self) -> List[Organization]:
        past_activities = utils.last_n_activities_attempted(
            self.learner.activity_attempt_counters, 10, self.query_cacher)

        providers = {
            activity.provider.identifier: activity.provider
            for activity in past_activities
        }
        return list(providers.values())
Esempio n. 2
0
    def can_instantiate(self) -> List[Person]:
        past_activities = utils.last_n_activities_attempted(
            self.learner.activity_attempt_counters, 10, self.query_cacher)
        authors = {
            activity.author.identifier: activity.author
            for activity in past_activities
        }

        return list(authors.values())
Esempio n. 3
0
    def _failed_unit_assessment_recently(self, tlo_id: str):
        # Checks to see if the unit assessment was failed within the past 3 attempts.
        activities = utils.last_n_activities_attempted(
            self.learner.activity_attempt_counters, 3, self.query_cacher)
        for activity in activities:
            if utils.tlo_in_activity(
                    tlo_id, activity
            ) and activity.learning_resource_type == MagicStrings.LearningResourceTypes.UNIT_ASSESSMENT:
                return True

        return False
Esempio n. 4
0
    def _get_required_self_report(self) -> Optional[LearningActivity]:
        last_5_activities = utils.last_n_activities_attempted(
            self.learner.activity_attempt_counters, 5, self.query_cacher)

        # Self report required if user has not yet taken a self report after having taken a regular activity
        for activity in last_5_activities:
            if utils.educational_use_in_activity(
                    activity, MagicStrings.EducationalUses.SELF_REPORT):
                return None
            if not utils.educational_use_in_activity(
                    activity, MagicStrings.EducationalUses.ASSESSES):
                return self.query_cacher.get_self_report()
        return None
Esempio n. 5
0
    def _get_required_check_on_learning_assessment(
            self) -> Optional[LearningActivity]:
        last_5_activities = utils.last_n_activities_attempted(
            self.learner.activity_attempt_counters, 5, self.query_cacher)
        for activity in last_5_activities:
            if utils.educational_use_in_activity(
                    activity, MagicStrings.EducationalUses.SELF_REPORT):
                continue
            if utils.educational_use_in_activity(
                    activity, MagicStrings.EducationalUses.ASSESSES):
                return None

            assessment_id = utils.get_check_on_learning_assessment_acitivity_id(
                activity)
            if assessment_id is not None:
                return self.query_cacher.get_activity(
                    utils.mongo_id_from_url(assessment_id))
        return None
Esempio n. 6
0
    def can_instantiate(self, active_elos: List[Competency]):
        elo_id_to_attempted_activities = {elo.id: [] for elo in active_elos}

        # Only look at last n activities from learner (list is [most recent, 2nd most recent, ... nth most recent])
        last_activities_attempted = last_n_activities_attempted(
            self.learner.activity_attempt_counters, self.HISTORY_LIMIT,
            self.query_cacher)

        return_elos = []
        for elo in active_elos:
            for activity in last_activities_attempted:
                if elo_in_activity(elo.id, activity):
                    if is_assessment(activity):
                        break

                    elo_id_to_attempted_activities[elo.id].append(activity)
                    if len(elo_id_to_attempted_activities[
                            elo.id]) == self.NUM_BEFORE_ASSESSMENT:
                        return_elos.append(elo)
                        break

        return return_elos