Commit e1d854be by Piotr Mitros

Initializing repo

parent 78a3f7cb
TemplateXBlock DoneXBlock
============== ==============
This is a simple template for an XBlock. It will play audio files as Lets a student mark they've finished an activity
an HTML5 audio element. If unavailable, it will fall back to an embed
element.
Usage: FutureLearn uses this kind of thing to great effect. Students can
read text, watch videos, etc., and mark when their done. Honor
<template src="http://server.tld/static/song.mp3" /> code grading, and convenient progress indication.
...@@ -2,16 +2,16 @@ ...@@ -2,16 +2,16 @@
# #
# Step 1: Come up with a short name for your XBlock. For example, if # Step 1: Come up with a short name for your XBlock. For example, if
# your XBlock plays audio files, 'audio' is a good name. # your XBlock plays audio files, 'audio' is a good name.
short-name : audio short-name : done
# Step 2: Create a repository on github for your XBlock. In the above # Step 2: Create a repository on github for your XBlock. In the above
# case, I strongly recommend the short name, followed by 'XBlock,' in # case, I strongly recommend the short name, followed by 'XBlock,' in
# camelcase. Do not initialize this repo. We'll do it for you # camelcase. Do not initialize this repo. We'll do it for you
github : git@github.com:pmitros/AudioXBlock.git github : git@github.com:pmitros/DoneXBlock.git
# Step 3: Give a short description of this XBlock # Step 3: Give a short description of this XBlock
description : Plays an audio file as an embed element description : Lets a student mark they've finished an activity
# Step 4: Give a multiline description. Keep the 2 line indent, please. # Step 4: Give a multiline description. Keep the 2 line indent, please.
overview : | overview : |
This XBlock plays an audio file as an HTML5 audio element. If FutureLearn uses this kind of thing to great effect. Students can
the audio element is not present, it will fall back to an read text, watch videos, etc., and mark when their done. Honor
embed element. code grading, and convenient progress indication.
# Once you're done, hit save, and watch the magic happen! # Once you're done, hit save, and watch the magic happen!
\ No newline at end of file
from .done import DoneXBlock
\ No newline at end of file
...@@ -7,7 +7,7 @@ from xblock.fields import Scope, Integer, String ...@@ -7,7 +7,7 @@ from xblock.fields import Scope, Integer, String
from xblock.fragment import Fragment from xblock.fragment import Fragment
class TemplateXBlock(XBlock): class DoneXBlock(XBlock):
""" """
This XBlock will play an MP3 file as an HTML5 audio element. This XBlock will play an MP3 file as an HTML5 audio element.
""" """
...@@ -27,16 +27,16 @@ class TemplateXBlock(XBlock): ...@@ -27,16 +27,16 @@ class TemplateXBlock(XBlock):
# TO-DO: change this view to display your data your own way. # TO-DO: change this view to display your data your own way.
def student_view(self, context=None): def student_view(self, context=None):
""" """
The primary view of the TemplateXBlock, shown to students The primary view of the DoneXBlock, shown to students
when viewing courses. when viewing courses.
""" """
html = self.resource_string("static/html/template.html") html = self.resource_string("static/html/done.html")
print self.src print self.src
print html.format print html.format
frag = Fragment(html.format(src = self.src)) frag = Fragment(html.format(src = self.src))
frag.add_css(self.resource_string("static/css/template.css")) frag.add_css(self.resource_string("static/css/done.css"))
frag.add_javascript(self.resource_string("static/js/src/template.js")) frag.add_javascript(self.resource_string("static/js/src/done.js"))
frag.initialize_js('TemplateXBlock') frag.initialize_js('DoneXBlock')
print self.xml_text_content() print self.xml_text_content()
return frag return frag
...@@ -46,11 +46,11 @@ class TemplateXBlock(XBlock): ...@@ -46,11 +46,11 @@ class TemplateXBlock(XBlock):
def workbench_scenarios(): def workbench_scenarios():
"""A canned scenario for display in the workbench.""" """A canned scenario for display in the workbench."""
return [ return [
("TemplateXBlock", ("DoneXBlock",
"""<vertical_demo> """<vertical_demo>
<template src="http://localhost/Ikea.mp3"> </template> <done src="http://localhost/Ikea.mp3"> </done>
<template src="http://localhost/skull.mp3"> </template> <done src="http://localhost/skull.mp3"> </done>
<template src="http://localhost/monkey.mp3"> </template> <done src="http://localhost/monkey.mp3"> </done>
</vertical_demo> </vertical_demo>
"""), """),
] ]
/* CSS for TemplateXBlock */ /* CSS for DoneXBlock */
.template_block .count { .done_block .count {
font-weight: bold; font-weight: bold;
} }
.template_block p { .done_block p {
cursor: pointer; cursor: pointer;
} }
\ No newline at end of file
<div class="template_block"> <div class="done_block">
<audio controls preload> <audio controls preload>
<source src="{src}"> <source src="{src}">
<embed height="50" width="100" src="{src}"> <embed height="50" width="100" src="{src}">
......
"""Setup for template XBlock.""" """Setup for done XBlock."""
import os import os
from setuptools import setup from setuptools import setup
...@@ -15,19 +15,19 @@ def package_data(pkg, root): ...@@ -15,19 +15,19 @@ def package_data(pkg, root):
setup( setup(
name='template-xblock', name='done-xblock',
version='0.1', version='0.1',
description='template XBlock', # TODO: write a better description. description='done XBlock', # TODO: write a better description.
packages=[ packages=[
'template', 'done',
], ],
install_requires=[ install_requires=[
'XBlock', 'XBlock',
], ],
entry_points={ entry_points={
'xblock.v1': [ 'xblock.v1': [
'template = template:TemplateXBlock', 'done = done:DoneXBlock',
] ]
}, },
package_data=package_data("template", "static"), package_data=package_data("done", "static"),
) )
\ No newline at end of file
from .template import TemplateXBlock
\ No newline at end of file
...@@ -3,14 +3,14 @@ import yaml ...@@ -3,14 +3,14 @@ import yaml
import os import os
commands = ''' commands = '''
git mv ./template/template.py ./template/{shortname}.py git mv ./done/done.py ./done/{shortname}.py
git mv ./template/static/html/template.html ./template/static/html/{shortname}.html git mv ./done/static/html/done.html ./done/static/html/{shortname}.html
git mv ./template/static/css/template.css ./template/static/css/{shortname}.css git mv ./done/static/css/done.css ./done/static/css/{shortname}.css
git mv ./template/static/js/src/template.js ./template/static/js/src/{shortname}.js git mv ./done/static/js/src/done.js ./done/static/js/src/{shortname}.js
git mv template {shortname} git mv done {shortname}
find . -type f | grep -v git | xargs sed -i 's/template/{shortname}/g' find . -type f | grep -v git | xargs sed -i 's/done/{shortname}/g'
find . -type f | grep -v git | xargs sed -i 's/Template/{Shortname}/g' find . -type f | grep -v git | xargs sed -i 's/Done/{Shortname}/g'
git remote rm origin git remote rm origin
git remote add origin {github} git remote add origin {github}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment