Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-ora2
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-ora2
Commits
b65bff93
Commit
b65bff93
authored
Apr 25, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version assessment model cache keys
parent
23e49f80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
apps/openassessment/assessment/serializers.py
+24
-3
No files found.
apps/openassessment/assessment/serializers.py
View file @
b65bff93
...
...
@@ -7,7 +7,6 @@ from copy import deepcopy
import
logging
from
django.core.cache
import
cache
from
django.utils.translation
import
ugettext
as
_
from
rest_framework
import
serializers
from
openassessment.assessment.models
import
(
Assessment
,
AssessmentPart
,
Criterion
,
CriterionOption
,
Rubric
,
...
...
@@ -19,6 +18,26 @@ from openassessment.assessment.models import (
logger
=
logging
.
getLogger
(
__name__
)
# Current version of the models in the cache
# Increment this to ignore assessment models currently in the cache
# when model fields change.
CACHE_VERSION
=
1
def
_versioned_cache_key
(
key
):
"""
Add a version number to a cache key, so we
Args:
key (unicode): The original, unversioned, cache key.
Returns:
unicode: Cache key with the version appended.
"""
return
u"{}.v{}"
.
format
(
key
,
CACHE_VERSION
)
class
InvalidRubric
(
Exception
):
"""This can be raised during the deserialization process."""
def
__init__
(
self
,
errors
):
...
...
@@ -202,8 +221,10 @@ def full_assessment_dict(assessment, rubric_dict=None):
Returns:
dict with keys 'rubric' (serialized Rubric model) and 'parts' (serialized assessment parts)
"""
assessment_cache_key
=
"assessment.full_assessment_dict.{}.{}.{}"
.
format
(
assessment
.
id
,
assessment
.
submission_uuid
,
assessment
.
scored_at
.
isoformat
()
assessment_cache_key
=
_versioned_cache_key
(
"assessment.full_assessment_dict.{}.{}.{}"
.
format
(
assessment
.
id
,
assessment
.
submission_uuid
,
assessment
.
scored_at
.
isoformat
()
)
)
assessment_dict
=
cache
.
get
(
assessment_cache_key
)
if
assessment_dict
:
...
...
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