def course_activity_view(request, course_id, activity_id):
    course = can_view_course(request, course_id)
    activity = Activity.objects.get(pk=activity_id)
    
    # log the activity in the tracker
    tracker = Tracker()
    tracker.user = request.user
    tracker.course = course
    tracker.type = activity.type 
    tracker.data = ""
    tracker.ip = request.META.get('REMOTE_ADDR','0.0.0.0')
    tracker.agent = request.META.get('HTTP_USER_AGENT','unknown')
    tracker.activity_title = activity.title
    tracker.section_title = activity.section.title
    tracker.save()
    
    if activity.type == "page":
        activity_content_file = activity.get_content()
        
        with codecs.open(settings.MEDIA_ROOT + "courses/" + course.shortname + "/" + activity_content_file, "r", "utf-8") as f:
            s = f.read()
        
        template = re.compile('\<body(?P<body>.*?)>(?P<content>.*)\<\/body\>', re.DOTALL)
        
        activity_content = template.search(s).group('content')
        activity_content =  activity_content.replace("images/",settings.MEDIA_URL + "courses/" + course.shortname + "/images/")
        
        return render_to_response('oppia/preview/course_activity_page.html',
                                  {'course': course, 'activity': activity , 'content' : activity_content }, 
                                  context_instance=RequestContext(request))
    else:
        activity_content= None
        return render_to_response('oppia/preview/course_activity_not_supported.html',
                                  {'course': course, 'activity': activity , 'content' : activity_content }, 
                                  context_instance=RequestContext(request)) 
Example #2
0
def course_activity_view(request, course_id, activity_id):
    course = check_can_view(request, course_id)
    activity = Activity.objects.get(pk=activity_id)
    
    # log the activity in the tracker
    tracker = Tracker()
    tracker.user = request.user
    tracker.course = course
    tracker.type = activity.type 
    tracker.data = ""
    tracker.ip = request.META.get('REMOTE_ADDR','0.0.0.0')
    tracker.agent = request.META.get('HTTP_USER_AGENT','unknown')
    tracker.activity_title = activity.title
    tracker.section_title = activity.section.title
    tracker.save()
    
    if activity.type == "page":
        activity_content_file = activity.get_content()
        
        with codecs.open(settings.MEDIA_ROOT + "courses/" + course.shortname + "/" + activity_content_file, "r", "utf-8") as f:
            s = f.read()
        
        template = re.compile('\<body(?P<body>.*?)>(?P<content>.*)\<\/body\>', re.DOTALL)
        
        activity_content = template.search(s).group('content')
        activity_content =  activity_content.replace("images/",settings.MEDIA_URL + "courses/" + course.shortname + "/images/")
        
        return render_to_response('oppia/preview/course_activity_page.html',
                                  {'course': course, 'activity': activity , 'content' : activity_content }, 
                                  context_instance=RequestContext(request))
    else:
        activity_content= None
        return render_to_response('oppia/preview/course_activity_not_supported.html',
                                  {'course': course, 'activity': activity , 'content' : activity_content }, 
                                  context_instance=RequestContext(request)) 
def record_mobile_tracker(request, course_id, type, page):
    t = Tracker()
    t.user = request.user
    t.ip = request.META.get('REMOTE_ADDR', oppia.DEFAULT_IP_ADDRESS)
    t.agent = request.META.get('HTTP_USER_AGENT', 'unknown')
    t.digest = ""
    t.data = ""
    t.course = course_id
    t.type = type
    t.completed = True
    t.activity_title = page
    t.save()
    return
def record_mobile_tracker(request, course_id, type, page):
    t = Tracker()
    t.user = request.user
    t.ip = request.META.get('REMOTE_ADDR', oppia.DEFAULT_IP_ADDRESS)
    t.agent = request.META.get('HTTP_USER_AGENT', 'unknown')
    t.digest = ""
    t.data = ""
    t.course = course_id
    t.type = type
    t.completed = True
    t.activity_title = page
    t.save()
    return
Example #5
0
def record_mobile_tracker(request, course_id, type, page):
    t = Tracker()
    t.user = request.user
    t.ip = request.META.get("REMOTE_ADDR", "0.0.0.0")
    t.agent = request.META.get("HTTP_USER_AGENT", "unknown")
    t.digest = ""
    t.data = ""
    t.course = course_id
    t.type = type
    t.completed = True
    t.activity_title = page
    t.save()
    return