Example #1
0
def create_new_exercise(exercise_outcome, exercise_source,
                        exercise_solving_speed, bookmark_id):
    """
    OBSOLETE!
    Use the /report_exercise_outcome/... API endpoint

    In the model parlance, an exercise is an entry in a table that
    logs the performance of an exercise. Every such performance, has a source, and an outcome.

    :param exercise_outcome:
    :param exercise_source:
    :param exercise_solving_speed:
    :param bookmark_id:
    :return:
    """

    try:
        bookmark = Bookmark.find(bookmark_id)
        new_source = ExerciseSource.find_by_source(exercise_source)
        new_outcome = ExerciseOutcome.find(exercise_outcome)

        if not new_source or not new_outcome:
            return "FAIL"

        exercise = Exercise(new_outcome, new_source, exercise_solving_speed,
                            datetime.datetime.now())
        bookmark.add_new_exercise(exercise)
        zeeguu.db.session.add(exercise)
        zeeguu.db.session.commit()

        update_probabilities_for_word(bookmark.origin)
        return "OK"
    except:
        return "FAIL"
Example #2
0
def report_exercise_outcome(exercise_outcome,exercise_source,exercise_solving_speed,bookmark_id):
    """
    In the model parlance, an exercise is an entry in a table that
    logs the performance of an exercise. Every such performance, has a source, and an outcome.

    :param exercise_outcome: One of: Correct, Retry, Wrong, Typo, Too easy
    :param exercise_source: has been assigned to your app by zeeguu
    :param exercise_solving_speed: in milliseconds
    :param bookmark_id: the bookmark for which the data is reported
    :return:
    """

    try:
        bookmark = Bookmark.find(bookmark_id)
        new_source = ExerciseSource.find_by_source(exercise_source)
        new_outcome = ExerciseOutcome.find(exercise_outcome)

        if not new_source:
            return "could not find source"

        if not new_outcome:
            return "could not find outcome"

        exercise = Exercise(new_outcome,new_source,exercise_solving_speed, datetime.now())
        bookmark.add_new_exercise(exercise)
        zeeguu.db.session.add(exercise)
        zeeguu.db.session.commit()

        from zeeguu.language.knowledge_estimator import update_probabilities_for_word
        update_probabilities_for_word(bookmark.origin)
        return "OK"
    except :
        traceback.print_exc()
        return "FAIL"
Example #3
0
def report_exercise_outcome(exercise_outcome, exercise_source,
                            exercise_solving_speed, bookmark_id):
    """
    In the model parlance, an exercise is an entry in a table that
    logs the performance of an exercise. Every such performance, has a source, and an outcome.

    :param exercise_outcome: One of: Correct, Retry, Wrong, Typo, Too easy
    :param exercise_source: has been assigned to your app by zeeguu
    :param exercise_solving_speed: in milliseconds
    :param bookmark_id: the bookmark for which the data is reported
    :return:
    """

    try:
        bookmark = Bookmark.find(bookmark_id)
        new_source = ExerciseSource.find_by_source(exercise_source)
        new_outcome = ExerciseOutcome.find(exercise_outcome)

        if not new_source:
            return "could not find source"

        if not new_outcome:
            return "could not find outcome"

        exercise = Exercise(new_outcome, new_source, exercise_solving_speed,
                            datetime.now())
        bookmark.add_new_exercise(exercise)
        zeeguu.db.session.add(exercise)
        zeeguu.db.session.commit()

        from zeeguu.language.knowledge_estimator import update_probabilities_for_word
        update_probabilities_for_word(bookmark.origin)
        return "OK"
    except:
        traceback.print_exc()
        return "FAIL"
Example #4
0
 def __get_or_create_outcome(cls, outcome):
     try:
         return ExerciseOutcome.find(outcome)
     except NoResultFound:
         return cls.__create_new_outcome(outcome)