コード例 #1
0
 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
         })
コード例 #2
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
     }
コード例 #3
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
 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(),
     }
コード例 #4
0
 def criterion(cls, criterion):
     return caliper.entities.DigitalResource(
         id=ResourceIRI.criterion(criterion.uuid),
         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).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
         dateModified=criterion.modified.replace(
             tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z')
コード例 #5
0
ファイル: object.py プロジェクト: ubc/acj-versus
    def assignment_question(cls, assignment):
        activity = Activity(
            id=ResourceIRI.assignment_question(assignment.course_uuid, assignment.uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('question'),
                name=LanguageMap({ 'en-US': LearningRecord.trim_text_to_size_limit(assignment.name) })
            )
        )
        if assignment.description:
            activity.definition.description = LanguageMap({
                'en-US': LearningRecord.trim_text_to_size_limit(assignment.description)
            })

        return activity
コード例 #6
0
ファイル: result.py プロジェクト: ubc/compair
    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
コード例 #7
0
ファイル: object.py プロジェクト: ubc/acj-versus
    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
コード例 #8
0
    def course(cls, course):
        otherIdentifiers = []
        if course.lti_linked:
            for lti_context in course.lti_contexts:
                lti_consumer = lti_context.lti_consumer

                otherIdentifiers.append(
                    caliper.entities.SystemIdentifier(
                        identifier=lti_context.context_id,
                        identifierType=CALIPER_SYSTEM_TYPES['LTI_CONTEXT_ID'],
                        source=lti_consumer.tool_consumer_instance_url,
                        extensions={
                            "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,
                            "lis_course_offering_sourcedid":
                            lti_context.lis_course_offering_sourcedid,
                            "lis_course_section_sourcedid":
                            lti_context.lis_course_section_sourcedid,
                        }))

        return caliper.entities.CourseOffering(
            id=ResourceIRI.course(course.uuid),
            academicSession=course.term,
            name=LearningRecord.trim_text_to_size_limit(course.name),
            dateCreated=course.created.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            dateModified=course.modified.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            otherIdentifiers=otherIdentifiers)
コード例 #9
0
    def self_evaluation_question(cls, assignment):
        dateToStartOn = assignment.answer_end.replace(
            tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
        dateToSubmit = None
        description = None
        if assignment.self_eval_start and assignment.self_eval_end:
            dateToStartOn = assignment.self_eval_start.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
            dateToSubmit = assignment.self_eval_end.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
        elif assignment.compare_start and assignment.compare_end:
            dateToStartOn = assignment.answer_end.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'

        if assignment.self_eval_instructions:
            description = LearningRecord.trim_text_to_size_limit(
                assignment.self_eval_instructions)

        return caliper.entities.AssessmentItem(
            id=ResourceIRI.self_evaluation_question(assignment.course_uuid,
                                                    assignment.uuid),
            name="Assignment self-evaluation",
            description=description,
            dateToStartOn=dateToStartOn,
            dateToSubmit=dateToSubmit,
            isPartOf=CaliperEntities.assignment(assignment),
            dateCreated=assignment.created.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            dateModified=assignment.modified.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z')
コード例 #10
0
ファイル: event.py プロジェクト: vishnu-meera/ACJ
    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
コード例 #11
0
ファイル: event.py プロジェクト: ubc/acj-versus
    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
コード例 #12
0
    def evaluation_question(cls, assignment, evaluation_number):
        dateToStartOn = assignment.answer_end.replace(
            tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
        dateToSubmit = None
        description = None
        if assignment.compare_start and assignment.compare_end:
            dateToStartOn = assignment.compare_start.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
            dateToSubmit = assignment.compare_end.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'

        if assignment.peer_feedback_prompt:
            description = LearningRecord.trim_text_to_size_limit(
                assignment.peer_feedback_prompt)

        return caliper.entities.AssessmentItem(
            id=ResourceIRI.evaluation_question(assignment.course_uuid,
                                               assignment.uuid,
                                               evaluation_number),
            name="Assignment Answer Evaluation #" + str(evaluation_number),
            description=description,
            dateToStartOn=dateToStartOn,
            dateToSubmit=dateToSubmit,
            isPartOf=CaliperEntities.assignment(assignment),
            dateCreated=assignment.created.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            dateModified=assignment.modified.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z')
コード例 #13
0
    def assignment(cls, assignment):
        activity = Activity(
            id=ResourceIRI.assignment(assignment.course_uuid, assignment.uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('assessment'),
                name=LanguageMap({
                    'en-US':
                    LearningRecord.trim_text_to_size_limit(assignment.name)
                })))
        if assignment.description:
            activity.definition.description = LanguageMap({
                'en-US':
                LearningRecord.trim_text_to_size_limit(assignment.description)
            })

        return activity
コード例 #14
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
    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
コード例 #15
0
    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
コード例 #16
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
    def assignment_question(cls, assignment):
        ret = {
            "id": ResourceIRI.assignment_question(assignment.course_uuid, assignment.uuid),
            "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"],
            "name": LearningRecord.trim_text_to_size_limit(assignment.name),
            "dateToStartOn": assignment.answer_start.replace(tzinfo=pytz.utc).isoformat(),
            "dateToSubmit": assignment.answer_end.replace(tzinfo=pytz.utc).isoformat(),
            "isPartOf": CaliperEntities.assignment(assignment),
            "dateCreated": assignment.created.replace(tzinfo=pytz.utc).isoformat(),
            "dateModified": assignment.modified.replace(tzinfo=pytz.utc).isoformat()
        }

        if assignment.description:
            ret["description"] = LearningRecord.trim_text_to_size_limit(assignment.description)

        return ret
コード例 #17
0
ファイル: statement.py プロジェクト: ubc/compair
    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).as_version()

        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
コード例 #18
0
    def assignment(cls, assignment):
        items = []
        description = None

        if assignment.description:
            description = LearningRecord.trim_text_to_size_limit(
                assignment.description)

        items.append(
            caliper.entities.AssessmentItem(id=ResourceIRI.assignment_question(
                assignment.course_uuid, assignment.uuid)))
        for index in range(assignment.number_of_comparisons):
            current = index + 1
            items.append(
                caliper.entities.AssessmentItem(
                    id=ResourceIRI.comparison_question(
                        assignment.course_uuid, assignment.uuid, current)))
            items.append(
                caliper.entities.AssessmentItem(
                    id=ResourceIRI.evaluation_question(
                        assignment.course_uuid, assignment.uuid, (current *
                                                                  2) - 1)))
            items.append(
                caliper.entities.AssessmentItem(
                    id=ResourceIRI.evaluation_question(
                        assignment.course_uuid, assignment.uuid, (current *
                                                                  2))))
        if assignment.enable_self_evaluation:
            items.append(
                caliper.entities.AssessmentItem(
                    id=ResourceIRI.self_evaluation_question(
                        assignment.course_uuid, assignment.uuid)))

        return caliper.entities.Assessment(
            id=ResourceIRI.assignment(assignment.course_uuid, assignment.uuid),
            name=LearningRecord.trim_text_to_size_limit(assignment.name),
            description=description,
            dateToStartOn=assignment.answer_start.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            isPartOf=CaliperEntities.course(assignment.course),
            items=items,
            dateCreated=assignment.created.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            dateModified=assignment.modified.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z')
コード例 #19
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
 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
         }
     }
コード例 #20
0
ファイル: object.py プロジェクト: ubc/acj-versus
    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
コード例 #21
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
    def assignment(cls, assignment):
        ret = {
            "id": ResourceIRI.assignment(assignment.course_uuid, assignment.uuid),
            "type": CALIPER_ENTITY_TYPES["ASSESSMENT"],
            "name": LearningRecord.trim_text_to_size_limit(assignment.name),
            "dateToStartOn": assignment.answer_start.replace(tzinfo=pytz.utc).isoformat(),
            "isPartOf": CaliperEntities.course(assignment.course),
            "items": [],
            "dateCreated": assignment.created.replace(tzinfo=pytz.utc).isoformat(),
            "dateModified": assignment.modified.replace(tzinfo=pytz.utc).isoformat()
        }

        ret["items"].append({
            "id": ResourceIRI.assignment_question(assignment.course_uuid, assignment.uuid),
            "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"]
        })

        for index in range(assignment.number_of_comparisons):
            current = index + 1
            ret["items"].append({
                "id": ResourceIRI.comparison_question(assignment.course_uuid, assignment.uuid, current),
                "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"]
            })
            ret["items"].append({
                "id": ResourceIRI.evaluation_question(assignment.course_uuid, assignment.uuid, (current * 2) - 1),
                "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"]
            })
            ret["items"].append({
                "id": ResourceIRI.evaluation_question(assignment.course_uuid, assignment.uuid, (current * 2)),
                "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"]
            })

        if assignment.enable_self_evaluation:
            ret["items"].append({
                "id": ResourceIRI.self_evaluation_question(assignment.course_uuid, assignment.uuid),
                "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"]
            })

        if assignment.description:
            ret["description"] = LearningRecord.trim_text_to_size_limit(assignment.description)

        return ret
