Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, April 9th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
4c95294b
Commit
4c95294b
authored
12 years ago
by
chrisndodge
Browse files
Options
Downloads
Plain Diff
Merge pull request #1810 from MITx/feature/cdodge/integrity-check-mongo-course
pylint/pep8 fixes
parents
f467d93f
02dfa09c
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cms/djangoapps/contentstore/management/commands/check_course.py
+7
-13
7 additions, 13 deletions
...angoapps/contentstore/management/commands/check_course.py
with
7 additions
and
13 deletions
cms/djangoapps/contentstore/management/commands/check_course.py
+
7
−
13
View file @
4c95294b
from
django.core.management.base
import
BaseCommand
,
CommandError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore.xml_importer
import
check_module_metadata_editability
from
xmodule.course_module
import
CourseDescriptor
from
request_cache.middleware
import
RequestCache
from
django.core.cache
import
get_cache
,
InvalidCacheBackendError
class
Command
(
BaseCommand
):
help
=
'''
Enumerates through the course and find common errors
'''
def
handle
(
self
,
*
args
,
**
options
):
if
len
(
args
)
!=
1
:
if
len
(
args
)
!=
1
:
raise
CommandError
(
"
check_course requires one argument: <location>
"
)
loc_str
=
args
[
0
]
loc
=
CourseDescriptor
.
id_to_location
(
loc_str
)
store
=
modulestore
()
# setup a request cache so we don't throttle the DB with all the metadata inheritance requests
store
.
request_cache
=
RequestCache
.
get_request_cache
()
course
=
store
.
get_item
(
loc
,
depth
=
3
)
err_cnt
=
0
def
_xlint_metadata
(
module
):
err_cnt
=
check_module_metadata_editability
(
module
)
for
child
in
module
.
get_children
():
err_cnt
=
err_cnt
+
_xlint_metadata
(
child
)
return
err_cnt
_xlint_metadata
(
course
)
err_cnt
=
err_cnt
+
_xlint_metadata
(
course
)
# we've had a bug where the xml_attributes field can we rewritten as a string rather than a dict
def
_check_xml_attributes_field
(
module
):
...
...
@@ -45,7 +43,7 @@ class Command(BaseCommand):
err_cnt
=
err_cnt
+
_check_xml_attributes_field
(
child
)
return
err_cnt
_check_xml_attributes_field
(
course
)
err_cnt
=
err_cnt
+
_check_xml_attributes_field
(
course
)
# check for dangling discussion items, this can cause errors in the forums
def
_get_discussion_items
(
module
):
...
...
@@ -58,17 +56,13 @@ class Command(BaseCommand):
return
discussion_items
discussion_items
=
_get_discussion_items
(
course
)
discussion_items
=
_get_discussion_items
(
course
)
# now query all discussion items via get_items() and compare with the tree-traversal
queried_discussion_items
=
store
.
get_items
([
'
i4x
'
,
course
.
location
.
org
,
course
.
location
.
course
,
'
discussion
'
,
None
,
None
])
'
discussion
'
,
None
,
None
])
for
item
in
queried_discussion_items
:
if
item
.
location
.
url
()
not
in
discussion_items
:
print
'
Found dangling discussion module = {0}
'
.
format
(
item
.
location
.
url
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment