Пример #1
0
 def get_kanji_question(self, partial_kanji, user):
     kanji_row = partial_kanji.kanji
     kanji = kanji_row.kanji
     error_dist = user.errordist_set.get(tag=self.uses_dist)
     distractors, _annotations = support.build_kanji_options(kanji, error_dist, exclude_set=set([kanji]))
     question = self.build_question(pivot=kanji, pivot_id=partial_kanji.id, pivot_type="k", stimulus=kanji_row.gloss)
     question.add_options(distractors, kanji)
     return question
Пример #2
0
 def get_kanji_question(self, partial_kanji, user):
     kanji_row = partial_kanji.kanji
     kanji = kanji_row.kanji
     error_dist = user.errordist_set.get(tag=self.uses_dist)
     distractors, _annotations = support.build_kanji_options(
         kanji, error_dist, exclude_set=set([kanji]))
     question = self.build_question(
         pivot=kanji,
         pivot_id=partial_kanji.id,
         pivot_type='k',
         stimulus=kanji_row.gloss,
     )
     question.add_options(distractors, kanji)
     return question
Пример #3
0
 def get_kanji_question(self, partial_kanji, user):
     "See parent."
     real_readings = set([r.reading for r in partial_kanji.kanji.reading_set.all()])
     answer = partial_kanji.reading_set.order_by("?")[0].reading
     kanji = partial_kanji.kanji.kanji
     question = self.build_question(
         pivot=kanji, pivot_id=partial_kanji.id, pivot_type="k", stimulus=kanji, annotation=kanji
     )
     question.save()
     error_dist = usermodel_models.ErrorDist.objects.get(user=user, tag=self.uses_dist)
     distractor_values, annotation_map = support.build_kanji_options(
         kanji, error_dist, adaptive=self.is_adaptive, exclude_set=real_readings
     )
     annotation_map[answer] = u"|".join(answer)
     question.add_options(distractor_values, answer, annotation_map)
     return question
Пример #4
0
 def get_kanji_question(self, partial_kanji, user):
     "See parent."
     real_readings = set([r.reading for r in \
             partial_kanji.kanji.reading_set.all()])
     answer = partial_kanji.reading_set.order_by('?')[0].reading
     kanji = partial_kanji.kanji.kanji
     question = self.build_question(pivot=kanji,
                                    pivot_id=partial_kanji.id,
                                    pivot_type='k',
                                    stimulus=kanji,
                                    annotation=kanji)
     question.save()
     error_dist = usermodel_models.ErrorDist.objects.get(user=user,
                                                         tag=self.uses_dist)
     distractor_values, annotation_map = support.build_kanji_options(
         kanji,
         error_dist,
         adaptive=self.is_adaptive,
         exclude_set=real_readings)
     annotation_map[answer] = u'|'.join(answer)
     question.add_options(distractor_values, answer, annotation_map)
     return question
Пример #5
0
    def _add_distractors(self, question, user):
        """
        Builds distractors for the question with appropriate annotations so
        that we can easily update the error model afterwards.   

        Note that the segments used here are simplistic, one per character,
        since the richer GP segments need not be supported by this error
        distribution.
        """
        error_dist = user.errordist_set.get(tag=self.uses_dist)
        pivot = question.pivot
        segments = list(pivot) # Simple segments
        if question.pivot_type == 'w':
            distractors, annotation_map = support.build_word_options(
                    segments, error_dist, exclude_set=set([pivot]))
        else:
            distractors, annotation_map = support.build_kanji_options(
                    question.pivot, error_dist, exclude_set=set([pivot]))
        annotation_map[pivot] = u'|'.join(segments)
        question.add_options(distractors, question.pivot,
                annotation_map=annotation_map)
        question.annotation = u'|'.join(segments)
        question.save()
        return
Пример #6
0
 def get_kanji_question(self, partial_kanji, user):
     "See parent."
     error_dist = usermodel_models.ErrorDist.objects.get(user=user,
             tag=self.uses_dist)
     exclude_set = set(row['reading'] for row in \
             partial_kanji.kanji.reading_set.values('reading'))
     answer = partial_kanji.reading_set.order_by('?').values(
             'reading')[0]['reading']
     kanji = partial_kanji.kanji.kanji
     question = self.build_question(
             pivot=kanji,
             pivot_id=partial_kanji.id,
             pivot_type='k',
             stimulus=kanji,
         )
     distractors, annotation_map = support.build_kanji_options(
             kanji, error_dist, exclude_set=exclude_set,
             adaptive=self.is_adaptive)
     annotation_map[answer] = answer         # No segments
     question.add_options(distractors, answer,
             annotation_map=annotation_map)
     question.annotation = kanji             # No segments
     question.save()
     return question