コード例 #22
0
    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
コード例 #23
0
    def assignment_question(cls, assignment):
        description = None
        if assignment.description:
            description = LearningRecord.trim_text_to_size_limit(
                assignment.description)

        return caliper.entities.AssessmentItem(
            id=ResourceIRI.assignment_question(assignment.course_uuid,
                                               assignment.uuid),
            name=LearningRecord.trim_text_to_size_limit(assignment.name),
            description=description,
            dateToStartOn=assignment.answer_start.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            dateToSubmit=assignment.answer_end.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            isPartOf=CaliperEntities.assignment(assignment),
            dateCreated=assignment.created.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z',
            dateModified=assignment.modified.replace(
                tzinfo=pytz.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z')
コード例 #24
0
ファイル: object.py プロジェクト: ubc/acj-versus
    def self_evaluation_attempt(cls, answer_comment):
        activity = Activity(
            id=ResourceIRI.self_evaluation_attempt(answer_comment.course_uuid, answer_comment.assignment_uuid,
                answer_comment.attempt_uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('attempt'),
                description=LanguageMap({ 'en-US': LearningRecord.trim_text_to_size_limit(answer_comment.content) }),
                extensions=Extensions()
            )
        )
        activity.definition.extensions["http://id.tincanapi.com/extension/attempt"] = cls._basic_attempt(answer_comment)

        return activity
コード例 #25
0
ファイル: object.py プロジェクト: ubc/acj-versus
    def evaluation_response(cls, answer_comment):
        activity = Activity(
            id=ResourceIRI.evaluation_response(answer_comment.course_uuid, answer_comment.assignment_uuid,
                answer_comment.answer_uuid, answer_comment.uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('solution'),
                description=LanguageMap({ 'en-US': LearningRecord.trim_text_to_size_limit(answer_comment.content) }),
                extensions=Extensions()
            )
        )

        activity.definition.extensions['http://id.tincanapi.com/extension/isDraft'] = answer_comment.draft

        return activity
コード例 #26
0
ファイル: object.py プロジェクト: ubc/acj-versus
    def evaluation_question(cls, assignment, evaluation_number):
        activity = Activity(
            id=ResourceIRI.evaluation_question(assignment.course_uuid, assignment.uuid, evaluation_number),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('question'),
                name=LanguageMap({ 'en-US': "Assignment Answer Evaluation #"+str(evaluation_number) }),
            )
        )
        if assignment.peer_feedback_prompt:
            activity.definition.description = LanguageMap({
                'en-US': LearningRecord.trim_text_to_size_limit(assignment.peer_feedback_prompt)
            })

        return activity
コード例 #27
0
ファイル: statement.py プロジェクト: ubc/acj-versus
    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
コード例 #28
0
ファイル: object.py プロジェクト: ubc/compair
    def group(cls, group):
        activity = Activity(
            id=ResourceIRI.group(group.course_uuid, group.uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('group'),
                name=LanguageMap({
                    'en-US':
                    LearningRecord.trim_text_to_size_limit(group.name)
                }),
                extensions=Extensions()))
        activity.definition.extensions[
            'http://id.tincanapi.com/extension/members'] = [
                XAPIActor.generate_actor(uc.user)
                for uc in group.user_courses.all()
            ]

        return activity
コード例 #29
0
    def self_evaluation_attempt(cls, answer_comment):
        activity = Activity(
            id=ResourceIRI.self_evaluation_attempt(
                answer_comment.course_uuid, answer_comment.assignment_uuid,
                answer_comment.attempt_uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('attempt'),
                description=LanguageMap({
                    'en-US':
                    LearningRecord.trim_text_to_size_limit(
                        answer_comment.content)
                }),
                extensions=Extensions()))
        activity.definition.extensions[
            "http://id.tincanapi.com/extension/attempt"] = cls._basic_attempt(
                answer_comment)

        return activity
コード例 #30
0
    def evaluation_response(cls, answer_comment):
        activity = Activity(
            id=ResourceIRI.evaluation_response(answer_comment.course_uuid,
                                               answer_comment.assignment_uuid,
                                               answer_comment.answer_uuid,
                                               answer_comment.uuid),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('solution'),
                description=LanguageMap({
                    'en-US':
                    LearningRecord.trim_text_to_size_limit(
                        answer_comment.content)
                }),
                extensions=Extensions()))

        activity.definition.extensions[
            'http://id.tincanapi.com/extension/isDraft'] = answer_comment.draft

        return activity
コード例 #31
0
    def evaluation_question(cls, assignment, evaluation_number):
        activity = Activity(
            id=ResourceIRI.evaluation_question(assignment.course_uuid,
                                               assignment.uuid,
                                               evaluation_number),
            definition=ActivityDefinition(
                type=XAPIActivity.activity_types.get('question'),
                name=LanguageMap({
                    'en-US':
                    "Assignment Answer Evaluation #" + str(evaluation_number)
                }),
            ))
        if assignment.peer_feedback_prompt:
            activity.definition.description = LanguageMap({
                'en-US':
                LearningRecord.trim_text_to_size_limit(
                    assignment.peer_feedback_prompt)
            })

        return activity
コード例 #32
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
    def evaluation_question(cls, assignment, evaluation_number):
        ret = {
            "id": ResourceIRI.evaluation_question(assignment.course_uuid, assignment.uuid, evaluation_number),
            "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"],
            "name": "Assignment Answer Evaluation #"+str(evaluation_number),
            "isPartOf": CaliperEntities.assignment(assignment),
            "dateCreated": assignment.created.replace(tzinfo=pytz.utc).isoformat(),
            "dateModified": assignment.modified.replace(tzinfo=pytz.utc).isoformat()
        }

        if assignment.compare_start and assignment.compare_end:
            ret["dateToStartOn"] = assignment.compare_start.replace(tzinfo=pytz.utc).isoformat()
            ret["dateToSubmit"] = assignment.compare_end.replace(tzinfo=pytz.utc).isoformat()
        else:
            ret["dateToStartOn"] = assignment.answer_end.replace(tzinfo=pytz.utc).isoformat()

        if assignment.peer_feedback_prompt:
            ret["description"] = LearningRecord.trim_text_to_size_limit(assignment.peer_feedback_prompt)

        return ret
