Example #1
0
def javascript_result(request):
    if request.method == "POST":
        rpc = json.loads(request.body)

        code = rpc["params"][0]
        activity_uri = rpc["method"]
        program_test = Activity.get(activity_uri)

        if request.user.is_authenticated() and "id" in rpc:
            ula = None
            try:
                ula = UserLearningActivity.objects.get(learning_activity__id=rpc["id"], user=request.user)

                s = SimpleSequencing()
                if rpc["result"] == "Success":
                    s.update(
                        ula,
                        progress_status="completed",
                        objective_status="satisfied",
                        objective_measure=30,
                        attempt=True,
                    )
                else:
                    s.update(ula, attempt=True)
                # s.update(ula)
                ## Mouse Dynamics
                event = ULA_Event.objects.create(ULA=ula, context=rpc)
                event.save()
            except ObjectDoesNotExist:
                # Assume is a non assigned program
                pass

        return HttpResponse(json.dumps({}), content_type="application/javascript")
Example #2
0
def execute_queue(request):
    if request.method == "POST":
        rpc = json.loads(request.body)
        print rpc

        code = rpc["params"][0]
        activity_uri = rpc["method"]
        program_test = Activity.get(activity_uri)
        unit_test = program_test["unit_test"]
        server = Cola(program_test["lang"])

        task = {"id": None, "method": "exec", "params": {"code": code, "test": unit_test}}
        task_id = server.enqueue(**task)

        if request.user.is_authenticated() and "id" in rpc:
            ula = None
            try:
                ula = UserLearningActivity.objects.get(learning_activity__id=rpc["id"], user=request.user)

                s = SimpleSequencing()
                s.update(ula)
                ## Mouse Dynamics
                event = ULA_Event.objects.create(ULA=ula, context=rpc)
                event.save()
            except ObjectDoesNotExist:
                # Assume is a non assigned program

                pass

        rpc["task_id"] = task_id

        result = {"result": "added", "error": None, "id": task_id}
        return HttpResponse(json.dumps(result), content_type="application/javascript")
Example #3
0
def path_program(request, path_id, uri):
    if request.user.is_authenticated():
        s = SimpleSequencing()
        try:
            requested_activity = UserLearningActivity.objects.get(learning_activity__id=path_id, user=request.user)
        except ObjectDoesNotExist as e:
            return HttpResponseNotFound("<h1>Learning Activity not found</h1>")
        root = None
        try:
            root = UserLearningActivity.objects.get(
                learning_activity=requested_activity.learning_activity.get_root(), user=request.user
            )
        except (ObjectDoesNotExist, IndexError) as e:
            return HttpResponseNotFound("<h1>Path not found</h1>")

        if request.method == "GET":
            # Exits last activity, and sets requested activity as current
            # if choice_exit consider complete
            _set_current(request, requested_activity, root, s)

        # Gets the current navegation tree as XML
        _XML = get_nav(root)
        # Escape for javascript
        XML = ET.tostring(_XML, "utf-8").replace('"', r"\"")

        breadcrumbs = s.get_current_path(requested_activity)
        program_quiz = Activity.get(requested_activity.learning_activity.uri)
        rating_totals = LearningActivityRating.objects.filter(
            learning_activity__uri=requested_activity.learning_activity.uri
        ).aggregate(Count("rating"), Avg("rating"))

        if program_quiz["lang"] == "javascript":
            template = "activitytree/programjs.html"
        else:
            template = "activitytree/program.html"

        return render_to_response(
            template,
            {
                "program_quiz": Activity.get(requested_activity.learning_activity.uri),
                "activity_uri": requested_activity.learning_activity.uri,
                "uri_id": "%s" % requested_activity.learning_activity.id,
                "uri": requested_activity.learning_activity.uri,
                "breadcrumbs": breadcrumbs,
                "root": requested_activity.learning_activity.get_root().uri,
                "root_id": "/%s" % requested_activity.learning_activity.get_root().id,
                "XML_NAV": XML,
                "rating_totals": rating_totals,
            },
            context_instance=RequestContext(request),
        )

    else:
        return HttpResponseRedirect("/login/?next=%s" % request.path)
