author_view doesn't display. How to set a different view for the studio?

128 views
Skip to first unread message

Christian Thomas

unread,
Apr 5, 2017, 2:11:26 AM4/5/17
to General Open edX discussion
Hello,

I am developing an XBlock. The student_view works so far, but I want a different one for the studio.

As far as I understand, the author_view should be used if available. But it doesn't. I created a little test code. In the studio it just prints "Student view".

Here is my code:

from xblock.core import XBlock
from xblock.fragment import Fragment


class InlineToolboxXBlock(XBlock):
    def student_view(self, context=None):
        return Fragment(u"Student View")

    def studio_view(self, context=None):
        return Fragment(u"Studio View")

    def author_view(self, context=None):
        return Fragment(u"Author View")

Any ideas what I am missing here?

Best regards,
Christian

Jill Vogel

unread,
Apr 5, 2017, 2:15:57 AM4/5/17
to edx-...@googlegroups.com
Hi Christian,

That's a common hurdle, something that really should be fixed..

But until then, you also need to set this on your class:

# Without this flag, studio will use student_view on newly-added blocks :/
has_author_view = True


Cheers,
--

Christian Thomas

unread,
Apr 5, 2017, 3:05:22 AM4/5/17
to General Open edX discussion
Hey Jill,

thank you for you fast answer. It works as expected.

Best regards,
Christian
Reply all
Reply to author
Forward
0 new messages