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
8283c07e
Commit
8283c07e
authored
Jul 10, 2015
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `superfluous-parens` pylint violations
Skipped 'print' statement violations, as print() is Py3k syntax.
parent
47b99720
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
95 additions
and
94 deletions
+95
-94
cms/djangoapps/contentstore/features/grading.py
+1
-1
cms/djangoapps/contentstore/features/pages.py
+1
-1
cms/djangoapps/contentstore/features/transcripts.py
+1
-1
cms/djangoapps/contentstore/features/upload.py
+1
-1
cms/djangoapps/contentstore/management/commands/import.py
+1
-1
cms/djangoapps/contentstore/tests/test_contentstore.py
+2
-2
cms/djangoapps/contentstore/utils.py
+2
-2
cms/djangoapps/contentstore/views/item.py
+1
-1
common/djangoapps/course_action_state/tests/test_managers.py
+1
-1
common/djangoapps/course_modes/models.py
+1
-1
common/djangoapps/student/models.py
+2
-2
common/djangoapps/student/roles.py
+1
-1
common/djangoapps/terrain/steps.py
+1
-1
common/djangoapps/track/contexts.py
+1
-1
common/lib/capa/capa/capa_problem.py
+1
-1
common/lib/capa/capa/checker.py
+1
-1
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/capa/capa/tests/response_xml_factory.py
+8
-8
common/lib/symmath/symmath/formula.py
+2
-2
common/lib/symmath/symmath/symmath_check.py
+11
-10
common/lib/xmodule/xmodule/capa_base.py
+1
-1
common/lib/xmodule/xmodule/capa_module.py
+1
-1
common/lib/xmodule/xmodule/contentstore/content.py
+1
-1
common/lib/xmodule/xmodule/course_module.py
+1
-1
common/lib/xmodule/xmodule/graders.py
+1
-1
common/lib/xmodule/xmodule/html_module.py
+1
-1
common/lib/xmodule/xmodule/modulestore/__init__.py
+3
-3
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+2
-2
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+1
-1
common/lib/xmodule/xmodule/modulestore/xml.py
+1
-1
common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py
+2
-2
common/lib/xmodule/xmodule/peer_grading_module.py
+1
-1
common/lib/xmodule/xmodule/tabs.py
+1
-1
common/lib/xmodule/xmodule/tests/test_capa_module.py
+1
-1
common/lib/xmodule/xmodule/tests/test_course_module.py
+7
-7
common/lib/xmodule/xmodule/tests/test_delay_between_attempts.py
+1
-1
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+1
-1
common/lib/xmodule/xmodule/video_module/video_handlers.py
+1
-1
common/lib/xmodule/xmodule/x_module.py
+1
-1
common/test/acceptance/pages/lms/edxnotes.py
+1
-1
common/test/acceptance/pages/lms/login_and_register.py
+1
-1
lms/djangoapps/class_dashboard/dashboard_data.py
+1
-1
lms/djangoapps/courseware/features/problems.py
+5
-5
lms/djangoapps/courseware/features/problems_setup.py
+1
-1
lms/djangoapps/courseware/features/video.py
+3
-3
lms/djangoapps/courseware/features/word_cloud.py
+1
-1
lms/djangoapps/courseware/module_render.py
+2
-2
lms/djangoapps/courseware/tests/test_submitting_problems.py
+1
-1
lms/djangoapps/instructor/views/instructor_dashboard.py
+1
-1
lms/djangoapps/open_ended_grading/staff_grading_service.py
+2
-2
lms/djangoapps/shoppingcart/tests/payment_fake.py
+1
-1
lms/djangoapps/shoppingcart/utils.py
+1
-1
lms/lib/comment_client/models.py
+2
-2
openedx/core/djangoapps/user_api/tests/test_views.py
+1
-1
openedx/core/djangoapps/user_api/views.py
+1
-1
No files found.
cms/djangoapps/contentstore/features/grading.py
View file @
8283c07e
...
...
@@ -170,7 +170,7 @@ def cannot_edit_fail(_step):
# try to change the grade range -- this should throw an exception
try
:
ranges
.
last
.
value
=
'Failure'
except
(
InvalidElementStateException
)
:
except
InvalidElementStateException
:
pass
# We should get this exception on failing to edit the element
# check to be sure that nothing has changed
...
...
cms/djangoapps/contentstore/features/pages.py
View file @
8283c07e
...
...
@@ -33,7 +33,7 @@ def see_a_static_page_named_foo(step, name):
@step
(
u'I should not see any static pages$'
)
def
not_see_any_static_pages
(
step
):
pages_css
=
'div.xmodule_StaticTabModule'
assert
(
world
.
is_css_not_present
(
pages_css
,
wait_time
=
30
)
)
assert
world
.
is_css_not_present
(
pages_css
,
wait_time
=
30
)
@step
(
u'I "(edit|delete)" the static page$'
)
...
...
cms/djangoapps/contentstore/features/transcripts.py
View file @
8283c07e
...
...
@@ -205,7 +205,7 @@ def check_text_in_the_captions(_step, text):
world
.
wait_for_present
(
'.video.is-captions-rendered'
)
world
.
wait_for
(
lambda
_
:
world
.
css_text
(
'.subtitles'
),
timeout
=
30
)
actual_text
=
world
.
css_text
(
'.subtitles'
)
assert
(
text
in
actual_text
)
assert
text
in
actual_text
@step
(
'I see value "([^"]*)" in the field "([^"]*)"$'
)
...
...
cms/djangoapps/contentstore/features/upload.py
View file @
8283c07e
...
...
@@ -74,7 +74,7 @@ def check_not_there(_step, file_name):
# the only file that was uploaded, our success criteria
# will be that there are no files.
# In the future we can refactor if necessary.
assert
(
world
.
is_css_not_present
(
ASSET_NAMES_CSS
)
)
assert
world
.
is_css_not_present
(
ASSET_NAMES_CSS
)
@step
(
u'I should see the file "([^"]*)" was uploaded$'
)
...
...
cms/djangoapps/contentstore/management/commands/import.py
View file @
8283c07e
...
...
@@ -29,7 +29,7 @@ class Command(BaseCommand):
raise
CommandError
(
"import requires at least one argument: <data directory> [--nostatic] [<course dir>...]"
)
data_dir
=
args
[
0
]
do_import_static
=
not
(
options
.
get
(
'nostatic'
,
False
)
)
do_import_static
=
not
options
.
get
(
'nostatic'
,
False
)
if
len
(
args
)
>
1
:
source_dirs
=
args
[
1
:]
else
:
...
...
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
8283c07e
...
...
@@ -659,7 +659,7 @@ class MiscCourseTests(ContentStoreTestCase):
direct_store_items
=
self
.
store
.
get_items
(
self
.
course
.
id
,
revision
=
ModuleStoreEnum
.
RevisionOption
.
published_only
)
items_from_direct_store
=
[
item
for
item
in
direct_store_items
if
(
item
.
location
==
self
.
problem
.
location
)
]
items_from_direct_store
=
[
item
for
item
in
direct_store_items
if
item
.
location
==
self
.
problem
.
location
]
self
.
assertEqual
(
len
(
items_from_direct_store
),
1
)
self
.
assertFalse
(
getattr
(
items_from_direct_store
[
0
],
'is_draft'
,
False
))
...
...
@@ -667,7 +667,7 @@ class MiscCourseTests(ContentStoreTestCase):
draft_store_items
=
self
.
store
.
get_items
(
self
.
course
.
id
,
revision
=
ModuleStoreEnum
.
RevisionOption
.
draft_only
)
items_from_draft_store
=
[
item
for
item
in
draft_store_items
if
(
item
.
location
==
self
.
problem
.
location
)
]
items_from_draft_store
=
[
item
for
item
in
draft_store_items
if
item
.
location
==
self
.
problem
.
location
]
self
.
assertEqual
(
len
(
items_from_draft_store
),
1
)
# TODO the below won't work for split mongo
self
.
assertTrue
(
getattr
(
items_from_draft_store
[
0
],
'is_draft'
,
False
))
...
...
cms/djangoapps/contentstore/utils.py
View file @
8283c07e
...
...
@@ -87,7 +87,7 @@ def get_lms_link_for_item(location, preview=False):
:param location: the location to jump to
:param preview: True if the preview version of LMS should be returned. Default value is false.
"""
assert
(
isinstance
(
location
,
UsageKey
)
)
assert
isinstance
(
location
,
UsageKey
)
if
settings
.
LMS_BASE
is
None
:
return
None
...
...
@@ -109,7 +109,7 @@ def get_lms_link_for_about_page(course_key):
Returns the url to the course about page from the location tuple.
"""
assert
(
isinstance
(
course_key
,
CourseKey
)
)
assert
isinstance
(
course_key
,
CourseKey
)
if
settings
.
FEATURES
.
get
(
'ENABLE_MKTG_SITE'
,
False
):
if
not
hasattr
(
settings
,
'MKTG_URLS'
):
...
...
cms/djangoapps/contentstore/views/item.py
View file @
8283c07e
...
...
@@ -242,7 +242,7 @@ def xblock_view_handler(request, usage_key_string, view_name):
log
.
debug
(
"Unable to render
%
s for
%
r"
,
view_name
,
xblock
,
exc_info
=
True
)
fragment
=
Fragment
(
render_to_string
(
'html_error.html'
,
{
'message'
:
str
(
exc
)}))
elif
view_name
in
(
PREVIEW_VIEWS
+
container_views
)
:
elif
view_name
in
PREVIEW_VIEWS
+
container_views
:
is_pages_view
=
view_name
==
STUDENT_VIEW
# Only the "Pages" view uses student view in Studio
can_edit
=
has_studio_write_access
(
request
.
user
,
usage_key
.
course_key
)
...
...
common/djangoapps/course_action_state/tests/test_managers.py
View file @
8283c07e
...
...
@@ -105,7 +105,7 @@ class TestCourseActionUIStateManager(TestCourseActionStateManagerBase):
)
# create course action states for all courses
for
CourseState
in
(
self
.
course_actions_displayable_states
+
self
.
courses_with_state3_non_displayable
)
:
for
CourseState
in
self
.
course_actions_displayable_states
+
self
.
courses_with_state3_non_displayable
:
action_class
.
objects
.
update_state
(
CourseState
.
course_key
,
CourseState
.
state
,
...
...
common/djangoapps/course_modes/models.py
View file @
8283c07e
...
...
@@ -457,7 +457,7 @@ class CourseMode(models.Model):
return
False
# Check that the default mode is available.
return
(
cls
.
HONOR
in
modes_dict
)
return
cls
.
HONOR
in
modes_dict
@classmethod
def
is_white_label
(
cls
,
course_id
,
modes_dict
=
None
):
...
...
common/djangoapps/student/models.py
View file @
8283c07e
...
...
@@ -885,7 +885,7 @@ class CourseEnrollment(models.Model):
# save it to the database so that it can have an ID that we can throw
# into our CourseEnrollment object. Otherwise, we'll get an
# IntegrityError for having a null user_id.
assert
(
isinstance
(
course_key
,
CourseKey
)
)
assert
isinstance
(
course_key
,
CourseKey
)
if
user
.
id
is
None
:
user
.
save
()
...
...
@@ -994,7 +994,7 @@ class CourseEnrollment(models.Model):
try
:
context
=
contexts
.
course_context_from_course_id
(
self
.
course_id
)
assert
(
isinstance
(
self
.
course_id
,
CourseKey
)
)
assert
isinstance
(
self
.
course_id
,
CourseKey
)
data
=
{
'user_id'
:
self
.
user
.
id
,
'course_id'
:
self
.
course_id
.
to_deprecated_string
(),
...
...
common/djangoapps/student/roles.py
View file @
8283c07e
...
...
@@ -99,7 +99,7 @@ class GlobalStaff(AccessRole):
def
add_users
(
self
,
*
users
):
for
user
in
users
:
if
(
user
.
is_authenticated
()
and
user
.
is_active
)
:
if
user
.
is_authenticated
()
and
user
.
is_active
:
user
.
is_staff
=
True
user
.
save
()
...
...
common/djangoapps/terrain/steps.py
View file @
8283c07e
...
...
@@ -95,7 +95,7 @@ def the_page_title_should_be(step, title):
@step
(
u'the page title should contain "([^"]*)"$'
)
def
the_page_title_should_contain
(
step
,
title
):
assert
(
title
in
world
.
browser
.
title
)
assert
title
in
world
.
browser
.
title
@step
(
'I log in$'
)
...
...
common/djangoapps/track/contexts.py
View file @
8283c07e
...
...
@@ -49,7 +49,7 @@ def course_context_from_course_id(course_id):
return
{
'course_id'
:
''
,
'org_id'
:
''
}
# TODO: Make this accept any CourseKey, and serialize it using .to_string
assert
(
isinstance
(
course_id
,
CourseKey
)
)
assert
isinstance
(
course_id
,
CourseKey
)
return
{
'course_id'
:
course_id
.
to_deprecated_string
(),
'org_id'
:
course_id
.
org
,
...
...
common/lib/capa/capa/capa_problem.py
View file @
8283c07e
...
...
@@ -853,7 +853,7 @@ class LoncapaProblem(object):
answer_id
=
1
input_tags
=
inputtypes
.
registry
.
registered_tags
()
inputfields
=
tree
.
xpath
(
"|"
.
join
([
'//'
+
response
.
tag
+
'[@id=$id]//'
+
x
for
x
in
(
input_tags
+
solution_tags
)
]),
"|"
.
join
([
'//'
+
response
.
tag
+
'[@id=$id]//'
+
x
for
x
in
input_tags
+
solution_tags
]),
id
=
response_id_str
)
...
...
common/lib/capa/capa/checker.py
View file @
8283c07e
...
...
@@ -99,7 +99,7 @@ def check_that_blanks_fail(problem):
for
answer_id
in
problem
.
get_question_answers
())
grading_results
=
problem
.
grade_answers
(
blank_answers
)
try
:
assert
(
all
(
result
==
'incorrect'
for
result
in
grading_results
.
values
()
))
assert
all
(
result
==
'incorrect'
for
result
in
grading_results
.
values
(
))
except
AssertionError
:
log
.
error
(
"Blank accepted as correct answer in {0} for {1}"
.
format
(
problem
,
...
...
common/lib/capa/capa/responsetypes.py
View file @
8283c07e
...
...
@@ -2719,7 +2719,7 @@ class ExternalResponse(LoncapaResponse):
exans
=
[
''
]
*
len
(
self
.
answer_ids
)
exans
[
0
]
=
msg
if
not
(
len
(
exans
)
==
len
(
self
.
answer_ids
)
):
if
not
len
(
exans
)
==
len
(
self
.
answer_ids
):
log
.
error
(
'Expected
%
s answers from external server, only got
%
s!'
,
len
(
self
.
answer_ids
),
len
(
exans
))
raise
Exception
(
'Short response from external server'
)
...
...
common/lib/capa/capa/tests/response_xml_factory.py
View file @
8283c07e
...
...
@@ -80,7 +80,7 @@ class ResponseXMLFactory(object):
# Add input elements
for
__
in
range
(
int
(
num_inputs
)):
input_element
=
self
.
create_input_element
(
**
kwargs
)
if
not
(
None
==
input_element
)
:
if
not
None
==
input_element
:
response_element
.
append
(
input_element
)
# The problem has an explanation of the solution
...
...
@@ -146,7 +146,7 @@ class ResponseXMLFactory(object):
choice_names
=
kwargs
.
get
(
'choice_names'
,
[
None
]
*
len
(
choices
))
# Create the <choicegroup>, <checkboxgroup>, or <radiogroup> element
assert
(
choice_type
in
group_element_names
)
assert
choice_type
in
group_element_names
group_element
=
etree
.
Element
(
group_element_names
[
choice_type
])
# Create the <choice> elements
...
...
@@ -412,8 +412,8 @@ class FormulaResponseXMLFactory(ResponseXMLFactory):
answer
=
kwargs
.
get
(
"answer"
,
None
)
hint_list
=
kwargs
.
get
(
"hints"
,
None
)
assert
(
answer
)
assert
(
sample_dict
and
num_samples
)
assert
answer
assert
sample_dict
and
num_samples
# Create the <formularesponse> element
response_element
=
etree
.
Element
(
"formularesponse"
)
...
...
@@ -518,7 +518,7 @@ class ImageResponseXMLFactory(ResponseXMLFactory):
rectangle
=
kwargs
.
get
(
'rectangle'
,
None
)
regions
=
kwargs
.
get
(
'regions'
,
None
)
assert
(
rectangle
or
regions
)
assert
rectangle
or
regions
# Create the <imageinput> element
input_element
=
etree
.
Element
(
"imageinput"
)
...
...
@@ -635,9 +635,9 @@ class OptionResponseXMLFactory(ResponseXMLFactory):
options_list
=
kwargs
.
get
(
'options'
,
None
)
correct_option
=
kwargs
.
get
(
'correct_option'
,
None
)
assert
(
options_list
and
correct_option
)
assert
(
len
(
options_list
)
>
1
)
assert
(
correct_option
in
options_list
)
assert
options_list
and
correct_option
assert
len
(
options_list
)
>
1
assert
correct_option
in
options_list
# Create the <optioninput> element
optioninput_element
=
etree
.
Element
(
"optioninput"
)
...
...
common/lib/symmath/symmath/formula.py
View file @
8283c07e
...
...
@@ -309,7 +309,7 @@ class formula(object):
with 'scriptN'. There have been problems using script_N or script(N)
"""
for
child
in
parent
:
if
(
gettag
(
child
)
==
'mstyle'
and
child
.
get
(
'mathvariant'
)
==
'script'
)
:
if
gettag
(
child
)
==
'mstyle'
and
child
.
get
(
'mathvariant'
)
==
'script'
:
newchild
=
etree
.
Element
(
'mi'
)
newchild
.
text
=
'script
%
s'
%
flatten_pmathml
(
child
[
0
])
parent
.
replace
(
child
,
newchild
)
...
...
@@ -397,7 +397,7 @@ class formula(object):
"""
for
child
in
parent
:
# fix msubsup
if
(
gettag
(
child
)
==
'msubsup'
and
len
(
child
)
==
3
)
:
if
gettag
(
child
)
==
'msubsup'
and
len
(
child
)
==
3
:
newchild
=
etree
.
Element
(
'msup'
)
newbase
=
etree
.
Element
(
'mi'
)
newbase
.
text
=
'
%
s_
%
s'
%
(
flatten_pmathml
(
child
[
0
]),
flatten_pmathml
(
child
[
1
]))
...
...
common/lib/symmath/symmath/symmath_check.py
View file @
8283c07e
...
...
@@ -86,7 +86,7 @@ def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym=
threshold
=
float
(
st
)
numerical
=
True
if
str
(
given
)
==
''
and
not
(
str
(
expect
)
==
''
)
:
if
str
(
given
)
==
''
and
not
str
(
expect
)
==
''
:
return
{
'ok'
:
False
,
'msg'
:
''
}
try
:
...
...
@@ -125,12 +125,12 @@ def check(expect, given, numerical=False, matrix=False, normphase=False, abcsym=
#msg += "dm = " + to_latex(dm) + " diff = " + str(abs(dm.vec().norm().evalf()))
#msg += "expect = " + to_latex(xexpect)
elif
dosimplify
:
if
(
sympy
.
simplify
(
xexpect
)
==
sympy
.
simplify
(
xgiven
)
):
if
sympy
.
simplify
(
xexpect
)
==
sympy
.
simplify
(
xgiven
):
return
{
'ok'
:
True
,
'msg'
:
msg
}
elif
numerical
:
if
(
abs
((
xexpect
-
xgiven
)
.
evalf
(
chop
=
True
))
<
threshold
)
:
if
abs
((
xexpect
-
xgiven
)
.
evalf
(
chop
=
True
))
<
threshold
:
return
{
'ok'
:
True
,
'msg'
:
msg
}
elif
(
xexpect
==
xgiven
)
:
elif
xexpect
==
xgiven
:
return
{
'ok'
:
True
,
'msg'
:
msg
}
#msg += "<p/>expect='%s', given='%s'" % (expect,given) # debugging
...
...
@@ -149,9 +149,9 @@ def make_error_message(msg):
def
is_within_tolerance
(
expected
,
actual
,
tolerance
):
if
expected
==
0
:
return
(
abs
(
actual
)
<
tolerance
)
return
abs
(
actual
)
<
tolerance
else
:
return
(
abs
(
abs
(
actual
-
expected
)
/
expected
)
<
tolerance
)
return
abs
(
abs
(
actual
-
expected
)
/
expected
)
<
tolerance
#-----------------------------------------------------------------------------
# Check function interface, which takes pmathml input
...
...
@@ -198,10 +198,11 @@ def symmath_check(expect, ans, dynamath=None, options=None, debug=None, xml=None
DEBUG
=
False
# options
do_matrix
=
'matrix'
in
(
options
or
''
)
do_qubit
=
'qubit'
in
(
options
or
''
)
do_imaginary
=
'imaginary'
in
(
options
or
''
)
do_numerical
=
'numerical'
in
(
options
or
''
)
if
options
is
None
:
options
=
''
do_matrix
=
'matrix'
in
options
do_qubit
=
'qubit'
in
options
do_numerical
=
'numerical'
in
options
# parse expected answer
try
:
...
...
common/lib/xmodule/xmodule/capa_base.py
View file @
8283c07e
...
...
@@ -469,7 +469,7 @@ class CapaMixin(CapaFields):
# If the problem is closed (and not a survey question with max_attempts==0),
# then do NOT show the reset button.
if
(
self
.
closed
()
and
not
is_survey_question
)
:
if
self
.
closed
()
and
not
is_survey_question
:
return
False
# Button only shows up for randomized problems if the question has been submitted
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
8283c07e
...
...
@@ -143,7 +143,7 @@ class CapaDescriptor(CapaFields, RawDescriptor):
Show them only if use_latex_compiler is set to True in
course settings.
"""
return
(
'latex'
not
in
template
[
'template_id'
]
or
course
.
use_latex_compiler
)
return
'latex'
not
in
template
[
'template_id'
]
or
course
.
use_latex_compiler
def
get_context
(
self
):
_context
=
RawDescriptor
.
get_context
(
self
)
...
...
common/lib/xmodule/xmodule/contentstore/content.py
View file @
8283c07e
...
...
@@ -105,7 +105,7 @@ class StaticContent(object):
if
course_key
is
None
:
return
None
assert
(
isinstance
(
course_key
,
CourseKey
)
)
assert
isinstance
(
course_key
,
CourseKey
)
placeholder_id
=
uuid
.
uuid4
()
.
hex
# create a dummy asset location with a fake but unique name. strip off the name, and return it
url_path
=
StaticContent
.
serialize_asset_key_with_slash
(
...
...
common/lib/xmodule/xmodule/course_module.py
View file @
8283c07e
...
...
@@ -1009,7 +1009,7 @@ class CourseDescriptor(CourseFields, SequenceDescriptor, LicenseMixin):
policy_str
=
grading_policy_file
.
read
()
# if we successfully read the file, stop looking at backups
break
except
(
IOError
)
:
except
IOError
:
msg
=
"Unable to load course settings file from '{0}'"
.
format
(
policy_path
)
log
.
warning
(
msg
)
...
...
common/lib/xmodule/xmodule/graders.py
View file @
8283c07e
...
...
@@ -310,7 +310,7 @@ class AssignmentFormatGrader(CourseGrader):
if
index
not
in
dropped_indices
:
aggregate_score
+=
mark
[
'percent'
]
if
(
len
(
breakdown
)
-
drop_count
>
0
)
:
if
len
(
breakdown
)
-
drop_count
>
0
:
aggregate_score
/=
len
(
breakdown
)
-
drop_count
return
aggregate_score
,
dropped_indices
...
...
common/lib/xmodule/xmodule/html_module.py
View file @
8283c07e
...
...
@@ -135,7 +135,7 @@ class HtmlDescriptor(HtmlFields, XmlDescriptor, EditingDescriptor): # pylint: d
Show them only if use_latex_compiler is set to True in
course settings.
"""
return
(
'latex'
not
in
template
[
'template_id'
]
or
course
.
use_latex_compiler
)
return
'latex'
not
in
template
[
'template_id'
]
or
course
.
use_latex_compiler
def
get_context
(
self
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
8283c07e
...
...
@@ -1151,7 +1151,7 @@ class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead):
# pylint: disable=fixme
# TODO (vshnayder): post-launch, make errors properties of items
# self.get_item(location)
assert
(
isinstance
(
course_key
,
CourseKey
)
)
assert
isinstance
(
course_key
,
CourseKey
)
return
self
.
_course_errors
[
course_key
]
.
errors
def
get_errored_courses
(
self
):
...
...
@@ -1169,7 +1169,7 @@ class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead):
Default impl--linear search through course list
"""
assert
(
isinstance
(
course_id
,
CourseKey
)
)
assert
isinstance
(
course_id
,
CourseKey
)
for
course
in
self
.
get_courses
(
**
kwargs
):
if
course
.
id
==
course_id
:
return
course
...
...
@@ -1184,7 +1184,7 @@ class ModuleStoreReadBase(BulkOperationsMixin, ModuleStoreRead):
to search for whether a potentially conflicting course exists in that case.
"""
# linear search through list
assert
(
isinstance
(
course_id
,
CourseKey
)
)
assert
isinstance
(
course_id
,
CourseKey
)
if
ignore_case
:
return
next
(
(
...
...
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
8283c07e
...
...
@@ -1495,7 +1495,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
partitioned_fields
=
self
.
partition_fields_by_scope
(
block_type
,
fields
)
new_def_data
=
partitioned_fields
.
get
(
Scope
.
content
,
{})
# persist the definition if persisted != passed
if
(
definition_locator
is
None
or
isinstance
(
definition_locator
.
definition_id
,
LocalId
)
):
if
definition_locator
is
None
or
isinstance
(
definition_locator
.
definition_id
,
LocalId
):
definition_locator
=
self
.
create_definition_from_data
(
course_key
,
new_def_data
,
block_type
,
user_id
)
elif
new_def_data
:
definition_locator
,
_
=
self
.
update_definition_from_data
(
course_key
,
definition_locator
,
new_def_data
,
user_id
)
...
...
@@ -2770,7 +2770,7 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
course_key
.
version_guid
is
None
or
index_entry
[
'versions'
][
course_key
.
branch
]
==
course_key
.
version_guid
)
if
(
is_head
or
force
)
:
if
is_head
or
force
:
return
index_entry
else
:
raise
VersionConflictError
(
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
8283c07e
...
...
@@ -1407,7 +1407,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
course_id
.
make_usage_key
(
'course_info'
,
'updates'
),
]
for
location
in
(
orphan_locations
+
detached_locations
)
:
for
location
in
orphan_locations
+
detached_locations
:
self
.
store
.
create_item
(
self
.
user_id
,
location
.
course_key
,
...
...
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
8283c07e
...
...
@@ -866,7 +866,7 @@ class XMLModuleStore(ModuleStoreReadBase):
:return: list of course locations
"""
courses
=
self
.
get_courses
()
return
[
course
.
location
.
course_key
for
course
in
courses
if
(
course
.
wiki_slug
==
wiki_slug
)
]
return
[
course
.
location
.
course_key
for
course
in
courses
if
course
.
wiki_slug
==
wiki_slug
]
def
heartbeat
(
self
):
"""
...
...
common/lib/xmodule/xmodule/open_ended_grading_classes/openendedchild.py
View file @
8283c07e
...
...
@@ -298,7 +298,7 @@ class OpenEndedChild(object):
def
_allow_reset
(
self
):
"""Can the module be reset?"""
return
(
self
.
child_state
==
self
.
DONE
and
self
.
child_attempts
<
self
.
max_attempts
)
return
self
.
child_state
==
self
.
DONE
and
self
.
child_attempts
<
self
.
max_attempts
def
max_score
(
self
):
"""
...
...
@@ -396,7 +396,7 @@ class OpenEndedChild(object):
@return: Boolean correct.
"""
correct
=
False
if
(
isinstance
(
score
,
(
int
,
long
,
float
,
complex
)
)):
if
isinstance
(
score
,
(
int
,
long
,
float
,
complex
)):
score_ratio
=
int
(
score
)
/
float
(
self
.
max_score
())
correct
=
(
score_ratio
>=
0.66
)
return
correct
...
...
common/lib/xmodule/xmodule/peer_grading_module.py
View file @
8283c07e
...
...
@@ -118,7 +118,7 @@ class PeerGradingModule(PeerGradingFields, XModule):
# We need to set the location here so the child modules can use it.
self
.
runtime
.
set
(
'location'
,
self
.
location
)
if
(
self
.
runtime
.
open_ended_grading_interface
)
:
if
self
.
runtime
.
open_ended_grading_interface
:
self
.
peer_gs
=
PeerGradingService
(
self
.
system
.
open_ended_grading_interface
,
self
.
system
.
render_template
)
else
:
self
.
peer_gs
=
MockPeerGradingService
()
...
...
common/lib/xmodule/xmodule/tabs.py
View file @
8283c07e
...
...
@@ -146,7 +146,7 @@ class CourseTab(object):
"""
Overrides the not equal operator as a partner to the equal operator.
"""
return
not
(
self
==
other
)
return
not
self
==
other
@classmethod
def
validate
(
cls
,
tab_dict
,
raise_error
=
True
):
...
...
common/lib/xmodule/xmodule/tests/test_capa_module.py
View file @
8283c07e
...
...
@@ -63,7 +63,7 @@ class CapaFactory(object):
"""
Return the input key to use when passing GET parameters
"""
return
(
"input_"
+
cls
.
answer_key
(
response_num
,
input_num
)
)
return
"input_"
+
cls
.
answer_key
(
response_num
,
input_num
)
@classmethod
def
answer_key
(
cls
,
response_num
=
2
,
input_num
=
1
):
...
...
common/lib/xmodule/xmodule/tests/test_course_module.py
View file @
8283c07e
...
...
@@ -241,25 +241,25 @@ class IsNewCourseTestCase(unittest.TestCase):
def
test_is_newish
(
self
):
descriptor
=
get_dummy_course
(
start
=
'2012-12-02T12:00'
,
is_new
=
True
)
assert
(
descriptor
.
is_newish
is
True
)
assert
descriptor
.
is_newish
is
True
descriptor
=
get_dummy_course
(
start
=
'2013-02-02T12:00'
,
is_new
=
False
)
assert
(
descriptor
.
is_newish
is
False
)
assert
descriptor
.
is_newish
is
False
descriptor
=
get_dummy_course
(
start
=
'2013-02-02T12:00'
,
is_new
=
True
)
assert
(
descriptor
.
is_newish
is
True
)
assert
descriptor
.
is_newish
is
True
descriptor
=
get_dummy_course
(
start
=
'2013-01-15T12:00'
)
assert
(
descriptor
.
is_newish
is
True
)
assert
descriptor
.
is_newish
is
True
descriptor
=
get_dummy_course
(
start
=
'2013-03-01T12:00'
)
assert
(
descriptor
.
is_newish
is
True
)
assert
descriptor
.
is_newish
is
True
descriptor
=
get_dummy_course
(
start
=
'2012-10-15T12:00'
)
assert
(
descriptor
.
is_newish
is
False
)
assert
descriptor
.
is_newish
is
False
descriptor
=
get_dummy_course
(
start
=
'2012-12-31T12:00'
)
assert
(
descriptor
.
is_newish
is
True
)
assert
descriptor
.
is_newish
is
True
def
test_end_date_text
(
self
):
# No end date set, returns empty string.
...
...
common/lib/xmodule/xmodule/tests/test_delay_between_attempts.py
View file @
8283c07e
...
...
@@ -58,7 +58,7 @@ class CapaFactoryWithDelay(object):
"""
Return the input key to use when passing GET parameters
"""
return
(
"input_"
+
cls
.
answer_key
(
input_num
)
)
return
"input_"
+
cls
.
answer_key
(
input_num
)
@classmethod
def
answer_key
(
cls
,
input_num
=
2
):
...
...
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
View file @
8283c07e
...
...
@@ -462,7 +462,7 @@ def get_or_create_sjson(item, transcripts):
source_subs_id
,
result_subs_dict
=
user_subs_id
,
{
1.0
:
user_subs_id
}
try
:
sjson_transcript
=
Transcript
.
asset
(
item
.
location
,
source_subs_id
,
item
.
transcript_language
)
.
data
except
(
NotFoundError
)
:
# generating sjson from srt
except
NotFoundError
:
# generating sjson from srt
generate_sjson_for_all_speeds
(
item
,
user_filename
,
result_subs_dict
,
item
.
transcript_language
)
sjson_transcript
=
Transcript
.
asset
(
item
.
location
,
source_subs_id
,
item
.
transcript_language
)
.
data
return
sjson_transcript
...
...
common/lib/xmodule/xmodule/video_module/video_handlers.py
View file @
8283c07e
...
...
@@ -125,7 +125,7 @@ class VideoStudentViewHandlers(object):
try
:
sjson_transcript
=
Transcript
.
asset
(
self
.
location
,
youtube_id
,
self
.
transcript_language
)
.
data
except
(
NotFoundError
)
:
except
NotFoundError
:
log
.
info
(
"Can't find content in storage for
%
s transcript: generating."
,
youtube_id
)
generate_sjson_for_all_speeds
(
self
,
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
8283c07e
...
...
@@ -371,7 +371,7 @@ class XModuleMixin(XModuleFields, XBlock):
"""
result
=
{}
for
field
in
self
.
fields
.
values
():
if
(
field
.
scope
==
scope
and
field
.
is_set_on
(
self
)
):
if
field
.
scope
==
scope
and
field
.
is_set_on
(
self
):
result
[
field
.
name
]
=
field
.
read_json
(
self
)
return
result
...
...
common/test/acceptance/pages/lms/edxnotes.py
View file @
8283c07e
...
...
@@ -174,7 +174,7 @@ class EdxNotesPageView(PageObject):
self
.
q
(
css
=
self
.
TAB_SELECTOR
)
.
first
.
click
()
try
:
return
self
.
wait_for_page
()
except
(
BrokenPromise
)
:
except
BrokenPromise
:
raise
PageLoadError
(
"Timed out waiting to load page '{!r}'"
.
format
(
self
))
def
is_browser_on_page
(
self
):
...
...
common/test/acceptance/pages/lms/login_and_register.py
View file @
8283c07e
...
...
@@ -197,7 +197,7 @@ class CombinedLoginAndRegisterPage(PageObject):
self
.
q
(
css
=
"#register-password"
)
.
fill
(
password
)
if
country
:
self
.
q
(
css
=
"#register-country option[value='{country}']"
.
format
(
country
=
country
))
.
click
()
if
(
terms_of_service
)
:
if
terms_of_service
:
self
.
q
(
css
=
"#register-honor_code"
)
.
click
()
# Submit it
...
...
lms/djangoapps/class_dashboard/dashboard_data.py
View file @
8283c07e
...
...
@@ -326,7 +326,7 @@ def get_d3_section_grade_distrib(course_id, section):
c_unit
+=
1
c_problem
=
0
for
child
in
unit
.
get_children
():
if
(
child
.
location
.
category
==
'problem'
)
:
if
child
.
location
.
category
==
'problem'
:
c_problem
+=
1
problem_set
.
append
(
child
.
location
)
problem_info
[
child
.
location
]
=
{
...
...
lms/djangoapps/courseware/features/problems.py
View file @
8283c07e
...
...
@@ -82,8 +82,8 @@ def input_problem_answer(_, problem_type, correctness):
"""
Have the browser input an answer (either correct or incorrect)
"""
assert
(
correctness
in
[
'correct'
,
'incorrect'
])
assert
(
problem_type
in
PROBLEM_DICT
)
assert
correctness
in
[
'correct'
,
'incorrect'
]
assert
problem_type
in
PROBLEM_DICT
answer_problem
(
world
.
scenario_dict
[
'COURSE'
]
.
number
,
problem_type
,
correctness
)
...
...
@@ -166,8 +166,8 @@ def assert_answer_mark(_step, problem_type, isnt_marked, correctness):
*correctness* is in ['correct', 'incorrect', 'unanswered']
"""
# Determine which selector(s) to look for based on correctness
assert
(
correctness
in
[
'correct'
,
'incorrect'
,
'unanswered'
])
assert
(
problem_type
in
PROBLEM_DICT
)
assert
correctness
in
[
'correct'
,
'incorrect'
,
'unanswered'
]
assert
problem_type
in
PROBLEM_DICT
# At least one of the correct selectors should be present
for
sel
in
PROBLEM_DICT
[
problem_type
][
correctness
]:
...
...
@@ -183,4 +183,4 @@ def assert_answer_mark(_step, problem_type, isnt_marked, correctness):
break
# Expect that we found the expected selector
assert
(
has_expected
)
assert
has_expected
lms/djangoapps/courseware/features/problems_setup.py
View file @
8283c07e
...
...
@@ -356,7 +356,7 @@ def add_problem_to_course(course, problem_type, extra_meta=None):
Add a problem to the course we have created using factories.
'''
assert
(
problem_type
in
PROBLEM_DICT
)
assert
problem_type
in
PROBLEM_DICT
# Generate the problem XML using capa.tests.response_xml_factory
factory_dict
=
PROBLEM_DICT
[
problem_type
]
...
...
lms/djangoapps/courseware/features/video.py
View file @
8283c07e
...
...
@@ -471,14 +471,14 @@ def check_text_in_the_captions(_step, text):
world
.
wait_for_present
(
'.video.is-captions-rendered'
)
world
.
wait_for
(
lambda
_
:
world
.
css_text
(
'.subtitles'
))
actual_text
=
world
.
css_text
(
'.subtitles'
)
assert
(
text
in
actual_text
)
assert
text
in
actual_text
@step
(
'I see text in the captions:'
)
def
check_captions
(
_step
):
world
.
wait_for_present
(
'.video.is-captions-rendered'
)
for
index
,
video
in
enumerate
(
_step
.
hashes
):
assert
(
video
.
get
(
'text'
)
in
world
.
css_text
(
'.subtitles'
,
index
=
index
)
)
assert
video
.
get
(
'text'
)
in
world
.
css_text
(
'.subtitles'
,
index
=
index
)
@step
(
'I select language with code "([^"]*)"$'
)
...
...
@@ -594,7 +594,7 @@ def i_can_download_transcript(_step, format, text):
request
=
RequestHandlerWithSessionId
()
assert
request
.
get
(
url
)
.
is_success
()
assert
request
.
check_header
(
'content-type'
,
formats
[
format
])
assert
(
text
.
encode
(
'utf-8'
)
in
request
.
content
)
assert
text
.
encode
(
'utf-8'
)
in
request
.
content
@step
(
'I select the transcript format "([^"]*)"$'
)
...
...
lms/djangoapps/courseware/features/word_cloud.py
View file @
8283c07e
...
...
@@ -26,7 +26,7 @@ def press_the_save_button(_step):
@step
(
'I see the empty result'
)
def
see_empty_result
(
_step
):
assert
(
world
.
css_text
(
'.your_words'
,
0
)
==
''
)
assert
world
.
css_text
(
'.your_words'
,
0
)
==
''
@step
(
'I fill inputs'
)
...
...
lms/djangoapps/courseware/module_render.py
View file @
8283c07e
...
...
@@ -1055,9 +1055,9 @@ def get_score_bucket(grade, max_grade):
Used with statsd tracking.
"""
score_bucket
=
"incorrect"
if
(
grade
>
0
and
grade
<
max_grade
)
:
if
grade
>
0
and
grade
<
max_grade
:
score_bucket
=
"partial"
elif
(
grade
==
max_grade
)
:
elif
grade
==
max_grade
:
score_bucket
=
"correct"
return
score_bucket
...
...
lms/djangoapps/courseware/tests/test_submitting_problems.py
View file @
8283c07e
...
...
@@ -174,7 +174,7 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
# if we don't already have a chapter create a new one
if
not
(
hasattr
(
self
,
'chapter'
)
):
if
not
hasattr
(
self
,
'chapter'
):
self
.
chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
category
=
'chapter'
...
...
lms/djangoapps/instructor/views/instructor_dashboard.py
View file @
8283c07e
...
...
@@ -112,7 +112,7 @@ def instructor_dashboard_2(request, course_id):
unicode
(
course_key
),
len
(
paid_modes
)
)
if
(
settings
.
FEATURES
.
get
(
'INDIVIDUAL_DUE_DATES'
)
and
access
[
'instructor'
])
:
if
settings
.
FEATURES
.
get
(
'INDIVIDUAL_DUE_DATES'
)
and
access
[
'instructor'
]
:
sections
.
insert
(
3
,
_section_extensions
(
course
))
# Gate access to course email by feature flag & by course-specific authorization
...
...
lms/djangoapps/open_ended_grading/staff_grading_service.py
View file @
8283c07e
...
...
@@ -257,7 +257,7 @@ def get_next(request, course_id):
'error': if success is False, will have an error message with more info.
"""
assert
(
isinstance
(
course_id
,
basestring
)
)
assert
isinstance
(
course_id
,
basestring
)
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
_check_access
(
request
.
user
,
course_key
)
...
...
@@ -300,7 +300,7 @@ def get_problem_list(request, course_id):
'error': if success is False, will have an error message with more info.
"""
assert
(
isinstance
(
course_id
,
basestring
)
)
assert
isinstance
(
course_id
,
basestring
)
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
_check_access
(
request
.
user
,
course_key
)
try
:
...
...
lms/djangoapps/shoppingcart/tests/payment_fake.py
View file @
8283c07e
...
...
@@ -102,7 +102,7 @@ class PaymentFakeView(View):
])
public_sig
=
processor_hash
(
hash_val
)
return
(
public_sig
==
post_params
.
get
(
'signature'
)
)
return
public_sig
==
post_params
.
get
(
'signature'
)
@classmethod
def
response_post_params
(
cls
,
post_params
):
...
...
lms/djangoapps/shoppingcart/utils.py
View file @
8283c07e
...
...
@@ -27,7 +27,7 @@ def is_shopping_cart_enabled():
settings
.
FEATURES
.
get
(
'ENABLE_SHOPPING_CART'
)
)
return
(
enable_paid_course_registration
and
enable_shopping_cart
)
return
enable_paid_course_registration
and
enable_shopping_cart
def
parse_pages
(
pdf_buffer
,
password
):
...
...
lms/lib/comment_client/models.py
View file @
8283c07e
...
...
@@ -35,7 +35,7 @@ class Model(object):
return
self
.
__getattr__
(
name
)
def
__setattr__
(
self
,
name
,
value
):
if
name
==
'attributes'
or
name
not
in
(
self
.
accessible_fields
+
self
.
updatable_fields
)
:
if
name
==
'attributes'
or
name
not
in
self
.
accessible_fields
+
self
.
updatable_fields
:
super
(
Model
,
self
)
.
__setattr__
(
name
,
value
)
else
:
self
.
attributes
[
name
]
=
value
...
...
@@ -46,7 +46,7 @@ class Model(object):
return
self
.
attributes
.
get
(
key
)
def
__setitem__
(
self
,
key
,
value
):
if
key
not
in
(
self
.
accessible_fields
+
self
.
updatable_fields
)
:
if
key
not
in
self
.
accessible_fields
+
self
.
updatable_fields
:
raise
KeyError
(
"Field {0} does not exist"
.
format
(
key
))
self
.
attributes
.
__setitem__
(
key
,
value
)
...
...
openedx/core/djangoapps/user_api/tests/test_views.py
View file @
8283c07e
...
...
@@ -78,7 +78,7 @@ class ApiTestCase(TestCase):
"""Given a user preference object, get the URI for the corresponding resource"""
prefs
=
self
.
get_json
(
USER_PREFERENCE_LIST_URI
)[
"results"
]
for
pref
in
prefs
:
if
(
pref
[
"user"
][
"id"
]
==
target_pref
.
user
.
id
and
pref
[
"key"
]
==
target_pref
.
key
)
:
if
pref
[
"user"
][
"id"
]
==
target_pref
.
user
.
id
and
pref
[
"key"
]
==
target_pref
.
key
:
return
pref
[
"url"
]
self
.
fail
()
...
...
openedx/core/djangoapps/user_api/views.py
View file @
8283c07e
...
...
@@ -196,7 +196,7 @@ class RegistrationView(APIView):
# Map field names to the instance method used to add the field to the form
self
.
field_handlers
=
{}
for
field_name
in
(
self
.
DEFAULT_FIELDS
+
self
.
EXTRA_FIELDS
)
:
for
field_name
in
self
.
DEFAULT_FIELDS
+
self
.
EXTRA_FIELDS
:
handler
=
getattr
(
self
,
"_add_{field_name}_field"
.
format
(
field_name
=
field_name
))
self
.
field_handlers
[
field_name
]
=
handler
...
...
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