本文整理汇总了Python中compair.learning_records.resource_iri.ResourceIRI.criterion方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceIRI.criterion方法的具体用法?Python ResourceIRI.criterion怎么用?Python ResourceIRI.criterion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类compair.learning_records.resource_iri.ResourceIRI
的用法示例。
在下文中一共展示了ResourceIRI.criterion方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comparison
# 需要导入模块: from compair.learning_records.resource_iri import ResourceIRI [as 别名]
# 或者: from compair.learning_records.resource_iri.ResourceIRI import criterion [as 别名]
def comparison(cls, comparison, **kwargs):
result = cls.basic_attempt(comparison, None, **kwargs)
result.extensions = Extensions() if not result.extensions else result.extensions
winner = "Undecided"
if comparison.winner == WinningAnswer.draw:
winner = "Draw"
elif comparison.winner == WinningAnswer.answer1:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer1_uuid)
elif comparison.winner == WinningAnswer.answer2:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer2_uuid)
result.response = winner
result.extensions['http://xapi.learninganalytics.ubc.ca/extension/criteria'] = {}
for comparison_criterion in comparison.comparison_criteria:
winner = "Undecided"
if comparison_criterion.winner == WinningAnswer.answer1:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer1_uuid)
elif comparison_criterion.winner == WinningAnswer.answer2:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer2_uuid)
result.extensions['http://xapi.learninganalytics.ubc.ca/extension/criteria'][
ResourceIRI.criterion(comparison_criterion.criterion_uuid)] = winner
return result
示例2: criterion
# 需要导入模块: from compair.learning_records.resource_iri import ResourceIRI [as 别名]
# 或者: from compair.learning_records.resource_iri.ResourceIRI import criterion [as 别名]
def criterion(cls, criterion):
return {
"id": ResourceIRI.criterion(criterion.uuid),
"type": CALIPER_ENTITY_TYPES["ENTITY"],
"name": LearningRecord.trim_text_to_size_limit(criterion.name),
"description": LearningRecord.trim_text_to_size_limit(criterion.description),
"dateCreated": criterion.created.replace(tzinfo=pytz.utc).isoformat(),
"dateModified": criterion.modified.replace(tzinfo=pytz.utc).isoformat(),
}
示例3: criterion
# 需要导入模块: from compair.learning_records.resource_iri import ResourceIRI [as 别名]
# 或者: from compair.learning_records.resource_iri.ResourceIRI import criterion [as 别名]
def criterion(cls, criterion):
activity = Activity(
id=ResourceIRI.criterion(criterion.uuid),
definition=ActivityDefinition(
type=XAPIActivity.activity_types.get('question'),
name=LanguageMap({ 'en-US': LearningRecord.trim_text_to_size_limit(criterion.name) })
)
)
if criterion.description:
activity.definition.description = LanguageMap({
'en-US': LearningRecord.trim_text_to_size_limit(criterion.description)
})
return activity
示例4: answer
# 需要导入模块: from compair.learning_records.resource_iri import ResourceIRI [as 别名]
# 或者: from compair.learning_records.resource_iri.ResourceIRI import criterion [as 别名]
def answer(cls, answer):
ret = {
"id": ResourceIRI.answer(answer.course_uuid, answer.assignment_uuid, answer.uuid),
"type": CALIPER_ENTITY_TYPES["RESPONSE"],
"dateCreated": answer.created.replace(tzinfo=pytz.utc).isoformat(),
"dateModified": answer.modified.replace(tzinfo=pytz.utc).isoformat(),
"extensions": {
"isDraft": answer.draft
}
}
ret["extensions"].update(cls._basic_content_extension(answer.content))
if answer.attempt_uuid:
ret["attempt"] = CaliperEntities.answer_attempt(answer)
if answer.score:
score = answer.score
score_details = {
"algorithm": score.scoring_algorithm.value,
"score": score.score,
"wins": score.wins,
"loses": score.loses,
"rounds": score.rounds,
"opponents": score.opponents,
"criteria": {}
}
if score.scoring_algorithm == ScoringAlgorithm.true_skill:
score_details['mu'] = score.variable1
score_details['sigma'] = score.variable2
ret["extensions"]["scoreDetails"] = score_details
for criterion_score in answer.criteria_scores:
score_details = {
"score": criterion_score.score,
"wins": criterion_score.wins,
"loses": criterion_score.loses,
"rounds": criterion_score.rounds,
"opponents": criterion_score.opponents,
}
if criterion_score.scoring_algorithm == ScoringAlgorithm.true_skill:
score_details["mu"] = criterion_score.variable1
score_details["sigma"] = criterion_score.variable2
ret["extensions"]["scoreDetails"]["criteria"][ResourceIRI.criterion(criterion_score.criterion_uuid)] = score_details
return ret
示例5: comparison
# 需要导入模块: from compair.learning_records.resource_iri import ResourceIRI [as 别名]
# 或者: from compair.learning_records.resource_iri.ResourceIRI import criterion [as 别名]
def comparison(cls, comparison, current_comparison=None):
winner = "Undecided"
if comparison.winner == WinningAnswer.draw:
winner = "Draw"
elif comparison.winner == WinningAnswer.answer1:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer1_uuid)
elif comparison.winner == WinningAnswer.answer2:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer2_uuid)
ret = {
"id": ResourceIRI.comparison(comparison.course_uuid, comparison.assignment_uuid, comparison.uuid),
"type": CALIPER_ENTITY_TYPES["RESPONSE"],
"dateCreated": comparison.created.replace(tzinfo=pytz.utc).isoformat(),
"dateModified": comparison.modified.replace(tzinfo=pytz.utc).isoformat(),
"extensions": {
"pairingAlgorithm": comparison.pairing_algorithm.value,
"winner": winner,
"criteria": {},
"answers": [
ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer1_uuid),
ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer2_uuid)
],
"completed": comparison.completed
}
}
for comparison_criterion in comparison.comparison_criteria:
winner = "Undecided"
if comparison_criterion.winner == WinningAnswer.answer1:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer1_uuid)
elif comparison_criterion.winner == WinningAnswer.answer2:
winner = ResourceIRI.answer(comparison.course_uuid, comparison.assignment_uuid, comparison.answer2_uuid)
ret["extensions"]["criteria"][ResourceIRI.criterion(comparison_criterion.criterion_uuid)] = winner
if comparison.attempt_uuid and current_comparison:
ret["attempt"] = CaliperEntities.comparison_attempt(comparison, current_comparison)
return ret
示例6: answer_score
# 需要导入模块: from compair.learning_records.resource_iri import ResourceIRI [as 别名]
# 或者: from compair.learning_records.resource_iri.ResourceIRI import criterion [as 别名]
def answer_score(cls, answer, score, **kwargs):
from compair.models import ScoringAlgorithm
result = cls.basic(**kwargs)
result.extensions = Extensions() if not result.extensions else result.extensions
result.score = Score(raw=score.score)
score_details = {
'score': score.score,
'algorithm': score.scoring_algorithm.value,
'wins': score.wins,
'loses': score.loses,
'rounds': score.rounds,
'opponents': score.opponents,
'criteria': {}
}
if score.scoring_algorithm == ScoringAlgorithm.true_skill:
score_details['mu'] = score.variable1
score_details['sigma'] = score.variable2
for criterion_score in answer.criteria_scores:
criterion_score_details = {
'score': criterion_score.score,
'wins': criterion_score.wins,
'loses': criterion_score.loses,
'rounds': criterion_score.rounds,
'opponents': criterion_score.opponents,
}
if criterion_score.scoring_algorithm == ScoringAlgorithm.true_skill:
criterion_score_details['mu'] = criterion_score.variable1
criterion_score_details['sigma'] = criterion_score.variable2
score_details['criteria'][ResourceIRI.criterion(criterion_score.criterion_uuid)] = criterion_score_details
result.extensions['http://xapi.learninganalytics.ubc.ca/extension/score-details'] = score_details
return result