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
8480ccd1
Commit
8480ccd1
authored
Feb 05, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Course sanity check
parent
0f848e52
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
3 deletions
+53
-3
courseware/capa/capa_problem.py
+1
-1
courseware/management/__init__.py
+0
-0
courseware/management/commands/__init__.py
+0
-0
courseware/management/commands/check_course.py
+50
-0
courseware/modules/capa_module.py
+2
-2
No files found.
courseware/capa/capa_problem.py
View file @
8480ccd1
...
...
@@ -83,7 +83,7 @@ class LoncapaProblem(object):
self
.
seed
=
struct
.
unpack
(
'i'
,
os
.
urandom
(
4
))[
0
]
## Parse XML file
log
.
debug
(
u"LoncapaProblem() opening file {0}"
.
format
(
filename
))
#
log.debug(u"LoncapaProblem() opening file {0}".format(filename))
file_text
=
open
(
filename
)
.
read
()
# Convert startouttext and endouttext to proper <text></text>
# TODO: Do with XML operations
...
...
courseware/management/__init__.py
0 → 100644
View file @
8480ccd1
courseware/management/commands/__init__.py
0 → 100644
View file @
8480ccd1
courseware/management/commands/check_course.py
0 → 100644
View file @
8480ccd1
import
os.path
from
lxml
import
etree
from
django.core.management.base
import
BaseCommand
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
mitx.courseware.content_parser
import
course_file
import
mitx.courseware.module_render
class
Command
(
BaseCommand
):
help
=
"Does basic validity tests on course.xml."
def
handle
(
self
,
*
args
,
**
options
):
check
=
True
sample_user
=
User
.
objects
.
all
()[
0
]
print
"Attempting to load courseware"
course
=
course_file
(
sample_user
)
print
"Confirming all problems have alphanumeric names"
for
problem
in
course
.
xpath
(
'//problem'
):
filename
=
problem
.
get
(
'filename'
)
if
not
filename
.
isalnum
():
print
"==============> Invalid (non-alphanumeric) filename"
,
filename
check
=
False
print
"Confirming all modules render. Nothing should print during this step. "
for
module
in
course
.
xpath
(
'//problem|//html|//video'
):
module_class
=
mitx
.
courseware
.
module_render
.
modx_modules
[
module
.
tag
]
# TODO: Abstract this out in render_module.py
try
:
instance
=
module_class
(
etree
.
tostring
(
module
),
module
.
get
(
'id'
),
ajax_url
=
''
,
state
=
None
,
track_function
=
lambda
x
,
y
,
z
:
None
,
render_function
=
lambda
x
:
{
'content'
:
''
,
'destroy_js'
:
''
,
'init_js'
:
''
,
'type'
:
'video'
})
except
:
print
"==============> Error in "
,
etree
.
tostring
(
module
)
check
=
False
print
"Module render check finished"
sections_dir
=
settings
.
DATA_DIR
+
"sections"
if
os
.
path
.
exists
(
sections_dir
):
print
"Checking all section includes are valid XML"
for
f
in
os
.
listdir
(
sections_dir
):
etree
.
parse
(
sections_dir
+
'/'
+
f
)
else
:
print
"Skipping check of include files -- no section includes dir ("
+
sections_dir
+
")"
if
check
:
print
'Courseware passes all checks!'
else
:
print
"Courseware fails some checks"
courseware/modules/capa_module.py
View file @
8480ccd1
...
...
@@ -131,7 +131,7 @@ class LoncapaModule(XModule):
display_due_date_string
=
content_parser
.
item
(
dom2
.
xpath
(
'/problem/@due'
))
if
len
(
display_due_date_string
)
>
0
:
self
.
display_due_date
=
dateutil
.
parser
.
parse
(
display_due_date_string
)
log
.
debug
(
"Parsed "
+
display_due_date_string
+
" to "
+
str
(
self
.
display_due_date
))
#
log.debug("Parsed " + display_due_date_string + " to " + str(self.display_due_date))
else
:
self
.
display_due_date
=
None
...
...
@@ -140,7 +140,7 @@ class LoncapaModule(XModule):
if
len
(
grace_period_string
)
>
0
and
self
.
display_due_date
:
self
.
grace_period
=
content_parser
.
parse_timedelta
(
grace_period_string
)
self
.
close_date
=
self
.
display_due_date
+
self
.
grace_period
log
.
debug
(
"Then parsed "
+
grace_period_string
+
" to closing date"
+
str
(
self
.
close_date
))
#
log.debug("Then parsed " + grace_period_string + " to closing date" + str(self.close_date))
else
:
self
.
grace_period
=
None
self
.
close_date
=
self
.
display_due_date
...
...
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