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
0de4f601
Commit
0de4f601
authored
Sep 29, 2014
by
Matt Drayer
Committed by
Jonathan Piacenti
Aug 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/rebase-20140916: Initial test fixes
parent
6454290f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
43 deletions
+69
-43
lms/djangoapps/api_manager/courses/tests.py
+3
-3
lms/djangoapps/api_manager/courseware_access.py
+3
-2
lms/djangoapps/api_manager/users/tests.py
+46
-25
lms/djangoapps/api_manager/users/views.py
+14
-12
lms/djangoapps/courseware/module_render.py
+1
-1
lms/envs/test.py
+2
-0
No files found.
lms/djangoapps/api_manager/courses/tests.py
View file @
0de4f601
...
@@ -1743,7 +1743,7 @@ class CoursesApiTests(TestCase):
...
@@ -1743,7 +1743,7 @@ class CoursesApiTests(TestCase):
response
=
self
.
do_get
(
test_uri
)
response
=
self
.
do_get
(
test_uri
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
len
(
response
.
data
[
'leaders'
]),
4
)
self
.
assertEqual
(
len
(
response
.
data
[
'leaders'
]),
4
)
self
.
assertEqual
(
response
.
data
[
'course_avg'
],
20
)
self
.
assertEqual
(
response
.
data
[
'course_avg'
],
14
)
# without count filter and user_id
# without count filter and user_id
test_uri
=
'{}/{}/metrics/completions/leaders/?user_id={}'
.
format
(
self
.
base_courses_uri
,
self
.
test_course_id
,
test_uri
=
'{}/{}/metrics/completions/leaders/?user_id={}'
.
format
(
self
.
base_courses_uri
,
self
.
test_course_id
,
...
@@ -1752,7 +1752,7 @@ class CoursesApiTests(TestCase):
...
@@ -1752,7 +1752,7 @@ class CoursesApiTests(TestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
len
(
response
.
data
[
'leaders'
]),
3
)
self
.
assertEqual
(
len
(
response
.
data
[
'leaders'
]),
3
)
self
.
assertEqual
(
response
.
data
[
'position'
],
2
)
self
.
assertEqual
(
response
.
data
[
'position'
],
2
)
self
.
assertEqual
(
response
.
data
[
'completions'
],
28
)
self
.
assertEqual
(
response
.
data
[
'completions'
],
19
)
# with skipleaders filter
# with skipleaders filter
test_uri
=
'{}/{}/metrics/completions/leaders/?user_id={}&skipleaders=true'
.
format
(
self
.
base_courses_uri
,
test_uri
=
'{}/{}/metrics/completions/leaders/?user_id={}&skipleaders=true'
.
format
(
self
.
base_courses_uri
,
...
@@ -1762,7 +1762,7 @@ class CoursesApiTests(TestCase):
...
@@ -1762,7 +1762,7 @@ class CoursesApiTests(TestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertIsNone
(
response
.
data
.
get
(
'leaders'
,
None
))
self
.
assertIsNone
(
response
.
data
.
get
(
'leaders'
,
None
))
self
.
assertIsNone
(
response
.
data
.
get
(
'position'
,
None
))
self
.
assertIsNone
(
response
.
data
.
get
(
'position'
,
None
))
self
.
assertEqual
(
response
.
data
[
'completions'
],
28
)
self
.
assertEqual
(
response
.
data
[
'completions'
],
19
)
# test with bogus course
# test with bogus course
test_uri
=
'{}/{}/metrics/completions/leaders/'
.
format
(
self
.
base_courses_uri
,
self
.
test_bogus_course_id
)
test_uri
=
'{}/{}/metrics/completions/leaders/'
.
format
(
self
.
base_courses_uri
,
self
.
test_bogus_course_id
)
...
...
lms/djangoapps/api_manager/courseware_access.py
View file @
0de4f601
...
@@ -69,8 +69,9 @@ def get_course_leaf_nodes(course_key, detached_categories):
...
@@ -69,8 +69,9 @@ def get_course_leaf_nodes(course_key, detached_categories):
nodes
=
[]
nodes
=
[]
verticals
=
get_modulestore
()
.
get_items
(
course_key
,
category
=
'vertical'
)
verticals
=
get_modulestore
()
.
get_items
(
course_key
,
category
=
'vertical'
)
for
vertical
in
verticals
:
for
vertical
in
verticals
:
nodes
.
extend
([
unit
for
unit
in
vertical
.
children
if
hasattr
(
vertical
,
'children'
):
if
getattr
(
unit
,
'category'
)
not
in
detached_categories
])
nodes
.
extend
([
unit
for
unit
in
vertical
.
children
if
getattr
(
unit
,
'category'
)
not
in
detached_categories
])
return
nodes
return
nodes
...
...
lms/djangoapps/api_manager/users/tests.py
View file @
0de4f601
This diff is collapsed.
Click to expand it.
lms/djangoapps/api_manager/users/views.py
View file @
0de4f601
...
@@ -23,7 +23,10 @@ from instructor.access import revoke_access, update_forum_role
...
@@ -23,7 +23,10 @@ from instructor.access import revoke_access, update_forum_role
from
lang_pref
import
LANGUAGE_KEY
from
lang_pref
import
LANGUAGE_KEY
from
lms.lib.comment_client.user
import
User
as
CommentUser
from
lms.lib.comment_client.user
import
User
as
CommentUser
from
lms.lib.comment_client.utils
import
CommentClientRequestError
from
lms.lib.comment_client.utils
import
CommentClientRequestError
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
notification_prefs.views
import
enable_notifications
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
UsageKey
,
CourseKey
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
from
student.models
import
CourseEnrollment
,
PasswordHistory
,
UserProfile
from
student.models
import
CourseEnrollment
,
PasswordHistory
,
UserProfile
from
openedx.core.djangoapps.user_api.models
import
UserPreference
from
openedx.core.djangoapps.user_api.models
import
UserPreference
from
student.roles
import
CourseAccessRole
,
CourseInstructorRole
,
CourseObserverRole
,
CourseStaffRole
,
CourseAssistantRole
,
UserBasedRole
from
student.roles
import
CourseAccessRole
,
CourseInstructorRole
,
CourseObserverRole
,
CourseStaffRole
,
CourseAssistantRole
,
UserBasedRole
...
@@ -32,9 +35,11 @@ from util.password_policy_validators import (
...
@@ -32,9 +35,11 @@ from util.password_policy_validators import (
validate_password_length
,
validate_password_complexity
,
validate_password_length
,
validate_password_complexity
,
validate_password_dictionary
validate_password_dictionary
)
)
from
xmodule.modulestore
import
InvalidLocationError
from
xmodule.modulestore.django
import
modulestore
from
api_manager.courses.serializers
import
CourseModuleCompletionSerializer
from
api_manager.courses.serializers
import
CourseModuleCompletionSerializer
from
api_manager.courseware_access
import
get_course
,
get_course_child
,
get_course_key
,
course_exists
,
calculate_proforma_grade
from
api_manager.courseware_access
import
get_course
,
get_course_child
,
get_course_
child_content
,
get_course_
key
,
course_exists
,
calculate_proforma_grade
from
api_manager.permissions
import
SecureAPIView
,
SecureListAPIView
,
IdsInFilterBackend
,
HasOrgsFilterBackend
from
api_manager.permissions
import
SecureAPIView
,
SecureListAPIView
,
IdsInFilterBackend
,
HasOrgsFilterBackend
from
api_manager.models
import
GroupProfile
,
APIUser
as
User
from
api_manager.models
import
GroupProfile
,
APIUser
as
User
from
api_manager.organizations.serializers
import
OrganizationSerializer
from
api_manager.organizations.serializers
import
OrganizationSerializer
...
@@ -42,12 +47,7 @@ from api_manager.utils import generate_base_uri, dict_has_items, extract_data_pa
...
@@ -42,12 +47,7 @@ from api_manager.utils import generate_base_uri, dict_has_items, extract_data_pa
from
projects.serializers
import
BasicWorkgroupSerializer
from
projects.serializers
import
BasicWorkgroupSerializer
from
.serializers
import
UserSerializer
,
UserCountByCitySerializer
,
UserRolesSerializer
from
.serializers
import
UserSerializer
,
UserCountByCitySerializer
,
UserRolesSerializer
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
UsageKey
,
CourseKey
from
opaque_keys.edx.locations
import
Location
from
xmodule.modulestore
import
InvalidLocationError
from
xmodule.modulestore.django
import
modulestore
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
AUDIT_LOG
=
logging
.
getLogger
(
"audit"
)
AUDIT_LOG
=
logging
.
getLogger
(
"audit"
)
...
@@ -121,7 +121,7 @@ def _save_child_position(parent_descriptor, target_child_location):
...
@@ -121,7 +121,7 @@ def _save_child_position(parent_descriptor, target_child_location):
we just compare id's from the array of children
we just compare id's from the array of children
"""
"""
for
position
,
child_location
in
enumerate
(
parent_descriptor
.
children
,
start
=
1
):
for
position
,
child_location
in
enumerate
(
parent_descriptor
.
children
,
start
=
1
):
if
child_location
==
target_child_location
:
if
unicode
(
child_location
)
==
unicode
(
target_child_location
)
:
# Only save if position changed
# Only save if position changed
if
position
!=
parent_descriptor
.
position
:
if
position
!=
parent_descriptor
.
position
:
parent_descriptor
.
position
=
position
parent_descriptor
.
position
=
position
...
@@ -332,6 +332,8 @@ class UsersList(SecureListAPIView):
...
@@ -332,6 +332,8 @@ class UsersList(SecureListAPIView):
profile
.
save
()
profile
.
save
()
UserPreference
.
set_preference
(
user
,
LANGUAGE_KEY
,
get_language
())
UserPreference
.
set_preference
(
user
,
LANGUAGE_KEY
,
get_language
())
if
settings
.
FEATURES
.
get
(
'ENABLE_DISCUSSION_EMAIL_DIGEST'
):
enable_notifications
(
user
)
# add this account creation to password history
# add this account creation to password history
# NOTE, this will be a NOP unless the feature has been turned on in configuration
# NOTE, this will be a NOP unless the feature has been turned on in configuration
...
@@ -755,13 +757,17 @@ def _get_current_position_loc(parent_module):
...
@@ -755,13 +757,17 @@ def _get_current_position_loc(parent_module):
An optimized lookup for the current position. The LMS version can cause unnecessary round trips to
An optimized lookup for the current position. The LMS version can cause unnecessary round trips to
the Mongo database
the Mongo database
"""
"""
if
not
hasattr
(
parent_module
,
'position'
):
if
not
hasattr
(
parent_module
,
'position'
):
return
None
return
None
if
not
parent_module
.
children
:
if
not
parent_module
.
children
:
return
None
return
None
index
=
0
index
=
0
if
parent_module
.
position
:
if
parent_module
.
position
:
index
=
parent_module
.
position
-
1
# position is 1 indexed
index
=
parent_module
.
position
-
1
# position is 1 indexed
...
@@ -859,15 +865,11 @@ class UsersCoursesDetail(SecureAPIView):
...
@@ -859,15 +865,11 @@ class UsersCoursesDetail(SecureAPIView):
response_data
[
'position_tree'
]
=
{}
response_data
[
'position_tree'
]
=
{}
parent_module
=
course_module
parent_module
=
course_module
while
parent_module
is
not
None
:
while
parent_module
is
not
None
:
current_child_loc
=
_get_current_position_loc
(
parent_module
)
current_child_loc
=
_get_current_position_loc
(
parent_module
)
if
current_child_loc
:
if
current_child_loc
:
response_data
[
'position_tree'
][
current_child_loc
.
category
]
=
{}
response_data
[
'position_tree'
][
current_child_loc
.
category
]
=
{}
response_data
[
'position_tree'
][
current_child_loc
.
category
][
'id'
]
=
unicode
(
current_child_loc
)
response_data
[
'position_tree'
][
current_child_loc
.
category
][
'id'
]
=
unicode
(
current_child_loc
)
_
,
_
,
parent_module
=
get_course_child
(
request
,
user
,
course_key
,
unicode
(
current_child_loc
),
load_content
=
True
)
_
,
_
,
parent_module
=
get_course_child
(
request
,
user
,
course_key
,
unicode
(
current_child_loc
),
load_content
=
True
)
else
:
else
:
parent_module
=
None
parent_module
=
None
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
response_data
,
status
=
status
.
HTTP_200_OK
)
...
...
lms/djangoapps/courseware/module_render.py
View file @
0de4f601
...
@@ -693,8 +693,8 @@ def get_module_system_for_user(user, field_data_cache, # TODO # pylint: disabl
...
@@ -693,8 +693,8 @@ def get_module_system_for_user(user, field_data_cache, # TODO # pylint: disabl
except
(
ValueError
,
TypeError
):
except
(
ValueError
,
TypeError
):
log
.
exception
(
'Non-integer
%
r passed as position.'
,
position
)
log
.
exception
(
'Non-integer
%
r passed as position.'
,
position
)
position
=
None
position
=
None
system
.
set
(
'position'
,
position
)
system
.
set
(
'position'
,
position
)
if
settings
.
FEATURES
.
get
(
'ENABLE_PSYCHOMETRICS'
)
and
user
.
is_authenticated
():
if
settings
.
FEATURES
.
get
(
'ENABLE_PSYCHOMETRICS'
)
and
user
.
is_authenticated
():
system
.
set
(
system
.
set
(
'psychometrics_handler'
,
# set callback for updating PsychometricsData
'psychometrics_handler'
,
# set callback for updating PsychometricsData
...
...
lms/envs/test.py
View file @
0de4f601
...
@@ -53,6 +53,8 @@ FEATURES['DISABLE_START_DATES'] = True
...
@@ -53,6 +53,8 @@ FEATURES['DISABLE_START_DATES'] = True
# the one in cms/envs/test.py
# the one in cms/envs/test.py
FEATURES
[
'ENABLE_DISCUSSION_SERVICE'
]
=
False
FEATURES
[
'ENABLE_DISCUSSION_SERVICE'
]
=
False
FEATURES
[
'ENABLE_DISCUSSION_EMAIL_DIGEST'
]
=
True
FEATURES
[
'ENABLE_SERVICE_STATUS'
]
=
True
FEATURES
[
'ENABLE_SERVICE_STATUS'
]
=
True
FEATURES
[
'ENABLE_HINTER_INSTRUCTOR_VIEW'
]
=
True
FEATURES
[
'ENABLE_HINTER_INSTRUCTOR_VIEW'
]
=
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