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
8c959528
Commit
8c959528
authored
Apr 23, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a last_modified method to FieldDataCache
parent
3430024d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
6 deletions
+41
-6
lms/djangoapps/courseware/model_data.py
+37
-0
lms/djangoapps/mobile_api/users/views.py
+4
-6
No files found.
lms/djangoapps/courseware/model_data.py
View file @
8c959528
...
...
@@ -282,6 +282,23 @@ class DjangoOrmFieldCache(object):
"""
return
self
.
_cache_key_for_kvs_key
(
kvs_key
)
in
self
.
_cache
@contract
(
kvs_key
=
DjangoKeyValueStore
.
Key
,
returns
=
"datetime|None"
)
def
last_modified
(
self
,
kvs_key
):
"""
Return when the supplied field was changed.
Arguments:
kvs_key (`DjangoKeyValueStore.Key`): The field value to delete
Returns: datetime if there was a modified date, or None otherwise
"""
field_object
=
self
.
_cache
.
get
(
self
.
_cache_key_for_kvs_key
(
kvs_key
))
if
field_object
is
None
:
return
None
else
:
return
field_object
.
modified
@contract
(
kvs_key
=
DjangoKeyValueStore
.
Key
)
def
_set_field_value
(
self
,
field_object
,
kvs_key
,
value
):
field_object
.
value
=
json
.
dumps
(
value
)
...
...
@@ -933,3 +950,23 @@ class FieldDataCache(object):
assert
user_id
==
self
.
user
.
id
assert
usage_key
.
course_key
==
self
.
course_id
self
.
cache
[
Scope
.
user_state
]
.
set_score
(
user_id
,
usage_key
,
score
,
max_score
)
@contract
(
key
=
DjangoKeyValueStore
.
Key
,
returns
=
"datetime|None"
)
def
last_modified
(
self
,
key
):
"""
Return when the supplied field was changed.
Arguments:
key (`DjangoKeyValueStore.Key`): The field value to delete
Returns: datetime if there was a modified date, or None otherwise
"""
if
key
.
scope
.
user
==
UserScope
.
ONE
and
not
self
.
user
.
is_anonymous
():
# If we're getting user data, we expect that the key matches the
# user we were constructed for.
assert
key
.
user_id
==
self
.
user
.
id
if
key
.
scope
not
in
self
.
cache
:
return
None
return
self
.
cache
[
key
.
scope
]
.
last_modified
(
key
)
lms/djangoapps/mobile_api/users/views.py
View file @
8c959528
...
...
@@ -149,12 +149,10 @@ class UserCourseStatus(views.APIView):
block_scope_id
=
course
.
location
,
field_name
=
None
)
student_module
=
field_data_cache
.
find
(
key
)
if
student_module
:
original_store_date
=
student_module
.
modified
if
modification_date
<
original_store_date
:
# old modification date so skip update
return
self
.
_get_course_info
(
request
,
course
)
original_store_date
=
field_data_cache
.
last_modified
(
key
)
if
original_store_date
is
not
None
and
modification_date
<
original_store_date
:
# old modification date so skip update
return
self
.
_get_course_info
(
request
,
course
)
save_positions_recursively_up
(
request
.
user
,
request
,
field_data_cache
,
module
)
return
self
.
_get_course_info
(
request
,
course
)
...
...
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