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
18855649
Commit
18855649
authored
May 29, 2014
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working version, hopefully with grading. Needs styling
parent
42fc0d81
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
14 deletions
+42
-14
README.md
+7
-2
done/done.py
+9
-2
done/static/html/done.html
+16
-8
done/static/js/src/done.js
+10
-2
No files found.
README.md
View file @
18855649
...
@@ -15,4 +15,10 @@ and this was on a short anough timeline that I did not have a chance
...
@@ -15,4 +15,10 @@ and this was on a short anough timeline that I did not have a chance
to reach out to FutureLearn for permission. This is probably worth
to reach out to FutureLearn for permission. This is probably worth
doing -- it'd be to the benefit of learners on all platforms and the
doing -- it'd be to the benefit of learners on all platforms and the
industry as a whole if we could aim for consistency of experience
industry as a whole if we could aim for consistency of experience
between platforms where convenient.
between platforms where convenient.
\ No newline at end of file
Limitations:
*
We can only have one of these per page. I'm waiting on XBlocks to
have a more mature client-side framework, since right now, managing
multiple per page would be messy.
done/done.py
View file @
18855649
...
@@ -14,7 +14,7 @@ class DoneXBlock(XBlock):
...
@@ -14,7 +14,7 @@ class DoneXBlock(XBlock):
# Fields are defined on the class. You can access them in your code as
# Fields are defined on the class. You can access them in your code as
# self.<fieldname>.
# self.<fieldname>.
src
=
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
...
@@ -27,7 +27,13 @@ class DoneXBlock(XBlock):
...
@@ -27,7 +27,13 @@ class DoneXBlock(XBlock):
@XBlock.json_handler
@XBlock.json_handler
def
toggle_button
(
self
,
data
,
suffix
=
''
):
def
toggle_button
(
self
,
data
,
suffix
=
''
):
print
data
self
.
done
=
data
[
'done'
]
if
data
[
'done'
]:
grade
=
1
else
:
grade
=
0
self
.
runtime
.
publish
(
self
,
'grade'
,
{
'value'
:
grade
,
'max_value'
:
1
})
return
{}
return
{}
...
@@ -42,6 +48,7 @@ class DoneXBlock(XBlock):
...
@@ -42,6 +48,7 @@ class DoneXBlock(XBlock):
#frag.add_javascript_url("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")
#frag.add_javascript_url("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")
frag
.
add_javascript_url
(
"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"
)
frag
.
add_javascript_url
(
"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"
)
frag
.
add_css
(
self
.
resource_string
(
"static/css/done.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/done.css"
))
frag
.
add_javascript
(
"var done_done = "
+
(
"true"
if
self
.
done
else
"false"
)
+
";"
)
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/done.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/done.js"
))
frag
.
initialize_js
(
'DoneXBlock'
)
frag
.
initialize_js
(
'DoneXBlock'
)
return
frag
return
frag
...
...
done/static/html/done.html
View file @
18855649
<div
class=
"done_block"
>
<div
class=
"done_block"
>
<div
style=
"width:
150px
"
>
<div
style=
"width:
200px; height:30px;
"
>
<div
class=
"windshield
_on windshield
"
>
<div
class=
"windshield"
>
<div
class=
"wipe wipe_o
n"
>
Wipe on
</div>
<div
class=
"wipe wipe_o
ff"
>
Undo
</div>
<div
class=
"wiper"
>
#
</div>
<div
class=
"wiper"
>
<span
class=
"ui-icon ui-icon-circle-plus"
></span>
</div>
<div
class=
"wipe wipe_o
ff"
>
Wipe off
</div>
<div
class=
"wipe wipe_o
n"
>
Mark as complete
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -13,24 +13,31 @@
...
@@ -13,24 +13,31 @@
-webkit-transition
:
width
0.2s
;
-webkit-transition
:
width
0.2s
;
transition
:
width
0.2s
;
transition
:
width
0.2s
;
text-align
:
center
;
text-align
:
center
;
vertical-align
:
middle
;
}
}
.windshield
{
.windshield
_animated
{
-webkit-transition
:
background-color
0.2s
;
-webkit-transition
:
background-color
0.2s
;
transition
:
background-color
0.2s
;
transition
:
background-color
0.2s
;
}
}
.windshield
{
height
:
100%
;
}
.windshield_on
{
.windshield_on
{
background-color
:
#700000
;
background-color
:
#700000
;
color
:
#4BA1A1
;
}
}
.windshield_off
{
.windshield_off
{
background-color
:
#048904
;
background-color
:
#048904
;
color
:
#D59763
;
}
}
.windshield_on
.wipe_on
{
.windshield_on
.wipe_on
{
display
:
inline-block
;
display
:
inline-block
;
width
:
6
0%
;
width
:
8
0%
;
overflow
:
hidden
;
overflow
:
hidden
;
text-overflow
:
clip
;
text-overflow
:
clip
;
white-space
:
nowrap
;
white-space
:
nowrap
;
...
@@ -47,11 +54,12 @@
...
@@ -47,11 +54,12 @@
.wiper
{
.wiper
{
display
:
inline-block
;
display
:
inline-block
;
width
:
7%
;
width
:
7%
;
vertical-align
:
middle
;
}
}
.windshield_off
.wipe_off
{
.windshield_off
.wipe_off
{
display
:
inline-block
;
display
:
inline-block
;
width
:
6
0%
;
width
:
8
0%
;
overflow
:
hidden
;
overflow
:
hidden
;
text-overflow
:
clip
;
text-overflow
:
clip
;
white-space
:
nowrap
;
white-space
:
nowrap
;
...
...
done/static/js/src/done.js
View file @
18855649
...
@@ -10,14 +10,22 @@ function DoneXBlock(runtime, element) {
...
@@ -10,14 +10,22 @@ function DoneXBlock(runtime, element) {
});
});
$
(
function
(
$
)
{
$
(
function
(
$
)
{
if
(
done_done
)
{
$
(
'.windshield'
).
addClass
(
"windshield_off"
).
removeClass
(
"windshield_on"
);
}
else
{
$
(
'.windshield'
).
addClass
(
"windshield_on"
).
removeClass
(
"windshield_off"
);
}
// Don't have animations on for above class changes. This is probably not necessary. I
// was seeing animations on page load. I did a few things to fix it. The line below
// wasn't the one that fixed it, but I decided to keep it anyways.
$
(
'.windshield'
).
addClass
(
"windshield_animated"
)
$
(
'.windshield'
).
click
(
function
(){
$
(
'.windshield'
).
click
(
function
(){
$
(
this
).
toggleClass
(
"windshield_on"
);
$
(
this
).
toggleClass
(
"windshield_on"
);
$
(
this
).
toggleClass
(
"windshield_off"
);
$
(
this
).
toggleClass
(
"windshield_off"
);
console
.
log
(
$
(
this
).
hasClass
(
"windshield_on"
));
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
handlerUrl
,
url
:
handlerUrl
,
data
:
JSON
.
stringify
({
"
hello"
:
"world"
}),
data
:
JSON
.
stringify
({
"
done"
:
$
(
this
).
hasClass
(
"windshield_off"
)
}),
success
:
updateCount
success
:
updateCount
});
});
...
...
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