Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DoneXBlock
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
DoneXBlock
Commits
c6444920
Commit
c6444920
authored
Nov 23, 2015
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8, pylint, response for testability
parent
ad602de1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
38 deletions
+55
-38
done/done.py
+46
-37
done/static/html/studioview.html
+9
-1
No files found.
done/done.py
View file @
c6444920
...
@@ -12,10 +12,11 @@ try:
...
@@ -12,10 +12,11 @@ try:
except
ImportError
:
except
ImportError
:
class
tracker
(
object
):
# pylint: disable=invalid-name
class
tracker
(
object
):
# pylint: disable=invalid-name
"""
"""
Define tracker if eventtracking cannot be imported. This is a workaround
Define tracker if eventtracking cannot be imported. This is a
so that the code works in both edx-platform and XBlock workbench (the latter
workaround so that the code works in both edx-platform and
of which does not support event emission). This should be replaced with XBlock's
XBlock workbench (the latter of which does not support event
emit(), but at present, emit() is broken.
emission). This should be replaced with XBlock's emit(), but
at present, emit() is broken.
"""
"""
def
__init__
(
self
):
def
__init__
(
self
):
""" Do nothing """
""" Do nothing """
...
@@ -26,36 +27,39 @@ except ImportError:
...
@@ -26,36 +27,39 @@ except ImportError:
""" In workbench, do nothing for event emission """
""" In workbench, do nothing for event emission """
pass
pass
def
resource_string
(
path
):
"""Handy helper for getting resources from our kit."""
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
return
data
.
decode
(
"utf8"
)
class
DoneXBlock
(
XBlock
):
class
DoneXBlock
(
XBlock
):
"""
"""
Show a toggle which lets students mark things as done.
Show a toggle which lets students mark things as done.
"""
"""
done
=
Boolean
(
done
=
Boolean
(
scope
=
Scope
.
user_state
,
scope
=
Scope
.
user_state
,
help
=
"Is the student done?"
,
help
=
"Is the student done?"
,
default
=
False
default
=
False
)
)
align
=
String
(
align
=
String
(
scope
=
Scope
.
settings
,
scope
=
Scope
.
settings
,
help
=
"Align left/right/center"
,
help
=
"Align left/right/center"
,
default
=
"left"
default
=
"left"
)
)
has_score
=
True
has_score
=
True
def
resource_string
(
self
,
path
):
# pylint: disable=unused-argument
"""Handy helper for getting resources from our kit."""
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
return
data
.
decode
(
"utf8"
)
@XBlock.json_handler
@XBlock.json_handler
def
toggle_button
(
self
,
data
,
suffix
=
''
):
def
toggle_button
(
self
,
data
,
suffix
=
''
):
"""
"""
Ajax call when the button is clicked. Input is a JSON dictionary
Ajax call when the button is clicked. Input is a JSON dictionary
with one boolean field: `done`. This will save this in the
with one boolean field: `done`. This will save this in the
XBlock field, and then issue an appropriate grade.
XBlock field, and then issue an appropriate grade.
"""
"""
self
.
done
=
data
[
'done'
]
self
.
done
=
data
[
'done'
]
if
data
[
'done'
]:
if
data
[
'done'
]:
...
@@ -67,21 +71,24 @@ class DoneXBlock(XBlock):
...
@@ -67,21 +71,24 @@ class DoneXBlock(XBlock):
# Above should emit a similar event. Once it does, we should be
# Above should emit a similar event. Once it does, we should be
# able to eliminate this
# able to eliminate this
tracker
.
emit
(
"edx.done.toggle"
,
{
'done'
:
self
.
done
})
tracker
.
emit
(
"edx.done.toggle"
,
{
'done'
:
self
.
done
})
return
{}
return
{
'state'
:
self
.
done
}
def
student_view
(
self
,
context
=
None
):
def
student_view
(
self
,
context
=
None
):
# pylint: disable=unused-argument
"""
"""
The primary view of the DoneXBlock, shown to students
The primary view of the DoneXBlock, shown to students
when viewing courses.
when viewing courses.
"""
"""
html_resource
=
self
.
resource_string
(
"static/html/done.html"
)
html_resource
=
resource_string
(
"static/html/done.html"
)
html
=
html_resource
.
format
(
done
=
self
.
done
,
html
=
html_resource
.
format
(
done
=
self
.
done
,
id
=
uuid
.
uuid1
(
0
))
id
=
uuid
.
uuid1
(
0
))
unchecked_png
=
self
.
runtime
.
local_resource_url
(
self
,
'public/check-empty.png'
)
(
unchecked_png
,
checked_png
)
=
(
checked_png
=
self
.
runtime
.
local_resource_url
(
self
,
'public/check-full.png'
)
self
.
runtime
.
local_resource_url
(
self
,
x
)
for
x
in
(
'public/check-empty.png'
,
'public/check-full.png'
)
)
frag
=
Fragment
(
html
)
frag
=
Fragment
(
html
)
frag
.
add_css
(
self
.
resource_string
(
"static/css/done.css"
))
frag
.
add_css
(
resource_string
(
"static/css/done.css"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/done.js"
))
frag
.
add_javascript
(
resource_string
(
"static/js/src/done.js"
))
frag
.
initialize_js
(
"DoneXBlock"
,
{
'state'
:
self
.
done
,
frag
.
initialize_js
(
"DoneXBlock"
,
{
'state'
:
self
.
done
,
'unchecked'
:
unchecked_png
,
'unchecked'
:
unchecked_png
,
'checked'
:
checked_png
,
'checked'
:
checked_png
,
...
@@ -89,7 +96,11 @@ class DoneXBlock(XBlock):
...
@@ -89,7 +96,11 @@ class DoneXBlock(XBlock):
return
frag
return
frag
def
studio_view
(
self
,
_context
=
None
):
# pylint: disable=unused-argument
def
studio_view
(
self
,
_context
=
None
):
# pylint: disable=unused-argument
frag
=
Fragment
(
pkg_resources
.
resource_string
(
"static/html/studioview.html"
))
'''
Minimal view with no configuration options giving some help text.
'''
html
=
resource_string
(
"static/html/studioview.html"
)
frag
=
Fragment
(
html
)
return
frag
return
frag
@staticmethod
@staticmethod
...
@@ -104,9 +115,11 @@ class DoneXBlock(XBlock):
...
@@ -104,9 +115,11 @@ class DoneXBlock(XBlock):
"""
),
"""
),
]
]
## Everything below is stolen from https://github.com/edx/edx-ora2/blob/master/apps/openassessment/xblock/lms_mixin.py
# Everything below is stolen from
## It's needed to keep the LMS+Studio happy.
# https://github.com/edx/edx-ora2/blob/master/apps/openassessment/
## It should be included as a mixin.
# xblock/lms_mixin.py
# It's needed to keep the LMS+Studio happy.
# It should be included as a mixin.
display_name
=
String
(
display_name
=
String
(
default
=
"Completion"
,
scope
=
Scope
.
settings
,
default
=
"Completion"
,
scope
=
Scope
.
settings
,
...
@@ -115,12 +128,14 @@ class DoneXBlock(XBlock):
...
@@ -115,12 +128,14 @@ class DoneXBlock(XBlock):
start
=
DateTime
(
start
=
DateTime
(
default
=
None
,
scope
=
Scope
.
settings
,
default
=
None
,
scope
=
Scope
.
settings
,
help
=
"ISO-8601 formatted string representing the start date of this assignment. We ignore this."
help
=
"ISO-8601 formatted string representing the start date "
"of this assignment. We ignore this."
)
)
due
=
DateTime
(
due
=
DateTime
(
default
=
None
,
scope
=
Scope
.
settings
,
default
=
None
,
scope
=
Scope
.
settings
,
help
=
"ISO-8601 formatted string representing the due date of this assignment. We ignore this."
help
=
"ISO-8601 formatted string representing the due date "
"of this assignment. We ignore this."
)
)
weight
=
Float
(
weight
=
Float
(
...
@@ -141,9 +156,3 @@ class DoneXBlock(XBlock):
...
@@ -141,9 +156,3 @@ class DoneXBlock(XBlock):
"""The maximum raw score of our problem.
"""The maximum raw score of our problem.
"""
"""
return
1
return
1
## More dummy code to keep Studio happy
def
studio_view
(
self
,
context
=
None
):
""" View for editing Instructor Tool block in Studio. """
# Display friendly message explaining that the block is not editable.
return
Fragment
(
u'<p>This block requires no configuration in Studio. A small number of advanced parameters are available via OLX.</p>'
)
done/static/html/studioview.html
View file @
c6444920
<div>
<div>
<p>
This is a very simple component with no configuration
<p>
This is a very simple component with no configuration
options. Nothing to see here... move along.
</p>
options. It is used for helping student keep track of what
portion of a course they've completed. For example, you might
place this underneath each text and video component, and students
can see in their progress page which portions are completed and
which still need to be watched or read.
</p>
<p>
It is also helpful to give students a way to sign off on having
completed something. They are less likely to skip material that
way.
</p>
<p>
<small>
(If you're a real power-user, in OLX, we do allow you to
<p>
<small>
(If you're a real power-user, in OLX, we do allow you to
add an align tag, which can left-, center-, or right-justify the
add an align tag, which can left-, center-, or right-justify the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment