Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
cdfae5a0
Commit
cdfae5a0
authored
Jun 20, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #128 from MITx/victor/show_student_state
Victor/show student state
parents
21508534
5e7535fb
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
110 additions
and
12 deletions
+110
-12
common/lib/xmodule/capa_module.py
+1
-1
common/lib/xmodule/progress.py
+34
-0
common/lib/xmodule/seq_module.py
+2
-2
common/lib/xmodule/tests.py
+16
-0
common/lib/xmodule/video_module.py
+21
-4
lms/djangoapps/courseware/module_render.py
+0
-0
lms/static/coffee/src/modules/problem.coffee
+1
-1
lms/static/coffee/src/modules/sequence.coffee
+15
-4
lms/static/sass/courseware/_sequence-nav.scss
+20
-0
No files found.
common/lib/xmodule/capa_module.py
View file @
cdfae5a0
...
@@ -298,7 +298,7 @@ class Module(XModule):
...
@@ -298,7 +298,7 @@ class Module(XModule):
after
=
self
.
get_progress
()
after
=
self
.
get_progress
()
d
.
update
({
d
.
update
({
'progress_changed'
:
after
!=
before
,
'progress_changed'
:
after
!=
before
,
'progress
'
:
after
.
ternary_str
(
),
'progress
_status'
:
Progress
.
to_js_status_str
(
after
),
})
})
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
return
json
.
dumps
(
d
,
cls
=
ComplexEncoder
)
...
...
common/lib/xmodule/progress.py
View file @
cdfae5a0
'''
'''
Progress class for modules. Represents where a student is in a module.
Progress class for modules. Represents where a student is in a module.
Useful things to know:
- Use Progress.to_js_status_str() to convert a progress into a simple
status string to pass to js.
- Use Progress.to_js_detail_str() to convert a progress into a more detailed
string to pass to js.
In particular, these functions have a canonical handing of None.
For most subclassing needs, you should only need to reimplement
frac() and __str__().
'''
'''
from
collections
import
namedtuple
from
collections
import
namedtuple
...
@@ -124,3 +135,26 @@ class Progress(object):
...
@@ -124,3 +135,26 @@ class Progress(object):
(
n
,
d
)
=
a
.
frac
()
(
n
,
d
)
=
a
.
frac
()
(
n2
,
d2
)
=
b
.
frac
()
(
n2
,
d2
)
=
b
.
frac
()
return
Progress
(
n
+
n2
,
d
+
d2
)
return
Progress
(
n
+
n2
,
d
+
d2
)
@staticmethod
def
to_js_status_str
(
progress
):
'''
Return the "status string" version of the passed Progress
object that should be passed to js. Use this function when
sending Progress objects to js to limit dependencies.
'''
if
progress
is
None
:
return
"NA"
return
progress
.
ternary_str
()
@staticmethod
def
to_js_detail_str
(
progress
):
'''
Return the "detail string" version of the passed Progress
object that should be passed to js. Use this function when
passing Progress objects to js to limit dependencies.
'''
if
progress
is
None
:
return
"NA"
return
str
(
progress
)
common/lib/xmodule/seq_module.py
View file @
cdfae5a0
...
@@ -74,8 +74,8 @@ class Module(XModule):
...
@@ -74,8 +74,8 @@ class Module(XModule):
for
contents
,
title
,
progress
in
zip
(
self
.
contents
,
titles
,
progresses
):
for
contents
,
title
,
progress
in
zip
(
self
.
contents
,
titles
,
progresses
):
contents
[
'title'
]
=
title
contents
[
'title'
]
=
title
contents
[
'progress_st
r'
]
=
str
(
progress
)
if
progress
is
not
None
else
""
contents
[
'progress_st
atus'
]
=
Progress
.
to_js_status_str
(
progress
)
contents
[
'progress_
stat'
]
=
progress
.
ternary_str
()
if
progress
is
not
None
else
""
contents
[
'progress_
detail'
]
=
Progress
.
to_js_detail_str
(
progress
)
for
(
content
,
element_class
)
in
zip
(
self
.
contents
,
child_classes
):
for
(
content
,
element_class
)
in
zip
(
self
.
contents
,
child_classes
):
new_class
=
'other'
new_class
=
'other'
...
...
common/lib/xmodule/tests.py
View file @
cdfae5a0
...
@@ -568,6 +568,22 @@ class ProgressTest(unittest.TestCase):
...
@@ -568,6 +568,22 @@ class ProgressTest(unittest.TestCase):
self
.
assertEqual
(
self
.
half_done
.
ternary_str
(),
"in_progress"
)
self
.
assertEqual
(
self
.
half_done
.
ternary_str
(),
"in_progress"
)
self
.
assertEqual
(
self
.
done
.
ternary_str
(),
"done"
)
self
.
assertEqual
(
self
.
done
.
ternary_str
(),
"done"
)
def
test_to_js_status
(
self
):
'''Test the Progress.to_js_status_str() method'''
self
.
assertEqual
(
Progress
.
to_js_status_str
(
self
.
not_started
),
"none"
)
self
.
assertEqual
(
Progress
.
to_js_status_str
(
self
.
half_done
),
"in_progress"
)
self
.
assertEqual
(
Progress
.
to_js_status_str
(
self
.
done
),
"done"
)
self
.
assertEqual
(
Progress
.
to_js_status_str
(
None
),
"NA"
)
def
test_to_js_detail_str
(
self
):
'''Test the Progress.to_js_detail_str() method'''
f
=
Progress
.
to_js_detail_str
for
p
in
(
self
.
not_started
,
self
.
half_done
,
self
.
done
):
self
.
assertEqual
(
f
(
p
),
str
(
p
))
# But None should be encoded as NA
self
.
assertEqual
(
f
(
None
),
"NA"
)
def
test_add
(
self
):
def
test_add
(
self
):
'''Test the Progress.add_counts() method'''
'''Test the Progress.add_counts() method'''
p
=
Progress
(
0
,
2
)
p
=
Progress
(
0
,
2
)
...
...
common/lib/xmodule/video_module.py
View file @
cdfae5a0
...
@@ -4,6 +4,7 @@ import logging
...
@@ -4,6 +4,7 @@ import logging
from
lxml
import
etree
from
lxml
import
etree
from
x_module
import
XModule
,
XModuleDescriptor
from
x_module
import
XModule
,
XModuleDescriptor
from
progress
import
Progress
log
=
logging
.
getLogger
(
"mitx.courseware.modules"
)
log
=
logging
.
getLogger
(
"mitx.courseware.modules"
)
...
@@ -15,17 +16,32 @@ class Module(XModule):
...
@@ -15,17 +16,32 @@ class Module(XModule):
video_time
=
0
video_time
=
0
def
handle_ajax
(
self
,
dispatch
,
get
):
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
Handle ajax calls to this video.
TODO (vshnayder): This is not being called right now, so the position
is not being saved.
'''
log
.
debug
(
u"GET {0}"
.
format
(
get
))
log
.
debug
(
u"GET {0}"
.
format
(
get
))
log
.
debug
(
u"DISPATCH {0}"
.
format
(
dispatch
))
log
.
debug
(
u"DISPATCH {0}"
.
format
(
dispatch
))
if
dispatch
==
'goto_position'
:
if
dispatch
==
'goto_position'
:
self
.
position
=
int
(
float
(
get
[
'position'
]))
self
.
position
=
int
(
float
(
get
[
'position'
]))
log
.
debug
(
u"NEW POSITION {0}"
.
format
(
self
.
position
))
log
.
info
(
u"NEW POSITION {0}"
.
format
(
self
.
position
))
return
json
.
dumps
({
'success'
:
True
})
return
json
.
dumps
({
'success'
:
True
})
raise
Http404
()
raise
Http404
()
def
get_progress
(
self
):
''' TODO (vshnayder): Get and save duration of youtube video, then return
fraction watched.
(Be careful to notice when video link changes and update)
For now, we have no way of knowing if the video has even been watched, so
just return None.
'''
return
None
def
get_state
(
self
):
def
get_state
(
self
):
log
.
debug
(
u"STATE POSITION {0}"
.
format
(
self
.
position
))
log
.
debug
(
u"STATE POSITION {0}"
.
format
(
self
.
position
))
return
json
.
dumps
({
'position'
:
self
.
position
})
return
json
.
dumps
({
'position'
:
self
.
position
})
@classmethod
@classmethod
def
get_xml_tags
(
c
):
def
get_xml_tags
(
c
):
...
@@ -41,15 +57,16 @@ class Module(XModule):
...
@@ -41,15 +57,16 @@ class Module(XModule):
'id'
:
self
.
item_id
,
'id'
:
self
.
item_id
,
'position'
:
self
.
position
,
'position'
:
self
.
position
,
'name'
:
self
.
name
,
'name'
:
self
.
name
,
'annotations'
:
self
.
annotations
'annotations'
:
self
.
annotations
,
})
})
def
__init__
(
self
,
system
,
xml
,
item_id
,
state
=
None
):
def
__init__
(
self
,
system
,
xml
,
item_id
,
state
=
None
):
XModule
.
__init__
(
self
,
system
,
xml
,
item_id
,
state
)
XModule
.
__init__
(
self
,
system
,
xml
,
item_id
,
state
)
xmltree
=
etree
.
fromstring
(
xml
)
xmltree
=
etree
.
fromstring
(
xml
)
self
.
youtube
=
xmltree
.
get
(
'youtube'
)
self
.
youtube
=
xmltree
.
get
(
'youtube'
)
self
.
name
=
xmltree
.
get
(
'name'
)
self
.
name
=
xmltree
.
get
(
'name'
)
self
.
position
=
0
self
.
position
=
0
if
state
is
not
None
:
if
state
is
not
None
:
state
=
json
.
loads
(
state
)
state
=
json
.
loads
(
state
)
if
'position'
in
state
:
if
'position'
in
state
:
...
...
lms/djangoapps/courseware/module_render.py
View file @
cdfae5a0
lms/static/coffee/src/modules/problem.coffee
View file @
cdfae5a0
...
@@ -19,7 +19,7 @@ class @Problem
...
@@ -19,7 +19,7 @@ class @Problem
update_progress
:
(
response
)
=>
update_progress
:
(
response
)
=>
if
response
.
progress_changed
if
response
.
progress_changed
@
element
.
attr
progress
:
response
.
progress
@
element
.
attr
progress
:
response
.
progress
_status
@
element
.
trigger
(
'progressChanged'
)
@
element
.
trigger
(
'progressChanged'
)
render
:
(
content
)
->
render
:
(
content
)
->
...
...
lms/static/coffee/src/modules/sequence.coffee
View file @
cdfae5a0
...
@@ -20,8 +20,16 @@ class @Sequence
...
@@ -20,8 +20,16 @@ class @Sequence
$
(
'.problems-wrapper'
).
bind
'progressChanged'
,
@
updateProgress
$
(
'.problems-wrapper'
).
bind
'progressChanged'
,
@
updateProgress
mergeProgress
:
(
p1
,
p2
)
->
mergeProgress
:
(
p1
,
p2
)
->
# if either is "NA", return the other one
if
p1
==
"NA"
return
p2
if
p2
==
"NA"
return
p1
# Both real progresses
if
p1
==
"done"
and
p2
==
"done"
if
p1
==
"done"
and
p2
==
"done"
return
"done"
return
"done"
# not done, so if any progress on either, in_progress
# not done, so if any progress on either, in_progress
w1
=
p1
==
"done"
or
p1
==
"in_progress"
w1
=
p1
==
"done"
or
p1
==
"in_progress"
w2
=
p2
==
"done"
or
p2
==
"in_progress"
w2
=
p2
==
"done"
or
p2
==
"in_progress"
...
@@ -31,7 +39,7 @@ class @Sequence
...
@@ -31,7 +39,7 @@ class @Sequence
return
"none"
return
"none"
updateProgress
:
=>
updateProgress
:
=>
new_progress
=
"
none
"
new_progress
=
"
NA
"
_this
=
this
_this
=
this
$
(
'.problems-wrapper'
).
each
(
index
)
->
$
(
'.problems-wrapper'
).
each
(
index
)
->
progress
=
$
(
this
).
attr
'progress'
progress
=
$
(
this
).
attr
'progress'
...
@@ -41,6 +49,7 @@ class @Sequence
...
@@ -41,6 +49,7 @@ class @Sequence
@
setProgress
(
new_progress
,
@
link_for
(
@
position
))
@
setProgress
(
new_progress
,
@
link_for
(
@
position
))
setProgress
:
(
progress
,
element
)
->
setProgress
:
(
progress
,
element
)
->
# If progress is "NA", don't add any css class
element
.
removeClass
(
'progress-none'
)
element
.
removeClass
(
'progress-none'
)
.
removeClass
(
'progress-some'
)
.
removeClass
(
'progress-some'
)
.
removeClass
(
'progress-done'
)
.
removeClass
(
'progress-done'
)
...
@@ -53,10 +62,12 @@ class @Sequence
...
@@ -53,10 +62,12 @@ class @Sequence
$
.
each
@
elements
,
(
index
,
item
)
=>
$
.
each
@
elements
,
(
index
,
item
)
=>
link
=
$
(
'<a>'
).
attr
class
:
"seq_
#{
item
.
type
}
_inactive"
,
'data-element'
:
index
+
1
link
=
$
(
'<a>'
).
attr
class
:
"seq_
#{
item
.
type
}
_inactive"
,
'data-element'
:
index
+
1
title
=
$
(
'<p>'
).
html
(
item
.
title
)
title
=
$
(
'<p>'
).
html
(
item
.
title
)
# TODO: add item.progress_str either to the title or somewhere else.
# TODO (vshnayder): add item.progress_detail either to the title or somewhere else.
# Make sure it gets updated after ajax calls
# Make sure it gets updated after ajax calls.
# implementation note: will need to figure out how to handle combining detail
# statuses of multiple modules in js.
list_item
=
$
(
'<li>'
).
append
(
link
.
append
(
title
))
list_item
=
$
(
'<li>'
).
append
(
link
.
append
(
title
))
@
setProgress
item
.
progress_stat
,
link
@
setProgress
item
.
progress_stat
us
,
link
@
$
(
'#sequence-list'
).
append
list_item
@
$
(
'#sequence-list'
).
append
list_item
...
...
lms/static/sass/courseware/_sequence-nav.scss
View file @
cdfae5a0
...
@@ -66,6 +66,26 @@ nav.sequence-nav {
...
@@ -66,6 +66,26 @@ nav.sequence-nav {
@include
transition
(
all
,
.4s
,
$ease-in-out-quad
);
@include
transition
(
all
,
.4s
,
$ease-in-out-quad
);
width
:
100%
;
width
:
100%
;
&
.progress
{
border-bottom-style
:
solid
;
border-bottom-width
:
4px
;
}
&
.progress-none
{
@extend
.progress
;
border-bottom-color
:
red
;
}
&
.progress-some
{
@extend
.progress
;
border-bottom-color
:
yellow
;
}
&
.progress-done
{
@extend
.progress
;
border-bottom-color
:
green
;
}
//video
//video
&
.seq_video_inactive
{
&
.seq_video_inactive
{
@extend
.inactive
;
@extend
.inactive
;
...
...
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