Example #4
0
def get_result(request):
    if request.method == "POST":
        rpc = json.loads(request.body)
        # We only need the Task identifier
        # TO DO:
        # No ID, Task Not Found
        task_id = rpc["id"]
        t = Task(id=task_id)

        # outcome:
        # -1 No result found
        # 0 Sub-process Success
        # 1 Sub-process Failure
        if t.get_result(task_id.split(":")[0]):

            if t.result:
                print t.result
                string_json = ""
                try:
                    string_json = json.loads(t.result[0])
                except Exception, e:
                    print e

                if request.user.is_authenticated():
                    try:
                        ula = UserLearningActivity.objects.get(
                            learning_activity__uri=rpc["params"][0], user=request.user
                        )
                        s = SimpleSequencing()

                        if string_json["result"] == "Success":
                            s.update(
                                ula,
                                progress_status="completed",
                                objective_status="satisfied",
                                objective_measure=30,
                                attempt=True,
                            )

                        else:
                            s.update(ula, attempt=True)
                    except Exception, e:
                        print e

                result = json.dumps({"result": string_json, "outcome": t.result[1]})
                return HttpResponse(result, content_type="application/javascript")

            else:
                return HttpResponse(json.dumps({"outcome": -1}), content_type="application/javascript")
Example #5
0
def program(request,uri):
    if request.user.is_authenticated():
        s = SimpleSequencing()
        # First, the requested_activity  exists??
        # Gets the Learning Activity object from uri
        requested_activity = _get_ula(request, s)

        if not requested_activity:
            return HttpResponseNotFound('<h1>Activity not found</h1>')

        # Gets the root of the User Learning Activity
        root = UserLearningActivity.objects.filter(learning_activity = requested_activity.learning_activity.get_root() ,user = request.user )[0]

        if request.method == 'GET':
            # Exits last activity, and sets requested activity as current
            # if choice_exit consider complete
            _set_current(request,requested_activity, root, s, objective_status=None, progress_status=None)

        if request.method == 'POST' and 'nav_event' in request.POST:
        # We are going to exit activity, get objective measure
            objective_measure = float(request.POST['objective_measure'])



            next_uri = None
            if  request.POST['nav_event'] == 'next':
                # Go TO NEXT ACTIVITY
                next_uri = s.get_next(root)
                pool_writting(next_uri,request.user)
            elif request.POST['nav_event'] == 'prev':
                # Go TO PREV ACTIVITY
                next_uri = s.get_prev(root)
            print next_uri

            if next_uri is None:
                    #No more activities ?
                return HttpResponseRedirect( root.learning_activity.uri)

            else:
                s.exit( requested_activity, progress_status = 'complete', objective_status = 'satisfied', objective_measure = objective_measure)
                next_activity = UserLearningActivity.objects.filter(learning_activity__uri = next_uri ,user = request.user )[0]
                return HttpResponseRedirect(next_activity.learning_activity.uri)


        # Gets the current navegation tree as HTML
        nav = s.get_nav(root)
        navegation_tree = s.nav_to_html(nav)



        return render_to_response('activitytree/program.html', {'program_quiz':activities[request.path],
                                                                'activity_uri':request.path,
                                                                'navegation': navegation_tree
                                                                },
                                  context_instance=RequestContext(request))

    else:
        return HttpResponseRedirect('/login/?next=%s' % request.path)
Example #6
0
j.save()

p = User.objects.create_user('paul', '*****@*****.**', '1234')
p.is_active = True
p.save()

lsj=LearningStyleInventory(visual=12,verbal=11,aural=15,physical=9,logical=11,
                          social=9, solitary=10, user = j)
lsj.save()

lsp=LearningStyleInventory(visual=12,verbal=11,aural=20,physical=9,logical=11,
                          social=9, solitary=7, user = p)
lsp.save()


s = SimpleSequencing()
s.assignActivityTree(j,POO)
s.assignActivityTree(p,POO)


estudiantes = [
]

for e in estudiantes:
    User.objects.filter(username=e[0]).delete()
    u = User.objects.create_user(e[0],e[0], e[1])
    u.is_active = True
    u.save()
    lsu=LearningStyleInventory(visual=e[2],verbal=e[3],aural=e[4],physical=e[5],logical=e[6],
                          social=e[7], solitary=e[8], user = u)
    lsu.save()
Example #7
0
def activity(request,uri):
    if request.user.is_authenticated():
        s = SimpleSequencing()
        # First, the requested_activity  exists??
        # Gets the Learning Activity object from uri

        #print "hasta aqui"
        requested_activity = _get_ula(request, s)


        if not requested_activity:
            return HttpResponseNotFound('<h1>Activity not found</h1>')

        # Gets the root of the User Learning Activity
        root = UserLearningActivity.objects.filter(learning_activity = requested_activity.learning_activity.get_root() ,user = request.user )[0]
        #Aqui mando la actividad actual a redis para que la escuche el script que manejara la actividad de el muestreo de kinect



        if request.method == 'GET':
            # Exits last activity, and sets requested activity as current
            # if choice_exit consider complete
            _set_current(request,requested_activity, root, s, objective_status=None, progress_status=None)

        if request.method == 'POST' and 'nav_event' in request.POST:

            if requested_activity.learning_activity.is_container:
                progress_status = None
                objective_status = None
            else:
                ###
                ###  What if status in POST??
                ###
                progress_status = 'complete'
                objective_status = 'satisfied'
            if request.POST['nav_event'] == 'next':
                # Go TO NEXT ACTIVITY

                next_uri = s.get_next(root)
                #az.set(request.user,next_uri)
                az.set("user",request.user)
                az.set("activity",next_uri)
                #
                if next_uri=="/activity/POO" or next_uri==None:
                    actividad=""
                else:
                    actividad=next_uri

                print actividad,request.user
                pool_writting(actividad,request.user)
            elif request.POST['nav_event'] == 'prev':
                # Go TO PREV ACTIVITY
                next_uri = s.get_prev(root)

            if next_uri is None:
                    #No more activities ?
                return HttpResponseRedirect( root.learning_activity.uri)

            else:

                s.exit( requested_activity, progress_status = progress_status, objective_status = objective_status)
                next_activity = UserLearningActivity.objects.filter(learning_activity__uri = next_uri ,user = request.user )[0]
                return HttpResponseRedirect(next_activity.learning_activity.uri)


        # Gets the current navegation tree as HTML
        nav = s.get_nav(root)
        navegation_tree = s.nav_to_html(nav)

        ####
        ####
        ####

        print requested_activity.learning_activity.uri
        content = activities[requested_activity.learning_activity.uri]

        return render_to_response('activitytree/'+ (requested_activity.learning_activity.uri).split('/')[1]+'.html',

                                  {'navegation': navegation_tree,
                                   'uri':requested_activity.learning_activity.uri,
                                   'content':content},
                                    context_instance=RequestContext(request))

        #####
        #####
        #####



    else:
        return HttpResponseRedirect('/login/?next=%s' % request.path)
Example #8
0
def test(request, uri, objective_status = None):
    if request.user.is_authenticated():
        s = SimpleSequencing()
        # First, the requested_activity  exists??
        # Gets the Learning Activity object from uri
        requested_activity = _get_ula(request, s)

        if not requested_activity:
            return HttpResponseNotFound('<h1>Activity not found</h1>')

        # Gets the root of the User Learning Activity
        root = UserLearningActivity.objects.filter(learning_activity = requested_activity.learning_activity.get_root() ,user = request.user )[0]

        feedback = None

        if request.method == 'GET':
            # Exits last activity, and sets requested activity as current
            # if choice_exit consider complete
            _set_current(request,requested_activity, root, s, objective_status=None, progress_status=None)

        elif request.method == 'POST':
            if 'check' in request.POST:
                feedback = _check_quiz(request.POST, activities[requested_activity.learning_activity.uri])
                # Exits the current Learning Activity
                objective_measure = feedback['total_correct']
                if objective_measure >= activities[requested_activity.learning_activity.uri]['satisfied_at_least']:
                    objective_status='satisfied'
                else:
                    objective_status='notSatisfied'
                print requested_activity.learning_activity.uri, objective_measure,objective_status

                s.update(requested_activity, progress_status = None, objective_status = objective_status, objective_measure = objective_measure)


            elif 'nav_event' in request.POST:
                next_uri = None

                if request.POST['nav_event'] == 'next' :
                    # Go TO NEXT ACTIVITY
                    next_uri = s.get_next(root)
                    progress_status = 'complete'
                    pool_writting(next_uri,request.user)
                elif request.POST['nav_event'] == 'prev':
                    # Go TO PREV ACTIVITY
                    next_uri = s.get_prev(root)
                    pool_writting(next_uri)
                if next_uri is None:
                        #No more activities ?
                    return HttpResponseRedirect( root.learning_activity.uri)
                else:
                    next_activity = UserLearningActivity.objects.filter(learning_activity__uri = next_uri ,user = request.user )[0]
                    return HttpResponseRedirect(next_activity.learning_activity.uri)

       # Gets the current navegation tree as HTML

        nav = s.get_nav(root)
        navegation_tree = s.nav_to_html(nav)

        content = activities[requested_activity.learning_activity.uri]
        if feedback:
            for q in content['questions']:
                if q['id'] in feedback:
                    q['feedback'] = feedback[q['id']]
                    if q['interaction']  in ['choiceInteraction','simpleChoice']:
                        q['feedback_options'] = zip(q['options'], feedback[q['id']]['user_answer'], feedback[q['id']]['checked'])

        return render_to_response('activitytree/'+(requested_activity.learning_activity.uri).split('/')[1]+'.html',
                                  {'navegation': navegation_tree,
                                   'uri':requested_activity.learning_activity.uri,
                                   'content':content,
                                   'feedback':feedback},
                                    context_instance=RequestContext(request))
    else:      
        return HttpResponseRedirect('/login/?next=%s' % request.path)
Example #9
0
__author__ = 'frank'
if __name__ == "__main__":
    import os
    print "####### DJANGO SETTINGS"
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "protoboard.settings")


from activitytree.models import LearningStyleInventory, LearningActivity, Course, UserLearningActivity
from django.contrib.auth.models import User
from activitytree.interaction_handler import SimpleSequencing
User.objects.filter(username='******').delete()
for i in range(200):

    nombre = "a"+str(i)
    edad = 8
    grado = 8
    correo='*****@*****.**'

    j = User.objects.create_user(nombre,correo,'1234' )
    j.is_active = True
    j.save()

    lsu=LearningStyleInventory(visual=0,verbal=0,aural=0,physical=0,logical=0,
                          social=0, solitary=0, age=edad, aca_lvl=grado, user = j)
    lsu.save()
    s = SimpleSequencing()

    a=LearningActivity.objects.all()
    print a[0]
    s.assignActivityTree(j,a[0])
('omar',            '1234', 7, 3, 7,12,16,17, 6),
('santana',           '1234',10, 9,13,13,13,14,13),
('hector',  '1234', 1,11,11,11,18,13,13),
('edie',           '1234',14, 6,16,12,12,13,12),
('baby',      '1234',15,18,20,17,13,18,17),
('saul',            '1234',13,11,14,11,14,14,13),
('brenda',             '1234',17,13,20,12,14,11,16),
('samara',         '1234',14,15,13,12,15,16,12),
('daniel',      '1234', 9, 8,15,11,13,14,13),
('jorge',           '1234',17,12,14,17,19,18,14),
('mike',             '1234',15,16,17,18,18,13,11),
('luis',            '1234',11, 7,11,10,11,12, 6),
('*****@*****.**',       '1234',12,10,12,13,10,18,10)]

