def answer_comment(cls, answer_comment): return caliper.entities.Comment( id=ResourceIRI.answer_comment(answer_comment.course_uuid, answer_comment.assignment_uuid, answer_comment.answer_uuid, answer_comment.uuid), commenter=CaliperActor.generate_actor(answer_comment.user), commentedOn=CaliperEntities.answer(answer_comment.answer), value=LearningRecord.trim_text_to_size_limit( answer_comment.content), dateCreated=answer_comment.created.replace( tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z', dateModified=answer_comment.modified.replace( tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z', extensions={ "type": answer_comment.comment_type.value, "isDraft": answer_comment.draft, "characterCount": LearningRecord.character_count(answer_comment.content) if answer_comment.content else 0, "wordCount": LearningRecord.word_count(answer_comment.content) if answer_comment.content else 0 })
def _basic_content_extension(cls, content): return { "content": LearningRecord.trim_text_to_size_limit(content), "characterCount": LearningRecord.character_count(content) if content else 0, "wordCount": LearningRecord.word_count(content) if content else 0 }
def basic_content(cls, content, **kwargs): result = cls.basic(**kwargs) if content: result.response = LearningRecord.trim_text_to_size_limit(content) result.extensions = Extensions() if not result.extensions else result.extensions character_count = LearningRecord.character_count(content) result.extensions['http://xapi.learninganalytics.ubc.ca/extension/character-count'] = character_count word_count = LearningRecord.word_count(content) result.extensions['http://xapi.learninganalytics.ubc.ca/extension/word-count'] = word_count return result
def answer_comment(cls, answer_comment): #TODO: this isn't in the Caliper spec yet return { "id": ResourceIRI.answer_comment(answer_comment.course_uuid, answer_comment.assignment_uuid, answer_comment.answer_uuid, answer_comment.uuid), "type": "Comment", "commenter": CaliperActor.generate_actor(answer_comment.user), "commented": CaliperEntities.answer(answer_comment.answer), "value": LearningRecord.trim_text_to_size_limit(answer_comment.content), "dateCreated": answer_comment.created.replace(tzinfo=pytz.utc).isoformat(), "dateModified": answer_comment.modified.replace(tzinfo=pytz.utc).isoformat(), "extensions": { "type": answer_comment.comment_type.value, "isDraft": answer_comment.draft, "characterCount": LearningRecord.character_count(answer_comment.content) if answer_comment.content else 0, "wordCount": LearningRecord.word_count(answer_comment.content) if answer_comment.content else 0 } }
def _basic_content_extension(cls, content): return { "content": LearningRecord.trim_text_to_size_limit(content), "characterCount": LearningRecord.character_count(content) if content else 0, "wordCount": LearningRecord.word_count(content) if content else 0 }