Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
acid-block
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
acid-block
Commits
f8faad69
Commit
f8faad69
authored
Nov 12, 2014
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Aside
PLAT-216
parent
df1a7f0c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
166 additions
and
51 deletions
+166
-51
acid/__init__.py
+1
-1
acid/acid.py
+97
-49
acid/static/css/acid.css
+5
-0
acid/static/html/aside.html.mako
+59
-0
acid/static/js/acid.js
+1
-1
setup.py
+3
-0
No files found.
acid/__init__.py
View file @
f8faad69
from
.acid
import
AcidBlock
,
AcidParentBlock
from
.acid
import
AcidBlock
,
AcidParentBlock
,
AcidAside
acid/acid.py
View file @
f8faad69
...
...
@@ -7,8 +7,8 @@ import webob
from
lazy
import
lazy
from
mako.lookup
import
TemplateLookup
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
Dict
,
Boolean
from
xblock.core
import
XBlock
,
XBlockAside
from
xblock.fields
import
Scope
,
Dict
from
xblock.fragment
import
Fragment
...
...
@@ -52,12 +52,10 @@ class FailureResponse(webob.Response):
@generate_fields
class
Acid
Block
(
XBlock
):
class
Acid
SharedMixin
(
object
):
"""
A testing block that checks the behavior of the container.
"""
has_children
=
False
SUCCESS_CLASS
=
'fa fa-check-square-o fa-lg pass'
FAILURE_CLASS
=
'fa fa-times fa-lg fail'
ERROR_CLASS
=
'fa fa-exclamation-triangle fa-lg error'
...
...
@@ -84,13 +82,6 @@ class AcidBlock(XBlock):
"""
return
self
.
template_lookup
.
get_template
(
path
)
.
render_unicode
(
**
kwargs
)
@lazy
def
parent_value
(
self
):
"""
This value is used to test that AcidBlock are visible to their parents.
"""
return
random
.
randint
(
0
,
9999
)
def
resource_string
(
self
,
path
):
"""Handy helper for getting resources from our kit."""
data
=
pkg_resources
.
resource_string
(
__name__
,
path
)
...
...
@@ -132,43 +123,6 @@ class AcidBlock(XBlock):
'handler_url'
:
self
.
runtime
.
handler_url
(
self
,
'check_storage'
,
suffix
,
query
)
}
def
fallback_view
(
self
,
view_name
,
context
=
None
):
# pylint: disable=W0613
"""
This view is used by the Acid XBlock to test various features of
the runtime it is contained in
"""
scopes
=
(
scope
for
scope
in
Scope
.
scopes
()
if
(
view_name
not
in
self
.
enabled_fields
or
scope
.
name
in
self
.
enabled_fields
[
view_name
])
)
scope_test_contexts
=
[]
for
scope
in
scopes
:
try
:
scope_test_contexts
.
append
(
self
.
setup_storage
(
scope
.
name
))
except
Exception
:
logging
.
warning
(
'Unable to use scope in acid test'
,
exc_info
=
True
)
frag
=
Fragment
(
self
.
render_template
(
'html/acid.html.mako'
,
error_class
=
self
.
ERROR_CLASS
,
success_class
=
self
.
SUCCESS_CLASS
,
failure_class
=
self
.
FAILURE_CLASS
,
unknown_class
=
self
.
UNKNOWN_CLASS
,
storage_tests
=
scope_test_contexts
,
local_resource_url
=
self
.
runtime
.
local_resource_url
(
self
,
'public/test_data.json'
),
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/jquery.ajaxq-0.0.1.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid_update_status.js'
))
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid.js'
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/acid.css"
))
frag
.
add_css_url
(
'//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'
)
frag
.
initialize_js
(
'AcidBlock'
)
return
frag
@XBlock.handler
def
check_storage
(
self
,
request
,
suffix
=
''
):
"""
...
...
@@ -227,6 +181,57 @@ class AcidBlock(XBlock):
return
SuccessResponse
(
self
.
setup_storage
(
scope
))
class
AcidBlock
(
XBlock
,
AcidSharedMixin
):
"""
A testing block that checks the behavior of the container. The XBlock specific aspects
"""
has_children
=
False
@lazy
def
parent_value
(
self
):
"""
This value is used to test that AcidBlock are visible to their parents.
"""
return
random
.
randint
(
0
,
9999
)
def
fallback_view
(
self
,
view_name
,
context
=
None
):
# pylint: disable=W0613
"""
This view is used by the Acid XBlock to test various features of
the runtime it is contained in
"""
scopes
=
(
scope
for
scope
in
Scope
.
scopes
()
if
(
view_name
not
in
self
.
enabled_fields
or
scope
.
name
in
self
.
enabled_fields
[
view_name
])
)
scope_test_contexts
=
[]
for
scope
in
scopes
:
try
:
scope_test_contexts
.
append
(
self
.
setup_storage
(
scope
.
name
))
except
Exception
:
logging
.
warning
(
'Unable to use scope in acid test'
,
exc_info
=
True
)
frag
=
Fragment
(
self
.
render_template
(
'html/acid.html.mako'
,
error_class
=
self
.
ERROR_CLASS
,
success_class
=
self
.
SUCCESS_CLASS
,
failure_class
=
self
.
FAILURE_CLASS
,
unknown_class
=
self
.
UNKNOWN_CLASS
,
storage_tests
=
scope_test_contexts
,
local_resource_url
=
self
.
runtime
.
local_resource_url
(
self
,
'public/test_data.json'
),
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/jquery.ajaxq-0.0.1.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid_update_status.js'
))
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid.js'
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/acid.css"
))
frag
.
add_css_url
(
'//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'
)
frag
.
initialize_js
(
'AcidBlock'
)
return
frag
@staticmethod
def
workbench_scenarios
():
"""A canned scenario for display in the workbench."""
...
...
@@ -241,6 +246,49 @@ class AcidBlock(XBlock):
]
class
AcidAside
(
XBlockAside
,
AcidSharedMixin
):
"""
A testing aside
"""
@XBlockAside.aside_for
(
'student_view'
)
def
aside_view
(
self
,
block
,
context
=
None
):
"""
This view is used by the Acid Aside to test various features of
the runtime it is contained in
"""
scopes
=
(
scope
for
scope
in
Scope
.
scopes
()
if
scope
.
name
in
self
.
enabled_fields
[
'student_view'
]
)
scope_test_contexts
=
[]
for
scope
in
scopes
:
try
:
scope_test_contexts
.
append
(
self
.
setup_storage
(
scope
.
name
))
except
Exception
:
logging
.
warning
(
'Unable to use scope in acid test'
,
exc_info
=
True
)
frag
=
Fragment
(
self
.
render_template
(
'html/aside.html.mako'
,
usage_id
=
block
.
scope_ids
.
usage_id
,
error_class
=
self
.
ERROR_CLASS
,
success_class
=
self
.
SUCCESS_CLASS
,
failure_class
=
self
.
FAILURE_CLASS
,
unknown_class
=
self
.
UNKNOWN_CLASS
,
storage_tests
=
scope_test_contexts
,
local_resource_url
=
self
.
runtime
.
local_resource_url
(
self
,
'public/test_data.json'
),
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/jquery.ajaxq-0.0.1.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid_update_status.js'
))
frag
.
add_javascript
(
self
.
resource_string
(
'static/js/acid.js'
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/acid.css"
))
frag
.
add_css_url
(
'//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'
)
frag
.
initialize_js
(
'AcidBlock'
)
return
frag
@generate_fields
class
AcidParentBlock
(
AcidBlock
):
"""
...
...
acid/static/css/acid.css
View file @
f8faad69
...
...
@@ -2,6 +2,11 @@
padding-left
:
30px
;
}
.aside-block
{
padding-left
:
8px
;
font-size
:
smaller
;
}
.fail
{
color
:
red
;
}
...
...
acid/static/html/aside.html.mako
0 → 100644
View file @
f8faad69
<%! import json %>
<div class="aside-block"
data-success-class="${success_class}"
data-failure-class="${failure_class}"
data-error-class="${error_class}"
data-unknown-class="${unknown_class}"
data-local-resource-url="${local_resource_url}"
>
<h6>Acid Aside for ${usage_id}</h6>
<p>JS init function run:
<span class="js-init-run">
<i class="${unknown_class}"></i>
</span>
</p>
<p>Resource Url Test:
<span class="local-resource-test">
<i class="${unknown_class}"></i>
</span>
</p>
<table class='storage-tests'>
<tr>
<th>Scope</th>
<th>Server-side<br>handler_url<br>returned</th>
<th>Server-side<br>handler_url<br>succeeded</th>
<th>Client-side<br>handler_url<br>returned</th>
<th>Client-side<br>handler_url<br>succeeded</th>
</tr>
% for test in storage_tests:
<tr class="scope-storage-test scope-${test['scope']} ${loop.cycle('', 'alt')}"
data-handler-url="${test['handler_url']}"
data-scope="${test['scope']}"
data-value="${test['value']}"
>
<td>${test['scope']}</td>
<td>
<span class="server-storage-test-returned">
<i class="${unknown_class}"></i>
</span>
</td>
<td>
<span class="server-storage-test-succeeded">
<i class="${unknown_class}"></i>
</span>
</td>
<td>
<span class="client-storage-test-returned">
<i class="${unknown_class}"></i>
</span>
</td>
<td>
<span class="client-storage-test-succeeded">
<i class="${unknown_class}"></i>
</span>
</td>
</tr>
% endfor
</table>
</div>
acid/static/js/acid.js
View file @
f8faad69
...
...
@@ -2,7 +2,7 @@
function
AcidBlock
(
runtime
,
element
)
{
function
acidData
(
key
)
{
return
$
(
'.acid-block'
,
element
).
data
(
key
);
return
$
(
'.acid-block
, .aside-block
'
,
element
).
data
(
key
);
}
function
mark
(
result
,
selector
,
subelem
,
msg
)
{
...
...
setup.py
View file @
f8faad69
...
...
@@ -31,6 +31,9 @@ setup(
'acid = acid:AcidBlock'
,
'acid_parent = acid:AcidParentBlock'
,
],
'xblock_asides.v1'
:
[
'acid_aside = acid:AcidAside'
,
]
},
package_data
=
package_data
(
"acid"
,
[
"static"
,
"public"
]),
)
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