コード例 #33
0
ファイル: event.py プロジェクト: ubc/compair
    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._core_context,
            'eventTime': LearningRecord.generate_timestamp(),
            'actor': caliper_actor,
            'edApp': CaliperEntities.compair_app()
        }

        session_extensions = {}
        if impersonation.is_impersonating() and user.id == current_user.id:
            session_extensions["impersonating-as"] = CaliperActor.generate_actor(user).as_dict()
        defaults['session'] = CaliperEntities.session(caliper_actor, request, session_extensions)

        if course:
            #todo add 'Group' which is the course or the group within the course
            defaults['membership'] = CaliperEntities.membership(course, user)

        return defaults
コード例 #34
0
ファイル: entities.py プロジェクト: vishnu-meera/ACJ
    def self_evaluation_question(cls, assignment):
        ret = {
            "id": ResourceIRI.self_evaluation_question(assignment.course_uuid, assignment.uuid),
            "type": CALIPER_ENTITY_TYPES["ASSESSMENT_ITEM"],
            "name": "Assignment self-evaluation",
            "isPartOf": CaliperEntities.assignment(assignment),
            "dateCreated": assignment.created.replace(tzinfo=pytz.utc).isoformat(),
            "dateModified": assignment.modified.replace(tzinfo=pytz.utc).isoformat(),
        }

        if assignment.self_eval_instructions:
            ret["description"] = LearningRecord.trim_text_to_size_limit(assignment.self_eval_instructions)

        if assignment.self_eval_start and assignment.self_eval_end:
            ret["dateToStartOn"] = assignment.self_eval_start.replace(tzinfo=pytz.utc).isoformat()
            ret["dateToSubmit"] = assignment.self_eval_end.replace(tzinfo=pytz.utc).isoformat()
        elif assignment.compare_start and assignment.compare_end:
            ret["dateToStartOn"] = assignment.answer_end.replace(tzinfo=pytz.utc).isoformat()
        else:
            ret["dateToStartOn"] = assignment.answer_end.replace(tzinfo=pytz.utc).isoformat()

        return ret
コード例 #35
0
ファイル: entities.py プロジェクト: ubc/acj-versus
 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
     }