예제 #1
0
def format_i4x(raw_event):
    # Parsing event_type
    module = helperclasses.ModuleURI(raw_event['event_type'])

    # Construct and set event_type
    raw_event['event_type'] = 'i4x_' + str(module.category) + '_' + str(
        module.action)

    # Set module if missing
    if 'module' not in raw_event:
        raw_event['module'] = module
예제 #2
0
def parse_video_id(raw_event):
    '''
    Video ID can either be found in 'video_id' or 
    'transcript_id' fields.
    '''
    if raw_event['video_id']:
        video_id = raw_event['video_id']
    elif raw_event['transcript_id']:
        video_id = raw_event['transcript_id']
    else:
        return
    raw_event['module'] = helperclasses.ModuleURI(video_id)
예제 #3
0
def parse_problem_id(raw_event):
    '''Gives a consistent URI formatting to problem IDs.
    Example :
        i4x-MITx-6_002x-problem-H10P2_New_Impedances_10_1
      becomes:
        i4x://MITx/6.002x/problem/H10P2_New_Impedances/10/1/
    
    That way, URL hierarchy and problem hierarchy can be handled 
    similarly.
    '''

    if raw_event.get('answer_identifier', ''):
        problem_id = raw_event['answer_identifier']
    elif raw_event.get('problem_id', ''):
        problem_id = raw_event['problem_id']
    else:
        return
            
    raw_event['module'] = helperclasses.ModuleURI(problem_id)
예제 #4
0
def parse_question_location(raw_event):
    if raw_event['question_location']:
        raw_event['module'] = helperclasses.ModuleURI(
            raw_event['question_location'])