Example #1
0
def _render_get_lesson_detail(request, lesson):
    try:
        workflow, created = _ensure_workflow(request, lesson)
    except ModuleVersion.DoesNotExist:
        return HttpResponseServerError('initial_json asks for missing module')
    except ValueError as err:
        return HttpResponseServerError('initial_json has invalid params: '
                                       + str(err))

    modules = visible_modules(request)

    init_state = make_init_state(request, workflow=workflow, modules=modules)
    init_state['lessonData'] = LessonSerializer(lesson).data

    # If we just initialized this workflow, start fetches and render
    if created:
        _queue_workflow_updates(workflow)
        if lesson.course:
            course_slug = lesson.course.slug
        else:
            course_slug = 'None'
        server.utils.log_user_event_from_request(
            request,
            'Start lesson in course %s' % (course_slug)
        )

    return TemplateResponse(request, 'workflow.html',
                            {'initState': init_state})
Example #2
0
def _render_get_lesson_detail(request, lesson):
    try:
        workflow, created = _ensure_workflow(request, lesson)
    except KeyError as err:
        return HttpResponseServerError(
            "initial_json asks for missing module: %s" % str(err))
    except ValueError as err:
        return HttpResponseServerError("initial_json has invalid params: " +
                                       str(err))

    modules = visible_modules(request)

    init_state = make_init_state(request, workflow=workflow, modules=modules)
    init_state["lessonData"] = jsonize_lesson(lesson)

    # If we just initialized this workflow, start fetches and render
    if created:
        _queue_workflow_updates(workflow)
        if lesson.course:
            course_slug = lesson.course.slug
        else:
            course_slug = "None"
        server.utils.log_user_event_from_request(
            request, "Start lesson in course %s" % (course_slug))

    return TemplateResponse(request, "workflow.html",
                            {"initState": init_state})
Example #3
0
def _render_get_lesson_detail(request, lesson):
    workflow = get_object_or_404(Workflow, owner=request.user, lesson_slug=lesson.slug)
    modules = Module.objects.all()

    init_state = make_init_state(request, workflow=workflow, modules=modules)
    init_state['lessonData'] = LessonSerializer(lesson).data
    return TemplateResponse(request, 'workflow.html',
                            { 'initState': init_state })
Example #4
0
def _render_get_lesson_detail(request, lesson):
    workflow = _ensure_workflow(request, lesson)
    modules = Module.objects.all()

    init_state = make_init_state(request, workflow=workflow, modules=modules)
    init_state['lessonData'] = LessonSerializer(lesson).data
    return TemplateResponse(request, 'workflow.html',
                            {'initState': init_state})