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
3430024d
Commit
3430024d
authored
Apr 23, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a temporary set_grade method to the FieldDataCache and UserStateCache
parent
c3bb2e9b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
16 deletions
+34
-16
lms/djangoapps/courseware/model_data.py
+25
-1
lms/djangoapps/courseware/module_render.py
+9
-15
No files found.
lms/djangoapps/courseware/model_data.py
View file @
3430024d
...
@@ -13,7 +13,7 @@ from .models import (
...
@@ -13,7 +13,7 @@ from .models import (
XModuleStudentInfoField
XModuleStudentInfoField
)
)
import
logging
import
logging
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
,
UsageKey
from
opaque_keys.edx.block_types
import
BlockTypeKeyV1
from
opaque_keys.edx.block_types
import
BlockTypeKeyV1
from
opaque_keys.edx.asides
import
AsideUsageKeyV1
from
opaque_keys.edx.asides
import
AsideUsageKeyV1
from
contracts
import
contract
,
new_contract
from
contracts
import
contract
,
new_contract
...
@@ -490,6 +490,18 @@ class UserStateCache(DjangoOrmFieldCache):
...
@@ -490,6 +490,18 @@ class UserStateCache(DjangoOrmFieldCache):
state
[
kvs_key
.
field_name
]
=
value
state
[
kvs_key
.
field_name
]
=
value
field_object
.
state
=
json
.
dumps
(
state
)
field_object
.
state
=
json
.
dumps
(
state
)
@contract
(
user_id
=
int
,
usage_key
=
UsageKey
,
score
=
"number|None"
,
max_score
=
"number|None"
)
def
set_score
(
self
,
user_id
,
usage_key
,
score
,
max_score
):
"""
UNSUPPORTED METHOD
Set the score and max_score for the specified user and xblock usage.
"""
field_object
=
self
.
_cache
[
usage_key
]
field_object
.
grade
=
score
field_object
.
max_grade
=
max_score
field_object
.
save
()
class
UserStateSummaryCache
(
DjangoOrmFieldCache
):
class
UserStateSummaryCache
(
DjangoOrmFieldCache
):
"""
"""
...
@@ -909,3 +921,15 @@ class FieldDataCache(object):
...
@@ -909,3 +921,15 @@ class FieldDataCache(object):
return
False
return
False
return
self
.
cache
[
key
.
scope
]
.
has
(
key
)
return
self
.
cache
[
key
.
scope
]
.
has
(
key
)
@contract
(
user_id
=
int
,
usage_key
=
UsageKey
,
score
=
"number|None"
,
max_score
=
"number|None"
)
def
set_score
(
self
,
user_id
,
usage_key
,
score
,
max_score
):
"""
UNSUPPORTED METHOD
Set the score and max_score for the specified user and xblock usage.
"""
assert
not
self
.
user
.
is_anonymous
()
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
)
lms/djangoapps/courseware/module_render.py
View file @
3430024d
...
@@ -416,24 +416,18 @@ def get_module_system_for_user(user, field_data_cache,
...
@@ -416,24 +416,18 @@ def get_module_system_for_user(user, field_data_cache,
"""
"""
user_id
=
event
.
get
(
'user_id'
,
user
.
id
)
user_id
=
event
.
get
(
'user_id'
,
user
.
id
)
# Construct the key for the module
grade
=
event
.
get
(
'value'
)
key
=
KeyValueStore
.
Key
(
max_grade
=
event
.
get
(
'max_value'
)
scope
=
Scope
.
user_state
,
user_id
=
user_id
,
field_data_cache
.
set_score
(
block_scope_id
=
descriptor
.
location
,
user_id
,
field_name
=
'grade'
descriptor
.
location
,
)
grade
,
StudentModule
.
objects
.
filter
(
max_grade
,
student__id
=
user_id
,
module_state_key
=
descriptor
.
location
,
course_id
=
course_id
,
)
.
update
(
grade
=
event
.
get
(
'value'
),
max_grade
=
event
.
get
(
'max_value'
)
)
)
# Bin score into range and increment stats
# Bin score into range and increment stats
score_bucket
=
get_score_bucket
(
student_module
.
grade
,
student_module
.
max_grade
)
score_bucket
=
get_score_bucket
(
grade
,
max_grade
)
tags
=
[
tags
=
[
u"org:{}"
.
format
(
course_id
.
org
),
u"org:{}"
.
format
(
course_id
.
org
),
...
...
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