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
ec90200b
Commit
ec90200b
authored
Aug 20, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix migration to remove out of date index
* reorder index fields
parent
d9c753e7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
8 deletions
+19
-8
lms/djangoapps/courseware/grades.py
+6
-4
lms/djangoapps/courseware/migrations/0003_done_grade_cache.py
+2
-0
lms/djangoapps/courseware/migrations/0004_add_field_studentmodule_course_id.py
+10
-3
lms/djangoapps/courseware/models.py
+1
-1
No files found.
lms/djangoapps/courseware/grades.py
View file @
ec90200b
...
@@ -76,7 +76,7 @@ def grade(student, request, course, student_module_cache=None):
...
@@ -76,7 +76,7 @@ def grade(student, request, course, student_module_cache=None):
# TODO: We may be able to speed this up by only getting a list of children IDs from section_module
# TODO: We may be able to speed this up by only getting a list of children IDs from section_module
# Then, we may not need to instatiate any problems if they are already in the database
# Then, we may not need to instatiate any problems if they are already in the database
for
module
in
yield_module_descendents
(
section_module
):
for
module
in
yield_module_descendents
(
section_module
):
(
correct
,
total
)
=
get_score
(
student
,
module
,
student_module_cache
)
(
correct
,
total
)
=
get_score
(
course
.
id
,
student
,
module
,
student_module_cache
)
if
correct
is
None
and
total
is
None
:
if
correct
is
None
and
total
is
None
:
continue
continue
...
@@ -171,7 +171,9 @@ def progress_summary(student, course, grader, student_module_cache):
...
@@ -171,7 +171,9 @@ def progress_summary(student, course, grader, student_module_cache):
graded
=
s
.
metadata
.
get
(
'graded'
,
False
)
graded
=
s
.
metadata
.
get
(
'graded'
,
False
)
scores
=
[]
scores
=
[]
for
module
in
yield_module_descendents
(
s
):
for
module
in
yield_module_descendents
(
s
):
(
correct
,
total
)
=
get_score
(
student
,
module
,
student_module_cache
)
# course is a module, not a descriptor...
course_id
=
course
.
descriptor
.
id
(
correct
,
total
)
=
get_score
(
course_id
,
student
,
module
,
student_module_cache
)
if
correct
is
None
and
total
is
None
:
if
correct
is
None
and
total
is
None
:
continue
continue
...
@@ -200,7 +202,7 @@ def progress_summary(student, course, grader, student_module_cache):
...
@@ -200,7 +202,7 @@ def progress_summary(student, course, grader, student_module_cache):
return
chapters
return
chapters
def
get_score
(
user
,
problem
,
student_module_cache
):
def
get_score
(
course_id
,
user
,
problem
,
student_module_cache
):
"""
"""
Return the score for a user on a problem, as a tuple (correct, total).
Return the score for a user on a problem, as a tuple (correct, total).
...
@@ -215,7 +217,7 @@ def get_score(user, problem, student_module_cache):
...
@@ -215,7 +217,7 @@ def get_score(user, problem, student_module_cache):
correct
=
0.0
correct
=
0.0
# If the ID is not in the cache, add the item
# If the ID is not in the cache, add the item
instance_module
=
get_instance_module
(
user
,
problem
,
student_module_cache
)
instance_module
=
get_instance_module
(
course_id
,
user
,
problem
,
student_module_cache
)
# instance_module = student_module_cache.lookup(problem.category, problem.id)
# instance_module = student_module_cache.lookup(problem.category, problem.id)
# if instance_module is None:
# if instance_module is None:
# instance_module = StudentModule(module_type=problem.category,
# instance_module = StudentModule(module_type=problem.category,
...
...
lms/djangoapps/courseware/migrations/0003_done_grade_cache.py
View file @
ec90200b
...
@@ -9,6 +9,8 @@ class Migration(SchemaMigration):
...
@@ -9,6 +9,8 @@ class Migration(SchemaMigration):
def
forwards
(
self
,
orm
):
def
forwards
(
self
,
orm
):
# NOTE (vshnayder): This constraint has the wrong field order, so it doesn't actually
# do anything. Migration 0004 actually removes this index.
# Removing unique constraint on 'StudentModule', fields ['module_id', 'module_type', 'student']
# Removing unique constraint on 'StudentModule', fields ['module_id', 'module_type', 'student']
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'module_id'
,
'module_type'
,
'student_id'
])
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'module_id'
,
'module_type'
,
'student_id'
])
...
...
lms/djangoapps/courseware/migrations/0004_add_field_studentmodule_course_id.py
View file @
ec90200b
...
@@ -16,13 +16,17 @@ class Migration(SchemaMigration):
...
@@ -16,13 +16,17 @@ class Migration(SchemaMigration):
# Removing unique constraint on 'StudentModule', fields ['module_id', 'student']
# Removing unique constraint on 'StudentModule', fields ['module_id', 'student']
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'module_id'
,
'student_id'
])
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'module_id'
,
'student_id'
])
# NOTE: manually remove this constaint (from 0001)--0003 tries, but fails.
# Removing unique constraint on 'StudentModule', fields ['module_id', 'module_type', 'student']
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'student_id'
,
'module_id'
,
'module_type'
])
# Adding unique constraint on 'StudentModule', fields ['course_id', 'module_state_key', 'student']
# Adding unique constraint on 'StudentModule', fields ['course_id', 'module_state_key', 'student']
db
.
create_unique
(
'courseware_studentmodule'
,
[
'
course_id'
,
'module_id'
,
'student
_id'
])
db
.
create_unique
(
'courseware_studentmodule'
,
[
'
student_id'
,
'module_id'
,
'course
_id'
])
def
backwards
(
self
,
orm
):
def
backwards
(
self
,
orm
):
# Removing unique constraint on 'StudentModule', fields ['
course_id', 'module_state_key', 'student
']
# Removing unique constraint on 'StudentModule', fields ['
studnet_id', 'module_state_key', 'course_id
']
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'
course_id'
,
'module_id'
,
'student
_id'
])
db
.
delete_unique
(
'courseware_studentmodule'
,
[
'
student_id'
,
'module_id'
,
'course
_id'
])
# Deleting field 'StudentModule.course_id'
# Deleting field 'StudentModule.course_id'
db
.
delete_column
(
'courseware_studentmodule'
,
'course_id'
)
db
.
delete_column
(
'courseware_studentmodule'
,
'course_id'
)
...
@@ -30,6 +34,9 @@ class Migration(SchemaMigration):
...
@@ -30,6 +34,9 @@ class Migration(SchemaMigration):
# Adding unique constraint on 'StudentModule', fields ['module_id', 'student']
# Adding unique constraint on 'StudentModule', fields ['module_id', 'student']
db
.
create_unique
(
'courseware_studentmodule'
,
[
'module_id'
,
'student_id'
])
db
.
create_unique
(
'courseware_studentmodule'
,
[
'module_id'
,
'student_id'
])
# Adding unique constraint on 'StudentModule', fields ['module_id', 'module_type', 'student']
db
.
create_unique
(
'courseware_studentmodule'
,
[
'student_id'
,
'module_id'
,
'module_type'
])
models
=
{
models
=
{
'auth.group'
:
{
'auth.group'
:
{
...
...
lms/djangoapps/courseware/models.py
View file @
ec90200b
...
@@ -43,7 +43,7 @@ class StudentModule(models.Model):
...
@@ -43,7 +43,7 @@ class StudentModule(models.Model):
course_id
=
models
.
CharField
(
max_length
=
255
,
db_index
=
True
)
course_id
=
models
.
CharField
(
max_length
=
255
,
db_index
=
True
)
class
Meta
:
class
Meta
:
unique_together
=
((
'
course_id'
,
'student'
,
'module_state_key
'
),)
unique_together
=
((
'
student'
,
'module_state_key'
,
'course_id
'
),)
## Internal state of the object
## Internal state of the object
state
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
state
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
...
...
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