本文整理汇总了Python中compair.learning_records.resource_iri.ResourceIRI类的典型用法代码示例。如果您正苦于以下问题:Python ResourceIRI类的具体用法?Python ResourceIRI怎么用?Python ResourceIRI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ResourceIRI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: comparison
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: answer
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
示例3: _defaults
def _defaults(cls, user, course=None):
caliper_actor = CaliperActor.generate_actor(user)
if impersonation.is_impersonating() and user.id == current_user.id:
caliper_actor = CaliperActor.generate_actor(impersonation.get_impersonation_original_user())
defaults = {
'context': CaliperSensor._version,
'eventTime': LearningRecord.generate_timestamp(),
'actor': caliper_actor,
'edApp': ResourceIRI.compair()
}
session = CaliperEntities.session(caliper_actor)
if request:
session.setdefault("extensions", {}).setdefault("browser-info", {})
if request.environ.get('HTTP_USER_AGENT'):
session["extensions"]["browser-info"]["userAgent"] = request.environ.get('HTTP_USER_AGENT')
if request.environ.get('HTTP_REFERER'):
session["extensions"]["browser-info"]["referer"] = request.environ.get('HTTP_REFERER')
if impersonation.is_impersonating() and user.id == current_user.id:
session["extensions"]["impersonating-as"] = CaliperActor.generate_actor(user)
defaults['session'] = session
if course:
defaults['membership'] = CaliperEntities.membership(course, user)
return defaults
示例4: course
def course(cls, course):
ret = {
"id": ResourceIRI.course(course.uuid),
"type": CALIPER_ENTITY_TYPES["COURSE_OFFERING"],
"academicSession": course.term,
"name": LearningRecord.trim_text_to_size_limit(course.name),
"dateCreated": course.created.replace(tzinfo=pytz.utc).isoformat(),
"dateModified": course.modified.replace(tzinfo=pytz.utc).isoformat(),
"extensions": {}
}
if course.lti_linked:
ret["extensions"]["ltiContexts"] = []
for lti_context in course.lti_contexts:
lti_consumer = lti_context.lti_consumer
ret["extensions"]["ltiContexts"].append({
"oauth_consumer_key": lti_consumer.oauth_consumer_key,
"tool_consumer_instance_guid": lti_consumer.tool_consumer_instance_guid,
"tool_consumer_instance_name": lti_consumer.tool_consumer_instance_name,
"tool_consumer_instance_url": lti_consumer.tool_consumer_instance_url,
"lis_course_offering_sourcedid": lti_context.lis_course_offering_sourcedid,
"lis_course_section_sourcedid": lti_context.lis_course_section_sourcedid,
"context_id": lti_context.context_id
})
return ret
示例5: report
def report(cls, file_name, mimetype):
return {
"id": ResourceIRI.report(file_name),
"type": CALIPER_ENTITY_TYPES["DOCUMENT"],
"name": file_name,
"mediaType": mimetype,
}
示例6: _add_default
def _add_default(cls, user, statement):
if not statement.timestamp:
statement.timestamp = LearningRecord.generate_timestamp()
if impersonation.is_impersonating() and user.id == current_user.id:
statement.actor = XAPIActor.generate_actor(impersonation.get_impersonation_original_user())
else:
statement.actor = XAPIActor.generate_actor(user)
# add default context info
if not statement.context:
statement.context = Context()
if not statement.context.context_activities:
statement.context.context_activities = ContextActivities()
if not statement.context.context_activities.category:
statement.context.context_activities.category = ActivityList()
statement.context.context_activities.category.append(
XAPIActivity.compair_source()
)
statement.context.platform = ResourceIRI.compair()
if not statement.context.extensions:
statement.context.extensions = Extensions()
statement.context.extensions['http://id.tincanapi.com/extension/session-info'] = {
'id': ResourceIRI.user_session(sess.get('session_id', '')),
'start_at': sess.get('start_at'),
'login_method': sess.get('login_method'),
}
if sess.get('end_at'):
statement.context.extensions['http://id.tincanapi.com/extension/session-info']['end_at'] = sess.get('end_at')
if impersonation.is_impersonating() and user.id == current_user.id:
statement.context.extensions['http://id.tincanapi.com/extension/session-info']['impersonating-as'] = XAPIActor.generate_actor(user)
statement.context.extensions['http://id.tincanapi.com/extension/browser-info'] = {}
if request and request.environ.get('HTTP_USER_AGENT'):
statement.context.extensions['http://id.tincanapi.com/extension/browser-info']['user-agent'] = request.environ.get('HTTP_USER_AGENT')
if request and request.environ.get('HTTP_REFERER'):
statement.context.extensions['http://id.tincanapi.com/extension/browser-info']['referer'] = request.environ.get('HTTP_REFERER')
return statement
示例7: compair_app
def compair_app(cls):
return {
"id": ResourceIRI.compair(),
"type": CALIPER_ENTITY_TYPES["SOFTWARE_APPLICATION"],
"name": "ComPAIR",
"description": "The ComPAIR learning application pairs student answers for deeper learning through comparison of peer work.",
"version": current_app.config.get('COMPAIR_VERSION')
}
示例8: _generate_compair_account
def _generate_compair_account(cls, user):
return {
"id": ResourceIRI.actor_homepage()+user.uuid,
"type": CALIPER_ENTITY_TYPES["PERSON"],
"name": user.fullname,
"dateCreated": user.created.replace(tzinfo=pytz.utc).isoformat(),
"dateModified": user.modified.replace(tzinfo=pytz.utc).isoformat(),
}
示例9: self_evaluation_question
def self_evaluation_question(cls, assignment):
return Activity(
id=ResourceIRI.self_evaluation_question(assignment.course_uuid, assignment.uuid),
definition=ActivityDefinition(
type=XAPIActivity.activity_types.get('question'),
name=LanguageMap({ 'en-US': "Assignment self-evaluation" })
)
)
示例10: comparison_question
def comparison_question(cls, assignment, comparison_number):
return Activity(
id=ResourceIRI.comparison_question(assignment.course_uuid, assignment.uuid, comparison_number),
definition=ActivityDefinition(
type=XAPIActivity.activity_types.get('question'),
name=LanguageMap({ 'en-US': "Assignment comparison #"+str(comparison_number) })
)
)
示例11: criterion
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(),
}
示例12: course
def course(cls, course):
activity = Activity(
id=ResourceIRI.course(course.uuid),
definition=ActivityDefinition(
type=XAPIActivity.activity_types.get('course'),
name=LanguageMap({ 'en-US': LearningRecord.trim_text_to_size_limit(course.name) })
)
)
return activity
示例13: _add_sis_data
def _add_sis_data(cls, context, course):
if course.lti_has_sis_data:
if not context.context_activities:
context.context_activities = ContextActivities()
if not context.context_activities.grouping:
context.context_activities.grouping = ActivityList()
sis_data = course.lti_sis_data
for sis_course_id, sis_section_ids in sis_data.items():
context.context_activities.grouping.append({
"id": ResourceIRI.sis_course(sis_course_id),
"objectType": "Activity"
})
for sis_section_id in sis_section_ids:
context.context_activities.grouping.append({
"id": ResourceIRI.sis_section(sis_course_id, sis_section_id),
"objectType": "Activity"
})
示例14: assignment_attempt
def assignment_attempt(cls, assignment, attempt_mixin_object, user):
ret = {
"id": ResourceIRI.assignment_attempt(assignment.course_uuid, assignment.uuid, attempt_mixin_object.attempt_uuid),
"type": CALIPER_ENTITY_TYPES["ATTEMPT"],
"assignee": CaliperActor.generate_actor(user),
"assignable": CaliperEntities.assignment(assignment),
}
ret.update(cls._basic_attempt(attempt_mixin_object))
return ret
示例15: answer_attachment
def answer_attachment(cls, answer, file, mimetype):
return {
"id": ResourceIRI.attachment(file.name),
"type": CALIPER_ENTITY_TYPES["DOCUMENT"],
"name": file.alias,
"mediaType": mimetype,
"isPartOf": CaliperEntities.answer(answer),
"dateCreated": file.created.replace(tzinfo=pytz.utc).isoformat(),
"dateModified": file.modified.replace(tzinfo=pytz.utc).isoformat()
}