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
8e443f59
Commit
8e443f59
authored
Oct 29, 2014
by
Matt Drayer
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/api-progress-generator-fix: Repaired existence check
parent
c9de3875
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
5 deletions
+33
-5
lms/djangoapps/progress/management/commands/generate_progress_entries.py
+14
-3
lms/djangoapps/progress/management/commands/tests/test_generate_progress_entries.py
+18
-2
lms/envs/test.py
+1
-0
No files found.
lms/djangoapps/progress/management/commands/generate_progress_entries.py
View file @
8e443f59
...
...
@@ -70,12 +70,23 @@ class Command(BaseCommand):
# For each user...
for
user
in
users
:
status
=
'skipped'
completions
=
CourseModuleCompletion
.
objects
.
filter
(
course_id
=
course
.
id
,
user_id
=
user
.
id
)
\
.
exclude
(
cat_list
)
.
count
()
progress
,
created
=
StudentProgress
.
objects
.
get_or_create
(
user
=
user
,
try
:
existing_record
=
StudentProgress
.
objects
.
get
(
user
=
user
,
course_id
=
course
.
id
)
if
existing_record
.
completions
!=
completions
:
existing_record
.
completions
=
completions
existing_record
.
save
()
status
=
'updated'
except
StudentProgress
.
DoesNotExist
:
new_record
=
StudentProgress
.
objects
.
create
(
user
=
user
,
course_id
=
course
.
id
,
completions
=
completions
)
log_msg
=
'Progress entry created -- Course: {}, User: {} (completions: {})'
.
format
(
course
.
id
,
user
.
id
completions
=
completions
)
status
=
'created'
log_msg
=
'Progress entry {} -- Course: {}, User: {} (completions: {})'
.
format
(
status
,
course
.
id
,
user
.
id
,
completions
)
print
log_msg
log
.
info
(
log_msg
)
lms/djangoapps/progress/management/commands/tests/test_generate_progress_entries.py
View file @
8e443f59
...
...
@@ -68,6 +68,13 @@ class GenerateProgressEntriesTests(ModuleStoreTestCase):
display_name
=
"lab problem 1"
,
metadata
=
{
'rerandomize'
:
'always'
,
'graded'
:
True
,
'format'
:
"Lab"
}
)
self
.
problem4
=
ItemFactory
.
create
(
parent_location
=
chapter2
.
location
,
category
=
'problem'
,
data
=
StringResponseXMLFactory
()
.
build_xml
(
answer
=
'bar'
),
display_name
=
"lab problem 2"
,
metadata
=
{
'rerandomize'
:
'always'
,
'graded'
:
True
,
'format'
:
"Lab"
}
)
# Create some users and enroll them
self
.
users
=
[
UserFactory
.
create
(
username
=
"testuser"
+
str
(
__
),
profile
=
'test'
)
for
__
in
xrange
(
3
)]
...
...
@@ -124,6 +131,15 @@ class GenerateProgressEntriesTests(ModuleStoreTestCase):
user0_entry
=
StudentProgress
.
objects
.
get
(
user
=
self
.
users
[
0
])
self
.
assertEqual
(
user0_entry
.
completions
,
3
)
# The first user will be skipped this next time around because they already have a progress record
# and their completions have not changed, and we need to test this valid use case ('skipped')
# We also need to test the 'updated' use case, so we'll add a new completion record for the
# second user which will alter their count on this next cycle and kick off the update flow
completion
,
created
=
CourseModuleCompletion
.
objects
.
get_or_create
(
user
=
self
.
users
[
1
],
course_id
=
self
.
course
.
id
,
content_id
=
unicode
(
self
.
problem4
.
location
),
stage
=
None
)
# Run the command across all users, but just for the specified course
generate_progress_entries
.
Command
()
.
handle
(
course_ids
=
course_ids
)
...
...
@@ -131,11 +147,11 @@ class GenerateProgressEntriesTests(ModuleStoreTestCase):
current_entries
=
StudentProgress
.
objects
.
all
()
self
.
assertEqual
(
len
(
current_entries
),
3
)
current_entries
=
StudentProgressHistory
.
objects
.
all
()
self
.
assertEqual
(
len
(
current_entries
),
3
)
self
.
assertEqual
(
len
(
current_entries
),
4
)
user0_entry
=
StudentProgress
.
objects
.
get
(
user
=
self
.
users
[
0
])
self
.
assertEqual
(
user0_entry
.
completions
,
3
)
user1_entry
=
StudentProgress
.
objects
.
get
(
user
=
self
.
users
[
1
])
self
.
assertEqual
(
user1_entry
.
completions
,
3
)
self
.
assertEqual
(
user1_entry
.
completions
,
4
)
user2_entry
=
StudentProgress
.
objects
.
get
(
user
=
self
.
users
[
2
])
self
.
assertEqual
(
user2_entry
.
completions
,
3
)
...
...
lms/envs/test.py
View file @
8e443f59
...
...
@@ -530,6 +530,7 @@ if FEATURES.get('STUDENT_PROGRESS', False) and "'progress'" not in INSTALLED_APP
INSTALLED_APPS
+=
(
'progress'
,)
############# Organizations app #################
FEATURES
[
'ORGANIZATIONS_APP'
]
=
True
if
FEATURES
.
get
(
'ORGANIZATIONS_APP'
)
and
"organizations"
not
in
INSTALLED_APPS
:
INSTALLED_APPS
+=
(
'organizations'
,)
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