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
a6a00431
Commit
a6a00431
authored
Jan 06, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use block type, rather than class names for StudentPreference field storage in LMS
parent
520822c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
lms/djangoapps/courseware/model_data.py
+3
-3
lms/djangoapps/courseware/tests/factories.py
+2
-2
lms/djangoapps/courseware/tests/test_model_data.py
+8
-8
No files found.
lms/djangoapps/courseware/model_data.py
View file @
a6a00431
...
...
@@ -142,7 +142,7 @@ class FieldDataCache(object):
return
self
.
_chunked_query
(
StudentModule
,
'module_state_key__in'
,
(
descriptor
.
location
.
url
(
)
for
descriptor
in
self
.
descriptors
),
(
str
(
descriptor
.
scope_ids
.
usage_id
)
for
descriptor
in
self
.
descriptors
),
course_id
=
self
.
course_id
,
student
=
self
.
user
.
pk
,
)
...
...
@@ -150,14 +150,14 @@ class FieldDataCache(object):
return
self
.
_chunked_query
(
XModuleUserStateSummaryField
,
'usage_id__in'
,
(
descriptor
.
location
.
url
(
)
for
descriptor
in
self
.
descriptors
),
(
str
(
descriptor
.
scope_ids
.
usage_id
)
for
descriptor
in
self
.
descriptors
),
field_name__in
=
set
(
field
.
name
for
field
in
fields
),
)
elif
scope
==
Scope
.
preferences
:
return
self
.
_chunked_query
(
XModuleStudentPrefsField
,
'module_type__in'
,
set
(
descriptor
.
module_class
.
__name__
for
descriptor
in
self
.
descriptors
),
set
(
descriptor
.
scope_ids
.
block_type
for
descriptor
in
self
.
descriptors
),
student
=
self
.
user
.
pk
,
field_name__in
=
set
(
field
.
name
for
field
in
fields
),
)
...
...
lms/djangoapps/courseware/tests/factories.py
View file @
a6a00431
...
...
@@ -131,7 +131,7 @@ class UserStateSummaryFactory(DjangoModelFactory):
field_name
=
'existing_field'
value
=
json
.
dumps
(
'old_value'
)
usage_id
=
location
(
'
def
_id'
)
.
url
()
usage_id
=
location
(
'
usage
_id'
)
.
url
()
class
StudentPrefsFactory
(
DjangoModelFactory
):
...
...
@@ -140,7 +140,7 @@ class StudentPrefsFactory(DjangoModelFactory):
field_name
=
'existing_field'
value
=
json
.
dumps
(
'old_value'
)
student
=
factory
.
SubFactory
(
UserFactory
)
module_type
=
'
MockProblemModule
'
module_type
=
'
mock_problem
'
class
StudentInfoFactory
(
DjangoModelFactory
):
...
...
lms/djangoapps/courseware/tests/test_model_data.py
View file @
a6a00431
...
...
@@ -15,7 +15,7 @@ from courseware.tests.factories import StudentModuleFactory as cmfStudentModuleF
from
courseware.tests.factories
import
UserStateSummaryFactory
from
courseware.tests.factories
import
StudentPrefsFactory
,
StudentInfoFactory
from
xblock.fields
import
Scope
,
BlockScope
from
xblock.fields
import
Scope
,
BlockScope
,
ScopeIds
from
xmodule.modulestore
import
Location
from
django.test
import
TestCase
from
django.db
import
DatabaseError
...
...
@@ -31,7 +31,7 @@ def mock_field(scope, name):
def
mock_descriptor
(
fields
=
[]):
descriptor
=
Mock
()
descriptor
.
location
=
location
(
'def_id'
)
descriptor
.
scope_ids
=
ScopeIds
(
'user1'
,
'mock_problem'
,
location
(
'def_id'
),
location
(
'usage_id'
)
)
descriptor
.
module_class
.
fields
.
values
.
return_value
=
fields
descriptor
.
fields
.
values
.
return_value
=
fields
descriptor
.
module_class
.
__name__
=
'MockProblemModule'
...
...
@@ -43,15 +43,15 @@ course_id = 'edX/test_course/test'
# The user ids here are 1 because we make a student in the setUp functions, and
# they get an id of 1. There's an assertion in setUp to ensure that assumption
# is still true.
user_state_summary_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
user_state_summary
,
None
,
location
(
'
def
_id'
))
settings_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
settings
,
None
,
location
(
'
def
_id'
))
user_state_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
user_state
,
1
,
location
(
'
def
_id'
))
prefs_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
preferences
,
1
,
'
MockProblemModule
'
)
user_state_summary_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
user_state_summary
,
None
,
location
(
'
usage
_id'
))
settings_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
settings
,
None
,
location
(
'
usage
_id'
))
user_state_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
user_state
,
1
,
location
(
'
usage
_id'
))
prefs_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
preferences
,
1
,
'
mock_problem
'
)
user_info_key
=
partial
(
DjangoKeyValueStore
.
Key
,
Scope
.
user_info
,
1
,
None
)
class
StudentModuleFactory
(
cmfStudentModuleFactory
):
module_state_key
=
location
(
'
def
_id'
)
.
url
()
module_state_key
=
location
(
'
usage
_id'
)
.
url
()
course_id
=
course_id
...
...
@@ -177,7 +177,7 @@ class TestMissingStudentModule(TestCase):
student_module
=
StudentModule
.
objects
.
all
()[
0
]
self
.
assertEquals
({
'a_field'
:
'a_value'
},
json
.
loads
(
student_module
.
state
))
self
.
assertEquals
(
self
.
user
,
student_module
.
student
)
self
.
assertEquals
(
location
(
'
def
_id'
)
.
url
(),
student_module
.
module_state_key
)
self
.
assertEquals
(
location
(
'
usage
_id'
)
.
url
(),
student_module
.
module_state_key
)
self
.
assertEquals
(
course_id
,
student_module
.
course_id
)
def
test_delete_field_from_missing_student_module
(
self
):
...
...
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