for e in estudiantes:
    User.objects.filter(username=e[0]).delete()
    u = User.objects.create_user(e[0],e[0], e[1])
    u.is_active = True
    u.save()
    lsu=LearningStyleInventory(visual=e[2],verbal=e[3],aural=e[4],physical=e[5],logical=e[6],
                          social=e[7], solitary=e[8], user = u)
    lsu.save()
    ss = SimpleSequencing()
    ss.assignActivityTree(u,PPP)

import os

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "protoboard.settings")

j.is_active = True
j.save()

p = User.objects.create_user('paul', '*****@*****.**', '1234')
p.is_active = True
p.save()

lsj=LearningStyleInventory(visual=12,verbal=11,aural=15,physical=9,logical=11,
                          social=9, solitary=10, age=5, aca_lvl=3, user = j)
lsj.save()

lsp=LearningStyleInventory(visual=12,verbal=11,aural=20,physical=9,logical=11,
                          social=9, solitary=7, age=15, aca_lvl=15, user = p)
lsp.save()

s = SimpleSequencing()


s.assignActivityTree(j,tec)
s.assignActivityTree(p,tec)


estudiantes = [
('edgar',          '1234',17,13,16,12,14,16,9, 25, 21),
('osuna',       '1234',15,12,14,18,14,19,8, 15, 4),
('malu',         '1234', 7,10, 4, 8,17,14,16, 12, 4),
('jose',        '1234',17, 6,16,13,14,11, 8, 18, 4),
('david',         '1234',15,10,13,14,17,15,11, 18, 4),
('juan',    '1234',11,13,11,10,13,18, 8, 18, 4),
('cota',              '1234',13, 7,18,14,12,10,13, 18, 4),
('omar',            '1234', 7, 3, 7,12,16,17, 6, 18, 4),
Example #12
0
def path_test(request, path_id, uri):

    if request.user.is_authenticated():
        s = SimpleSequencing()
        try:
            requested_activity = UserLearningActivity.objects.get(learning_activity__id=path_id, user=request.user)
        except ObjectDoesNotExist as e:
            return HttpResponseNotFound("<h1>Learning Activity not found</h1>")

        root = None

        try:
            root = UserLearningActivity.objects.get(
                learning_activity=requested_activity.learning_activity.get_root(), user=request.user
            )
        except (ObjectDoesNotExist, IndexError) as e:
            return HttpResponseNotFound("<h1>Path not found</h1>")

        feedback = None
        attempts_left = requested_activity.learning_activity.attempt_limit - requested_activity.num_attempts
        if request.method == "GET":
            # Exits last activity, and sets requested activity as current
            # if choice_exit consider complete
            _set_current(request, requested_activity, root, s, objective_status=None, progress_status=None)

        elif request.method == "POST":
            if "check" in request.POST and attempts_left:

                # quiz = activities[requested_activity.learning_activity.uri]
                quiz = Activity.get(requested_activity.learning_activity.uri)

                feedback = _check_quiz(request.POST, quiz)
                # Updates the current Learning Activity
                objective_measure = float(feedback["total_correct"]) / len(quiz["questions"]) * 100
                if feedback["total_correct"] >= quiz["satisfied_at_least"]:
                    objective_status = "satisfied"
                else:
                    objective_status = "notSatisfied"

                s.update(
                    requested_activity,
                    objective_status=objective_status,
                    objective_measure=objective_measure,
                    attempt=True,
                )
                attempts_left -= 1

        # Gets the current navegation tree as HTML

        _XML = get_nav(root)
        # Escape for javascript
        XML = ET.tostring(_XML, "utf-8").replace('"', r"\"")  # navegation_tree = s.nav_to_html(nav)
        rating_totals = LearningActivityRating.objects.filter(
            learning_activity__uri=requested_activity.learning_activity.uri
        ).aggregate(Count("rating"), Avg("rating"))

        breadcrumbs = s.get_current_path(requested_activity)

        test = Activity.get(requested_activity.learning_activity.uri)

        if feedback:
            for q in test["questions"]:
                if q["id"] in feedback:
                    q["feedback"] = feedback[q["id"]]
                    if q["interaction"] in ["choiceInteraction", "simpleChoice"]:
                        q["feedback_options"] = zip(
                            q["options"], feedback[q["id"]]["user_answer"], feedback[q["id"]]["checked"]
                        )

        return render_to_response(
            "activitytree/" + (requested_activity.learning_activity.uri).split("/")[1] + ".html",
            {
                "XML_NAV": XML,
                "uri": requested_activity.learning_activity.uri,
                "content": test,
                "feedback": feedback,
                "breadcrumbs": breadcrumbs,
                "uri_id": "/%s" % requested_activity.learning_activity.id,
                "attempt_limit": requested_activity.learning_activity.attempt_limit,
                "num_attempts": requested_activity.num_attempts,
                "attempts_left": attempts_left,
                "root_id": "/%s" % requested_activity.learning_activity.get_root().id,
                "root": requested_activity.learning_activity.get_root().uri,
            },
            context_instance=RequestContext(request),
        )
    else:

        return HttpResponseRedirect("/login/?next=%s" % request.path)
Example #13
0
def path_activity(request, path_id, uri):
    learning_activity = None
    try:
        learning_activity = LearningActivity.objects.get(pk=path_id)
    except ObjectDoesNotExist:
        return HttpResponseNotFound("<h1>Learning Activity not found</h1>")

    if request.user.is_authenticated():
        root = None
        s = SimpleSequencing()
        requested_activity = None

        if request.method == "GET":
            try:
                requested_activity = UserLearningActivity.objects.get(learning_activity__id=path_id, user=request.user)
            except (ObjectDoesNotExist, IndexError) as e:
                requested_activity = None

            # The requested_activity was NOT FOUND
            if not requested_activity:  # The requested_activity was not found
                # Maybe a
                # 'start' REQUEST?
                #    if 'nav' in request.GET and request.GET['nav'] == 'start':
                if learning_activity and learning_activity.root is None:
                    s.assignActivityTree(request.user, learning_activity)
                    requested_activity = UserLearningActivity.objects.get(
                        learning_activity__id=path_id, user=request.user
                    )
                    _set_current(request, requested_activity, requested_activity, s)
                    return HttpResponseRedirect("/%s%s" % (path_id, uri))
                # If is not a root learning activity then sorry, not found
                else:
                    return HttpResponseNotFound("<h1>Activity not found</h1>")
            # Else NOT FOUND
            # else:
            #    return HttpResponseNotFound('<h1>Activity not found</h1>')

            # We have a valid requested_activity, lets handle OTHER NAVIGATION REQUEST

            # Get root of activity tree
            root = UserLearningActivity.objects.filter(
                learning_activity=requested_activity.learning_activity.get_root(), user=request.user
            )[0]
            # 'continue' REQUEST?
            if requested_activity.is_root() and "nav" in request.GET and request.GET["nav"] == "continue":
                current_activity = s.get_current(requested_activity)
                if current_activity:
                    requested_activity = current_activity
                    return HttpResponseRedirect(
                        "/%s%s" % (requested_activity.learning_activity.id, requested_activity.learning_activity.uri)
                    )
                else:
                    _set_current(request, requested_activity, root, s, objective_status=None, progress_status=None)
            # Else is a
            # 'choice' REQUEST
            else:
                _set_current(request, requested_activity, root, s)

        if request.method == "POST" and "nav_event" in request.POST:
            # Get root of activity tree
            root = None
            try:
                root = UserLearningActivity.objects.get(learning_activity__id=path_id, user=request.user)
            except (ObjectDoesNotExist, IndexError) as e:
                root = None

            if not root or not root.is_root():
                return HttpResponseNotFound("<h1>Activity not found</h1>")

            current_activity = s.get_current(root)

            if current_activity.learning_activity.choice_exit:
                objective_status = "satisfied"
                progress_status = "complete"
            else:
                progress_status = None
                objective_status = None

            # 'next' REQUEST
            if request.POST["nav_event"] == "next":
                # Go TO NEXT ACTIVITY
                s.exit(current_activity, progress_status=progress_status, objective_status=objective_status)
                next_uri = s.get_next(root, current_activity)

            # 'prev' REQUEST
            elif request.POST["nav_event"] == "prev":
                # Go TO PREV ACTIVITY
                s.exit(current_activity, progress_status=progress_status, objective_status=objective_status)
                next_uri = s.get_prev(root, current_activity)

            # No more activities ?
            if next_uri is None:

                return HttpResponseRedirect("/%s%s" % (root.learning_activity.id, root.learning_activity.uri))

            else:
                next_activity = UserLearningActivity.objects.get(learning_activity__id=next_uri, user=request.user)
                return HttpResponseRedirect(
                    "/%s%s" % (next_activity.learning_activity.id, next_activity.learning_activity.uri)
                )

        _XML = get_nav(root)
        # Escape for javascript
        XML = ET.tostring(_XML, "utf-8").replace('"', r"\"")

        breadcrumbs = s.get_current_path(requested_activity)

        rating_totals = LearningActivityRating.objects.filter(
            learning_activity__uri=requested_activity.learning_activity.uri
        ).aggregate(Count("rating"), Avg("rating"))

        activity_content = Activity.get(requested_activity.learning_activity.uri)

        if activity_content and "content" in activity_content:
            content = activity_content["content"]
        else:
            content = ""

        update_pool(requested_activity.learning_activity.uri)

        if (requested_activity.learning_activity.uri).split("/")[2] == "video":
            return render_to_response(
                "activitytree/video.html",
                {
                    "XML_NAV": XML,
                    "uri": requested_activity.learning_activity.uri,
                    "uri_id": requested_activity.learning_activity.id,
                    "video": activity_content,
                    "breadcrumbs": breadcrumbs,
                    "root": requested_activity.learning_activity.get_root().uri,
                    "root_id": "/%s" % requested_activity.learning_activity.get_root().id,
                    "rating_totals": rating_totals,
                },
                context_instance=RequestContext(request),
            )

        elif requested_activity.learning_activity.is_container:

            return render_to_response(
                "activitytree/container.html",
                {
                    "XML_NAV": XML,
                    "children": requested_activity.get_children(),
                    "uri": requested_activity.learning_activity.uri,
                    "uri_id": "/%s" % requested_activity.learning_activity.id,
                    "content": content,
                    "root": requested_activity.learning_activity.get_root().uri,
                    "root_id": "/%s" % requested_activity.learning_activity.get_root().id,
                    "breadcrumbs": breadcrumbs,
                },
                context_instance=RequestContext(request),
            )
        else:
            return render_to_response(
                "activitytree/activity.html",
                {
                    "XML_NAV": XML,
                    "uri": requested_activity.learning_activity.uri,
                    "uri_id": "/%s" % requested_activity.learning_activity.id,
                    "content": content,
                    "root": requested_activity.learning_activity.get_root().uri,
                    "root_id": "/%s" % requested_activity.learning_activity.get_root().id,
                    "breadcrumbs": breadcrumbs,
                    "rating_totals": rating_totals,
                },
                context_instance=RequestContext(request),
            )

    else:
        return HttpResponseRedirect("/login/?next=%s" % request.path)