diff --git a/docs/xblock-tutorial/anatomy/python.rst b/docs/xblock-tutorial/anatomy/python.rst index 8b20ce0c0..57dda2f3f 100644 --- a/docs/xblock-tutorial/anatomy/python.rst +++ b/docs/xblock-tutorial/anatomy/python.rst @@ -1,8 +1,8 @@ .. _The XBlock Python File: -####################### +###################### The XBlock Python File -####################### +###################### This section of the tutorial walks through the Python file, `thumbs.py`_, for the Thumbs XBlock example in the XBlock SDK. @@ -18,9 +18,9 @@ scenarios. :local: :depth: 1 -******************** +******************* Thumb XBlock Fields -******************** +******************* The ``thumbs.py`` file defines the following fields for the XBlock in the ``ThumbsBlockBase`` class. @@ -42,9 +42,9 @@ Note the following details about the fields in the Thumbs XBlock. For more information, see :ref:`XBlock Fields`. -************************** +************************* Thumb XBlock Student View -************************** +************************* The ``thumbs.py`` file defines the student view for the XBlock in the ``ThumbsBlockBase`` class. @@ -60,14 +60,18 @@ Note the following details about student view. .. code-block:: python - html_str = pkg_resources.resource_string(__name__, "static/html/thumbs.html") - frag = Fragment(unicode(html_str).format(self=self)) + html_str = pkg_resources.resource_string( + __name__, + "static/html/thumbs.html".decode('utf-8') + ) + frag = Fragment(str(html_str).format(block=self)) * The JavaScript and CSS file contents are added to the fragment with the - ``add_javascript()`` and ``add_css`` methods. + ``add_javascript()`` and ``add_css()`` methods. * The JavaScript in the fragment must be initialized using the name of the - XBlock class. The name also maps to the function that initializes the XBlock in the :ref:`JavaScript file `. + XBlock class. The name also maps to the function that initializes the XBlock + in the :ref:`JavaScript file `. .. code-block:: python @@ -75,9 +79,9 @@ Note the following details about student view. For more information, see :ref:`View Methods`. -************************** +************************* Thumb XBlock Vote Handler -************************** +************************* The ``thumbs.py`` file defines a handler that adds a user's vote to the XBlock. diff --git a/docs/xblock-tutorial/reusable/code_thumbs_fields.rst b/docs/xblock-tutorial/reusable/code_thumbs_fields.rst index 5288e0699..c9b2fa549 100644 --- a/docs/xblock-tutorial/reusable/code_thumbs_fields.rst +++ b/docs/xblock-tutorial/reusable/code_thumbs_fields.rst @@ -1,9 +1,18 @@ .. code-block:: python class ThumbsBlockBase(object): - upvotes = Integer(help="Number of up votes", default=0, - scope=Scope.user_state_summary) - downvotes = Integer(help="Number of down votes", default=0, - scope=Scope.user_state_summary) - voted = Boolean(help="Has this student voted?", default=False, - scope=Scope.user_state) + upvotes = Integer( + help="Number of up votes", + default=0, + scope=Scope.user_state_summary + ) + downvotes = Integer( + help="Number of down votes", + default=0, + scope=Scope.user_state_summary + ) + voted = Boolean( + help="Has this student voted?", + default=False, + scope=Scope.user_state + ) diff --git a/docs/xblock-tutorial/reusable/code_thumbs_student_view.rst b/docs/xblock-tutorial/reusable/code_thumbs_student_view.rst index 2864774f7..5fb191a49 100644 --- a/docs/xblock-tutorial/reusable/code_thumbs_student_view.rst +++ b/docs/xblock-tutorial/reusable/code_thumbs_student_view.rst @@ -11,16 +11,24 @@ # Load the HTML fragment from within the package and fill in the template - html_str = pkg_resources.resource_string(__name__, "static/html/thumbs.html") - frag = Fragment(unicode(html_str).format(self=self)) + html_str = pkg_resources.resource_string( + __name__, + "static/html/thumbs.html".decode('utf-8') + ) + frag = Fragment(str(html_str).format(block=self)) # Load the CSS and JavaScript fragments from within the package - css_str = pkg_resources.resource_string(__name__, "static/css/thumbs.css") - frag.add_css(unicode(css_str)) + css_str = pkg_resources.resource_string( + __name__, + "static/css/thumbs.css".decode('utf-8') + ) + frag.add_css(str(css_str)) - js_str = pkg_resources.resource_string(__name__, - "static/js/src/thumbs.js") - frag.add_javascript(unicode(js_str)) + js_str = pkg_resources.resource_string( + __name__, + "static/js/src/thumbs.js".decode('utf-8') + ) + frag.add_javascript(str(js_str)) frag.initialize_js('ThumbsBlock') return frag