Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
ab0f07eb
Commit
ab0f07eb
authored
13 years ago
by
Piotr Mitros
Browse files
Options
Downloads
Patches
Plain Diff
Code cleaned up to be slighlty more explicit
--HG-- branch : profile-cache
parent
7bea9382
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
courseware/views.py
+18
-14
18 additions, 14 deletions
courseware/views.py
with
18 additions
and
14 deletions
courseware/views.py
+
18
−
14
View file @
ab0f07eb
...
...
@@ -38,28 +38,31 @@ def get_grade(request, problem, cache):
## HACK: assumes max score is fixed per problem
id
=
problem
.
get
(
'
id
'
)
correct
=
0
# If the ID is not in the cache, add the item
if
id
not
in
cache
:
module
=
StudentModule
(
module_type
=
'
problem
'
,
# TODO: Move into StudentModule.__init__?
module_id
=
id
,
student
=
request
.
user
,
state
=
None
,
grade
=
0
,
max_grade
=
None
,
done
=
'
i
'
)
cache
[
id
]
=
module
# Grab the # correct from cache
if
id
in
cache
:
response
=
cache
[
id
]
if
response
.
grade
!=
None
:
correct
=
response
.
grade
# Grab max grade from cache, or if it doesn't exist, compute and save to DB
if
id
in
cache
and
response
.
max_grade
!=
None
:
total
=
response
.
max_grade
el
if
id
in
cache
and
response
.
max_grade
==
Non
e
:
total
=
response
.
max_grade
el
s
e
:
total
=
courseware
.
modules
.
capa_module
.
Module
(
etree
.
tostring
(
problem
),
"
id
"
).
max_score
()
response
.
max_grade
=
total
response
.
save
()
else
:
# if id not in cache
total
=
courseware
.
modules
.
capa_module
.
Module
(
etree
.
tostring
(
problem
),
"
id
"
).
max_score
()
module
=
StudentModule
(
module_type
=
'
problem
'
,
module_id
=
id
,
student
=
request
.
user
,
state
=
None
,
grade
=
0
,
max_grade
=
total
,
done
=
'
i
'
)
total
=
courseware
.
modules
.
capa_module
.
Module
(
etree
.
tostring
(
problem
),
"
id
"
).
max_score
()
module
.
save
()
cache
[
id
]
=
module
return
(
correct
,
total
)
...
...
@@ -255,6 +258,7 @@ def profile(request):
'
grade_summary
'
:
grade_summary
,
'
csrf
'
:
csrf
(
request
)[
'
csrf_token
'
]
}
return
render_to_response
(
'
profile.html
'
,
context
)
def
format_url_params
(
params
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment