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
42792e97
Commit
42792e97
authored
Dec 02, 2014
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract common base functionality for storing xblock fields in the relation db
parent
ccbff2da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
56 deletions
+25
-56
lms/djangoapps/courseware/models.py
+25
-56
No files found.
lms/djangoapps/courseware/models.py
View file @
42792e97
...
...
@@ -130,38 +130,46 @@ class StudentModuleHistory(models.Model):
history_entry
.
save
()
class
X
ModuleUserStateSummaryField
(
models
.
Model
):
class
X
BlockFieldBase
(
models
.
Model
):
"""
Stores data set in the Scope.user_state_summary scope by an xmodule field
Base class for all XBlock field storage.
"""
class
Meta
:
unique_together
=
((
'usage_id'
,
'field_name'
),)
abstract
=
True
# The name of the field
field_name
=
models
.
CharField
(
max_length
=
64
,
db_index
=
True
)
# The definition id for the module
usage_id
=
LocationKeyField
(
max_length
=
255
,
db_index
=
True
)
# The value of the field. Defaults to None dumped as json
value
=
models
.
TextField
(
default
=
'null'
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
db_index
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
,
db_index
=
True
)
def
__repr__
(
self
):
return
'XModuleUserStateSummaryField<
%
r>'
%
({
'field_name'
:
self
.
field_name
,
'usage_id'
:
self
.
usage_id
,
'value'
:
self
.
value
,
},)
def
__unicode__
(
self
):
return
unicode
(
repr
(
self
))
return
u'{}<{!r}'
.
format
(
self
.
__class__
.
__name__
,
{
key
:
getattr
(
self
,
key
)
for
key
in
self
.
_meta
.
get_all_field_names
()
if
key
not
in
(
'created'
,
'modified'
)
}
)
class
XModuleUserStateSummaryField
(
XBlockFieldBase
):
"""
Stores data set in the Scope.user_state_summary scope by an xmodule field
"""
class
Meta
:
unique_together
=
((
'usage_id'
,
'field_name'
),)
# The definition id for the module
usage_id
=
LocationKeyField
(
max_length
=
255
,
db_index
=
True
)
class
XModuleStudentPrefsField
(
models
.
Model
):
class
XModuleStudentPrefsField
(
XBlockFieldBase
):
"""
Stores data set in the Scope.preferences scope by an xmodule field
"""
...
...
@@ -169,33 +177,13 @@ class XModuleStudentPrefsField(models.Model):
class
Meta
:
unique_together
=
((
'student'
,
'module_type'
,
'field_name'
),)
# The name of the field
field_name
=
models
.
CharField
(
max_length
=
64
,
db_index
=
True
)
# The type of the module for these preferences
module_type
=
models
.
CharField
(
max_length
=
64
,
db_index
=
True
)
# The value of the field. Defaults to None dumped as json
value
=
models
.
TextField
(
default
=
'null'
)
student
=
models
.
ForeignKey
(
User
,
db_index
=
True
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
db_index
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
,
db_index
=
True
)
def
__repr__
(
self
):
return
'XModuleStudentPrefsField<
%
r>'
%
({
'field_name'
:
self
.
field_name
,
'module_type'
:
self
.
module_type
,
'student'
:
self
.
student
.
username
,
'value'
:
self
.
value
,
},)
def
__unicode__
(
self
):
return
unicode
(
repr
(
self
))
class
XModuleStudentInfoField
(
models
.
Model
):
class
XModuleStudentInfoField
(
XBlockFieldBase
):
"""
Stores data set in the Scope.preferences scope by an xmodule field
"""
...
...
@@ -203,27 +191,8 @@ class XModuleStudentInfoField(models.Model):
class
Meta
:
unique_together
=
((
'student'
,
'field_name'
),)
# The name of the field
field_name
=
models
.
CharField
(
max_length
=
64
,
db_index
=
True
)
# The value of the field. Defaults to None dumped as json
value
=
models
.
TextField
(
default
=
'null'
)
student
=
models
.
ForeignKey
(
User
,
db_index
=
True
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
db_index
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
,
db_index
=
True
)
def
__repr__
(
self
):
return
'XModuleStudentInfoField<
%
r>'
%
({
'field_name'
:
self
.
field_name
,
'student'
:
self
.
student
.
username
,
'value'
:
self
.
value
,
},)
def
__unicode__
(
self
):
return
unicode
(
repr
(
self
))
class
OfflineComputedGrade
(
models
.
Model
):
"""
...
...
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