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
0a650f39
Commit
0a650f39
authored
Aug 13, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #393 from MITx/feature/victor/bad-content-warn-not-error
Feature/victor/bad content warn not error
parents
03d04c1f
69a0e628
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
30 deletions
+53
-30
common/djangoapps/student/views.py
+2
-2
common/lib/capa/capa/capa_problem.py
+8
-8
common/lib/capa/capa/inputtypes.py
+7
-7
common/lib/xmodule/xmodule/capa_module.py
+1
-1
common/lib/xmodule/xmodule/modulestore/xml.py
+5
-4
common/lib/xmodule/xmodule/x_module.py
+5
-4
doc/development.md
+25
-4
No files found.
common/djangoapps/student/views.py
View file @
0a650f39
...
@@ -128,7 +128,7 @@ def dashboard(request):
...
@@ -128,7 +128,7 @@ def dashboard(request):
try
:
try
:
courses
.
append
(
course_from_id
(
enrollment
.
course_id
))
courses
.
append
(
course_from_id
(
enrollment
.
course_id
))
except
ItemNotFoundError
:
except
ItemNotFoundError
:
log
.
error
(
"User {0} enrolled in non-exist
a
nt course {1}"
log
.
error
(
"User {0} enrolled in non-exist
e
nt course {1}"
.
format
(
user
.
username
,
enrollment
.
course_id
))
.
format
(
user
.
username
,
enrollment
.
course_id
))
message
=
""
message
=
""
...
@@ -182,7 +182,7 @@ def change_enrollment(request):
...
@@ -182,7 +182,7 @@ def change_enrollment(request):
try
:
try
:
course
=
course_from_id
(
course_id
)
course
=
course_from_id
(
course_id
)
except
ItemNotFoundError
:
except
ItemNotFoundError
:
log
.
error
(
"User {0} tried to enroll in non-existant course {1}"
log
.
warning
(
"User {0} tried to enroll in non-existant course {1}"
.
format
(
user
.
username
,
enrollment
.
course_id
))
.
format
(
user
.
username
,
enrollment
.
course_id
))
return
{
'success'
:
False
,
'error'
:
'The course requested does not exist.'
}
return
{
'success'
:
False
,
'error'
:
'The course requested does not exist.'
}
...
...
common/lib/capa/capa/capa_problem.py
View file @
0a650f39
...
@@ -229,14 +229,14 @@ class LoncapaProblem(object):
...
@@ -229,14 +229,14 @@ class LoncapaProblem(object):
Calls the Response for each question in this problem, to do the actual grading.
Calls the Response for each question in this problem, to do the actual grading.
'''
'''
self
.
student_answers
=
convert_files_to_filenames
(
answers
)
self
.
student_answers
=
convert_files_to_filenames
(
answers
)
oldcmap
=
self
.
correct_map
# old CorrectMap
oldcmap
=
self
.
correct_map
# old CorrectMap
newcmap
=
CorrectMap
()
# start new with empty CorrectMap
newcmap
=
CorrectMap
()
# start new with empty CorrectMap
# log.debug('Responders: %s' % self.responders)
# log.debug('Responders: %s' % self.responders)
for
responder
in
self
.
responders
.
values
():
# Call each responsetype instance to do actual grading
for
responder
in
self
.
responders
.
values
():
# Call each responsetype instance to do actual grading
if
'filesubmission'
in
responder
.
allowed_inputfields
:
# File objects are passed only if responsetype
if
'filesubmission'
in
responder
.
allowed_inputfields
:
# File objects are passed only if responsetype
# explicitly allows for file submissions
# explicitly allows for file submissions
results
=
responder
.
evaluate_answers
(
answers
,
oldcmap
)
results
=
responder
.
evaluate_answers
(
answers
,
oldcmap
)
else
:
else
:
...
@@ -295,9 +295,9 @@ class LoncapaProblem(object):
...
@@ -295,9 +295,9 @@ class LoncapaProblem(object):
try
:
try
:
ifp
=
self
.
system
.
filestore
.
open
(
file
)
# open using ModuleSystem OSFS filestore
ifp
=
self
.
system
.
filestore
.
open
(
file
)
# open using ModuleSystem OSFS filestore
except
Exception
as
err
:
except
Exception
as
err
:
log
.
error
(
'Error
%
s in problem xml include:
%
s'
%
(
log
.
warning
(
'Error
%
s in problem xml include:
%
s'
%
(
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)))
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)))
log
.
error
(
'Cannot find file
%
s in
%
s'
%
(
log
.
warning
(
'Cannot find file
%
s in
%
s'
%
(
file
,
self
.
system
.
filestore
))
file
,
self
.
system
.
filestore
))
# if debugging, don't fail - just log error
# if debugging, don't fail - just log error
# TODO (vshnayder): need real error handling, display to users
# TODO (vshnayder): need real error handling, display to users
...
@@ -306,11 +306,11 @@ class LoncapaProblem(object):
...
@@ -306,11 +306,11 @@ class LoncapaProblem(object):
else
:
else
:
continue
continue
try
:
try
:
incxml
=
etree
.
XML
(
ifp
.
read
())
# read in and convert to XML
incxml
=
etree
.
XML
(
ifp
.
read
())
# read in and convert to XML
except
Exception
as
err
:
except
Exception
as
err
:
log
.
error
(
'Error
%
s in problem xml include:
%
s'
%
(
log
.
warning
(
'Error
%
s in problem xml include:
%
s'
%
(
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)))
err
,
etree
.
tostring
(
inc
,
pretty_print
=
True
)))
log
.
error
(
'Cannot parse XML in
%
s'
%
(
file
))
log
.
warning
(
'Cannot parse XML in
%
s'
%
(
file
))
# if debugging, don't fail - just log error
# if debugging, don't fail - just log error
# TODO (vshnayder): same as above
# TODO (vshnayder): same as above
if
not
self
.
system
.
get
(
'DEBUG'
):
if
not
self
.
system
.
get
(
'DEBUG'
):
...
...
common/lib/capa/capa/inputtypes.py
View file @
0a650f39
...
@@ -313,13 +313,13 @@ def filesubmission(element, value, status, render_template, msg=''):
...
@@ -313,13 +313,13 @@ def filesubmission(element, value, status, render_template, msg=''):
if
status
==
'incomplete'
:
# Flag indicating that the problem has been queued, 'msg' is length of queue
if
status
==
'incomplete'
:
# Flag indicating that the problem has been queued, 'msg' is length of queue
status
=
'queued'
status
=
'queued'
queue_len
=
msg
queue_len
=
msg
msg
=
'Submitted to grader. (Queue length:
%
s)'
%
queue_len
msg
=
'Submitted to grader. (Queue length:
%
s)'
%
queue_len
context
=
{
'id'
:
eid
,
'state'
:
status
,
'msg'
:
msg
,
'value'
:
value
,
context
=
{
'id'
:
eid
,
'state'
:
status
,
'msg'
:
msg
,
'value'
:
value
,
'queue_len'
:
queue_len
'queue_len'
:
queue_len
}
}
html
=
render_template
(
"filesubmission.html"
,
context
)
html
=
render_template
(
"filesubmission.html"
,
context
)
return
etree
.
XML
(
html
)
return
etree
.
XML
(
html
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
...
@@ -339,16 +339,16 @@ def textbox(element, value, status, render_template, msg=''):
...
@@ -339,16 +339,16 @@ def textbox(element, value, status, render_template, msg=''):
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
hidden
=
element
.
get
(
'hidden'
,
''
)
# if specified, then textline is hidden and id is stored in div of name given by hidden
if
not
value
:
value
=
element
.
text
# if no student input yet, then use the default input given by the problem
if
not
value
:
value
=
element
.
text
# if no student input yet, then use the default input given by the problem
# Check if problem has been queued
# Check if problem has been queued
queue_len
=
0
queue_len
=
0
if
status
==
'incomplete'
:
# Flag indicating that the problem has been queued, 'msg' is length of queue
if
status
==
'incomplete'
:
# Flag indicating that the problem has been queued, 'msg' is length of queue
status
=
'queued'
status
=
'queued'
queue_len
=
msg
queue_len
=
msg
msg
=
'Submitted to grader. (Queue length:
%
s)'
%
queue_len
msg
=
'Submitted to grader. (Queue length:
%
s)'
%
queue_len
# For CodeMirror
# For CodeMirror
mode
=
element
.
get
(
'mode'
,
'python'
)
mode
=
element
.
get
(
'mode'
,
'python'
)
linenumbers
=
element
.
get
(
'linenumbers'
,
'true'
)
linenumbers
=
element
.
get
(
'linenumbers'
,
'true'
)
tabsize
=
element
.
get
(
'tabsize'
,
'4'
)
tabsize
=
element
.
get
(
'tabsize'
,
'4'
)
tabsize
=
int
(
tabsize
)
tabsize
=
int
(
tabsize
)
...
...
common/lib/xmodule/xmodule/capa_module.py
View file @
0a650f39
...
@@ -150,7 +150,7 @@ class CapaModule(XModule):
...
@@ -150,7 +150,7 @@ class CapaModule(XModule):
# TODO (vshnayder): do modules need error handlers too?
# TODO (vshnayder): do modules need error handlers too?
# We shouldn't be switching on DEBUG.
# We shouldn't be switching on DEBUG.
if
self
.
system
.
DEBUG
:
if
self
.
system
.
DEBUG
:
log
.
error
(
msg
)
log
.
warning
(
msg
)
# TODO (vshnayder): This logic should be general, not here--and may
# TODO (vshnayder): This logic should be general, not here--and may
# want to preserve the data instead of replacing it.
# want to preserve the data instead of replacing it.
# e.g. in the CMS
# e.g. in the CMS
...
...
common/lib/xmodule/xmodule/modulestore/xml.py
View file @
0a650f39
...
@@ -50,8 +50,9 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
...
@@ -50,8 +50,9 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
# have been imported into the cms from xml
# have been imported into the cms from xml
xml
=
clean_out_mako_templating
(
xml
)
xml
=
clean_out_mako_templating
(
xml
)
xml_data
=
etree
.
fromstring
(
xml
)
xml_data
=
etree
.
fromstring
(
xml
)
except
:
except
Exception
as
err
:
log
.
exception
(
"Unable to parse xml: {xml}"
.
format
(
xml
=
xml
))
log
.
warning
(
"Unable to parse xml: {err}, xml: {xml}"
.
format
(
err
=
str
(
err
),
xml
=
xml
))
raise
raise
# VS[compat]. Take this out once course conversion is done
# VS[compat]. Take this out once course conversion is done
...
@@ -194,7 +195,7 @@ class XMLModuleStore(ModuleStoreBase):
...
@@ -194,7 +195,7 @@ class XMLModuleStore(ModuleStoreBase):
if
org
is
None
:
if
org
is
None
:
msg
=
(
"No 'org' attribute set for course in {dir}. "
msg
=
(
"No 'org' attribute set for course in {dir}. "
"Using default 'edx'"
.
format
(
dir
=
course_dir
))
"Using default 'edx'"
.
format
(
dir
=
course_dir
))
log
.
error
(
msg
)
log
.
warning
(
msg
)
tracker
(
msg
)
tracker
(
msg
)
org
=
'edx'
org
=
'edx'
...
@@ -206,7 +207,7 @@ class XMLModuleStore(ModuleStoreBase):
...
@@ -206,7 +207,7 @@ class XMLModuleStore(ModuleStoreBase):
dir
=
course_dir
,
dir
=
course_dir
,
default
=
course_dir
default
=
course_dir
))
))
log
.
error
(
msg
)
log
.
warning
(
msg
)
tracker
(
msg
)
tracker
(
msg
)
course
=
course_dir
course
=
course_dir
...
...
common/lib/xmodule/xmodule/x_module.py
View file @
0a650f39
...
@@ -522,7 +522,7 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
...
@@ -522,7 +522,7 @@ class XModuleDescriptor(Plugin, HTMLSnippet):
# Put import here to avoid circular import errors
# Put import here to avoid circular import errors
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.error_module
import
ErrorDescriptor
msg
=
"Error loading from xml."
msg
=
"Error loading from xml."
log
.
exception
(
msg
)
log
.
warning
(
msg
+
" "
+
str
(
err
)
)
system
.
error_tracker
(
msg
)
system
.
error_tracker
(
msg
)
err_msg
=
msg
+
"
\n
"
+
exc_info_to_str
(
sys
.
exc_info
())
err_msg
=
msg
+
"
\n
"
+
exc_info_to_str
(
sys
.
exc_info
())
descriptor
=
ErrorDescriptor
.
from_xml
(
xml_data
,
system
,
org
,
course
,
descriptor
=
ErrorDescriptor
.
from_xml
(
xml_data
,
system
,
org
,
course
,
...
@@ -615,9 +615,10 @@ class DescriptorSystem(object):
...
@@ -615,9 +615,10 @@ class DescriptorSystem(object):
try:
try:
x = access_some_resource()
x = access_some_resource()
check_some_format(x)
check_some_format(x)
except SomeProblem:
except SomeProblem as err:
msg = 'Grommet {0} is broken'.format(x)
msg = 'Grommet {0} is broken: {1}'.format(x, str(err))
log.exception(msg) # don't rely on handler to log
log.warning(msg) # don't rely on tracker to log
# NOTE: we generally don't want content errors logged as errors
self.system.error_tracker(msg)
self.system.error_tracker(msg)
# work around
# work around
return 'Oops, couldn't load grommet'
return 'Oops, couldn't load grommet'
...
...
doc/development.md
View file @
0a650f39
...
@@ -34,12 +34,34 @@ This will import all courses in your data directory into mongodb
...
@@ -34,12 +34,34 @@ This will import all courses in your data directory into mongodb
This runs all the tests (long, uses collectstatic):
This runs all the tests (long, uses collectstatic):
rake test
rake test
If if you aren't changing static files, can run
`rake test`
once, then run
rake fasttest_{lms,cms}
xmodule can be tested independently, with this:
xmodule can be tested independently, with this:
rake test_common/lib/xmodule
rake test_common/lib/xmodule
To see all available rake commands, do this:
To see all available rake commands, do this:
rake -T
rake -T
\ No newline at end of file
To run a single django test class:
django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/courseware/tests/tests.py:TestViewAuth
To run a single django test:
django-admin.py test --settings=lms.envs.test --pythonpath=. lms/djangoapps/courseware/tests/tests.py:TestViewAuth.test_dark_launch
To run a single nose test file:
nosetests common/lib/xmodule/xmodule/tests/test_stringify.py
To run a single nose test:
nosetests common/lib/xmodule/xmodule/tests/test_stringify.py:test_stringify
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