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
d03b0701
Commit
d03b0701
authored
Aug 30, 2016
by
Eric Fischer
Committed by
GitHub
Aug 30, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13336 from edx/efischer/grades_fix
Deserialize BlockRecord.locator into a real BlockUsageLocator
parents
5c01e745
401a81ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
lms/djangoapps/grades/models.py
+9
-1
lms/djangoapps/grades/tests/test_models.py
+6
-3
No files found.
lms/djangoapps/grades/models.py
View file @
d03b0701
...
...
@@ -17,6 +17,7 @@ from django.db.utils import IntegrityError
from
model_utils.models
import
TimeStampedModel
from
coursewarehistoryextended.fields
import
UnsignedBigIntAutoField
from
opaque_keys.edx.locator
import
BlockUsageLocator
from
xmodule_django.models
import
CourseKeyField
,
UsageKeyField
...
...
@@ -62,7 +63,14 @@ class BlockRecordSet(frozenset):
Return a BlockRecordSet from a json list.
"""
block_dicts
=
json
.
loads
(
blockrecord_json
)
record_generator
=
(
BlockRecord
(
**
block
)
for
block
in
block_dicts
)
record_generator
=
(
BlockRecord
(
locator
=
BlockUsageLocator
.
from_string
(
block
[
"locator"
]),
weight
=
block
[
"weight"
],
max_score
=
block
[
"max_score"
],
)
for
block
in
block_dicts
)
return
cls
(
record_generator
)
def
to_hash
(
self
):
...
...
lms/djangoapps/grades/tests/test_models.py
View file @
d03b0701
...
...
@@ -36,8 +36,8 @@ class GradesModelTestCase(TestCase):
block_type
=
'problem'
,
block_id
=
'block_id_b'
)
self
.
record_a
=
BlockRecord
(
unicode
(
self
.
locator_a
)
,
1
,
10
)
self
.
record_b
=
BlockRecord
(
unicode
(
self
.
locator_b
)
,
1
,
10
)
self
.
record_a
=
BlockRecord
(
self
.
locator_a
,
1
,
10
)
self
.
record_b
=
BlockRecord
(
self
.
locator_b
,
1
,
10
)
@ddt.ddt
...
...
@@ -89,7 +89,10 @@ class VisibleBlocksTest(GradesModelTestCase):
Happy path test to ensure basic create functionality works as expected.
"""
vblocks
=
VisibleBlocks
.
objects
.
create_from_blockrecords
([
self
.
record_a
])
expected_json
=
json
.
dumps
([
self
.
record_a
.
_asdict
()],
separators
=
(
','
,
':'
),
sort_keys
=
True
)
list_of_block_dicts
=
[
self
.
record_a
.
_asdict
()]
for
block_dict
in
list_of_block_dicts
:
block_dict
[
'locator'
]
=
unicode
(
block_dict
[
'locator'
])
# BlockUsageLocator is not json-serializable
expected_json
=
json
.
dumps
(
list_of_block_dicts
,
separators
=
(
','
,
':'
),
sort_keys
=
True
)
expected_hash
=
b64encode
(
sha1
(
expected_json
)
.
digest
())
self
.
assertEqual
(
expected_json
,
vblocks
.
blocks_json
)
self
.
assertEqual
(
expected_hash
,
vblocks
.
hashed
)
...
...
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